@@ -172,7 +172,7 @@ def process_local_image(self):
172
172
elif field == "input_mask" :
173
173
if self .p ['input_mask' ] == '0' :
174
174
# Create mask from landcover array
175
- mask = np .ones (dims )
175
+ mask = np .ones (dims , np . int32 )
176
176
mask [np .logical_or .reduce ((in_data ['landcover' ] == res .WATER ,
177
177
in_data ['landcover' ] == res .URBAN ,
178
178
in_data ['landcover' ] == res .SNOW ))] = 0
@@ -530,12 +530,12 @@ def run(self, in_data, mask=None):
530
530
"resistance_form" : [self .resistance_form , self .res_params ]}
531
531
532
532
if mask is None :
533
- mask = np .ones (in_data ['LAI' ].shape )
533
+ mask = np .ones (in_data ['LAI' ].shape , np . int32 )
534
534
535
535
# Create the output dictionary
536
536
out_data = dict ()
537
537
for field in self ._get_output_structure ():
538
- out_data [field ] = np .zeros (in_data ['LAI' ].shape ) + np .NaN
538
+ out_data [field ] = np .zeros (in_data ['LAI' ].shape , np . float32 ) + np .NaN
539
539
540
540
# Esimate diffuse and direct irradiance
541
541
difvis , difnir , fvis , fnir = rad .calc_difuse_ratio (
@@ -591,10 +591,11 @@ def run(self, in_data, mask=None):
591
591
f_c = in_data ['f_c' ][i ])
592
592
593
593
# Net shortwave radiation for vegetation
594
- F = np .zeros (in_data ['LAI' ].shape )
594
+ F = np .zeros (in_data ['LAI' ].shape , np . float32 )
595
595
F [i ] = in_data ['LAI' ][i ] / in_data ['f_c' ][i ]
596
596
# Clumping index
597
- omega0 , Omega = np .zeros (in_data ['LAI' ].shape ), np .zeros (in_data ['LAI' ].shape )
597
+ omega0 = np .zeros (in_data ['LAI' ].shape , np .float32 )
598
+ Omega = np .zeros (in_data ['LAI' ].shape , np .float32 )
598
599
omega0 [i ] = CI .calc_omega0_Kustas (
599
600
in_data ['LAI' ][i ],
600
601
in_data ['f_c' ][i ],
@@ -637,7 +638,7 @@ def run(self, in_data, mask=None):
637
638
638
639
if self .water_stress :
639
640
i = np .array (np .logical_and (~ noVegPixels , mask == 1 ))
640
- [_ , _ , _ , _ , _ , _ , out_data ['LE_0' ][i ], _ ,
641
+ [_ , _ , _ , _ , _ , _ , out_data ['LE_0' ][i ], _ ,
641
642
out_data ['LE_C_0' ][i ], _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ] = \
642
643
pet .shuttleworth_wallace (
643
644
in_data ['T_A1' ][i ],
@@ -670,13 +671,11 @@ def run(self, in_data, mask=None):
670
671
671
672
out_data ['CWSI' ][i ] = 1.0 - (out_data ['LE_C1' ][i ] / out_data ['LE_C_0' ][i ])
672
673
673
-
674
674
if self .calc_daily_ET :
675
- out_data ['ET_day' ] = met .flux_2_evaporation (in_data ['S_dn_24' ] * out_data ['LE1' ] / in_data ['S_dn' ],
676
- t_k = 20 + 273.15 ,
675
+ out_data ['ET_day' ] = met .flux_2_evaporation (in_data ['S_dn_24' ] * out_data ['LE1' ] / in_data ['S_dn' ],
676
+ t_k = 20 + 273.15 ,
677
677
time_domain = 24 )
678
-
679
-
678
+
680
679
print ("Finished processing!" )
681
680
return out_data
682
681
@@ -801,7 +800,7 @@ def _set_param_array(self, parameter, dims, band=1):
801
800
802
801
# See if the parameter is a number
803
802
try :
804
- array = np .zeros (dims ) + float (parameter )
803
+ array = np .zeros (dims , np . float32 ) + float (parameter )
805
804
return success , array
806
805
except ValueError :
807
806
pass
@@ -814,19 +813,19 @@ def _set_param_array(self, parameter, dims, band=1):
814
813
return success , array
815
814
# If it is then get the value of that parameter
816
815
try :
817
- array = np .zeros (dims ) + float (inputString )
816
+ array = np .zeros (dims , np . float32 ) + float (inputString )
818
817
except ValueError :
819
818
try :
820
819
fid = gdal .Open (inputString , gdal .GA_ReadOnly )
821
820
if self .subset :
822
821
array = fid .GetRasterBand (band ).ReadAsArray (self .subset [0 ],
823
822
self .subset [1 ],
824
823
self .subset [2 ],
825
- self .subset [3 ])
824
+ self .subset [3 ]). astype ( np . float32 )
826
825
else :
827
- array = fid .GetRasterBand (band ).ReadAsArray ()
826
+ array = fid .GetRasterBand (band ).ReadAsArray (). astype ( np . float32 )
828
827
except AttributeError :
829
- print ("%s image not present for parameter %s" % (inputString , parameter ))
828
+ print ("%s image not present for parameter %s" % (inputString , parameter ))
830
829
success = False
831
830
finally :
832
831
fid = None
@@ -1065,7 +1064,7 @@ def _get_input_structure(self):
1065
1064
# Soil heat flux parameter
1066
1065
("G" , "Soil Heat Flux Parameter" ),
1067
1066
('S_dn_24' , 'Daily shortwave irradiance' )])
1068
-
1067
+
1069
1068
return input_fields
1070
1069
1071
1070
def _set_special_model_input (self , field , dims ):
@@ -1577,9 +1576,9 @@ def _set_special_model_input(self, field, dims):
1577
1576
inputs [field ] = fid .GetRasterBand (1 ).ReadAsArray (subset [0 ],
1578
1577
subset [1 ],
1579
1578
subset [2 ],
1580
- subset [3 ])
1579
+ subset [3 ]). astype ( np . float32 )
1581
1580
else :
1582
- inputs [field ] = fid .GetRasterBand (1 ).ReadAsArray ()
1581
+ inputs [field ] = fid .GetRasterBand (1 ).ReadAsArray (). astype ( np . float32 )
1583
1582
inputs ['scale' ] = [geo_LR , prj_LR , self .geo , self .prj ]
1584
1583
success = True
1585
1584
else :
0 commit comments