diff --git a/modules/aeolus/aeolus_amv.py b/modules/aeolus/aeolus_amv.py index 9034c254d63653e45988c4bebbf75816e5ffdb69..768f952f980179ba4ebf65ed36f8196767dd68ac 100644 --- a/modules/aeolus/aeolus_amv.py +++ b/modules/aeolus/aeolus_amv.py @@ -1743,7 +1743,7 @@ def match_amvs_to_aeolus_fast(aeolus_dict, amv_files_path, amv_source='OPS', ban # dist = haversine_np(lon, lat, amv_lons[in_box], amv_lats[in_box]) param_nd = np.vstack(param_s) param_nd = param_nd[:, in_box] - match_dict[key].append(param_nd) + match_dict[key].append((cc, ll, f_idx, prof, param_nd)) return match_dict @@ -1928,12 +1928,13 @@ def create_file(filename, aeolus_to_amv_dct, aeolus_dct, amv_files, cld_lyr=Fals rootgrp.close() -def create_file_new(match_dct, filename, amv_params): +def create_file_new(match_dct, filename, clvrx_params): grd_x_len = 9 grd_y_len = 9 num_aparams = 7 num_aprofs = len(match_dct) max_num_alevels = 0 + max_num_amvs = 0 alons = [] alats = [] @@ -1944,19 +1945,20 @@ def create_file_new(match_dct, filename, amv_params): # scan to get max num levels keys = list(match_dct.keys()) for key in keys: - tup = match_dct.get(key) - prof = tup[4] - lat = prof[0, 0] - lon = prof[0, 1] - alons.append(lon) - alats.append(lat) - atimes.append(tup[0]) - elems.append(tup[1]) - lines.append(tup[2]) - - nlevs = prof.shape[0] - if nlevs > max_num_alevels: - max_num_alevels = nlevs + tup_s = match_dct.get(key) + for tup in tup_s: + prof = tup[3] + lat = prof[0, 0] + lon = prof[0, 1] + alons.append(lon) + alats.append(lat) + atimes.append(key) + elems.append(tup[0]) + lines.append(tup[1]) + + nlevs = prof.shape[0] + if nlevs > max_num_alevels: + max_num_alevels = nlevs alons = np.array(alons) alats = np.array(alats) @@ -1998,7 +2000,7 @@ def create_file_new(match_dct, filename, amv_params): # ----- Product variables ---------------- nc4_vars = [] var_s = rg_exmpl.variables - for pidx, param in enumerate(amv_params): + for pidx, param in enumerate(clvrx_params): v = var_s[param] attr_s = v.ncattrs() if '_FillValue' in attr_s: @@ -2018,20 +2020,23 @@ def create_file_new(match_dct, filename, amv_params): prf_line[:] = lines prf_time[:] = atimes - for idx, key in enumerate(keys): - tup = match_dct.get(key) - prof = tup[4] - param_nd = tup[5] - - nlevs = prof.shape[0] - for k in range(nlevs): - prf_spd[idx,k] = prof[k,6] - prf_azm[idx,k] = prof[k,5] - prf_hht[idx,k] = prof[k,3] - prf_hhb[idx,k] = prof[k,4] - - for pidx, param in enumerate(clvrx_params): - nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :] + idx = 0 + for key in enumerate(keys): + tup_s = match_dct.get(key) + for tup in tup_s: + prof = tup[3] + param_nd = tup[4] + + nlevs = prof.shape[0] + for k in range(nlevs): + prf_spd[idx,k] = prof[k,6] + prf_azm[idx,k] = prof[k,5] + prf_hht[idx,k] = prof[k,3] + prf_hhb[idx,k] = prof[k,4] + + for pidx, param in enumerate(clvrx_params): + nc4_vars[pidx][idx, :, :] = param_nd[pidx, :, :] + idx += 1 rg_exmpl.close() rootgrp.close()