import radar_functions as rf import custom_vars as cv import pyart import matplotlib.pyplot as plt radar = rf.read_radar( "Data/RADAR/SR/level_0/2017-03-14/SRO-250--2017-03-14--18-20-23.mvol") # radar = pyart.io.read_uf("Data/RADAR/CTH/level_0_hdf5/2017-03-14/PNOVA2-20170314195729.HDF5") #radar = rf.read_radar(cv.filename) print(radar.info()) # display = pyart.graph.RadarDisplay(radar) # fig = plt.figure() # display.plot('cross_correlation_ratio', 0) # plt.show()
def read_dealise_region(filename, dbz_field='corrected_reflectivity', vel_field='corrected_velocity'): """ Reading radar data with radar_funs and: - Dealise data with pyart region-based algorithm - Add a mising_value (and _FillValue if not available) field inside reflectivity (DT) and velocity (VT) fields Parameters ---------- filename: .mvol or .HDF5 file dbz_field: name of the reflectivity field to be used vel_field: name of the velocity field to be used Returns ------- radar: dealised Py-ART radar data """ # Reading radar = read_radar(filename) # Dealising cp = deepcopy(radar.fields[dbz_field]['data']) radar.add_field_like(dbz_field, 'DT', cp, replace_existing=True) gatefilter = pyart.correct.GateFilter(radar) gatefilter.exclude_masked(dbz_field) corr_vel = pyart.correct.dealias_region_based(radar, vel_field=vel_field, keep_original=False, gatefilter=gatefilter, centered=True) radar.add_field('VT', corr_vel, replace_existing=True) # Adding missing_value try: radar.fields['DT']['missing_value'] = [ 1.0 * radar.fields['DT']['_FillValue'] ] radar.fields['VT']['missing_value'] = [ 1.0 * radar.fields['VT']['_FillValue'] ] except KeyError: radar.fields['DT']['_FillValue'] = ( radar.fields['DT']['data'].fill_value) radar.fields['DT']['missing_value'] = [ 1.0 * radar.fields['DT']['_FillValue'] ] radar.fields['VT']['_FillValue'] = ( radar.fields['VT']['data'].fill_value) radar.fields['VT']['missing_value'] = [ 1.0 * radar.fields['VT']['_FillValue'] ] # Defining original and corrected velocity fieds if vel_field == 'corrected_velocity': radar.add_field_like(vel_field, 'velocity', deepcopy(radar.fields[vel_field]['data']), replace_existing=True) radar.add_field_like('VT', vel_field, deepcopy(radar.fields['VT']['data']), replace_existing=True) else: radar.add_field_like('VT', 'corrected_velocity', deepcopy(radar.fields['VT']['data']), replace_existing=True) return radar
xlim_aoi, ylim_aoi, case, zero_height=cv.zerodeg_height, forty_height=cv.fortydeg_height, ): """ """ # Reading merged radar + converting to xarray grid = misc.open_object(filepath_m) xgrid = grid.to_xarray().squeeze() del grid # Reading radar + gridding + calculating mass + converting to xarray radar = rf.read_radar(filepath_r) radar = rf.calculate_radar_hid(radar, sounding) gradar = rf.grid_radar( radar, xlim=cv.grid_xlim, ylim=cv.grid_ylim, fields=["MI"], grid_shape=cv.grid_shape, ) xgradar = gradar.to_xarray().squeeze() del radar, gradar # Merging files xgrid = xgrid.assign({"MI": xgradar.MI}) xgrid = xgrid.swap_dims({"x": "lon", "y": "lat"}) del xgradar
def read_dealise_4dd(filename, date, station, dbz_field='corrected_reflectivity', vel_field='corrected_velocity'): """ Reading radar data with radar_funs and: - Dealise data with pyart FourDD algorithm - Add a mising_value (and _FillValue if not available) field inside reflectivity (DT) and velocity (VT) fields Parameters ---------- filename: .mvol or .HDF5 file date: date of the sounding (datetime.datetime) station: name of the METAR sounding station dbz_field: name of the reflectivity field to be used vel_field: name of the velocity field to be used Returns ------- radar: dealised Py-ART radar data """ # Reading radar = read_radar(filename) # Getting sounding data sounding = acquire_sounding_wind_data(date, station) # Dealising cp = deepcopy(radar.fields[dbz_field]['data']) radar.add_field_like(dbz_field, 'DT', cp, replace_existing=True) gatefilter = pyart.correct.GateFilter(radar) gatefilter.exclude_transition() gatefilter.exclude_invalid(vel_field) gatefilter.exclude_invalid(dbz_field) gatefilter.exclude_outside(dbz_field, 0, 80) corr_vel = pyart.correct.dealias_fourdd(radar, sonde_profile=sounding, gatefilter=gatefilter, vel_field=vel_field) radar.add_field('VT', corr_vel, replace_existing=True) # missing_value try: radar.fields['DT']['missing_value'] = [ 1.0 * radar.fields['DT']['_FillValue'] ] radar.fields['VT']['missing_value'] = [ 1.0 * radar.fields['VT']['_FillValue'] ] except KeyError: radar.fields['DT']['_FillValue'] = ( radar.fields['DT']['data'].fill_value) radar.fields['DT']['missing_value'] = [ 1.0 * radar.fields['DT']['_FillValue'] ] radar.fields['VT']['_FillValue'] = ( radar.fields['VT']['data'].fill_value) radar.fields['VT']['missing_value'] = [ 1.0 * radar.fields['VT']['_FillValue'] ] # Defining original and corrected velocity fieds if vel_field == 'corrected_velocity': radar.add_field_like(vel_field, 'velocity', deepcopy(radar.fields[vel_field]['data']), replace_existing=True) radar.add_field_like('VT', vel_field, deepcopy(radar.fields['VT']['data']), replace_existing=True) else: radar.add_field_like('VT', 'corrected_velocity', deepcopy(radar.fields['VT']['data']), replace_existing=True) return radar
- Classifying into 10 hydrometeor types (Drizzle, Rain, Ice Crystals, Aggregates, Wet/Melting Snow, Vertically Aligned Ice, Low-Density Graupel, High-Density Graupel, Hail and Big Drops) - Calculating liquid and ice water mass - Plotting data Based on CSU_RadarTools Demonstration Notebook by Timothy Lang. @author: Camila Lopes ([email protected]) """ import radar_functions as rf import custom_vars as cv import custom_cbars radar = rf.read_radar(cv.filename) # radar = pyart.io.read_uf(cv.filename) radar = rf.calculate_radar_hid(radar, cv.sounding_name, "S") grid = rf.grid_radar(radar, fields=[ 'corrected_reflectivity', 'FH', 'MW', 'MI', 'cross_correlation_ratio', 'differential_reflectivity', 'specific_differential_phase' ], origin=(radar.latitude['data'][0], radar.longitude['data'][0]), xlim=cv.grid_xlim, ylim=cv.grid_ylim, grid_shape=cv.grid_shape) grid.fields['specific_differential_phase']['units'] = r'$\degree\ km^{-1}$'