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

Apply metadata setup function

In all scripts still in use
parent 3442e731
......@@ -71,6 +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)
ds.to_netcdf(ofile, encoding=encoding)
......
......@@ -49,6 +49,7 @@ def main():
gc = gc.assign_coords(zone=args['zone'],
data='globcolour')
lib.setup_meta_attrs(gc, args)
with ProgressBar():
gc.to_netcdf(lib.data.clouds.get_filename(data='globcolour',
......
......@@ -38,6 +38,7 @@ def main():
ofile = lib.data.SN_separation.get_filename(args['fixes'])
lib.check_output_dir(ofile, file=True)
lib.setup_meta_attrs(sep, args)
sep.to_dataset().to_netcdf(ofile)
return sep
......
......@@ -17,9 +17,9 @@ def main(args):
ofile = lib.data.p_frt_mask.get_filename(args)
lib.check_output_dir(ofile, file=True)
mask.to_dataset(name='mask').to_netcdf(
ofile,
encoding={'mask': {'zlib': True, 'dtype': 'bool'}})
ds = mask.to_dataset(name='mask')
lib.setup_meta_attrs(ds, args)
ds.to_netcdf(ofile, encoding={'mask': {'zlib': True, 'dtype': 'bool'}})
return mask
......
......@@ -41,6 +41,7 @@ def main():
lib.check_output_dir(outdir)
year = '2000'
lib.setup_meta_attrs(tot, args)
tot.to_netcdf(path.join(outdir, year, year + '0101.nc'),
encoding={var_name: {'zlib': True}})
......
......@@ -21,6 +21,7 @@ def main():
dst = box.extract(ds)
dst = dst.hf.mean(['lat', 'lon'])
lib.setup_meta_attrs(dst, args)
dst.to_netcdf(ofile)
......
......@@ -130,6 +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)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -110,6 +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)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -129,6 +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)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -92,6 +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)
hist.to_netcdf(ofile, encoding=encoding)
m_end()
......
......@@ -33,6 +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)
ds.to_netcdf(filename, encoding={'land': {'zlib': True}})
return ds
......
......@@ -64,6 +64,7 @@ def merge_products(args):
encoding[var]['add_offset'] = 0.05
for _, d in ds.groupby('time'):
lib.setup_meta_attrs(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)
......
......@@ -66,7 +66,7 @@ def l2_to_map(args):
log.warning('l3mapgen failed on %s', f)
else:
log.info('fixing coords on %s', ofile)
fix_coords(ofile)
fix_coords(ofile, args)
def get_l2_filelist(args) -> Finder:
......@@ -107,7 +107,7 @@ def is_in_bounds(file) -> bool:
return True
def fix_coords(file):
def fix_coords(file, args):
ds = xr.open_dataset(file)
ds.load()
ds.close()
......@@ -122,6 +122,7 @@ def fix_coords(file):
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)
ds.to_netcdf(file, encoding=encoding)
......
......@@ -109,5 +109,6 @@ if __name__ == '__main__':
for zone in zones.values():
zone.add_to_ds(ds)
lib.setup_meta_attrs(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