Skip to content
Snippets Groups Projects
Commit c236c6e8 authored by tuckersiegel's avatar tuckersiegel
Browse files

add leap days back in

parent 2d5603a2
No related branches found
No related tags found
No related merge requests found
...@@ -62,16 +62,16 @@ for year in years: ...@@ -62,16 +62,16 @@ for year in years:
tmaxs = data.tmax.data tmaxs = data.tmax.data
if is_leap_year(year): # extra day in leap year screws everything up # if is_leap_year(year): # extra day in leap year screws everything up
tmin_1 = tmins[:59] # tmin_1 = tmins[:59]
tmin_2 = tmins[60:] # tmin_2 = tmins[60:]
tmax_1 = tmaxs[:59] # tmax_1 = tmaxs[:59]
tmin_2 = tmaxs[60:] # tmin_2 = tmaxs[60:]
tmins = np.concatenate([tmin_1, tmin_2], axis=0) # tmins = np.concatenate([tmin_1, tmin_2], axis=0)
tmaxs = np.concatenate([tmax_1, tmin_2], axis=0) # tmaxs = np.concatenate([tmax_1, tmin_2], axis=0)
locs = [] locs = []
...@@ -127,30 +127,52 @@ gdd = db["normals"] ...@@ -127,30 +127,52 @@ gdd = db["normals"]
resp = gdd.create_index([ ("location", "2dsphere") ]) resp = gdd.create_index([ ("location", "2dsphere") ])
resp = gdd.create_index([ ("year", 1) ]) resp = gdd.create_index([ ("year", 1) ])
single_year_min = np.zeros((365, 621, 1405)) single_year_min = np.zeros((366, 621, 1405))
single_year_max = np.zeros((365, 621, 1405)) single_year_max = np.zeros((366, 621, 1405))
ld_min = np.zeros((single_year_min.shape[-2], single_year_min.shape[-1]))
ld_max = np.zeros((single_year_min.shape[-2], single_year_min.shape[-1]) )
ld_count = 0
for year in range(1981, 2010+1): for year in range(1981, 2010+1):
print (year) print (year)
data = xr.open_dataset("data/temps_%s.nc" % year) data = xr.open_dataset("data/temps_%s.nc" % year)
tmins = data.tmin.data tmins = data.tmin.data
tmaxs = data.tmax.data tmaxs = data.tmax.data
## idx 59 is leap day
if not is_leap_year(year): # extra day in leap year screws everything up
if is_leap_year(year): # extra day in leap year screws everything up insert = np.zeros((1, tmins.shape[-2], tmins.shape[-1]))
insert[:] = np.nan
tmin_1 = tmins[:59] tmin_1 = tmins[:59]
tmin_2 = tmins[60:] tmin_2 = tmins[59:]
tmax_1 = tmaxs[:59] tmax_1 = tmaxs[:59]
tmin_2 = tmaxs[60:] tmin_2 = tmaxs[59:]
tmins = np.concatenate([tmin_1, insert, tmin_2], axis=0)
tmaxs = np.concatenate([tmax_1, insert, tmin_2], axis=0)
else:
ld_min += tmins[59]
ld_max += tmaxs[59]
ld_count += 1
tmins = np.concatenate([tmin_1, tmin_2], axis=0)
tmaxs = np.concatenate([tmax_1, tmin_2], axis=0)
single_year_max += tmaxs/30 single_year_max += tmaxs/30
single_year_min += tmins/30 single_year_min += tmins/30
ld_min = ld_min/ld_count
ld_max = ld_max/ld_count
single_year_min[59] = ld_min
single_year_max[59] = ld_max
x = np.where(~np.isnan(np.nanmean(single_year_max, axis=0))) x = np.where(~np.isnan(np.nanmean(single_year_max, axis=0)))
# x = [(a, b) for a, b in zip(x[0], x[1])] # x = [(a, b) for a, b in zip(x[0], x[1])]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment