Exemple #1
0
def get_times(itime, ftime, int_hr):
    times = utils.generate_times(itime, ftime, 60 * 60 * int_hr)
    #times = [itime,]
    time_strs = []
    for t in times:
        time_strs.append(utils.string_from_time('output', t))
    return time_strs
Exemple #2
0
def get_times(itime, ftime, int_hr):
    times = utils.generate_times(itime, ftime, 60 * 60 * int_hr)
    # times = [itime,]
    time_strs = []
    for t in times:
        time_strs.append(utils.string_from_time("output", t))
    return time_strs
elif case[:4] == '2013':
    nct = inittime = (2013, 8, 15, 0, 0, 0)
    itime = (2013, 8, 15, 21, 0, 0)
    ftime = (2013, 8, 16, 8, 0, 0)
    iwind = (2013, 8, 15, 21, 0, 0)
    fwind = (2013, 8, 16, 7, 0, 0)
    ptime = (2013, 8, 16, 3, 0, 0)
    compt = [(2013, 8, d, h, 0, 0) for d, h in zip((15, 16, 16), (22, 2, 6))]
    matchnc = '/chinook2/jrlawson/bowecho/20130815_hires/wrfout_d02_2013-08-15_00:00:00'
else:
    raise Exception

# hourly = (1.0/12)
hourly = 1
level = 2000
times = utils.generate_times(itime, ftime, hourly * 60 * 60)
# times = [(2011,4,20,2,0,0),]
# times = [(2013,8,15,22,0,0),]
# dtetimes = utils.generate_times(itime,ftime,3*60*60)

skewT_time = (2006, 5, 27, 0, 0, 0)
skewT_latlon = (36.73, -102.51)  # Boise City, OK

for ens in ensnames:
    if skewT:
        for en in ensnames:
            for ex in experiments:
                outdir, ncdir = get_folders(en, ex)
                p.plot_skewT(skewT_time,
                             latlon=skewT_latlon,
                             outdir=outdir,
Exemple #4
0
elif wy == 2011:
    radar_view = "upper_missvly"

if plot == "cref":
    va_str = "cref"
    lv_str = "sfc"


elif plot == "shear03":
    va_str = "shear"
    lv_str = "0to3"

elif plot == "shear06":
    va_str = "shear"
    lv_str = "0to6"
    times = utils.generate_times(itime, ftime, 60 * 60 * 1)

elif plot == "strongestwind":
    va_str = "strongestwind"
    duration = raw_input("What duration? ")
    # lv_str = ''

elif plot == "streamlines":
    va_str = "streamlines"
    lv_str = "sfc"

else:
    va_str = plot
    # lv_str = 'sfc'

if plot != "strongestwind":
Exemple #5
0
PLOT['Z'][300] = N.arange(7800,9900,30)
PLOT['Z'][500] = N.arange(5000,6000,30)
PLOT['Z'][700] = N.arange(2800,3430,30)
nrow = 3
ncol = 3
pt = 'contour'
t = 0
clvs = False
sm = 5
hourly = 6
fname = 'GEFS_NAM_compare'

p = WRFEnviron()

for case in NC:
    times = utils.generate_times(NC[case]['itime'],NC[case]['ftime'],hourly*60*60)
    for tn, t in enumerate(times):
        mnc = os.path.join(NC[case]['Gncdir'],NC[case]['Gnc'])
        fig,axes = plt.subplots(nrow,ncol,figsize=(6,6))
        axn = 0
        for vrbl in PLOT.keys():
            for lv,clvs in PLOT[vrbl].items():
                for model,ncdir in zip(['RUC','GEFSR2','NAM'],(NC[case]['Rncdir'],NC[case]['Gncdir'],NC[case]['Nncdir'])):
                    if model=='RUC':
                        nct = t
                    else:
                        nct = NC[case]['nct']
                    cb = p.plot2D(vrbl,utc=t,level=lv,ncdir=ncdir,fig=fig,ax=axes.flat[axn],cb=False,clvs=clvs,nct=nct,smooth=sm,plottype=pt,save=False,match_nc=mnc)
                    axes.flat[axn].set_title('{0} {1}'.format(model,lv))
                    axn += 1
        fnameout = fname+'_{0:04d}_{1:02d}h.png'.format(NC[case]['nct'][0],tn*hourly)
                    'ensnames':['s{0:02d}'.format(e) for e in range(1,11)],
                    'ncroot':'/chinook2/jrlawson/bowecho/20110419/NAM/anl/WSM5'}
    BOW['hires1'] = {'dom':2,'ncf':'wrfout_d02_2011-04-19_00:00:00',
                    'ensnames':['s{0:02d}'.format(e) for e in range(21,31)],
                    'ncroot':'/chinook2/jrlawson/bowecho/20110419_hires/'}
    nct = (2011,4,19,0,0,0)
    itime = (2011,4,19,0,0,0)
    ftime = (2011,4,20,12,0,0)


outdir = '/home/jrlawson/public_html/bowecho/hires/{0}'.format(case)


hourly = 1
level = 2000
times = utils.generate_times(itime,ftime,hourly*60*60)

# vrbl = 'wind10'; lv = False
vrbl = 'T2'; lv = False
# vrbl = 'cref'; lv= False
# vrbl = 'Q2'; lv = False
# vrbl = 'U10'; lv = False

th = 15

entire_domain = True
limited_domain = False

tstats = []
pvalues = []
Exemple #7
0
plot_cref = 1

# ncroot = '/chinook2/jrlawson/bowecho/20130815/GEFSR2_paper1/p09'
ncdir = {
    'SINGLE': '/chinook2/jrlawson/bowecho/20130815/GEFSR2_paper2/p09/ICBC/',
    'NESTED': '/chinook2/jrlawson/bowecho/20130815_hires/'
}
# ncdir = {'SINGLE':'/chinook2/jrlawson/bowecho/20130815/GEFSR2_paper2/p09/ICBC/s06',
# 'NESTED':'/chinook2/jrlawson/bowecho/20130815_hires/s22'}
ncfile = 'wrfout_d01_2013-08-15_00:00:00'
nct = (2013, 8, 15, 0, 0, 0)
itime = (2013, 8, 15, 20, 0, 0)
ftime = (2013, 8, 15, 23, 0, 0)
interval = 1 * 60 * 60
times = utils.generate_times(itime, ftime, interval)
outdir = '/home/jrlawson/public_html/bowecho/paper2'
# lims = {'Nlim':41.0,'Elim':-95.4,'Slim':35.9,'Wlim':-102.0}
lims = {'Nlim': 41.0, 'Elim': -97.4, 'Slim': 38.3, 'Wlim': -101.0}
# ensm = {'SINGLE':'s06','NESTED':'s12'}

PLOTS = {
    'PMSL_gradient': {
        'lv': 2000,
        'clvs': N.arange(0.02, 0.18, 0.02),
        'cbl': 'PMSL gradient (Pa/m)',
        'cmap': 'cubehelix_r',
        'extend': 'max'
    },
    'T2_gradient': {
        'lv': 2000,
Exemple #8
0
config = Settings()
p = WRFEnviron(config)

skewT = 0
plot2D = 0
streamlines = 1
rucplot = 0
coldpoolstrength = 0

itime = (2007,7,20,0,0,0)
ftime = (2007,7,22,0,0,0)
# times = [(2013,8,15,18,0,0),]
levels = 2000

times = utils.generate_times(itime,ftime,2*60*60)

#shear_times = utils.generate_times(itime,ftime,3*60*60)
#sl_times = utils.generate_times(sl_itime,sl_ftime,1*60*60)
# skewT_time = (2013,8,16,3,0,0)
# skewT_latlon = (35.2435,-97.4708)
# thresh = 10

#variables = {'cref':{}} ; variables['cref'] = {'lv':2000,'pt':times}
#variables = {'strongestwind':{}} ; variables['strongestwind'] = {'lv':2000, 'itime':itime, 'ftime':ftime, 'range':(thresh,27.5,1.25)}
#variables['PMSL'] = {'lv':2000,'pt':times,'plottype':'contour','smooth':5}
#variables['wind10'] = {'lv':2000,'pt':times}
#variables['buoyancy'] = {'lv':2000,'pt':times}
#variables['shear'] = {'top':3,'bottom':0,'pt':shear_times}
# variables = {'shear':{'pt':shear_times, 'top':3, 'bottom':0}}
# variables = {'thetae':{'lv':2000,'pt':times}, 'CAPE':{'pt':times}}
    "WSM6_Hail_STCH_MAX",
    "WDM5",
    "WDM5_MAX",
    "WDM5_STCH",
    "WDM5_STCH_MAX",
]
ncfile = "wrfout_d01_2013-08-15_00:00:00"
nct = (2013, 8, 15, 0, 0, 0)
# itime = (2013,8,15,17,0,0)
itime = (2013, 8, 16, 3, 0, 0)
# ftime = (2013,8,16,8,0,0)
ftime = (2013, 8, 16, 4, 0, 0)
# interval = 60*20
interval = 60 * 60

times = utils.generate_times(itime, ftime, interval)
outdir = "/home/jrlawson/public_html/bowecho/paper1/all_MAX/"
# outdir = '/home/jrlawson/public_html/bowecho/paper1/all_MAX/animate'

MAXmembers = [x for x in members if x.endswith("MAX")]

# lims = {'Nlim':42.0,'Elim':-95.0,'Slim':34.0,'Wlim':-104.0}
lims = {"Nlim": 39.5, "Elim": -95.6, "Slim": 35.8, "Wlim": -101.5}


def make_subplot_label(ax, label):
    ax.text(0.05, 0.15, label, transform=ax.transAxes, bbox={"facecolor": "white"}, fontsize=15, zorder=1000)
    return


cb_saved = {}
Exemple #10
0
    def ensemble_array(self,
                       vrbl,
                       level=None,
                       itime=False,
                       ftime=False,
                       fcsttime=False,
                       Nlim=None,
                       Elim=None,
                       Slim=None,
                       Wlim=None,
                       inclusive=False,
                       lats=None,
                       lons=None,
                       dom=1):
        """
        Returns 5D array of data for ranges.

        Needs to load WRFOut files if self.loadobj is False.

        Ordered in descending order on pert. members
        First dimension is ensemble members.

        Arguments:
            inclusive (bool, optional): if True, included time specified
                at ftime in the time range. Default is False (like Python).

        TODO: lat/lon box is in the correct projection?
        TODO: Implement bounding lat/lon box.
        TODO: rename to "get()" or "ensemble_get()"?
        """

        ens_no = 0
        # pdb.set_trace()
        if vrbl is 'accum_precip':
            qpf = self.accumulated(
                vrbl='RAINNC',
                itime=itime,
                ftime=ftime,
                level=level,
                Nlim=Nlim,
                Elim=Elim,
                Slim=Slim,
                Wlim=Wlim,
                inclusive=inclusive,
            )
            return qpf
        for nm, mem in enumerate(self.member_names):
            print("Working on member {0}".format(mem))
            if mem is self.ctrl:
                print("Skipping control member.")
                continue
            else:
                ens_no += 1

                # if itime and ftime:
                if isinstance(itime, datetime.datetime) and isinstance(
                        ftime, datetime.datetime):
                    # fts = N.arange(itime,ftime,self.hdt)
                    fts = utils.generate_times(itime,
                                               ftime,
                                               self.hdt,
                                               inclusive=inclusive)
                else:
                    fts = [
                        fcsttime,
                    ]

                # if Nlim:
                # data = self.members[mem][dom][t]['data'].get(
                # vrbl,level=level)
                # ens_data,lats,lons = utils.return_subdomain(
                # data,self.examplenc.lats1D,
                # self.examplenc.lons1D,Nlim,
                # Elim,Slim,Wlim,fmt='latlon')
                # else:
                # pdb.set_trace()
                for tn, ft in enumerate(fts):
                    if len(fts) > 1:
                        t, tidx = self.find_file_for_t(ft, mem, dom=dom)
                    else:
                        t = self.initutc
                        tidx = ft
                    print("Loading data for time {0}".format(ft))
                    # pdb.set_trace()
                    fpath = self.members[mem][dom][t]['fpath']
                    DF = self.datafile_object(fpath, loadobj=True)
                    m_t_data = DF.get(vrbl,
                                      utc=tidx,
                                      level=level,
                                      lons=lons,
                                      lats=lats)[0, ...]

                if ens_no == 1:
                    nz, nlats, nlons = m_t_data.shape
                    nt = len(fts)
                    all_ens_data = N.zeros((self.nperts, nt, nz, nlats, nlons))

                all_ens_data[ens_no - 1, tn, :, :, :] = m_t_data

        if Nlim:
            return all_ens_data, lats, lons
        else:
            return all_ens_data
Exemple #11
0
p = WRFEnviron()

if case[:4] == '2006':
    itime = (2006, 5, 26, 0, 0, 0)
    ftime = (2006, 5, 27, 12, 0, 0)
elif case[:4] == '2009':
    itime = (2009, 9, 10, 0, 0, 0)
    ftime = (2009, 9, 11, 18, 0, 0)
elif case[:4] == '2011':
    itime = (2011, 4, 19, 0, 0, 0)
    ftime = (2011, 4, 20, 15, 0, 0)
else:
    itime = (2013, 8, 15, 0, 0, 0)
    ftime = (2013, 8, 16, 15, 0, 0)

times = utils.generate_times(itime, ftime, 2 * 3600)

if experiment == 'STCH':
    picklefolder = os.path.join(wrfout_root, case, IC, ens, MP)
    p.C.output_root = os.path.join(output_root, case, IC, ens, MP)

    path_to_wrfouts = []
    for s in stoch_names:
        fpath = os.path.join(wrfout_root, case, IC, ens, MP, s)
        path_to_wrfouts.append(p.wrfout_files_in(fpath, dom=1)[0])
    sensitivity = 0

elif experiment == 'ICBC':
    picklefolder = os.path.join(wrfout_root, case, IC)
    p.C.output_root = os.path.join(output_root, case, IC)
    sensitivity = ens_names
Exemple #12
0
p = WRFEnviron()

if case[:4] == '2006':
    itime = (2006,5,26,0,0,0)
    ftime = (2006,5,27,12,0,0)
elif case[:4] == '2009':
    itime = (2009,9,10,0,0,0)
    ftime = (2009,9,11,18,0,0)
elif case[:4] == '2011':
    itime = (2011,4,19,0,0,0)
    ftime = (2011,4,20,15,0,0)
else:
    itime = (2013,8,15,0,0,0)
    ftime = (2013,8,16,15,0,0)

times = utils.generate_times(itime,ftime,2*3600)

if experiment=='STCH':
    picklefolder = os.path.join(wrfout_root,case,IC,ens,MP)
    p.C.output_root = os.path.join(output_root,case,IC,ens,MP)
 
    path_to_wrfouts = []
    for s in stoch_names:
        fpath = os.path.join(wrfout_root,case,IC,ens,MP,s)
        path_to_wrfouts.append(p.wrfout_files_in(fpath,dom=1)[0])
    sensitivity=0

elif experiment=='ICBC':
    picklefolder = os.path.join(wrfout_root,case,IC)
    p.C.output_root = os.path.join(output_root,case,IC)
    sensitivity=ens_names
Exemple #13
0
 def generate_times(self, itime, ftime, x):
     """
     Wrapper for utility method.
     """
     y = utils.generate_times(itime, ftime, x)
     return y
Exemple #14
0
    def ensemble_array(self,vrbl,level=None,itime=False,ftime=False,
                        fcsttime=False,Nlim=None,Elim=None,
                        Slim=None,Wlim=None,inclusive=False,
                        lats=None,lons=None,dom=1):
        """
        Returns 5D array of data for ranges.

        Needs to load WRFOut files if self.loadobj is False.

        Ordered in descending order on pert. members
        First dimension is ensemble members.

        Arguments:
            inclusive (bool, optional): if True, included time specified
                at ftime in the time range. Default is False (like Python).

        TODO: lat/lon box is in the correct projection?
        TODO: Implement bounding lat/lon box.
        TODO: rename to "get()" or "ensemble_get()"?
        """

        ens_no = 0
        # pdb.set_trace()
        if vrbl is 'accum_precip':
            qpf = self.accumulated(vrbl='RAINNC',itime=itime,ftime=ftime,
                            level=level,Nlim=Nlim,Elim=Elim,
                            Slim=Slim,Wlim=Wlim,inclusive=inclusive,)
            return qpf
        for nm,mem in enumerate(self.member_names):
            print("Working on member {0}".format(mem))
            if mem is self.ctrl:
                print("Skipping control member.")
                continue
            else:
                ens_no += 1

               # if itime and ftime:
                if isinstance(itime,datetime.datetime) and isinstance(
                            ftime,datetime.datetime):
                    # fts = N.arange(itime,ftime,self.hdt)
                    fts = utils.generate_times(itime,ftime,self.hdt,
                                inclusive=inclusive)
                else:
                    fts = [fcsttime,]

                # if Nlim:
                    # data = self.members[mem][dom][t]['data'].get(
                                                        # vrbl,level=level)
                    # ens_data,lats,lons = utils.return_subdomain(
                                                    # data,self.examplenc.lats1D,
                                                    # self.examplenc.lons1D,Nlim,
                                                    # Elim,Slim,Wlim,fmt='latlon')
                # else:
                # pdb.set_trace()
                for tn, ft in enumerate(fts):
                    if len(fts) > 1:
                        t, tidx = self.find_file_for_t(ft,mem,dom=dom)
                    else:
                        t = self.initutc
                        tidx = ft
                    print("Loading data for time {0}".format(ft))
                    # pdb.set_trace()
                    fpath = self.members[mem][dom][t]['fpath']
                    DF = self.datafile_object(fpath,loadobj=True)
                    m_t_data = DF.get(
                                vrbl,utc=tidx,level=level,lons=lons,lats=lats)[0,...]

                if ens_no == 1:
                    nz,nlats,nlons = m_t_data.shape
                    nt = len(fts)
                    all_ens_data = N.zeros((self.nperts,nt,nz,nlats,nlons))

                all_ens_data[ens_no-1,tn,:,:,:] = m_t_data

        if Nlim:
            return all_ens_data,lats,lons
        else:
            return all_ens_data