Ejemplo n.º 1
0
def calculate_dsd_parameters(radar):
    from csu_radartools import csu_dsd

    if 'kdp' not in radar.fields.keys():
        radar = get_kdp(radar)
    kd = extract_unmasked_data(radar, 'kdp')
    dz = extract_unmasked_data(radar, 'reflectivity')
    dr = extract_unmasked_data(radar, 'differential_reflectivity')

    d0, Nw, mu = csu_dsd.calc_dsd(dz=dz, zdr=dr, kdp=kd, band='S')
    radar = add_field_to_radar_object(d0,
                                      radar,
                                      field_name='D0',
                                      units='mm',
                                      long_name='Median Volume Diameter',
                                      standard_name='Median Volume Diameter')
    logNw = np.log10(Nw)
    radar = add_field_to_radar_object(
        logNw,
        radar,
        field_name='NW',
        units='',
        long_name='Normalized Intercept Parameter',
        standard_name='Normalized Intercept Parameter')
    radar = add_field_to_radar_object(mu,
                                      radar,
                                      field_name='MU',
                                      units='',
                                      long_name='Mu',
                                      standard_name='Mu')
    return radar
Ejemplo n.º 2
0
 def get_dsd(self):
     """Calculate DSD information, add to radar object."""
     dz = self.radar.fields[self.name_dz]['data']
     dr = self.radar.fields[self.name_dr]['data']
     kd = self.radar.fields[self.name_kd]['data']
     d0, Nw, mu = csu_dsd.calc_dsd(dz=dz,
                                   zdr=dr,
                                   kdp=kd,
                                   band=self.band,
                                   method='2009')
     self.add_field_to_radar_object(d0,
                                    field_name='D0',
                                    units='mm',
                                    long_name='Median Volume Diameter',
                                    standard_name='Median Volume Diameter')
     self.add_field_to_radar_object(
         Nw,
         field_name='NW',
         units='mm-1 m-3',
         long_name='Normalized Intercept Parameter',
         standard_name='Normalized Intercept Parameter')
     self.add_field_to_radar_object(mu,
                                    field_name='MU',
                                    units=' ',
                                    long_name='Mu',
                                    standard_name='Mu')
Ejemplo n.º 3
0
def dsd_retrieval(radar, gatefilter, kdp_name, zdr_name, refl_name='DBZ_CORR'):
    """
    Compute the DSD retrieval using the csu library.

    Parameters:
    ===========
    radar:
        Py-ART radar structure.
    refl_name: str
        Reflectivity field name.
    zdr_name: str
        ZDR field name.
    kdp_name: str
        KDP field name.

    Returns:
    ========
    nw_dict: dict
        Normalized Intercept Parameter.
    d0_dict: dict
        Median Volume Diameter.
    """
    dbz = radar.fields[refl_name]['data'].copy().filled(np.NaN)
    zdr = radar.fields[zdr_name]['data'].copy()
    try:
        kdp = radar.fields[kdp_name]['data'].copy().filled(np.NaN)
    except AttributeError:
        kdp = radar.fields[kdp_name]['data'].copy()

    d0, Nw, mu = csu_dsd.calc_dsd(dz=dbz, zdr=zdr, kdp=kdp, band='C')

    Nw = np.log10(Nw)
    Nw[gatefilter.gate_excluded] = np.NaN
    Nw = np.ma.masked_invalid(Nw).astype(np.float32)
    np.ma.set_fill_value(Nw, np.NaN)

    d0[gatefilter.gate_excluded] = np.NaN
    d0 = np.ma.masked_invalid(d0).astype(np.float32)
    np.ma.set_fill_value(d0, np.NaN)

    nw_dict = {
        'data': Nw,
        'long_name': 'normalized_intercept_parameter',
        '_FillValue': np.NaN,
        '_Least_significant_digit': 2,
        'reference': "doi:10.1175/2009JTECHA1258.1"
    }

    d0_dict = {
        'data': d0,
        'units': 'mm',
        'long_name': 'median_volume_diameter',
        '_FillValue': np.NaN,
        '_Least_significant_digit': 2,
        'reference': "doi:10.1175/2009JTECHA1258.1"
    }

    return nw_dict, d0_dict
Ejemplo n.º 4
0
def dsd_retrieval(radar,
                  refl_name='DBZ',
                  zdr_name='ZDR_CORR',
                  kdp_name='KDP_GG'):
    """
    Compute the DSD retrieval using the csu library.

    Parameters:
    ===========
        radar:
            Py-ART radar structure.
        refl_name: str
            Reflectivity field name.
        zdr_name: str
            ZDR field name.
        kdp_name: str
            KDP field name.

    Returns:
    ========
        nw_dict: dict
            Normalized Intercept Parameter.
        d0_dict: dict
            Median Volume Diameter.
    """
    dbz = radar.fields[refl_name]['data'].filled(np.NaN)
    zdr = radar.fields[zdr_name]['data']
    try:
        kdp = radar.fields[kdp_name]['data'].filled(np.NaN)
    except AttributeError:
        kdp = radar.fields[kdp_name]['data']

    d0, Nw, mu = csu_dsd.calc_dsd(dz=dbz, zdr=zdr, kdp=kdp, band='C')

    Nw = np.log10(Nw)
    Nw = np.ma.masked_where(np.isnan(Nw), Nw)
    d0 = np.ma.masked_where(np.isnan(d0), d0)

    nw_dict = {
        'data': Nw,
        'units': 'AU',
        'long_name': 'Normalized Intercept Parameter',
        'standard_name': 'Normalized Intercept Parameter',
        'description':
        "Log10 of the NW. Retrieval based on Bringi et al. (2009)."
    }

    d0_dict = {
        'data': d0,
        'units': 'mm',
        'long_name': 'Median Volume Diameter',
        'standard_name': 'Median Volume Diameter',
        'description': "D0 retrieval based on Bringi et al. (2009)."
    }

    return nw_dict, d0_dict
Ejemplo n.º 5
0
 def get_dsd(self):
     """Calculate DSD information, add to radar object."""
     dz = self.radar.fields[self.name_dz]['data']
     dr = self.radar.fields[self.name_dr]['data']
     kd = self.radar.fields[self.name_kd]['data']
     d0, Nw, mu = csu_dsd.calc_dsd(dz=dz, zdr=dr, kdp=kd, band=self.band,
                                   method='2009')
     self.add_field_to_radar_object(d0, field_name='D0', units='mm',
                                    long_name='Median Volume Diameter',
                                    standard_name='Median Volume Diameter')
     self.add_field_to_radar_object(
         Nw, field_name='NW', units='mm-1 m-3',
         long_name='Normalized Intercept Parameter',
         standard_name='Normalized Intercept Parameter')
     self.add_field_to_radar_object(mu, field_name='MU', units=' ',
                                    long_name='Mu', standard_name='Mu')
Ejemplo n.º 6
0
filepath = '/data/pyart_examples/'
radarfile = 'cfrad.20040805_213003.000_to_20040805_214323.000_SPOL_v1_SUR.nc'
radarS = pyart.io.read(filepath + radarfile)
print(radarS.fields.keys())

# Extract relevant radar fields
dzS = radarS.fields['DZ']['data']
drS = radarS.fields['DR']['data']
kdS = radarS.fields['KD']['data']

# ---------------------------------------------------
# test of DSD retrieval
# ---------------------------------------------------
d0, Nw, mu = csu_dsd.calc_dsd(dz=dzS,
                              zdr=drS,
                              kdp=kdS,
                              band='S',
                              method='2004')
radarS = add_field_to_radar_object(d0,
                                   radarS,
                                   field_name='D0',
                                   units='mm',
                                   long_name='Median Volume Diameter',
                                   standard_name='Median Volume Diameter',
                                   dz_field='DZ')
logNw = np.log10(Nw)
radarS = add_field_to_radar_object(
    logNw,
    radarS,
    field_name='NW',
    units='',
Ejemplo n.º 7
0
def dsd_retrieval(radar,
                  gatefilter,
                  kdp_name,
                  zdr_name,
                  refl_name="DBZ_CORR",
                  band="C"):
    """
    Compute the DSD retrieval using the csu library.

    Parameters:
    ===========
    radar:
        Py-ART radar structure.
    refl_name: str
        Reflectivity field name.
    zdr_name: str
        ZDR field name.
    kdp_name: strs
        KDP field name.
    band: str
        Radar frequency band.

    Returns:
    ========
    nw_dict: dict
        Normalized Intercept Parameter.
    d0_dict: dict
        Median Volume Diameter.
    """
    dbz = radar.fields[refl_name]["data"].copy().filled(np.NaN)
    zdr = radar.fields[zdr_name]["data"].copy()
    try:
        kdp = radar.fields[kdp_name]["data"].copy().filled(np.NaN)
    except AttributeError:
        kdp = radar.fields[kdp_name]["data"].copy()

    d0, Nw, mu = csu_dsd.calc_dsd(dz=dbz, zdr=zdr, kdp=kdp, band=band)

    Nw = np.log10(Nw)
    Nw[gatefilter.gate_excluded] = np.NaN
    Nw = np.ma.masked_invalid(Nw).astype(np.float32)
    np.ma.set_fill_value(Nw, np.NaN)

    d0[gatefilter.gate_excluded] = np.NaN
    d0 = np.ma.masked_invalid(d0).astype(np.float32)
    np.ma.set_fill_value(d0, np.NaN)

    nw_dict = {
        "data": Nw,
        "long_name": "normalized_intercept_parameter",
        "units": " ",
        "_FillValue": np.NaN,
        "_Least_significant_digit": 2,
        "reference": "doi:10.1175/2009JTECHA1258.1",
    }

    d0_dict = {
        "data": d0,
        "units": "mm",
        "long_name": "median_volume_diameter",
        "_FillValue": np.NaN,
        "_Least_significant_digit": 2,
        "reference": "doi:10.1175/2009JTECHA1258.1",
    }

    return nw_dict, d0_dict
Ejemplo n.º 8
0
# Read in the data
filepath = '/data/pyart_examples/'
radarfile = 'cfrad.20060119_170029.000_to_20060121_020810.000_CPOL_v1_PPI.nc'
radar = pyart.io.read(filepath + radarfile)
print(radar.fields.keys())

# Extract relevant radar fields
dz = radar.fields['ZC']['data']
dr = radar.fields['ZD']['data']
kd = radar.fields['KD']['data']
rh = radar.fields['RH']['data']

# ---------------------------------------------------
# test of DSD retrieval
# ---------------------------------------------------
d0, Nw, mu = csu_dsd.calc_dsd(dz=dz, zdr=dr, kdp=kd, band='C')
radar = add_field_to_radar_object(d0,
                                  radar,
                                  field_name='D0',
                                  units='mm',
                                  long_name='Median Volume Diameter',
                                  standard_name='Median Volume Diameter')
logNw = np.log10(Nw)
radar = add_field_to_radar_object(
    logNw,
    radar,
    field_name='NW',
    units='',
    long_name='Normalized Intercept Parameter',
    standard_name='Normalized Intercept Parameter')
radar = add_field_to_radar_object(mu,