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

Rename to setup_metadata

parent 7c832934
......@@ -71,7 +71,7 @@ def merge_pigments(args):
image = images_grp[modis_file][image_idx]
pig = xr.open_dataset(f)[var]
ds[var][dict(lon=image.slice_x, lat=image.slice_y)] = pig.values
lib.setup_meta_attrs(ds, args)
lib.setup_metadata(ds, args)
ds.to_netcdf(ofile, encoding=encoding)
......
......@@ -25,6 +25,6 @@ clouds = clouds.rename(CHL='cloud_probability')
clouds = clouds.chunk({'time': 1})
odir = lib.data.clouds_maps.get_root(args)
lib.setup_meta_attrs(clouds, args)
lib.setup_metadata(clouds, args)
save_chunks_by_date(clouds, path.join(odir, '%Y/cloud_%Y%m.nc'),
encoding={'_all': {'zlib': True}})
......@@ -49,7 +49,7 @@ def main():
gc = gc.assign_coords(zone=args['zone'],
data='globcolour')
lib.setup_meta_attrs(gc, args)
lib.setup_metadata(gc, args)
with ProgressBar():
gc.to_netcdf(lib.data.clouds.get_filename(data='globcolour',
......
......@@ -38,7 +38,7 @@ def main(args):
'_FillValue': -32767.,
'dtype': 'int16',
'scale_factor': 1e-3}}
lib.setup_meta_attrs(hi, args)
lib.setup_metadata(hi, args)
save_chunks_by_date(hi, filename=filename,
encoding=encoding)
......
......@@ -18,7 +18,7 @@ def main(args):
ofile = lib.data.p_frt_mask.get_filename(args)
lib.check_output_dir(ofile, file=True)
ds = mask.to_dataset(name='mask')
lib.setup_meta_attrs(ds, args)
lib.setup_metadata(ds, args)
ds.to_netcdf(ofile, encoding={'mask': {'zlib': True, 'dtype': 'bool'}})
return mask
......
......@@ -50,7 +50,7 @@ def main():
outdir = lib.data.front_probability.get_root(args, period='monthly')
lib.check_output_dir(path.join(outdir, str(args['year'])))
lib.setup_meta_attrs(mth, args)
lib.setup_metadata(mth, args)
save_chunks_by_date(mth, path.join(outdir, '%Y/%Y%m%d.nc'))
return mth
......
......@@ -41,7 +41,7 @@ def main():
lib.check_output_dir(outdir)
year = '2000'
lib.setup_meta_attrs(tot, args)
lib.setup_metadata(tot, args)
tot.to_netcdf(path.join(outdir, year, year + '0101.nc'),
encoding={var_name: {'zlib': True}})
......
......@@ -21,7 +21,7 @@ def main():
dst = box.extract(ds)
dst = dst.hf.mean(['lat', 'lon'])
lib.setup_meta_attrs(dst, args)
lib.setup_metadata(dst, args)
dst.to_netcdf(ofile)
......
......@@ -130,7 +130,7 @@ def main(args):
m_next("Executing computations / Writing to disk")
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
lib.setup_meta_attrs(hist, args)
lib.setup_metadata(hist, args)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -110,7 +110,7 @@ def main(args):
# filename=path.join(lib.root_data, 'graph.pdf'))
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
lib.setup_meta_attrs(hist, args)
lib.setup_metadata(hist, args)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -129,7 +129,7 @@ def main(args):
m_next("Executing computations / Writing to disk")
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
lib.setup_meta_attrs(hist, args)
lib.setup_metadata(hist, args)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -92,7 +92,7 @@ def main(args):
hist = hist.load()
ofile = lib.data.hists.get_filename(args)
lib.check_output_dir(ofile, file=True)
lib.setup_meta_attrs(hist, args)
lib.setup_metadata(hist, args)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -33,7 +33,7 @@ def write_land(ds, land, filename, grid):
ds = ds.isel(time=0)
ds = enlarge(ds)
ds = ds.reset_coords(drop=True)
lib.setup_meta_attrs(ds)
lib.setup_metadata(ds)
ds.to_netcdf(filename, encoding={'land': {'zlib': True}})
return ds
......
......@@ -25,7 +25,7 @@ def main(args):
lib.check_output_dir(path.join(finder.root, '{:d}'.format(args['year'])))
filename = finder.get_filename()
lib.setup_meta_attrs(ds, args)
lib.setup_metadata(ds, args)
save_chunks_by_date(ds, filename,
encoding={'_all': {'zlib': True}})
......
......@@ -64,7 +64,7 @@ def merge_products(args):
encoding[var]['add_offset'] = 0.05
for _, d in ds.groupby('time'):
lib.setup_meta_attrs(d, args)
lib.setup_metadata(d, args)
s = str(d.time.dt.strftime('%Y%m%d').values)
ofile = path.join(odir, 'A_{}.nc'.format(s))
d.to_netcdf(ofile, encoding=encoding)
......
......@@ -122,7 +122,7 @@ def fix_coords(file, args):
encoding = {v: {'zlib': True,
'_FillValue': nc.default_fillvals[ds[v].dtype.str[1:]]}
for v in ds.data_vars}
lib.setup_meta_attrs(ds, args)
lib.setup_metadata(ds, args)
ds.to_netcdf(file, encoding=encoding)
......
......@@ -56,7 +56,7 @@ def main(args):
zlib=True))
ofile = lo.get_filename(args, Y='%Y', m='%m', d='%d', relative=False)
lib.setup_meta_attrs(ds_out, args)
lib.setup_metadata(ds_out, args)
save_chunks_by_date(ds_out, ofile, encoding=encoding)
return ds_out
......
......@@ -162,7 +162,7 @@ def get_args(args, add_args=None, description=''):
return dargs
def setup_meta_attrs(ds: xr.Dataset,
def setup_metadata(ds: xr.Dataset,
args: Dict = None,
**kwargs: Any) -> xr.Dataset:
"""Set some dataset attributes with information on how it was created.
......
......@@ -109,6 +109,6 @@ if __name__ == '__main__':
for zone in zones.values():
zone.add_to_ds(ds)
lib.setup_meta_attrs(ds, args)
lib.setup_metadata(ds, args)
ds.to_netcdf(get_filename('zones', region=args['region'], grid=grid),
encoding={v: {'zlib': True} for v in ds.data_vars})
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