# -*- coding: utf-8 -*- """ @author: ppantina """ ##Use this to make batch changes to L1B files without reprocessing everything import h5py import numpy as np import sub_params #for parameters import os ##Change these variables as needed radName = input('Which radar? CRS, EXRAD, HIWRAP_KU, HIWRAP_KA: ') flightDate = input('Which date? yyyymmdd (append flight number if needed) ') versionLetter = input('Which version are you modifying?: A, B, C, ... ') ##Next, read the parameter file to fine radar-relevant variables. fileNameParams = 'radar_params_irma.xlsx' config = sub_params.sub_params(fileNameParams, flightDate, radName) L1B_dir = config['Directory_L1B'] L1B_file = config['experimentName'] + '_' + radName + '_L1B_Rev'+ versionLetter + '_' + flightDate + '.h5' L1B_filepath = L1B_dir + L1B_file newVersion = '-' ''' ###Update the Revision Letter and filename### f = h5py.File(L1B_filepath, 'r+') del (f['Information/L1B_Revision']) f['Information/L1B_Revision'] = np.string_([newVersion]) f.close() print ('Converted', versionLetter, 'to', newVersion) L1B_filepathNew = L1B_filepath.replace('Rev'+versionLetter, 'Rev' + newVersion) os.rename(L1B_filepath, L1B_filepathNew) print ('Renamed file') ''' ''' ###Update the Revision Letter and filename### f = h5py.File(L1B_filepath, 'r+') del (f['Information/L1B_Revision_Note']) f['Information/L1B_Revision_Note'] = np.string_(['']) f.close() print ('Updated Note') ''' ###Update the Revision Letter and filename### f = h5py.File(L1B_filepath, 'r+') del (f['Products/Data/Velocity_uncorrected']) del (f['Products/Data/Velocity_corrected']) f['Products/Data/Velocity_uncorrected'] = np.zeros_like(f['Products/Combined/Data/dBZe'])*np.nan f['Products/Data/Velocity_corrected'] = np.zeros_like(f['Products/Combined/Data/dBZe'])*np.nan f.close()