Skip to content
Snippets Groups Projects
Commit f2563282 authored by tomrink's avatar tomrink
Browse files

minor

parent e3a6322b
Branches
No related tags found
No related merge requests found
......@@ -1494,8 +1494,9 @@ def match_aeolus_to_clavrx(aeolus_dict, clvrx_files):
keys = list(aeolus_dict.keys())
last_f_idx = -1
cnt = 0
param_nd = None
dataset = None
dataset_s = []
for key in keys:
fname, ftime, f_idx = clvrx_files.get_file_containing_time(key)
......@@ -1508,14 +1509,8 @@ def match_aeolus_to_clavrx(aeolus_dict, clvrx_files):
if f_idx != last_f_idx:
last_f_idx = f_idx
ds = Dataset(fname)
param_s = []
for param in clvrx_params:
param_s.append(ds[param][:,:])
param_nd = np.stack(param_s, axis=0)
ds.close()
dataset = Dataset(fname)
dataset_s.append(dataset)
for prof in prof_s:
lat = prof[0, 0]
......@@ -1530,10 +1525,14 @@ def match_aeolus_to_clavrx(aeolus_dict, clvrx_files):
# if c_rng is None:
# continue
tiles = param_nd[:, cc-4:cc+5, ll-4:ll+5]
match_dict[cnt] = (key, cc, ll, f_idx, prof, tiles)
data = []
for param in clvrx_params:
data.append(dataset[param][cc-4:cc+5, ll-4:ll+5])
param_nd = np.stack(data, axis=0)
match_dict[cnt] = (key, cc, ll, f_idx, prof, param_nd)
cnt += 1
for ds in dataset_s:
ds.close()
return match_dict
......@@ -1574,6 +1573,9 @@ def create_file_2(match_dct, filename, clvrx_params):
elems = np.array(elems)
lines = np.array(lines)
# Sample file to retrieve and copy variable attributes
rg_exmpl = Dataset('/home/rink/data/clavrx/clavrx_OR_ABI-L1b-RadF-M6C01_G16_s20192930000343.level2.nc', 'r')
# the top level group for the output file
rootgrp = Dataset(filename, 'w', format='NETCDF4')
......@@ -1604,15 +1606,14 @@ def create_file_2(match_dct, filename, clvrx_params):
# ----- Product variables ----------------
nc4_vars = []
#out_params = amv_files.get_out_parameters()
#meta_dict = amv_files.get_meta_dict()
var_s = rg_exmpl.variables
for pidx, param in enumerate(clvrx_params):
#u, t = meta_dict.get(param)
u = None
t = 'f4'
var = rootgrp.createVariable(param, t, ['num_aeolus_profs', 'grd_y_len', 'grd_x_len'])
if u is not None:
var.units = u
v = var_s[param]
var = rootgrp.createVariable(param, v.dtype, ['num_aeolus_profs', 'grd_y_len', 'grd_x_len'])
# copy attributes from example to new output variable of the same name
attr_s = v.ncattrs()
for attr in attr_s:
var.setncattr(attr, v.getncattr(attr))
nc4_vars.append(var)
# Write data to file ---------------------
......@@ -1637,7 +1638,7 @@ def create_file_2(match_dct, filename, clvrx_params):
for pidx, param in enumerate(clvrx_params):
nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :]
rg_exmpl.close()
rootgrp.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment