Exemple #1
1
    def __init__(self,Wctrl_fpath,Wmod_fpath,vrbl,utc,lv=False,
                    accum_hr=False,radar_datadir=False,thresh=False,
                    footprint=500):
        self.utc = utc
        self.C = {}
        self.M = {}
        self.thresh = thresh
        self.footprint = footprint

        self.M['WRFOut'] = WRFOut(Wmod_fpath)
        self.dx = self.M['WRFOut'].dx
        self.compute_d(self.M['WRFOut'])

        if Wctrl_fpath is False and (vrbl=='REFL_comp' or vrbl=='cref'):
            use_radar_obs = True
            self.C['data'] = self.get_radar_verif(utc,radar_datadir)
        else:
            use_radar_obs = False
            Wctrl = WRFOut(Wctrl_fpath)

        # Get 2D grids for ctrl and model
        if vrbl == 'accum_precip':
            if not accum_hr:
                raise Exception("Need to set accumulation hours.")
            self.C['data'] = Wctrl.compute_accum_rain(utc,accum_hr)[0,0,:,:]
            self.M['data'] = self.M['WRFOut'].compute_accum_rain(utc,accum_hr)[0,0,:,:]
        else:
            self.M['data'] = self.M['WRFOut'].get(vrbl,level=lv,utc=utc)[0,0,:,:]
            if not use_radar_obs:
                self.C['data'] = Wctrl.get(vrbl,level=lv,utc=utc)[0,0,:,:]

        # Set negative values to 0 
        # if vrbl == 'REFL_comp':
        self.C['data'][self.C['data']<0] = 0
        self.M['data'][self.M['data']<0] = 0
        self.vrbl = vrbl
       
        """
        fig, ax = plt.subplots(1)
        ax.pcolor(self.C['data'])
        fig.savefig('/home/jrlawson/public_html/bowecho/SALtests/obs_pcolor.png')
        plt.close(fig)
        fig, ax = plt.subplots(1)
        ax.pcolor(self.M['data'])
        fig.savefig('/home/jrlawson/public_html/bowecho/SALtests/mod_pcolor.png')
        plt.close(fig)
        import pdb; pdb.set_trace()
        """

        self.identify_objects()
        self.compute_amplitude()
        self.compute_location()
        self.compute_structure()

        print("S = {0}    A = {1}     L = {2}".format(self.S,self.A,self.L))