diff --git a/modules/amv/caliop_clavrx_amv.py b/modules/amv/caliop_clavrx_amv.py index b9fd448b20e12be3c95b86fc1323f2b81037a504..5b995f38ab007cc7856ce7a868eefada0cfc1afc 100644 --- a/modules/amv/caliop_clavrx_amv.py +++ b/modules/amv/caliop_clavrx_amv.py @@ -1,3 +1,4 @@ +import os import numpy as np import xarray as xr from netCDF4 import Dataset @@ -106,10 +107,9 @@ def match_calipso_clavrx_to_amvs(calipso_clavrx_ds, calipso_clavrx_file, amv_fil 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 max_num_amvs = 0 - alons = [] alats = [] atimes = [] @@ -118,6 +118,12 @@ def create_file(match_dct, filename, caliop_clavrx_params, amv_params, amv_filen fidxs = [] 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') # scan to get max num levels, amvs @@ -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') # 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_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 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_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 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) - 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)