Loading 2NETCDF.py +38 −2 Original line number Diff line number Diff line Loading @@ -189,6 +189,22 @@ def hpl_to_netcdf(file_path,path_out,institution=None,contact=None,overwrite=Fal dataset_temp.close() print('%s is created succesfully' % path_file) ''' class that contains information about the doppler lidar instrument. ''' class lidar_location: def __init__(self,lat,lon,zsl,name,lidar_id,bearing,diff_WGS84=np.nan,diff_geoid=np.nan,diff_bessel=np.nan): self.lat = lat self.lon = lon self.zsl = zsl self.name = name self.lidar_id = lidar_id self.bearing = bearing self.diff_WGS84 = diff_WGS84 self.diff_geoid = diff_geoid self.diff_bessel = diff_bessel ''' convert level0 netCDF data into level1 netCDF data input variables: Loading Loading @@ -280,15 +296,35 @@ def to_netcdf_l1(file_path,file_name_out,lidar_info,path_out): # Added by Jonathan Minz - 25.04.2024 if __name__ == '__main__': # location where l0 netcdf files are stored. # This location is created by the above defined function - NOT user defined. file_path = '/Users/jminz/Documents/Project/2024/DataManagement_LAFI/Script_testing/Data Lidar/2024/202404/20240423' # location where l1 netcdf files should be stored. # User defined. path_out = '/Users/jminz/Documents/Project/2024/DataManagement_LAFI/Script_testing/Data Lidar' print('finding hpl files to netcdf') list_of_hpl_files = glob.glob('Stare*') # instantiate the UHOH Doppler Lidar lidar_info = lidar_location(48.710612, 9.190746, 388.0, 115, 0.0, 10000) # convert hpl files to l0 netcdf files print(f'found {len(list_of_hpl_files)} files') for idx, file in enumerate(list_of_hpl_files): print(f'convert file no.{idx+1} {file} to l0 netcdf') hpl_to_netcdf(file, path_out) print('converted hpl to l0 file') print('converted hpl files to l0 netcdf files') # convert l0 netcdf files to l1 netcdf files print('converting l0 to l1 netcdf files') list_of_l0_ncfiles = glob.glob(os.path.join(file_path,'Stare*')) print(f'found {len(list_of_l0_ncfiles)} files') for idx_nc, file_nc in enumerate(list_of_l0_ncfiles): print(f'converting file {file_nc}') file_name_l0 = file_nc.split('/')[12].split('l')[0] file_out_name_l1 = file_name_l0+'l1.nc' print(f'{file_out_name_l1}') print('converting l0 netcdf to l1 file') #to_netcdf_l1() to_netcdf_l1(file_nc, file_out_name_l1, lidar_info, path_out) print('SUCCESS: conversion from hpl to l0 netcdf complete') No newline at end of file Loading
2NETCDF.py +38 −2 Original line number Diff line number Diff line Loading @@ -189,6 +189,22 @@ def hpl_to_netcdf(file_path,path_out,institution=None,contact=None,overwrite=Fal dataset_temp.close() print('%s is created succesfully' % path_file) ''' class that contains information about the doppler lidar instrument. ''' class lidar_location: def __init__(self,lat,lon,zsl,name,lidar_id,bearing,diff_WGS84=np.nan,diff_geoid=np.nan,diff_bessel=np.nan): self.lat = lat self.lon = lon self.zsl = zsl self.name = name self.lidar_id = lidar_id self.bearing = bearing self.diff_WGS84 = diff_WGS84 self.diff_geoid = diff_geoid self.diff_bessel = diff_bessel ''' convert level0 netCDF data into level1 netCDF data input variables: Loading Loading @@ -280,15 +296,35 @@ def to_netcdf_l1(file_path,file_name_out,lidar_info,path_out): # Added by Jonathan Minz - 25.04.2024 if __name__ == '__main__': # location where l0 netcdf files are stored. # This location is created by the above defined function - NOT user defined. file_path = '/Users/jminz/Documents/Project/2024/DataManagement_LAFI/Script_testing/Data Lidar/2024/202404/20240423' # location where l1 netcdf files should be stored. # User defined. path_out = '/Users/jminz/Documents/Project/2024/DataManagement_LAFI/Script_testing/Data Lidar' print('finding hpl files to netcdf') list_of_hpl_files = glob.glob('Stare*') # instantiate the UHOH Doppler Lidar lidar_info = lidar_location(48.710612, 9.190746, 388.0, 115, 0.0, 10000) # convert hpl files to l0 netcdf files print(f'found {len(list_of_hpl_files)} files') for idx, file in enumerate(list_of_hpl_files): print(f'convert file no.{idx+1} {file} to l0 netcdf') hpl_to_netcdf(file, path_out) print('converted hpl to l0 file') print('converted hpl files to l0 netcdf files') # convert l0 netcdf files to l1 netcdf files print('converting l0 to l1 netcdf files') list_of_l0_ncfiles = glob.glob(os.path.join(file_path,'Stare*')) print(f'found {len(list_of_l0_ncfiles)} files') for idx_nc, file_nc in enumerate(list_of_l0_ncfiles): print(f'converting file {file_nc}') file_name_l0 = file_nc.split('/')[12].split('l')[0] file_out_name_l1 = file_name_l0+'l1.nc' print(f'{file_out_name_l1}') print('converting l0 netcdf to l1 file') #to_netcdf_l1() to_netcdf_l1(file_nc, file_out_name_l1, lidar_info, path_out) print('SUCCESS: conversion from hpl to l0 netcdf complete') No newline at end of file