4242
4343from carlson_leaf_area_index import carlson_leaf_area_index
4444from sun_angles import calculate_daylight
45- from verma_net_radiation import verma_net_radiation , daily_Rn_integration_verma
46- from daily_evapotranspiration_upscaling import daily_ET_from_instantaneous , daily_ET_from_daily_LE
45+ from verma_net_radiation import verma_net_radiation , daylight_Rn_integration_verma
46+ from daylight_evapotranspiration import daylight_ET_from_instantaneous_LE , daylight_ET_from_daylight_LE
4747
4848from PTJPL import GAMMA_PA
4949from PTJPL import BETA_PA
7777def PTJPLSM (
7878 NDVI : Union [Raster , np .ndarray , float ],
7979 Rn_Wm2 : Union [Raster , np .ndarray , float ] = None ,
80- Rn_daily_Wm2 : Union [Raster , np .ndarray , float ] = None ,
80+ Rn_daylight_Wm2 : Union [Raster , np .ndarray , float ] = None ,
8181 geometry : RasterGeometry = None ,
8282 time_UTC : datetime = None ,
8383 hour_of_day : np .ndarray = None ,
@@ -107,7 +107,7 @@ def PTJPLSM(
107107 wilting_point_directory : str = SOIL_CAPACITY_DIRECTORY ,
108108 canopy_height_directory : str = GEDI_DOWNLOAD_DIRECTORY ,
109109 floor_Topt : bool = FLOOR_TOPT ,
110- upscale_to_daily : bool = UPSCALE_TO_DAILY ,
110+ upscale_to_daylight : bool = UPSCALE_TO_DAYLIGHT ,
111111 regenerate_net_radiation : bool = False ,
112112 resampling : str = RESAMPLING ) -> Dict [str , Union [Raster , np .ndarray ]]:
113113 """
@@ -307,8 +307,8 @@ def PTJPLSM(
307307 elif SWin_Wm2 is not None :
308308 logger .info ("using given shortwave radiation (SWin_Wm2)" )
309309
310- if upscale_to_daily :
311- logger .info ("running Verma net radiation with daily upscaling" )
310+ if upscale_to_daylight :
311+ logger .info ("running Verma net radiation with daylight upscaling" )
312312 else :
313313 logger .info ("running instantaneous Verma net radiation" )
314314
@@ -319,13 +319,13 @@ def PTJPLSM(
319319 emissivity = emissivity ,
320320 Ta_C = Ta_C ,
321321 RH = RH ,
322- upscale_to_daily = upscale_to_daily ,
322+ upscale_to_daylight = upscale_to_daylight ,
323323 )
324324
325325 Rn_Wm2 = Rn_results ["Rn_Wm2" ]
326326
327- if "Rn_daily_Wm2 " in Rn_results :
328- Rn_daily_Wm2 = Rn_results ["Rn_daily_Wm2 " ]
327+ if "Rn_daylight_Wm2 " in Rn_results :
328+ Rn_daylight_Wm2 = Rn_results ["Rn_daylight_Wm2 " ]
329329
330330 elif Rn_Wm2 is not None :
331331 logger .info ("using given net radiation (Rn_Wm2) for PT-JPL-SM processing" )
@@ -465,49 +465,25 @@ def PTJPLSM(
465465 check_distribution (LE_Wm2 , "LE_Wm2" )
466466 results ["LE_Wm2" ] = LE_Wm2
467467
468- if upscale_to_daily and time_UTC is not None :
469- logger .info ("started daily ET upscaling" )
468+ if upscale_to_daylight and time_UTC is not None :
469+ logger .info ("started daylight ET upscaling" )
470470 t_et = TicToc ()
471471 t_et .tic ()
472472
473- if Rn_daily_Wm2 is None :
474- logger .info ("running daily net radiation integration" )
475- Rn_daily_Wm2 = daily_Rn_integration_verma (
476- Rn_Wm2 = Rn_Wm2 ,
477- time_UTC = time_UTC ,
478- geometry = geometry
479- )
480-
481- check_distribution (Rn_daily_Wm2 , "Rn_daily_Rn_Wm2" )
482- results ["Rn_daily_Wm2" ] = Rn_daily_Wm2
483-
484- EF = rt .where ((LE_Wm2 == 0 ) | ((Rn_Wm2 - G_Wm2 ) == 0 ), 0 , LE_Wm2 / (Rn_Wm2 - G_Wm2 ))
485- check_distribution (EF , "EF" )
486- results ["EF" ] = EF
487-
488- # Calculate latent heat flux during daylight
489- LE_daylight_Wm2 = EF * Rn_daily_Wm2
490- check_distribution (LE_daylight_Wm2 , "LE_daylight_Wm2" )
491- results ["LE_daylight_Wm2" ] = LE_daylight_Wm2
492-
493- # Calculate daily ET
494- # ET = daily_ET_from_daily_LE(LE_daylight_Wm2, datetime_UTC=time_UTC, geometry=geometry)
495-
496- daylight_hours = calculate_daylight (day_of_year = day_of_year , time_UTC = time_UTC , geometry = geometry )
497-
498- # convert length of day in hours to seconds
499- daylight_seconds = daylight_hours * 3600.0
500-
501- LAMBDA_JKG_WATER_20C = 2450000.0
502-
503- # factor seconds out of watts to get joules and divide by latent heat of vaporization to get kilograms
504- ET_daily_kg = rt .clip (LE_daylight_Wm2 * daylight_seconds / LAMBDA_JKG_WATER_20C , 0.0 , None )
505-
506- check_distribution (ET_daily_kg , "ET_daily_kg" )
507- results ["ET_daily_kg" ] = ET_daily_kg
473+ # Use new upscaling function from daylight_evapotranspiration
474+ daylight_results = daylight_ET_from_instantaneous_LE (
475+ LE_instantaneous_Wm2 = LE_Wm2 ,
476+ Rn_instantaneous_Wm2 = Rn_Wm2 ,
477+ G_instantaneous_Wm2 = G_Wm2 ,
478+ day_of_year = day_of_year ,
479+ time_UTC = time_UTC ,
480+ geometry = geometry
481+ )
482+ # Add all returned daylight results to output
483+ results .update (daylight_results )
508484
509485 elapsed_et = t_et .tocvalue ()
510- logger .info (f"completed daily ET upscaling (elapsed: { elapsed_et :.2f} seconds)" )
486+ logger .info (f"completed daylight ET upscaling (elapsed: { elapsed_et :.2f} seconds)" )
511487
512488 elapsed = t .tocvalue ()
513489 logger .info (f"PT-JPL-SM model run complete (elapsed: { elapsed :.2f} seconds)" )
0 commit comments