@@ -429,6 +429,11 @@ def onset_plots(
429
429
int (dry_spell ),
430
430
time_coord = "T" ,
431
431
)
432
+ isnan = np .isnan (onset_delta ["onset_delta" ]).mean ()
433
+ if isnan == 1 :
434
+ error_fig = pingrid .error_fig (error_msg = "No onset dates were found" )
435
+ germ_sentence = ""
436
+ return error_fig , error_fig , germ_sentence
432
437
except TypeError :
433
438
error_fig = pingrid .error_fig (
434
439
error_msg = "Please ensure all input boxes are filled for the calculation to run."
@@ -552,6 +557,10 @@ def cess_plots(
552
557
int (cess_dry_spell ),
553
558
time_coord = "T" ,
554
559
)
560
+ isnan = np .isnan (cess_delta ["cess_delta" ]).mean ()
561
+ if isnan == 1 :
562
+ error_fig = pingrid .error_fig (error_msg = "No cessation dates were found" )
563
+ return error_fig , error_fig , tab_style
555
564
except TypeError :
556
565
error_fig = pingrid .error_fig (error_msg = "Please ensure all input boxes are filled for the calculation to run." )
557
566
return (
@@ -669,6 +678,10 @@ def length_plots(
669
678
int (dry_spell ),
670
679
time_coord = "T" ,
671
680
)
681
+ isnan = np .isnan (onset_delta ["onset_delta" ]).mean ()
682
+ if isnan == 1 :
683
+ error_fig = pingrid .error_fig (error_msg = "No onset dates were found" )
684
+ return error_fig , error_fig , tab_style
672
685
except TypeError :
673
686
error_fig = pingrid .error_fig (
674
687
error_msg = "Please ensure all onset input boxes are filled."
@@ -685,17 +698,29 @@ def length_plots(
685
698
int (cess_dry_spell ),
686
699
time_coord = "T" ,
687
700
)
701
+ isnan = np .isnan (cess_delta ["cess_delta" ]).mean ()
702
+ if isnan == 1 :
703
+ error_fig = pingrid .error_fig (error_msg = "No cessation dates were found" )
704
+ return error_fig , error_fig , tab_style
688
705
except TypeError :
689
706
error_fig = pingrid .error_fig (error_msg = "Please ensure all cessation input boxes are filled" )
690
707
return error_fig , error_fig , tab_style
691
708
if cess_delta ["T" ][0 ] < onset_delta ["T" ][0 ]:
692
709
cess_delta = cess_delta .isel ({"T" : slice (1 , None )})
693
710
if cess_delta ["T" ].size != onset_delta ["T" ].size :
694
711
onset_delta = onset_delta .isel ({"T" : slice (None , - 2 )})
695
- seasonal_length = (
696
- (cess_delta ["T" ] + cess_delta ["cess_delta" ]).drop_indexes ("T" )
697
- - (onset_delta ["T" ] + onset_delta ["onset_delta" ]).drop_indexes ("T" )
698
- )
712
+ try :
713
+ seasonal_length = (
714
+ (cess_delta ["T" ] + cess_delta ["cess_delta" ]).drop_indexes ("T" )
715
+ - (onset_delta ["T" ] + onset_delta ["onset_delta" ]).drop_indexes ("T" )
716
+ )
717
+ isnan = np .isnan (seasonal_length ).mean ()
718
+ if isnan == 1 :
719
+ error_fig = pingrid .error_fig (error_msg = "Onset or cessation not found for any season" )
720
+ return error_fig , error_fig , tab_style
721
+ except TypeError :
722
+ error_fig = pingrid .error_fig (error_msg = "Please ensure all onset/cessation input boxes are filled" )
723
+ return error_fig , error_fig , tab_style
699
724
length_graph = pgo .Figure ()
700
725
length_graph .add_trace (
701
726
pgo .Scatter (
0 commit comments