Beispiel #1
0
    def get_sars(self):
        '''
        Function to get the SARS analogues from the hail and
        supercell databases. Requires calling get_kinematics()
        and get_parcels() first. Also calculates the significant
        hail parameter.
        
        Function returns nothing, but sets the following variables:

        self.matches - the matches from SARS HAIL
        self.ship - significant hail parameter
        self.supercell_matches - the matches from SARS SUPERCELL
        
        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        sfc_6km_shear = utils.KTS2MS(
            utils.mag(self.sfc_6km_shear[0], self.sfc_6km_shear[1]))
        sfc_3km_shear = utils.KTS2MS(
            utils.mag(self.sfc_3km_shear[0], self.sfc_3km_shear[1]))
        sfc_9km_shear = utils.KTS2MS(
            utils.mag(self.sfc_9km_shear[0], self.sfc_9km_shear[1]))
        h500t = interp.temp(self, 500.)
        lapse_rate = params.lapse_rate(self, 700., 500., pres=True)
        srh3km = self.srh3km[0]
        srh1km = self.srh1km[0]
        mucape = self.mupcl.bplus
        mlcape = self.mlpcl.bplus
        mllcl = self.mlpcl.lclhght
        mumr = thermo.mixratio(self.mupcl.pres, self.mupcl.dwpc)
        self.ship = params.ship(self)

        ## Cambios para el hemisferio sur JP JP
        if self.latitude < 0:
            srh1km = -srh1km
            srh3km = -srh3km

        self.hail_database = 'sars_hail.txt'
        self.supercell_database = 'sars_supercell.txt'
        try:
            self.matches = hail(self.hail_database, mumr, mucape, h500t,
                                lapse_rate, sfc_6km_shear, sfc_9km_shear,
                                sfc_3km_shear, srh3km)
        except:
            self.matches = ([], [], 0, 0, 0)
        try:
            self.supercell_matches = supercell(self.supercell_database, mlcape,
                                               mllcl, h500t, lapse_rate,
                                               utils.MS2KTS(sfc_6km_shear),
                                               srh1km,
                                               utils.MS2KTS(sfc_3km_shear),
                                               utils.MS2KTS(sfc_9km_shear),
                                               srh3km)
        except Exception as e:
            self.supercell_matches = ([], [], 0, 0, 0)
Beispiel #2
0
    def get_sars(self):
        '''
        Function to get the SARS analogues from the hail and
        supercell databases. Requires calling get_kinematics()
        and get_parcels() first. Also calculates the significant
        hail parameter.
        
        Function returns nothing, but sets the following variables:

        self.matches - the matches from SARS HAIL
        self.ship - significant hail parameter
        self.supercell_matches - the matches from SARS SUPERCELL
        
        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        sfc_6km_shear = utils.KTS2MS( utils.mag( self.sfc_6km_shear[0], self.sfc_6km_shear[1]) )
        sfc_3km_shear = utils.KTS2MS( utils.mag( self.sfc_3km_shear[0], self.sfc_3km_shear[1]) )
        sfc_9km_shear = utils.KTS2MS( utils.mag( self.sfc_9km_shear[0], self.sfc_9km_shear[1]) )
        h500t = interp.temp(self, 500.)
        lapse_rate = params.lapse_rate( self, 700., 500., pres=True )
        srh3km = self.srh3km[0]
        srh1km = self.srh1km[0]
        mucape = self.mupcl.bplus
        mlcape = self.mlpcl.bplus
        mllcl = self.mlpcl.lclhght
        mumr = thermo.mixratio(self.mupcl.pres, self.mupcl.dwpc)
        self.ship = params.ship(self)

        self.hail_database = 'sars_hail.txt'
        self.supercell_database = 'sars_supercell.txt'
        try:
            self.matches = hail(self.hail_database, mumr, mucape, h500t, lapse_rate, sfc_6km_shear,
                sfc_9km_shear, sfc_3km_shear, srh3km)
        except:
            self.matches = ([], [], 0, 0, 0)
        try:
            self.supercell_matches = supercell(self.supercell_database, mlcape, mllcl, h500t, lapse_rate, utils.MS2KTS(sfc_6km_shear), srh1km, utils.MS2KTS(sfc_3km_shear), utils.MS2KTS(sfc_9km_shear), srh3km)
        except Exception as e:
            self.supercell_matches = ([], [], 0, 0, 0)
Beispiel #3
0
def check_hail_cal(use_db=True):
    # Check the calibration of the SARS hail
    database_fn = os.path.join(os.path.dirname(__file__), 'sars_hail.txt')
    hail_db = np.loadtxt(database_fn, skiprows=1, dtype=bytes)
    hits = 0
    cn = 0
    miss = 0
    fa = 0
    match = 0
    for f in hail_db:
        mumr = float(f[4])
        mucape = float(f[3])
        lr = float(f[7])
        h5_temp = float(f[5])
        shr = float(f[10])
        shr9 = float(f[11])
        shr3 = float(f[9])
        srh = float(f[12])
        if use_db is True:
            out = sars.hail('sars_hail.txt', mumr, mucape, h5_temp, lr, shr,
                            shr9, shr3, srh)
        else:
            new_prof = get_profile(f, 'hail')
            if new_prof is None:
                continue
            out = new_prof.right_matches
        m = int(f[0].decode('utf-8') in out[0])
        if m == 0:
            data = calc_inputs(new_prof, 'hail')
            #print("C:", data)
            #print("T:", [mumr, mucape, h5_temp, lr, shr, shr9, shr3, srh])
        match += m
        #print(f[0], match)
        if out[-1] >= .5 and float(f[2]) >= 2:
            hits += 1
        elif out[-1] >= .5 and float(f[2]) < 2:
            fa += 1
        elif out[-1] < .5 and float(f[2]) < 2:
            cn += 1
        elif out[-1] < .5 and float(f[2]) >= 2:
            miss += 1
    print("--- SARS HAIL CALIBRATION ---")
    print_stats(hits, cn, miss, fa, match)
    return {'hits': hits, 'cn': cn, 'miss': miss, 'fa': fa, 'match': match}
Beispiel #4
0
''' Create the Sounding (Profile) Object '''