-
Notifications
You must be signed in to change notification settings - Fork 13
/
emissivity.py
76 lines (67 loc) · 2.2 KB
/
emissivity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from grass.pygrass.modules.shortcuts import general as g
from dummy_mapcalc_strings import replace_dummies
from constants import DUMMY_MAPCALC_STRING_FROM_GLC
from constants import EQUATION
import grass.script as grass
from helpers import run
def determine_average_emissivity(
outname,
emissivity_output,
landcover_map,
avg_lse_expression,
info=False,
):
"""
Produce an average emissivity map based on FROM-GLC map covering the region
of interest.
"""
msg = ('\n|i Determining average land surface emissivity based on a look-up table ')
if info:
msg += (f'\n Expression:\n\n {avg_lse_expression}')
g.message(msg)
avg_lse_expression = replace_dummies(
avg_lse_expression,
instring=DUMMY_MAPCALC_STRING_FROM_GLC,
outstring=landcover_map,
)
avg_lse_equation = EQUATION.format(
result=outname,
expression=avg_lse_expression,
)
grass.mapcalc(avg_lse_equation, overwrite=True)
if info:
run('r.info', map=outname, flags='r')
# save land surface emissivity map?
if emissivity_output:
run('g.rename', raster=(outname, emissivity_output))
def determine_delta_emissivity(
outname,
delta_emissivity_output,
landcover_map,
delta_lse_expression,
info=False,
):
"""
Produce a delta emissivity map based on the FROM-GLC map covering the
region of interest.
"""
msg = ('\n|i Determining delta land surface emissivity based on a '
'look-up table ')
if info:
msg += (f'\n Expression:\n\n {delta_lse_expression}')
g.message(msg)
delta_lse_expression = replace_dummies(
delta_lse_expression,
instring=DUMMY_MAPCALC_STRING_FROM_GLC,
outstring=landcover_map,
)
delta_lse_equation = EQUATION.format(
result=outname,
expression=delta_lse_expression,
)
grass.mapcalc(delta_lse_equation, overwrite=True)
if info:
run('r.info', map=outname, flags='r')
# save delta land surface emissivity map?
if delta_emissivity_output:
run('g.rename', raster=(outname, delta_emissivity_output))