Commit bedf6483 authored by Clément Haëck's avatar Clément Haëck
Browse files

Up hist to timeseries script

parent 4185115c
......@@ -14,11 +14,12 @@ def main():
def add_args(parser):
parser.add_argument('-threshold', type=float, default=15.)
args = lib.get_args(['region', 'number',
args = lib.get_args(['region', 'year', 'number',
'scale', 'coef', 'zone', 'fixes'],
add_args=add_args)
args['days'] = 1
args['Y'] = args['fixes']['Y']
args['Y'] = args['year']
args['fixes']['Y'] = args['year']
args['fixes']['number'] = args['number']
args['fixes']['scale'] = args['scale']
args['fixes']['coef'] = args['coef']
......@@ -26,7 +27,8 @@ def main():
args['fixes']['threshold'] = args['threshold']
ds = lib.data.hists.get_data(args)
ds = ds.squeeze()
ds = ds.chunk(dict(zone=1, mask=1, variable=1))
ds = ds.chunk({dim: 1 for dim in ['mask', 'zone', 'variable']
if dim in ds.dims})
ts = pd.DatetimeIndex([])
for year in set(ds.time.dt.year.values):
......@@ -34,7 +36,8 @@ def main():
periods=46))
ts = ts.append(pd.to_datetime(['{}/12/31'.format(year)]))
hist = ds.hist.groupby_bins('time', ts, labels=ts[:-1]).sum()
hist = ds.hist.groupby_bins('time', ts, labels=ts[:-1],
right=False).sum()
hist = hist.rename(time_bins='time').to_dataset()
hist['bins'] = ds.bins
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment