コード例 #1
0
            distance = abs(tpvmod.rEarth * tpvmod.distance_on_unit_sphere(
                event_latnow, event_lonnow, lats_tpvs_now[iii],
                lons_tpvs_now[iii]))
            distnow = distance / 1000.

            if iii == 0:
                distsave = distnow
                dist_prev = distnow
            else:
                if distnow < dist_prev:
                    distsave = distnow
        distarr.append(distsave)
    #print(distarr)

    distarr = np.array(distarr)
    mstats(distarr)

    del indnow
    [indnow] = np.where(distarr < 100.)
    N100 = len(indnow)

    del indnow
    [indnow] = np.where(distarr < 250.)
    N250 = len(indnow)

    del indnow
    [indnow] = np.where(distarr < 500.)
    N500 = len(indnow)

    del indnow
    [indnow] = np.where(distarr < 750.)
コード例 #2
0
       
       cint_trth = 1
       cflevs_trth =  np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
       #cflevs_trth_cntrs = cflevs_trth[0:12]
       cflevs_trth_cntrs = cflevs_trth
       cflevs_trth_ticks = np.arange(cbar_min_trth,cbar_max_trth,4*cint_trth)
       cmap_opt = plt.cm.jet
       #cmap_opt = plt.cm.Blues_r

       trth = ndimage.gaussian_filter(trth,0.75)
       
       trth = um.filter_numeric_nans(trth,trth_thresh+cint_trth,trth_thresh+cint_trth,'high')
         
       
       plotvar = trth
       mstats(plotvar)
          	    
       #plotvar, lons = um.addcyclic(trth[tt,:,:].squeeze(), lonin)	    	    	    	    
       #plotvar = ndimage.gaussian_filter(plotvar,0.75)   
       
       titletext1 = 'Tropopause potential temperature gradient %s at %s UTC' % (dt.strftime('%d %b %Y'), dt.strftime('%H00'))        
   if plot_field == 'trpr' :
 
       cbarlabel = 'Pressure (hPa)'    
       
       cint_trth = 20
       cbar_max_trth = 800.
       cbar_min_trth = 300.
       cflevs_trth =  np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
       #cflevs_trth_cntrs = cflevs_trth[0:12]
       cflevs_trth_cntrs = cflevs_trth
コード例 #3
0
    cbar_min_slp = -30  #1004-(20*cint_slp)
    cbar_max_slp = 30  #1004+(20*cint_slp)
    cflevs_slp = np.arange(cbar_min_slp, cbar_max_slp + (cint_slp / 2),
                           cint_slp)
    #cflevs_slp = [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10]

if (subtract_mean_standardize == True):
    subtract_mean = False

if (diff == False):
    infile = np.load(fLoad)
    den_arr = infile['den_arr']
    count_arr = infile['count_arr']
    hit_arr = infile['hit_arr']

    mstats(den_arr)

    tpvs_peryear = hit_arr / (nyears_tpv[0])
    if (plot_tpvsperyear == True):
        den_arr = tpvs_peryear

    if (subtract_mean == True):
        den_arr = den_arr - np.nanmean(den_arr)

    if (subtract_mean_standardize == True):
        den_arr = (den_arr - np.nanmean(den_arr)) / np.std(den_arr)

else:
    infile1 = np.load(fLoad)
    infile2 = np.load(fLoad2)
    den_arr1 = infile1['den_arr']
コード例 #4
0
# How to read in a file and extract the years of analysis
###########################
ab = np.loadtxt(datadir+infile1, skiprows=1)       
years_april = ab[:,0]
slp_april = ab[:,1]

inds = np.where( (years_april>=analysis_years[0]) & (years_april<=analysis_years[1]))
tmp = slp_april[inds]
del slp_april
slp_april = tmp
del tmp

years = years_april[inds]

# to check statistics, make sure mstats.m is in this directory and type:
mstats(slp_april)

###########################
# If you want to calculate a running mean, do something like this:
###########################
#new_array = np.zeros(len(slp_april)) # create a new array with all zeros
#new_array[0:nyears] = float('NaN') # change to zeros in the years where you can't compute a 5-y mean to NaNs
#for ii in range(nyears,len(new_array)):
#        new_array[ii] = np.nanmean(slp_april[ii:ii+nyears+1])

###########################
# To calculate the long-term climatology, try something like:
###########################
#inds_climo = np.where( (years>=climo_years[0]) & (years<=climo_years[1]))
#myarray_climo = np.nanmean(myarray[inds_climo])
コード例 #5
0
                cmap_opt = plt.cm.RdBu_r
        else:
            cint = 3
            cbar_min = -45
            cbar_max = 45 + (cint / 2)

            cbar_labels = 'meters'
            titlestring = "Geopotential height " + date_string

            cmap_opt = plt.cm.RdBu_r

        figname = "erainterim_cross_section_analysis_ghgt_" + orient
    elif plot_option == 10:
        plot_cross = w_cross
        mstats(plot_cross)

        if plot_anomaly == 'true':
            plot_cross = w_cross_anom
            cint = 0.01
            cbar_min = -0.1
            cbar_max = 0.1 + (cint / 2)

            cbar_labels = 'Pa s-1'
            titlestring = "Vertical velocity anomaly " + date_string

            cmap_opt = plt.cm.RdBu
            if standardize_anomaly == 'true':
                cint = 0.1
                cbar_min = -2
                cbar_max = 2 + (cint / 2)
コード例 #6
0
	    cbar_labels = 'Standard deviations' 
	    titlestring = "Standardized Eliassen-Palm flux divergence " + date_string

	    cmap_opt = plt.cm.RdBu		    
    else:
        cint = -0.01
        cbar_min = -0.1
        cbar_max = 0.1+(cint/2)            
        
	cbar_labels = ''
	titlestring = "Eliassen-Palm flux divergence " + date_string
	
	cmap_opt = plt.cm.RdBu 

    mstats(plot_cross)

elif plot_option == 9:
    plot_cross = geop_cross / 9.81
    
    if plot_anomaly == 'true':
        plot_cross = geop_cross_anom / 9.81
        cint = 50
        cbar_min = -500
        cbar_max = 500+(cint/2)     
	
	cbar_labels = 'meters'
	titlestring = "Geopotential height anomaly " + date_string
	
	cmap_opt = plt.cm.RdBu_r		   
        if standardize_anomaly == 'true':            
コード例 #7
0
Lv = 2.5*10**(6.0) # J kg-1

###########################
# Read file, compute stuff
###########################
if read_temperature_fromfile == 'True':
    ab = np.loadtxt(datadir+infile1, skiprows=0)       
    lats = ab[:,0]
    T1 = ab[:,1]
    [refind] = np.where(lats==reference_latitude)
    print refind
else:
    T1 = np.arange(-40,41,0.25)+273.15 # Virtual temperatures
    [refind] = np.where(T1 == 273.15)
# Check to make sure it read in correctly
mstats(T1)    
es1 = wm.claus_clap(T1) # saturation vapor pressure
ws1 = (epsi*es1)/(pres1-es1) # saturation mixing ratio

# Compute moist adiabatic lapse rate, first in z-coords
sat_lapse = (9.81/cp)*(( (1 + (Lv*ws1)/(Rd*T1))) / (1 + (ws1*(Lv**2)/(cp*Rv*T1**2.0)) ) )
Rho=pres1/(Rv*T1) # Density, moist air
sat_lapse_isobaric = -sat_lapse/(Rho*9.81) # Convert to p-coords

# Temperature at top of ascent layer (T2) is equal to what it was initially (T1) plus slope (-gamma_m) * deltap
T2 = T1 - (sat_lapse_isobaric)*(pres2-pres1) 

# Convert to Celsius (needed for plot if not reading from file)
T1C = T1 - 273.15
T2C = T2 - 273.15
コード例 #8
0
		cmap_opt = plt.cm.RdBu_r
	else:
            cint = 3
            cbar_min = -45
            cbar_max = 45+(cint/2)            

	    cbar_labels = 'meters'
	    titlestring = "Geopotential height " + date_string

	    cmap_opt = plt.cm.RdBu_r 	

	figname = "erainterim_cross_section_analysis_ghgt_" + orient	        
    elif plot_option == 10:
	plot_cross = w_cross
	mstats(plot_cross)

	if plot_anomaly == 'true':
            plot_cross = w_cross_anom
            cint = 0.01
            cbar_min = -0.1
            cbar_max = 0.1+(cint/2)     

	    cbar_labels = 'Pa s-1'
	    titlestring = "Vertical velocity anomaly " + date_string

	    cmap_opt = plt.cm.RdBu		   
            if standardize_anomaly == 'true':            
        	cint = 0.1
        	cbar_min = -2 
        	cbar_max = 2 + (cint/2)      
コード例 #9
0
                x] <= 2:  # only getting tpv tracks for winter months
            plotvar_summer.append(np.median(
                data.variables[str(varname)][x, :]))
        elif trackStartMon[x] > 5 and trackStartMon[x] < 9:
            plotvar_winter.append(np.median(data.variables[str(varname)][
                x, :]))  # only getting tpv tracks for summer months
        else:
            continue

data.close()

plotvar = np.array(plotvar)
plotvar_winter = np.array(plotvar_winter)
plotvar_summer = np.array(plotvar_summer)

mstats(plotvar)
mstats(plotvar_winter)
mstats(plotvar_summer)

############################
# Plots
############################
plotvar_cntl = plotvar
plotvar_exp1 = plotvar_winter
plotvar_exp2 = plotvar_summer

golden = (pylab.sqrt(5) + 1.) / 2.
figprops = dict(figsize=(8., 8. / golden), dpi=128)
adjustprops = dict(left=0.15,
                   bottom=0.1,
                   right=0.90,
コード例 #10
0
        cint_trth = 1
        cflevs_trth = np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
        #cflevs_trth_cntrs = cflevs_trth[0:12]
        cflevs_trth_cntrs = cflevs_trth
        cflevs_trth_ticks = np.arange(cbar_min_trth, cbar_max_trth,
                                      4 * cint_trth)
        cmap_opt = plt.cm.jet
        #cmap_opt = plt.cm.Blues_r

        trth = ndimage.gaussian_filter(trth, 0.75)

        trth = um.filter_numeric_nans(trth, trth_thresh + cint_trth,
                                      trth_thresh + cint_trth, 'high')

        plotvar = trth
        mstats(plotvar)

        #plotvar, lons = um.addcyclic(trth[tt,:,:].squeeze(), lonin)
        #plotvar = ndimage.gaussian_filter(plotvar,0.75)

        titletext1 = 'Tropopause potential temperature gradient %s at %s UTC' % (
            dt.strftime('%d %b %Y'), dt.strftime('%H00'))
    if plot_field == 'trpr':

        cbarlabel = 'Pressure (hPa)'

        cint_trth = 20
        cbar_max_trth = 800.
        cbar_min_trth = 300.
        cflevs_trth = np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
        #cflevs_trth_cntrs = cflevs_trth[0:12]