@@ -106,10 +106,10 @@ def getFragments(nSeasons, nGoodDays, dailyWetState, dailyDepth, stnDetails, nea
106106 dataIdxEnd = (date .toordinal (date (
107107 int (dayVecEnd [0 ]),int (dayVecEnd [1 ]),int (dayVecEnd [2 ])))
108108 - date .toordinal (date (yearStart ,1 ,1 ))+ 1 )
109-
109+ SUBDAILY_SCALE = 0.1
110110 tmpSubDaily = np .ones ((nDaysKnown , recordsPerDay ,)) * missingDay #dimensions flipped
111- tmpSubDaily [dataIdxStart :dataIdxEnd , :] = ds ['rainfall' ][:].data / 10 #
112-
111+ tmpSubDaily [dataIdxStart :dataIdxEnd , :] = ds ['rainfall' ][:].data * SUBDAILY_SCALE
112+
113113 # This is the index into the days dimension of tmpSubDaily
114114 idxDayLinear = 0
115115 # Loop over each year in this station
@@ -118,19 +118,25 @@ def getFragments(nSeasons, nGoodDays, dailyWetState, dailyDepth, stnDetails, nea
118118 #for loopDay in range(nDaysCurrYear):
119119 for loopDay in range (ndaysYearLeap ):
120120 # still need to handle a leap year...
121- if (loopDay == idxfebTwentyNine and
122- nDaysCurrYear != ndaysYearLeap ):
121+ if (loopDay == idxfebTwentyNine and
122+ nDaysCurrYear != ndaysYearLeap ):
123123 continue
124+ daily_bad = dailyWetState [loopSeason ][loopDay ,idxYear ] == stateBad
125+ day_is_wet = dailyDepth [loopSeason ][loopDay ,idxYear ] > param ['dryWetCutoff' ]
126+ the_fragment = tmpSubDaily [idxDayLinear ,:]
127+ subdaily_missing = (np .min (the_fragment ) < 0 )
128+ if subdaily_missing and day_is_wet and not daily_bad :
129+ num_missing = np .sum (the_fragment < 0 )
130+ print (f'{ fnameNC } : Missing sub-daily data found for year { loopYear } , day { loopDay } : { num_missing } timesteps' )
131+
124132 # But otherwise work through:
125- if (dailyWetState [loopSeason ][loopDay ,idxYear ] != stateBad and
126- dailyDepth [loopSeason ][loopDay ,idxYear ] > param ['dryWetCutoff' ]):
127-
133+ if day_is_wet and not subdaily_missing and not daily_bad :
128134 fragments [loopSeason ][loopDay ,int (fragmentCounter [loopDay ]),:] = \
129- tmpSubDaily [ idxDayLinear ,:]
130-
135+ the_fragment
136+
131137 fragmentsState [loopSeason ][loopDay ,int (fragmentCounter [loopDay ])]= \
132138 dailyWetState [loopSeason ][loopDay , idxYear ]
133-
139+
134140 fragmentsDailyDepth [loopSeason ][loopDay ,int (fragmentCounter [loopDay ])]= \
135141 dailyDepth [loopSeason ][loopDay ,idxYear ]
136142
0 commit comments