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

snapshot...

parent 50967ca6
No related branches found
No related tags found
No related merge requests found
import os
import numpy as np import numpy as np
import xarray as xr import xarray as xr
from netCDF4 import Dataset from netCDF4 import Dataset
...@@ -106,10 +107,9 @@ def match_calipso_clavrx_to_amvs(calipso_clavrx_ds, calipso_clavrx_file, amv_fil ...@@ -106,10 +107,9 @@ def match_calipso_clavrx_to_amvs(calipso_clavrx_ds, calipso_clavrx_file, amv_fil
return match_dict return match_dict
def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filenames): def create_file(match_dct, output_path, target_filepath, caliop_clavrx_params, amv_params, amv_filenames):
num_aprofs = 0 num_aprofs = 0
max_num_amvs = 0 max_num_amvs = 0
alons = [] alons = []
alats = [] alats = []
atimes = [] atimes = []
...@@ -118,6 +118,12 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen ...@@ -118,6 +118,12 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen
fidxs = [] fidxs = []
amvs_cnt = [] amvs_cnt = []
filename = os.path.split(target_filepath)[1]
w_o_ext, ext = os.path.splitext(filename)
filename = w_o_ext+'.amvs'+ext
output_filepath = output_path+filename
amv_file_s = np.array(amv_filenames, dtype='object') amv_file_s = np.array(amv_filenames, dtype='object')
# scan to get max num levels, amvs # scan to get max num levels, amvs
...@@ -154,7 +160,7 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen ...@@ -154,7 +160,7 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen
caliop_clavrx_exmpl = Dataset('/data/Personal/rink/clavrx_calipso/g16_s20201050200_06kmCLay.matchup.calipso.h5', 'r') caliop_clavrx_exmpl = Dataset('/data/Personal/rink/clavrx_calipso/g16_s20201050200_06kmCLay.matchup.calipso.h5', 'r')
# the top level group for the output file # the top level group for the output file
rootgrp = Dataset(filename, 'w', format='NETCDF4') rootgrp = Dataset(output_filepath, 'w', format='NETCDF4')
dim_amvs = rootgrp.createDimension('max_num_amvs', size=max_num_amvs) dim_amvs = rootgrp.createDimension('max_num_amvs', size=max_num_amvs)
dim_num_aeolus_prof = rootgrp.createDimension('num_caliop_profs', size=num_aprofs) dim_num_aeolus_prof = rootgrp.createDimension('num_caliop_profs', size=num_aprofs)
...@@ -262,7 +268,7 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen ...@@ -262,7 +268,7 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen
rootgrp.close() rootgrp.close()
def run_caliop_clavrx_amv_match(output_file, path_to_caliop_clavrx, path_to_amvs, amv_source='OPS', band='14'): def run_caliop_clavrx_amv_match(output_path, path_to_caliop_clavrx, path_to_amvs, amv_source='OPS', band='14'):
caliop_clavrx_params = get_parameters_caliop_clavrx() caliop_clavrx_params = get_parameters_caliop_clavrx()
caliop_clavrx_ds = CLAVRx_CALIPSO(path_to_caliop_clavrx) caliop_clavrx_ds = CLAVRx_CALIPSO(path_to_caliop_clavrx)
...@@ -274,5 +280,5 @@ def run_caliop_clavrx_amv_match(output_file, path_to_caliop_clavrx, path_to_amvs ...@@ -274,5 +280,5 @@ def run_caliop_clavrx_amv_match(output_file, path_to_caliop_clavrx, path_to_amvs
for file in caliop_clavrx_ds.flist: for file in caliop_clavrx_ds.flist:
match_dict = match_calipso_clavrx_to_amvs(caliop_clavrx_ds, file, amv_ds, amv_source=amv_source, band=band) match_dict = match_calipso_clavrx_to_amvs(caliop_clavrx_ds, file, amv_ds, amv_source=amv_source, band=band)
create_file(match_dict, output_file, caliop_clavrx_params, amv_params, amv_filenames) create_file(match_dict, output_path, file, caliop_clavrx_params, amv_params, amv_filenames)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment