@@ -63,6 +63,7 @@ def build_historical_rainfall_dict(lat, lon, dataset, start_date, end_date, dail
6363 dict of int: (float, int): keys are the start date year for each term, values are
6464 a tuple of total rainfall and the number of days in the term for the term period starting that year
6565 bool is_final: true if all data included is from the final dataset
66+ If there is missing rainfall data for a period, the value for that year will be None, None
6667 Raises:
6768 DatasetError: If no matching dataset found on server
6869 InputOutOfRangeError: If the lat/lon is outside the dataset range in metadata
@@ -87,9 +88,11 @@ def build_historical_rainfall_dict(lat, lon, dataset, start_date, end_date, dail
8788 # end date is tricky because it could be in the next calendar year
8889 historical_end = end_date .replace (year = year + (end_date .year - start_date .year ))
8990 year_term = listify_period (historical_start , historical_end )
90- if daily_cap :
91- yearly_rain = [min (rainfall_dict [date ], daily_cap ) for date in year_term ]
91+ yearly_rain = [rainfall_dict [date ] for date in year_term ]
92+ if None in yearly_rain :
93+ yearly_rainfall [year ]= None , None
9294 else :
93- yearly_rain = [rainfall_dict [date ] for date in year_term ]
94- yearly_rainfall [year ] = (sum (yearly_rain ), len (yearly_rain ))
95+ if daily_cap :
96+ yearly_rain = list (map (lambda x : min (x , daily_cap ), yearly_rain ))
97+ yearly_rainfall [year ] = (sum (yearly_rain ), len (yearly_rain ))
9598 return yearly_rainfall , is_final
0 commit comments