PM-JPL 1.2.1__py3-none-any.whl → 1.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PMJPL/ECOv002-cal-val-PM-JPL-inputs.csv +1048 -0
- PMJPL/ECOv002-cal-val-PM-JPL-outputs.csv +1048 -0
- PMJPL/ECOv002-static-tower-PM-JPL-inputs.csv +122 -0
- PMJPL/ECOv002_calval_PMJPL_inputs.py +19 -0
- PMJPL/ECOv002_static_tower_PMJPL_inputs.py +19 -0
- PMJPL/PMJPL.py +45 -378
- PMJPL/{parameters.py → PMJPL_parameter_from_IGBP.py} +22 -7
- PMJPL/VPD_factor.py +1 -1
- PMJPL/__init__.py +1 -6
- PMJPL/calculate_gamma.py +128 -0
- PMJPL/canopy_aerodynamic_resistance.py +151 -18
- PMJPL/canopy_conductance.py +71 -15
- PMJPL/closed_minimum_temperature.py +11 -0
- PMJPL/closed_vapor_pressure_deficit.py +11 -0
- PMJPL/constants.py +6 -1
- PMJPL/correctance_factor.py +56 -7
- PMJPL/generate_PMJPL_inputs.py +263 -0
- PMJPL/interception.py +1 -3
- PMJPL/leaf_conductance_to_evaporated_water.py +11 -0
- PMJPL/leaf_conductance_to_sensible_heat.py +58 -0
- PMJPL/maximum_boundary_layer_resistance.py +11 -0
- PMJPL/minimum_boundary_layer_resistance.py +11 -0
- PMJPL/{tmin_factor.py → minimum_temperature_factor.py} +2 -2
- PMJPL/mod16.csv +19 -0
- PMJPL/model.py +690 -0
- PMJPL/open_minimum_temperature.py +11 -0
- PMJPL/open_vapor_pressure_deficit.py +11 -0
- PMJPL/potential_soil_evaporation.py +2 -2
- PMJPL/potential_stomatal_conductance.py +11 -0
- PMJPL/process_PMJPL_table.py +208 -0
- PMJPL/process_daily_ET_table.py +40 -0
- PMJPL/transpiration.py +4 -4
- PMJPL/verify.py +77 -0
- PMJPL/version.py +4 -0
- PMJPL/wet_canopy_resistance.py +1 -0
- PMJPL/wet_soil_evaporation.py +4 -4
- {pm_jpl-1.2.1.dist-info → pm_jpl-1.7.0.dist-info}/METADATA +18 -21
- pm_jpl-1.7.0.dist-info/RECORD +42 -0
- {pm_jpl-1.2.1.dist-info → pm_jpl-1.7.0.dist-info}/WHEEL +1 -1
- PMJPL/MCD12C1/MCD12C1.py +0 -10
- PMJPL/MCD12C1/__init__.py +0 -1
- PMJPL/SEBAL/SEBAL.py +0 -45
- PMJPL/SEBAL/__init__.py +0 -1
- PMJPL/downscaling/__init__.py +0 -1
- PMJPL/downscaling/downscaling.py +0 -271
- PMJPL/downscaling/linear_downscale.py +0 -71
- PMJPL/evapotranspiration_conversion/__init__.py +0 -1
- PMJPL/evapotranspiration_conversion/evapotranspiration_conversion.py +0 -80
- PMJPL/fwet.py +0 -21
- PMJPL/meteorology_conversion/__init__.py +0 -1
- PMJPL/meteorology_conversion/meteorology_conversion.py +0 -123
- PMJPL/penman_monteith/__init__.py +0 -1
- PMJPL/penman_monteith/penman_monteith.py +0 -20
- PMJPL/priestley_taylor/__init__.py +0 -1
- PMJPL/priestley_taylor/priestley_taylor.py +0 -27
- PMJPL/santanello/__init__.py +0 -1
- PMJPL/santanello/santanello.py +0 -46
- PMJPL/soil_heat_flux/__init__.py +0 -1
- PMJPL/soil_heat_flux/soil_heat_flux.py +0 -62
- PMJPL/vegetation_conversion/__init__.py +0 -1
- PMJPL/vegetation_conversion/vegetation_conversion.py +0 -47
- PMJPL/verma_net_radiation/__init__.py +0 -1
- PMJPL/verma_net_radiation/verma_net_radiation.py +0 -108
- pm_jpl-1.2.1.dist-info/RECORD +0 -44
- {pm_jpl-1.2.1.dist-info → pm_jpl-1.7.0.dist-info}/licenses/LICENSE +0 -0
- {pm_jpl-1.2.1.dist-info → pm_jpl-1.7.0.dist-info}/top_level.txt +0 -0
PMJPL/downscaling/downscaling.py
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
from dateutil import parser
|
|
3
|
-
import numpy as np
|
|
4
|
-
from rasters import Raster, RasterGeometry, RasterGrid
|
|
5
|
-
import rasters as rt
|
|
6
|
-
|
|
7
|
-
DEFAULT_UPSAMPLING = "average"
|
|
8
|
-
DEFAULT_DOWNSAMPLING = "linear"
|
|
9
|
-
|
|
10
|
-
def bias_correct(
|
|
11
|
-
coarse_image: Raster,
|
|
12
|
-
fine_image: Raster,
|
|
13
|
-
upsampling: str = "average",
|
|
14
|
-
downsampling: str = "linear",
|
|
15
|
-
return_bias: bool = False):
|
|
16
|
-
fine_geometry = fine_image.geometry
|
|
17
|
-
coarse_geometry = coarse_image.geometry
|
|
18
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
19
|
-
bias_coarse = upsampled - coarse_image
|
|
20
|
-
bias_fine = bias_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
21
|
-
bias_corrected_fine = fine_image - bias_fine
|
|
22
|
-
|
|
23
|
-
if return_bias:
|
|
24
|
-
return bias_corrected_fine, bias_fine
|
|
25
|
-
else:
|
|
26
|
-
return bias_corrected_fine
|
|
27
|
-
|
|
28
|
-
def linear_downscale(
|
|
29
|
-
coarse_image: Raster,
|
|
30
|
-
fine_image: Raster,
|
|
31
|
-
upsampling: str = "average",
|
|
32
|
-
downsampling: str = "linear",
|
|
33
|
-
use_gap_filling: bool = False,
|
|
34
|
-
apply_scale: bool = True,
|
|
35
|
-
apply_bias: bool = True,
|
|
36
|
-
return_scale_and_bias: bool = False) -> Raster:
|
|
37
|
-
if upsampling is None:
|
|
38
|
-
upsampling = DEFAULT_UPSAMPLING
|
|
39
|
-
|
|
40
|
-
if downsampling is None:
|
|
41
|
-
downsampling = DEFAULT_DOWNSAMPLING
|
|
42
|
-
|
|
43
|
-
coarse_geometry = coarse_image.geometry
|
|
44
|
-
fine_geometry = fine_image.geometry
|
|
45
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
46
|
-
|
|
47
|
-
if apply_scale:
|
|
48
|
-
scale_coarse = coarse_image / upsampled
|
|
49
|
-
scale_coarse = rt.where(coarse_image == 0, 0, scale_coarse)
|
|
50
|
-
scale_coarse = rt.where(upsampled == 0, 0, scale_coarse)
|
|
51
|
-
scale_fine = scale_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
52
|
-
scale_corrected_fine = fine_image * scale_fine
|
|
53
|
-
fine_image = scale_corrected_fine
|
|
54
|
-
else:
|
|
55
|
-
scale_fine = fine_image * 0 + 1
|
|
56
|
-
|
|
57
|
-
if apply_bias:
|
|
58
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
59
|
-
bias_coarse = upsampled - coarse_image
|
|
60
|
-
bias_fine = bias_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
61
|
-
bias_corrected_fine = fine_image - bias_fine
|
|
62
|
-
fine_image = bias_corrected_fine
|
|
63
|
-
else:
|
|
64
|
-
bias_fine = fine_image * 0
|
|
65
|
-
|
|
66
|
-
if use_gap_filling:
|
|
67
|
-
gap_fill = coarse_image.to_geometry(fine_geometry, resampling=downsampling)
|
|
68
|
-
fine_image = fine_image.fill(gap_fill)
|
|
69
|
-
|
|
70
|
-
if return_scale_and_bias:
|
|
71
|
-
fine_image["scale"] = scale_fine
|
|
72
|
-
fine_image["bias"] = bias_fine
|
|
73
|
-
|
|
74
|
-
return fine_image
|
|
75
|
-
|
|
76
|
-
def NDVI_to_FVC(NDVI: Raster) -> Raster:
|
|
77
|
-
NDVIv = 0.52 # +- 0.03
|
|
78
|
-
NDVIs = 0.04 # +- 0.03
|
|
79
|
-
FVC = rt.clip((NDVI - NDVIs) / (NDVIv - NDVIs), 0, 1)
|
|
80
|
-
|
|
81
|
-
return FVC
|
|
82
|
-
|
|
83
|
-
def downscale_air_temperature(
|
|
84
|
-
time_UTC: datetime,
|
|
85
|
-
Ta_K_coarse: Raster,
|
|
86
|
-
ST_K: Raster,
|
|
87
|
-
water: Raster = None,
|
|
88
|
-
fine_geometry: RasterGeometry = None,
|
|
89
|
-
coarse_geometry: RasterGeometry = None,
|
|
90
|
-
resampling: str = None,
|
|
91
|
-
upsampling: str = None,
|
|
92
|
-
downsampling: str = None,
|
|
93
|
-
apply_scale: bool = True,
|
|
94
|
-
apply_bias: bool = True,
|
|
95
|
-
return_scale_and_bias: bool = False) -> Raster:
|
|
96
|
-
"""
|
|
97
|
-
near-surface air temperature (Ta) in Kelvin
|
|
98
|
-
:param time_UTC: date/time in UTC
|
|
99
|
-
:param geometry: optional target geometry
|
|
100
|
-
:param resampling: optional sampling method for resampling to target geometry
|
|
101
|
-
:return: raster of Ta
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
if isinstance(time_UTC, str):
|
|
105
|
-
time_UTC = parser.parse(time_UTC)
|
|
106
|
-
|
|
107
|
-
if fine_geometry is None:
|
|
108
|
-
fine_geometry = ST_K.geometry
|
|
109
|
-
|
|
110
|
-
if coarse_geometry is None:
|
|
111
|
-
coarse_geometry = Ta_K_coarse.geometry
|
|
112
|
-
|
|
113
|
-
ST_K_water = None
|
|
114
|
-
|
|
115
|
-
if water is not None:
|
|
116
|
-
ST_K_water = rt.where(water, ST_K, np.nan)
|
|
117
|
-
ST_K = rt.where(water, np.nan, ST_K)
|
|
118
|
-
|
|
119
|
-
scale = None
|
|
120
|
-
bias = None
|
|
121
|
-
|
|
122
|
-
Ta_K = linear_downscale(
|
|
123
|
-
coarse_image=Ta_K_coarse,
|
|
124
|
-
fine_image=ST_K,
|
|
125
|
-
upsampling=upsampling,
|
|
126
|
-
downsampling=downsampling,
|
|
127
|
-
apply_scale=apply_scale,
|
|
128
|
-
apply_bias=apply_bias,
|
|
129
|
-
return_scale_and_bias=return_scale_and_bias
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
if water is not None:
|
|
133
|
-
Ta_K_water = linear_downscale(
|
|
134
|
-
coarse_image=Ta_K_coarse,
|
|
135
|
-
fine_image=ST_K_water,
|
|
136
|
-
upsampling=upsampling,
|
|
137
|
-
downsampling=downsampling,
|
|
138
|
-
apply_scale=apply_scale,
|
|
139
|
-
apply_bias=apply_bias,
|
|
140
|
-
return_scale_and_bias=False
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
Ta_K = rt.where(water, Ta_K_water, Ta_K)
|
|
144
|
-
|
|
145
|
-
Ta_K.filenames = Ta_K_coarse.filenames
|
|
146
|
-
|
|
147
|
-
return Ta_K
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def downscale_soil_moisture(
|
|
151
|
-
time_UTC: datetime,
|
|
152
|
-
fine_geometry: RasterGrid,
|
|
153
|
-
coarse_geometry: RasterGrid,
|
|
154
|
-
SM_coarse: Raster,
|
|
155
|
-
SM_resampled: Raster,
|
|
156
|
-
ST_fine: Raster,
|
|
157
|
-
NDVI_fine: Raster,
|
|
158
|
-
water: Raster,
|
|
159
|
-
fvlim=0.5,
|
|
160
|
-
a=0.5,
|
|
161
|
-
smoothing="linear") -> Raster:
|
|
162
|
-
fine = fine_geometry
|
|
163
|
-
ST_fine = ST_fine.mask(~water)
|
|
164
|
-
NDVI_fine = NDVI_fine.mask(~water)
|
|
165
|
-
FVC_fine = NDVI_to_FVC(NDVI_fine)
|
|
166
|
-
soil_fine = FVC_fine < fvlim
|
|
167
|
-
Tmin_coarse = ST_fine.to_geometry(coarse_geometry, resampling="min")
|
|
168
|
-
Tmax_coarse = ST_fine.to_geometry(coarse_geometry, resampling="max")
|
|
169
|
-
Ts_fine = ST_fine.mask(soil_fine)
|
|
170
|
-
Tsmin_coarse = Ts_fine.to_geometry(coarse_geometry, resampling="min").fill(Tmin_coarse)
|
|
171
|
-
Tsmax_coarse = Ts_fine.to_geometry(coarse_geometry, resampling="max").fill(Tmax_coarse)
|
|
172
|
-
ST_coarse = ST_fine.to_geometry(coarse_geometry, resampling="average")
|
|
173
|
-
SEE_coarse = (Tsmax_coarse - ST_coarse) / rt.clip(Tsmax_coarse - Tsmin_coarse, 1, None)
|
|
174
|
-
SM_SEE_proportion = (SM_coarse / SEE_coarse).to_geometry(fine, resampling=smoothing)
|
|
175
|
-
Tsmax_fine = Tsmax_coarse.to_geometry(fine_geometry, resampling=smoothing)
|
|
176
|
-
Tsrange_fine = (Tsmax_coarse - Tsmin_coarse).to_geometry(fine, resampling=smoothing)
|
|
177
|
-
SEE_fine = (Tsmax_fine - ST_fine) / rt.clip(Tsrange_fine, 1, None)
|
|
178
|
-
|
|
179
|
-
SEE_mean = SEE_coarse.to_geometry(fine, resampling=smoothing)
|
|
180
|
-
SM_fine = rt.clip(SM_resampled + a * SM_SEE_proportion * (SEE_fine - SEE_mean), 0, 1)
|
|
181
|
-
SM_fine = SM_fine.mask(~water)
|
|
182
|
-
|
|
183
|
-
return SM_fine
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def downscale_vapor_pressure_deficit(
|
|
187
|
-
time_UTC: datetime,
|
|
188
|
-
VPD_Pa_coarse: Raster,
|
|
189
|
-
ST_K: Raster,
|
|
190
|
-
fine_geometry: RasterGeometry = None,
|
|
191
|
-
coarse_geometry: RasterGeometry = None,
|
|
192
|
-
resampling: str = None,
|
|
193
|
-
upsampling: str = None,
|
|
194
|
-
downsampling: str = None,
|
|
195
|
-
return_scale_and_bias: bool = False) -> Raster:
|
|
196
|
-
if upsampling is None:
|
|
197
|
-
upsampling = "average"
|
|
198
|
-
|
|
199
|
-
if downsampling is None:
|
|
200
|
-
downsampling = "linear"
|
|
201
|
-
|
|
202
|
-
if fine_geometry is None:
|
|
203
|
-
fine_geometry = ST_K.geometry
|
|
204
|
-
|
|
205
|
-
if coarse_geometry is None:
|
|
206
|
-
coarse_geometry = VPD_Pa_coarse.geometry
|
|
207
|
-
|
|
208
|
-
return linear_downscale(
|
|
209
|
-
coarse_image=VPD_Pa_coarse,
|
|
210
|
-
fine_image=ST_K,
|
|
211
|
-
upsampling=upsampling,
|
|
212
|
-
downsampling=downsampling,
|
|
213
|
-
return_scale_and_bias=return_scale_and_bias
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
def downscale_relative_humidity(
|
|
218
|
-
time_UTC: datetime,
|
|
219
|
-
RH_coarse: Raster,
|
|
220
|
-
SM,
|
|
221
|
-
ST_K,
|
|
222
|
-
VPD_kPa,
|
|
223
|
-
water: Raster = None,
|
|
224
|
-
fine_geometry: RasterGeometry = None,
|
|
225
|
-
coarse_geometry: RasterGeometry = None,
|
|
226
|
-
resampling: str = None,
|
|
227
|
-
upsampling: str = None,
|
|
228
|
-
downsampling: str = None) -> Raster:
|
|
229
|
-
if upsampling is None:
|
|
230
|
-
upsampling = "average"
|
|
231
|
-
|
|
232
|
-
if downsampling is None:
|
|
233
|
-
downsampling = "linear"
|
|
234
|
-
|
|
235
|
-
if fine_geometry is None:
|
|
236
|
-
fine_geometry = SM.geometry
|
|
237
|
-
|
|
238
|
-
if coarse_geometry is None:
|
|
239
|
-
coarse_geometry = RH_coarse.geometry
|
|
240
|
-
|
|
241
|
-
bias_fine = None
|
|
242
|
-
|
|
243
|
-
RH_estimate_fine = SM ** (1 / VPD_kPa)
|
|
244
|
-
|
|
245
|
-
RH = bias_correct(
|
|
246
|
-
coarse_image=RH_coarse,
|
|
247
|
-
fine_image=RH_estimate_fine,
|
|
248
|
-
upsampling=upsampling,
|
|
249
|
-
downsampling=downsampling,
|
|
250
|
-
return_bias=False
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
if water is not None:
|
|
254
|
-
ST_K_water = rt.where(water, ST_K, np.nan)
|
|
255
|
-
RH_coarse_complement = 1 - RH_coarse
|
|
256
|
-
RH_complement_water = linear_downscale(
|
|
257
|
-
coarse_image=RH_coarse_complement,
|
|
258
|
-
fine_image=ST_K_water,
|
|
259
|
-
upsampling=upsampling,
|
|
260
|
-
downsampling=downsampling,
|
|
261
|
-
apply_bias=True,
|
|
262
|
-
return_scale_and_bias=False
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
RH_water = 1 - RH_complement_water
|
|
266
|
-
RH = rt.where(water, RH_water, RH)
|
|
267
|
-
|
|
268
|
-
RH = rt.clip(RH, 0, 1)
|
|
269
|
-
|
|
270
|
-
return RH
|
|
271
|
-
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from rasters import Raster
|
|
2
|
-
import rasters as rt
|
|
3
|
-
|
|
4
|
-
DEFAULT_UPSAMPLING = "average"
|
|
5
|
-
DEFAULT_DOWNSAMPLING = "linear"
|
|
6
|
-
|
|
7
|
-
def bias_correct(
|
|
8
|
-
coarse_image: Raster,
|
|
9
|
-
fine_image: Raster,
|
|
10
|
-
upsampling: str = "average",
|
|
11
|
-
downsampling: str = "linear",
|
|
12
|
-
return_bias: bool = False):
|
|
13
|
-
fine_geometry = fine_image.geometry
|
|
14
|
-
coarse_geometry = coarse_image.geometry
|
|
15
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
16
|
-
bias_coarse = upsampled - coarse_image
|
|
17
|
-
bias_fine = bias_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
18
|
-
bias_corrected_fine = fine_image - bias_fine
|
|
19
|
-
|
|
20
|
-
if return_bias:
|
|
21
|
-
return bias_corrected_fine, bias_fine
|
|
22
|
-
else:
|
|
23
|
-
return bias_corrected_fine
|
|
24
|
-
|
|
25
|
-
def linear_downscale(
|
|
26
|
-
coarse_image: Raster,
|
|
27
|
-
fine_image: Raster,
|
|
28
|
-
upsampling: str = "average",
|
|
29
|
-
downsampling: str = "cubic",
|
|
30
|
-
use_gap_filling: bool = False,
|
|
31
|
-
apply_scale: bool = True,
|
|
32
|
-
apply_bias: bool = True,
|
|
33
|
-
return_scale_and_bias: bool = False) -> Raster:
|
|
34
|
-
if upsampling is None:
|
|
35
|
-
upsampling = DEFAULT_UPSAMPLING
|
|
36
|
-
|
|
37
|
-
if downsampling is None:
|
|
38
|
-
downsampling = DEFAULT_DOWNSAMPLING
|
|
39
|
-
|
|
40
|
-
coarse_geometry = coarse_image.geometry
|
|
41
|
-
fine_geometry = fine_image.geometry
|
|
42
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
43
|
-
|
|
44
|
-
if apply_scale:
|
|
45
|
-
scale_coarse = coarse_image / upsampled
|
|
46
|
-
scale_coarse = rt.where(coarse_image == 0, 0, scale_coarse)
|
|
47
|
-
scale_coarse = rt.where(upsampled == 0, 0, scale_coarse)
|
|
48
|
-
scale_fine = scale_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
49
|
-
scale_corrected_fine = fine_image * scale_fine
|
|
50
|
-
fine_image = scale_corrected_fine
|
|
51
|
-
else:
|
|
52
|
-
scale_fine = fine_image * 0 + 1
|
|
53
|
-
|
|
54
|
-
if apply_bias:
|
|
55
|
-
upsampled = fine_image.to_geometry(coarse_geometry, resampling=upsampling)
|
|
56
|
-
bias_coarse = upsampled - coarse_image
|
|
57
|
-
bias_fine = bias_coarse.to_geometry(fine_geometry, resampling=downsampling)
|
|
58
|
-
bias_corrected_fine = fine_image - bias_fine
|
|
59
|
-
fine_image = bias_corrected_fine
|
|
60
|
-
else:
|
|
61
|
-
bias_fine = fine_image * 0
|
|
62
|
-
|
|
63
|
-
if use_gap_filling:
|
|
64
|
-
gap_fill = coarse_image.to_geometry(fine_geometry, resampling=downsampling)
|
|
65
|
-
fine_image = fine_image.fill(gap_fill)
|
|
66
|
-
|
|
67
|
-
if return_scale_and_bias:
|
|
68
|
-
fine_image["scale"] = scale_fine
|
|
69
|
-
fine_image["bias"] = bias_fine
|
|
70
|
-
|
|
71
|
-
return fine_image
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .evapotranspiration_conversion import *
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
from sun_angles import SHA_deg_from_DOY_lat, daylight_from_SHA, sunrise_from_SHA
|
|
3
|
-
|
|
4
|
-
import rasters as rt
|
|
5
|
-
from rasters import Raster
|
|
6
|
-
import numpy as np
|
|
7
|
-
import pandas as pd
|
|
8
|
-
|
|
9
|
-
from ..meteorology_conversion.meteorology_conversion import celcius_to_kelvin
|
|
10
|
-
from ..verma_net_radiation.verma_net_radiation import daily_Rn_integration_verma
|
|
11
|
-
|
|
12
|
-
# latent heat of vaporization for water at 20 Celsius in Joules per kilogram
|
|
13
|
-
LAMBDA_JKG_WATER_20C = 2450000.0
|
|
14
|
-
|
|
15
|
-
def lambda_Jkg_from_Ta_K(Ta_K: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
16
|
-
# Calculate the latent heat of vaporization (J kg-1)
|
|
17
|
-
return (2.501 - 0.002361 * (Ta_K - 273.15)) * 1e6
|
|
18
|
-
|
|
19
|
-
def lambda_Jkg_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
20
|
-
Ta_K = celcius_to_kelvin(Ta_C)
|
|
21
|
-
lambda_Jkg = lambda_Jkg_from_Ta_K(Ta_K)
|
|
22
|
-
|
|
23
|
-
return lambda_Jkg
|
|
24
|
-
|
|
25
|
-
def daily_ET_from_daily_LE(
|
|
26
|
-
LE_daylight: Union[Raster, np.ndarray],
|
|
27
|
-
daylight_hours: Union[Raster, np.ndarray],
|
|
28
|
-
lambda_Jkg: float = LAMBDA_JKG_WATER_20C) -> Union[Raster, np.ndarray]:
|
|
29
|
-
"""
|
|
30
|
-
Calculate daily evapotranspiration (ET) from daily latent heat flux (LE).
|
|
31
|
-
|
|
32
|
-
Parameters:
|
|
33
|
-
LE_daily (Union[Raster, np.ndarray]): Daily latent heat flux.
|
|
34
|
-
daylight_hours (Union[Raster, np.ndarray]): Length of day in hours.
|
|
35
|
-
latent_vaporization (float, optional): Latent heat of vaporization. Defaults to LATENT_VAPORIZATION.
|
|
36
|
-
|
|
37
|
-
Returns:
|
|
38
|
-
Union[Raster, np.ndarray]: Daily evapotranspiration in kilograms.
|
|
39
|
-
"""
|
|
40
|
-
# convert length of day in hours to seconds
|
|
41
|
-
daylight_seconds = daylight_hours * 3600.0
|
|
42
|
-
|
|
43
|
-
# factor seconds out of watts to get joules and divide by latent heat of vaporization to get kilograms
|
|
44
|
-
ET_daily_kg = rt.clip(LE_daylight * daylight_seconds / LAMBDA_JKG_WATER_20C, 0.0, None)
|
|
45
|
-
|
|
46
|
-
return ET_daily_kg
|
|
47
|
-
|
|
48
|
-
def process_daily_ET_table(input_df: pd.DataFrame) -> pd.DataFrame:
|
|
49
|
-
hour_of_day = input_df.hour_of_day
|
|
50
|
-
DOY = input_df.doy
|
|
51
|
-
lat = input_df.lat
|
|
52
|
-
LE = input_df.LE
|
|
53
|
-
Rn = input_df.Rn
|
|
54
|
-
EF = LE / Rn
|
|
55
|
-
|
|
56
|
-
SHA_deg = SHA_deg_from_DOY_lat(DOY=DOY, latitude=lat)
|
|
57
|
-
sunrise_hour = sunrise_from_SHA(SHA_deg)
|
|
58
|
-
daylight_hours = daylight_from_SHA(SHA_deg)
|
|
59
|
-
|
|
60
|
-
Rn_daylight = daily_Rn_integration_verma(
|
|
61
|
-
Rn=Rn,
|
|
62
|
-
hour_of_day=hour_of_day,
|
|
63
|
-
DOY=DOY,
|
|
64
|
-
lat=lat,
|
|
65
|
-
sunrise_hour=sunrise_hour,
|
|
66
|
-
daylight_hours=daylight_hours
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
LE_daylight = EF * Rn_daylight
|
|
70
|
-
ET = daily_ET_from_daily_LE(LE_daylight, daylight_hours)
|
|
71
|
-
|
|
72
|
-
output_df = input_df.copy()
|
|
73
|
-
output_df["EF"] = EF
|
|
74
|
-
output_df["sunrise_hour"] = sunrise_hour
|
|
75
|
-
output_df["daylight_hours"] = daylight_hours
|
|
76
|
-
output_df["Rn_daylight"] = Rn_daylight
|
|
77
|
-
output_df["ET"] = ET
|
|
78
|
-
|
|
79
|
-
return output_df
|
|
80
|
-
|
PMJPL/fwet.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from typing import Union
|
|
3
|
-
from rasters import Raster
|
|
4
|
-
|
|
5
|
-
from .constants import RH_THRESHOLD, MIN_FWET
|
|
6
|
-
|
|
7
|
-
def calculate_fwet(
|
|
8
|
-
RH: Union[Raster, np.ndarray],
|
|
9
|
-
RH_threshold: float = RH_THRESHOLD,
|
|
10
|
-
min_fwet: float = MIN_FWET) -> Union[Raster, np.ndarray]:
|
|
11
|
-
"""
|
|
12
|
-
calculates relative surface wetness
|
|
13
|
-
:param RH: relative humdity from 0.0 to 1.0
|
|
14
|
-
:return: relative surface wetness from 0.0 to 1.0
|
|
15
|
-
"""
|
|
16
|
-
fwet = np.float32(np.clip(RH ** 4.0, min_fwet, None))
|
|
17
|
-
|
|
18
|
-
if RH_threshold is not None:
|
|
19
|
-
fwet = np.where(RH < RH_threshold, min_fwet, fwet)
|
|
20
|
-
|
|
21
|
-
return fwet
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .meteorology_conversion import *
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
import numpy as np
|
|
3
|
-
import rasters as rt
|
|
4
|
-
from rasters import Raster
|
|
5
|
-
|
|
6
|
-
# gas constant for dry air in joules per kilogram per kelvin
|
|
7
|
-
RD = 286.9
|
|
8
|
-
|
|
9
|
-
# gas constant for moist air in joules per kilogram per kelvin
|
|
10
|
-
RW = 461.5
|
|
11
|
-
|
|
12
|
-
# specific heat of water vapor in joules per kilogram per kelvin
|
|
13
|
-
CPW = 1846.0
|
|
14
|
-
|
|
15
|
-
# specific heat of dry air in joules per kilogram per kelvin
|
|
16
|
-
CPD = 1005.0
|
|
17
|
-
|
|
18
|
-
def kelvin_to_celsius(T_K: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
19
|
-
"""
|
|
20
|
-
convert temperature in kelvin to celsius.
|
|
21
|
-
:param T_K: temperature in kelvin
|
|
22
|
-
:return: temperature in celsius
|
|
23
|
-
"""
|
|
24
|
-
return T_K - 273.15
|
|
25
|
-
|
|
26
|
-
def celcius_to_kelvin(T_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
27
|
-
"""
|
|
28
|
-
convert temperature in celsius to kelvin.
|
|
29
|
-
:param T_C: temperature in celsius
|
|
30
|
-
:return: temperature in kelvin
|
|
31
|
-
"""
|
|
32
|
-
return T_C + 273.15
|
|
33
|
-
|
|
34
|
-
def calculate_specific_humidity(
|
|
35
|
-
Ea_Pa: Union[Raster, np.ndarray],
|
|
36
|
-
Ps_Pa: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
37
|
-
"""
|
|
38
|
-
Calculate the specific humidity of air as a ratio of kilograms of water to kilograms of air.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
Ea_Pa (Union[Raster, np.ndarray]): Actual water vapor pressure in Pascal.
|
|
42
|
-
surface_pressure_Pa (Union[Raster, np.ndarray]): Surface pressure in Pascal.
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
Union[Raster, np.ndarray]: Specific humidity in kilograms of water per kilograms of air.
|
|
46
|
-
"""
|
|
47
|
-
return ((0.622 * Ea_Pa) / (Ps_Pa - (0.387 * Ea_Pa)))
|
|
48
|
-
|
|
49
|
-
def calculate_specific_heat(specific_humidity: Union[Raster, np.ndarray]):
|
|
50
|
-
# calculate specific heat capacity of the air (Cp)
|
|
51
|
-
# in joules per kilogram per kelvin
|
|
52
|
-
# from specific heat of water vapor (CPW)
|
|
53
|
-
# and specific heat of dry air (CPD)
|
|
54
|
-
Cp_Jkg = specific_humidity * CPW + (1 - specific_humidity) * CPD
|
|
55
|
-
|
|
56
|
-
return Cp_Jkg
|
|
57
|
-
|
|
58
|
-
def calculate_air_density(
|
|
59
|
-
surface_pressure_Pa: Union[Raster, np.ndarray],
|
|
60
|
-
Ta_K: Union[Raster, np.ndarray],
|
|
61
|
-
specific_humidity: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
62
|
-
"""
|
|
63
|
-
Calculate air density.
|
|
64
|
-
|
|
65
|
-
Parameters:
|
|
66
|
-
surface_pressure_Pa (Union[Raster, np.ndarray]): Surface pressure in Pascal.
|
|
67
|
-
Ta_K (Union[Raster, np.ndarray]): Air temperature in Kelvin.
|
|
68
|
-
specific_humidity (Union[Raster, np.ndarray]): Specific humidity.
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
Union[Raster, np.ndarray]: Air density in kilograms per cubic meter.
|
|
72
|
-
"""
|
|
73
|
-
# numerator: Pa(N / m ^ 2 = kg * m / s ^ 2); denominator: J / kg / K * K)
|
|
74
|
-
rhoD = surface_pressure_Pa / (RD * Ta_K)
|
|
75
|
-
|
|
76
|
-
# calculate air density (rho) in kilograms per cubic meter
|
|
77
|
-
rho = rhoD * ((1.0 + specific_humidity) / (1.0 + specific_humidity * (RW / RD)))
|
|
78
|
-
|
|
79
|
-
return rho
|
|
80
|
-
|
|
81
|
-
def SVP_kPa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
82
|
-
"""
|
|
83
|
-
Calculate the saturation vapor pressure in kiloPascal (kPa) from air temperature in Celsius.
|
|
84
|
-
|
|
85
|
-
Parameters:
|
|
86
|
-
Ta_C (Union[Raster, np.ndarray]): Air temperature in Celsius.
|
|
87
|
-
|
|
88
|
-
Returns:
|
|
89
|
-
Union[Raster, np.ndarray]: Saturation vapor pressure in kPa.
|
|
90
|
-
|
|
91
|
-
"""
|
|
92
|
-
SVP_kPa = np.clip(0.611 * np.exp((Ta_C * 17.27) / (Ta_C + 237.7)), 1, None)
|
|
93
|
-
|
|
94
|
-
return SVP_kPa
|
|
95
|
-
|
|
96
|
-
def SVP_Pa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
97
|
-
"""
|
|
98
|
-
Calculate the saturation vapor pressure in Pascal (Pa) from the air temperature in Celsius (Ta_C).
|
|
99
|
-
|
|
100
|
-
Parameters:
|
|
101
|
-
Ta_C (Union[Raster, np.ndarray]): Air temperature in Celsius.
|
|
102
|
-
|
|
103
|
-
Returns:
|
|
104
|
-
Union[Raster, np.ndarray]: Saturation vapor pressure in Pascal (Pa).
|
|
105
|
-
"""
|
|
106
|
-
return SVP_kPa_from_Ta_C(Ta_C) * 1000
|
|
107
|
-
|
|
108
|
-
def calculate_surface_pressure(elevation_m: Union[Raster, np.ndarray], Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
109
|
-
"""
|
|
110
|
-
Calculate surface pressure using elevation and air temperature.
|
|
111
|
-
|
|
112
|
-
Parameters:
|
|
113
|
-
elevation_m (Union[Raster, np.ndarray]): Elevation in meters.
|
|
114
|
-
Ta_K (Union[Raster, np.ndarray]): Air temperature in Kelvin.
|
|
115
|
-
|
|
116
|
-
Returns:
|
|
117
|
-
Union[Raster, np.ndarray]: Surface pressure in Pascal (Pa).
|
|
118
|
-
"""
|
|
119
|
-
Ta_K = kelvin_to_celsius(Ta_C)
|
|
120
|
-
Ps_Pa = 101325.0 * (1.0 - 0.0065 * elevation_m / Ta_K) ** (9.807 / (0.0065 * 287.0)) # [Pa]
|
|
121
|
-
|
|
122
|
-
return Ps_Pa
|
|
123
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .penman_monteith import *
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
import numpy as np
|
|
3
|
-
from ..evapotranspiration_conversion.evapotranspiration_conversion import lambda_Jkg_from_Ta_C
|
|
4
|
-
from ..meteorology_conversion.meteorology_conversion import celcius_to_kelvin
|
|
5
|
-
|
|
6
|
-
from rasters import Raster
|
|
7
|
-
|
|
8
|
-
SPECIFIC_HEAT_CAPACITY_AIR = 1013 # J kg-1 K-1, Monteith & Unsworth (2001)
|
|
9
|
-
MOL_WEIGHT_WET_DRY_RATIO_AIR = 0.622
|
|
10
|
-
|
|
11
|
-
def calculate_gamma(
|
|
12
|
-
Ta_C: Union[Raster, np.ndarray],
|
|
13
|
-
Ps_Pa: Union[Raster, np.ndarray],
|
|
14
|
-
Cp_Jkg: Union[Raster, np.ndarray, float] = SPECIFIC_HEAT_CAPACITY_AIR,
|
|
15
|
-
RMW: Union[Raster, np.ndarray, float] = MOL_WEIGHT_WET_DRY_RATIO_AIR) -> Union[Raster, np.ndarray]:
|
|
16
|
-
# calculate latent heat of vaporization (J kg-1)
|
|
17
|
-
lambda_Jkg = lambda_Jkg_from_Ta_C(Ta_C)
|
|
18
|
-
gamma = (Cp_Jkg * Ps_Pa) / (lambda_Jkg * RMW)
|
|
19
|
-
|
|
20
|
-
return gamma
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .priestley_taylor import *
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
import numpy as np
|
|
3
|
-
|
|
4
|
-
from rasters import Raster
|
|
5
|
-
|
|
6
|
-
# psychrometric constant gamma in kiloPascal per degree Celsius
|
|
7
|
-
# same as value for ventilated (Asmann type) psychrometers, with an air movement of some 5 m/s
|
|
8
|
-
# http://www.fao.org/docrep/x0490e/x0490e07.htm
|
|
9
|
-
GAMMA_KPA = 0.0662 # kPa/C
|
|
10
|
-
|
|
11
|
-
# psychrometric constant gamma in Pascal per degree Celsius
|
|
12
|
-
GAMMA_PA = GAMMA_KPA * 1000
|
|
13
|
-
|
|
14
|
-
def delta_kPa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
15
|
-
return 4098 * (0.6108 * np.exp(17.27 * Ta_C / (237.7 + Ta_C))) / (Ta_C + 237.3) ** 2
|
|
16
|
-
|
|
17
|
-
def delta_Pa_from_Ta_C(Ta_C: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
18
|
-
return delta_kPa_from_Ta_C(Ta_C) * 1000
|
|
19
|
-
|
|
20
|
-
def calculate_epsilon(delta: Union[Raster, np.ndarray], gamma: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
21
|
-
return delta / (delta + gamma)
|
|
22
|
-
|
|
23
|
-
def epsilon_from_Ta_C(Ta_C: Union[Raster, np.ndarray], gamma_Pa: Union[Raster, np.ndarray, float] = GAMMA_PA) -> Union[Raster, np.ndarray]:
|
|
24
|
-
delta_Pa = delta_Pa_from_Ta_C(Ta_C)
|
|
25
|
-
epsilon = calculate_epsilon(delta=delta_Pa, gamma=gamma_Pa)
|
|
26
|
-
|
|
27
|
-
return epsilon
|
PMJPL/santanello/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .santanello import *
|
PMJPL/santanello/santanello.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
import numpy as np
|
|
3
|
-
|
|
4
|
-
import rasters as rt
|
|
5
|
-
from rasters import Raster
|
|
6
|
-
|
|
7
|
-
def calculate_soil_heat_flux(
|
|
8
|
-
seconds_of_day: Union[Raster, np.ndarray],
|
|
9
|
-
Rn: Union[Raster, np.ndarray],
|
|
10
|
-
SM: Union[Raster, np.ndarray]) -> Union[Raster, np.ndarray]:
|
|
11
|
-
"""
|
|
12
|
-
This function calculates the soil heat flux (G) based on the method proposed by Santanello and Friedl (2003).
|
|
13
|
-
The method estimates G as a function of time of day, net radiation (Rn), and soil moisture (SM).
|
|
14
|
-
|
|
15
|
-
Parameters:
|
|
16
|
-
seconds_of_day (np.ndarray): Time in seconds of the day since midnight
|
|
17
|
-
Rn (np.ndarray): Net radiation in W/m^2
|
|
18
|
-
SM (np.ndarray): Soil moisture in m^3/m^3
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
G (np.ndarray): Soil heat flux in W/m^2
|
|
22
|
-
|
|
23
|
-
Reference:
|
|
24
|
-
Santanello, J. A., & Friedl, M. A. (2003). Diurnal covariation in soil heat flux and net radiation. Journal of Applied Meteorology, 42(6), 851-862.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
# Constants for wet and dry surface conditions
|
|
28
|
-
cgMIN = 0.05 # for wet surface
|
|
29
|
-
cgMAX = 0.35 # for dry surface
|
|
30
|
-
tgMIN = 74000 # for wet surface
|
|
31
|
-
tgMAX = 100000 # for dry surface
|
|
32
|
-
|
|
33
|
-
# Solar noon in seconds
|
|
34
|
-
solNooN = 12 * 60 * 60
|
|
35
|
-
tg0 = solNooN - seconds_of_day
|
|
36
|
-
|
|
37
|
-
# Estimating soil heat flux (G) according to Santanello and Friedl (2003)
|
|
38
|
-
cg = (1 - SM) * cgMAX + SM * cgMIN
|
|
39
|
-
tg = (1 - SM) * tgMAX + SM * tgMIN
|
|
40
|
-
|
|
41
|
-
G = Rn * cg * np.cos(2 * np.pi * (tg0 + 10800) / tg)
|
|
42
|
-
|
|
43
|
-
# Adjusting G for negative net radiation
|
|
44
|
-
G = rt.where(Rn < 0, -G, G)
|
|
45
|
-
|
|
46
|
-
return G
|
PMJPL/soil_heat_flux/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .soil_heat_flux import *
|