@@ -853,15 +853,19 @@ def onset_tile(tz, tx, ty):
853
853
cess_soil_moisture ,
854
854
cess_dry_spell ,
855
855
)
856
+ if cess_dates ["T" ][0 ] < onset_dates ["T" ][0 ]:
857
+ cess_dates = cess_dates .isel ({"T" : slice (1 , None )})
858
+ if cess_dates ["T" ].size != onset_dates ["T" ].size :
859
+ onset_dates = onset_dates .isel ({"T" : slice (None , - 2 )})
860
+ cess_dates = (cess_dates ["T" ] + cess_dates ["cess_delta" ]).drop_indexes ("T" )
861
+ onset_dates = (onset_dates ["T" ] + onset_dates ["onset_delta" ]).drop_indexes ("T" )
856
862
if "length" in map_choice :
857
- if cess_dates ["T" ][0 ] < onset_dates ["T" ][0 ]:
858
- cess_dates = cess_dates .isel ({"T" : slice (1 , None )})
859
- if cess_dates ["T" ].size != onset_dates ["T" ].size :
860
- onset_dates = onset_dates .isel ({"T" : slice (None , - 2 )})
861
- seasonal_length = (
862
- (cess_dates ["T" ] + cess_dates ["cess_delta" ]).drop_indexes ("T" )
863
- - (onset_dates ["T" ] + onset_dates ["onset_delta" ]).drop_indexes ("T" )
864
- ) #.astype("timedelta64[D]")
863
+ seasonal_length = cess_dates - onset_dates
864
+ else :
865
+ seasonal_total = precip_tile .where (
866
+ (precip_tile ["T" ] >= onset_dates .rename ({"T" : "Ty" }))
867
+ & (precip_tile ["T" ] <= cess_dates .rename ({"T" : "Ty" }))
868
+ ).sum ("T" )
865
869
if map_choice == "mean" :
866
870
map_data = onset_dates .onset_delta .mean ("T" )
867
871
map_max = np .timedelta64 (search_days , 'D' )
@@ -886,6 +890,17 @@ def onset_tile(tz, tx, ty):
886
890
map_data = (seasonal_length < np .timedelta64 (prob_exc_thresh_length , 'D' )).mean ("T" ) * 100
887
891
map_max = 100
888
892
colormap = pingrid .CORRELATION_COLORMAP
893
+ if map_choice == "total_mean" :
894
+ map_data = seasonal_total .mean ("Ty" )
895
+ map_max = CONFIG ["map_text" ][map_choice ]["map_max" ]
896
+ colormap = pingrid .RAINFALL_COLORMAP
897
+ if map_choice == "total_stddev" :
898
+ map_data = seasonal_total .std (dim = "Ty" , skipna = True )
899
+ map_max = CONFIG ["map_text" ][map_choice ]["map_max" ]
900
+ if map_choice == "total_pe" :
901
+ map_data = (seasonal_total < prob_exc_thresh_tot ).mean ("Ty" ) * 100
902
+ map_max = 100
903
+ colormap = pingrid .CORRELATION_COLORMAP
889
904
map_data .attrs ["colormap" ] = colormap
890
905
map_data = map_data .rename (X = "lon" , Y = "lat" )
891
906
map_data .attrs ["scale_min" ] = map_min
@@ -928,6 +943,16 @@ def set_colorbar(search_start_day, search_start_month, search_days, map_choice):
928
943
tick_freq = 5
929
944
map_max = CONFIG ["map_text" ][map_choice ]["map_max" ]
930
945
unit = "days"
946
+ if map_choice == "total_mean" :
947
+ colorbar = pingrid .to_dash_colorscale (pingrid .RAINFALL_COLORMAP )
948
+ tick_freq = 100
949
+ map_max = CONFIG ["map_text" ][map_choice ]["map_max" ]
950
+ unit = "mm"
951
+ if map_choice == "total_stddev" :
952
+ tick_freq = 30
953
+ )
954
+ map_max = CONFIG ["map_text" ][map_choice ]["map_max" ]
955
+ unit = "mm"
931
956
if map_choice == "monit" :
932
957
precip = rr_mrg .precip .isel ({"T" : slice (- 366 , None )})
933
958
search_start_dm = calc .sel_day_and_month (
0 commit comments