Exemple #1
0
def main(argv):
    inputfile = ''
    outputfile = ''
    try:
        opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="])
    except getopt.GetoptError:
        print 'test.py -i <inputfile> -o <outputfile>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'test.py -i <inputfile> -o <outputfile>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--ofile"):
            outputfile = arg
    print 'Input file is "', inputfile
    #    print 'Output file is "', outputfile

    #    path = 'L:\Radar2016\sample_data\pky1.vol'
    path = inputfile
    files = sorted(glob.glob(path))

    tstart = dt.datetime.now()
    for filename in files:
        print 'Creating folder ' + filename + '.dir ...'

        #filename = 'n:\\rason1\F2017111606S6008157.csv'

        #StaNo = filename[-20:-15]
        StaNo = '96253'

        rason_datetime = filename[-14:-4]
        #rason_datetime = filename[-22:-12]
        YY = str(rason_datetime[0:4])
        MM = str(rason_datetime[4:6])
        DD = str(rason_datetime[6:8])
        HH = str(rason_datetime[8:10])
        dt_rason = dt.datetime.strptime(YY + '-' + MM + '-' + DD + '_' + HH,
                                        '%Y-%m-%d_%H')
        #dt_rason = dt_rason - dt.timedelta(hours=6) # 6 hours time difference
        strdt_rason = dt_rason.strftime('%Y-%m-%d_%H')

        df = pd.read_csv(filename, nrows=0)
        rason_type = df.columns[0]
        rason_release_date_local = df.columns[4]
        rason_release_time_local = df.columns[5]
        rason_sounding_length = df.columns[7]
        rason_lat = str(round(float(df.columns[9]), 2))
        rason_lon = str(round(float(df.columns[10]), 2))
        rason_observer = df.columns[13]

        newdir = filename + '.dir'
        try:
            os.mkdir(newdir, 0755)
        except:
            print newdir + ' already exists'

        df = pd.read_csv(filename, skiprows=6)

        obstime = df[df.columns[0]].map(
            lambda x: dt.datetime.strptime(str(x), '%H:%M:%S'))  #ObsTime
        height = pad(df[df.columns[11]].replace('-----',
                                                np.nan).astype(float))  #Height
        lat = pad(df[df.columns[17]].replace('-----',
                                             np.nan).astype(float))  #GeodetLat
        lon = pad(df[df.columns[18]].replace('-----',
                                             np.nan).astype(float))  #GeodetLon
        wd = pad(df[df.columns[9]].replace(
            '-----', np.nan).astype(float))  #Wind Direction
        ws = pad(df[df.columns[10]].replace(
            '-----', np.nan).astype(float))  # Wind Speed
        press = df[df.columns[20]].replace('-----', np.nan)  #Pressure
        press = pad(press.replace('------', np.nan).astype(float))
        temp = pad(df[df.columns[21]].replace(
            '-----', np.nan).astype(float))  #Temperature
        rh = pad(df[df.columns[22]].replace(
            '-----', np.nan).astype(float))  #Relative Humidity
        dewtemp = temp - ((100 - rh) / 5.)  # Dewpoint temperature

        #_AllowedKeys=['pres','hght','temp','dwpt','relh','mixr','drct','sknt','thta','thte','thtv']

        mydata=dict(zip(('StationNumber','SoundingDate','hght','pres','temp','dwpt','relh','drct','sknt'),\
        ('Bengkulu ('+StaNo+')', strdt_rason +'UTC', height, press,temp,dewtemp,rh,wd,ws)))
        S = SkewT.Sounding(soundingdata=mydata)

        #S.do_thermodynamics()

        #S.plot_skewt(tmin=-40.,tmax=40.,pmin=100.,pmax=1050.,parcel_type='sb')

        try:
            #S.plot_skewt(tmin=-40.,tmax=40.,pmin=100.,pmax=1050.,parcel_type='mu')
            ##S.plot_skewt(parcel_type='sb',imagename='f:/rason/test.png')

            #S.fig.savefig(newdir+'\\'+StaNo+'_skewt-mu_'+strdt_rason+'.png', format='png', dpi=500)

            #S.plot_skewt(tmin=-40.,tmax=40.,pmin=100.,pmax=1050.,parcel_type='ml')
            ##S.plot_skewt(parcel_type='sb',imagename='f:/rason/test.png')

            #S.fig.savefig(newdir+'\\'+StaNo+'_skewt-ml_'+strdt_rason+'.png', format='png', dpi=500)

            S.plot_skewt(tmin=-40.,
                         tmax=40.,
                         pmin=100.,
                         pmax=1050.,
                         parcel_type='sb')
            #S.plot_skewt(parcel_type='sb',imagename='f:/rason/test.png')

            S.fig.savefig(newdir + '\\' + StaNo + '_skewt-sb_' + strdt_rason +
                          '.png',
                          format='png',
                          dpi=500)
        except:
            #S.make_skewt_axes()
            S.make_skewt_axes(tmin=-40., tmax=40., pmin=100., pmax=1050.)
            #S.make_skewt_axes(tmin=-50,tmax=40,pmin=100)
            S.add_profile(lw=1)
            #pc=S.most_unstable_parcel()
            #sounding.lift_parcel(*pc,totalcape=True)

        #S.fig.savefig('f:/rason/test.png', format='png', dpi=500)
        #S.fig.savefig(newdir+'\\'+strdt_rason+'UTC-bengkulu-skewt.png', format='png', dpi=500)

        #parcel=S.get_parcel()
        #S.lift_parcel(*parcel)
        #S.get_cape(*parcel)

        # Create a Figure Manager
        #mySkewT_Figure = figure()

        # Add an Skew-T axes to the Figure
        #mySkewT_Axes = mySkewT_Figure.add_subplot(111, projection='skewx')

        # Add a profile to the Skew-T diagram
        #mySkewT_Axes.addProfile(press.astype(float),temp.astype(float), dewtemp.astype(float) ,
        #                hPa=True, celsius=True, method=1, diagnostics=True, useVirtual=0)

        # Show the figure
        #mySkewT_Figure.show()

        print 'Plotting figures in ' + filename + '.dir ...'

        # draw figure
        fig = pl.figure(figsize=(10, 8))

        pl.plot(temp.astype(float), height.astype(float) / 1000, 'b')
        pl.plot(dewtemp.astype(float), height.astype(float) / 1000, 'r')
        #pl.xlabel('Temperature (C)')
        pl.ylabel('Height (km)', fontsize=12)
        pl.ylim(0, 30)
        pl.xlim(-120, 40)
        pl.text(-100, -3, 'Temperature (C)', color='b', fontsize=12)
        pl.text(-50, -3, 'Dew Point Temperature (C)', color='r', fontsize=12)
        pl.title('Temperature ' + HH + 'UTC ' + DD + '-' + MM + '-' + YY +
                 ' LON=' + rason_lon + ',LAT=' + rason_lat,
                 fontsize=12)
        #cbar = pl.colorbar(pm, shrink=0.75)
        fig.savefig(newdir + '\\' + StaNo + '_t_' + strdt_rason + '.png',
                    format='png',
                    dpi=500)

        fig = pl.figure(figsize=(10, 8))

        pl.plot(rh.astype(float), height.astype(float) / 1000, 'b')
        #pl.plot(dewtemp.astype(float),height.astype(float)/1000,'r')
        #pl.xlabel('Relative Humidity (%)')
        pl.ylabel('Height (km)', fontsize=12)
        pl.ylim(0, 30)
        pl.xlim(0, 100)
        pl.text(10, -3, 'Relative Humidity (%)', color='b', fontsize=12)
        #pl.text(-100,4000,'Dew point temperature',color='r')
        pl.title('Humidity ' + HH + 'UTC ' + DD + '-' + MM + '-' + YY +
                 ' LON=' + rason_lon + ',LAT=' + rason_lat,
                 fontsize=12)
        #cbar = pl.colorbar(pm, shrink=0.75)
        fig.savefig(newdir + '\\' + StaNo + '_rh_' + strdt_rason + '.png',
                    format='png',
                    dpi=500)

        fig = pl.figure(figsize=(10, 8))
        ax1 = fig.add_subplot(111)
        ax2 = ax1.twiny()

        ax1.plot(wd.astype(float), height.astype(float) / 1000, 'y')
        ax1.set_xlim(0, 360)
        ax1.set_xticks(np.arange(0, 361, 45))
        ax1.set_ylim(0, 30)

        ax2.plot(ws.astype(float), height.astype(float) / 1000, 'g')
        ax2.set_xlim(0, 50)
        ax2.set_ylim(0, 30)
        #pl.xlabel('Temperature (C)')
        ax1.set_ylabel('Height (km)', fontsize=12)
        ax1.text(45, -3, 'Wind Direction (deg)', color='y', fontsize=12)
        ax2.text(5, 32, 'Wind Speed (m/s)', color='g', fontsize=12)
        ax2.text(23,
                 32,
                 'Wind ' + HH + 'UTC ' + DD + '-' + MM + '-' + YY + ' LON=' +
                 rason_lon + ',LAT=' + rason_lat,
                 fontsize=12)
        #pl.title('Wind',fontsize=12)
        #cbar = pl.colorbar(pm, shrink=0.75)

        fig.savefig(newdir + '\\' + StaNo + '_wind_' + strdt_rason + '.png',
                    format='png',
                    dpi=500)
#*****************************************************************************\
#Cambiar fechas
timestamp = [datenum_to_datetime(t) for t in timesd]
time_my = np.array(timestamp)
#*****************************************************************************\
#Seleccionando Caso
caso=297 #1999-05-31 11:00:00
#caso=295 #1999-05-30 11:00:00
#caso=114 #2006-02-26 23:00:00
#print time_my[caso]

n_nnan=np.count_nonzero(~np.isnan(pres[:,caso]))

#*****************************************************************************\
height_m=hght[0:n_nnan-1,caso]
pressure_pa=pres[0:n_nnan-1,caso]
temperature_c=temp[0:n_nnan-1,caso]
dewpoint_c=dwpo[0:n_nnan-1,caso]
wsp=wspd[0:n_nnan-1,caso]
wdir=wdir[0:n_nnan-1,caso]


print n_nnan

mydata=dict(zip(('hght','pres','temp','dwpt','drct','sknt','StationNumber','SoundingDate'),(height_m,pressure_pa,temperature_c,dewpoint_c,wdir,wsp,'BoM',time_my[caso])))

S=SkewT.Sounding(soundingdata=mydata)
S.plot_skewt(color='r')
show()

Exemple #3
0
 def calc_cape(self, fnamelist, u, v, precip99, xy, idx, latlons):
     r'''Description:
         Variable required to calculate Convective Available Potential
         Energy: $\int_{zf}^{zn} g
         \left( \frac{T_{v, parcel} - T_{v,env}}{T_{v,env}}\right)
         \mathrm{d}z$
         If > 0 storms possible if enough moisture
         Notes:
             Blindly follows Rory's meathod
         Args:
             fnamelist (:obj:`list` of :obj:`str`): list of filenames:
                 [qf, q15f, Tf, t15f]
             u (iris.cube): x_wind
             v (iris.cube): y_wind
             precip99 (float): 99th percentile precp
             xy (iris.Constraint): slice from genslice
             idx (int): index
             latlons (:obj:`list` of :obj:`int`): list of lat-lons:
                 [llon, llat, ulat, ulon]
             idx: row index
         Returns:
         CAPE(dataframe): dataframe containing Vars for cape calculations
         TEPHI(dataframe): dataframe containg vars for tephigrams
     '''
     qf, q15f, Tf, t15f = fnamelist
     # ? 975 is a max value ?
     T = iris.load_cube(Tf)
     q = iris.load_cube(qf)
     # Find mslp but keep it greater that 975
     mslp = self.allvars['eve_mslp_mean'].loc[idx] / 100
     if mslp > 975:
         mslp = 975
     # Special slice
     xy850 = genslice(latlons, n1=mslp, n2=100)
     T = iris.load_cube(Tf)
     Q = iris.load_cube(qf)
     T850 = T[3, :, :].extract(xy850)
     q850 = Q[3, :, :].extract(xy850)
     Tp = T850.data
     Qp = q850.data
     Tp[Tp < 100] = np.nan
     Qp[Qp < 100] = np.nan
     Tcol = np.nanmean(Tp, axis=(1, 2))
     Qcol = np.nanmean(Qp, axis=(1, 2))
     pressures = T850.coord('pressure').points
     P = np.append(pressures, mslp)
     pval = T850.data.shape[0] + 1
     Temp = Tcol
     T15 = cubemean(iris.load_cube(t15f)[11, :, :].extract(xy)).data
     T = np.append(Temp, T15)
     Tkel = T - 273.16
     humcol = Qcol
     Q15 = cubemean(iris.load_cube(q15f)[11, :, :].extract(xy)).data
     hum = np.append(humcol, Q15)
     dwpt = np.zeros_like(P)
     if pval == 18:
         humidity = ((0.263 * hum * P * 100) / 2.714**((17.67 * (Tkel)) /
                                                       (T - 29.65)))
         RH_650 = (0.263 * hum * P) / 2.714**((17.67 * (Tkel)) /
                                              (T - 29.65))
         height = T * ((mslp / P)**(1. / 5.257) - 1) / 0.0065
         height[-1] = 1.5
         dwpt[:] = self.mcdp(Tkel, humidity)  # vectorized dew_point calc
     else:
         height, dwpt, humidity, RH_650 = np.zeros((4, pval))
     RH_650 = RH_650[np.where((P > 690) & (P <= 710))[0]]
     xwind = cubemean(u[3, :, :])
     ywind = cubemean(v[3, :, :])
     self.allvars['Tephi_pressure'].loc[idx] = np.average(pressures, axis=0)
     self.allvars['Tephi_T'].loc[idx] = np.average(T, axis=0)
     self.allvars['Tephi_dewpT'].loc[idx] = np.average(dwpt, axis=0)
     self.allvars['Tephi_height'].loc[idx] = np.average(height, axis=0)
     self.allvars['Tephi_Q'].loc[idx] = np.average(humidity, axis=0)
     self.allvars['Tephi_p99'].loc[idx] = precip99 * 3600.
     self.allvars['Tephi_xwind'].loc[idx] = xwind.data
     self.allvars['Tephi_ywind'].loc[idx] = ywind.data
     self.allvars['Tephi_RH650'].loc[idx] = np.average(RH_650, axis=0)
     mydata = dict(
         zip(('hght', 'pres', 'temp', 'dwpt'),
             (height[::-1], P[::-1], Tkel[::-1], dwpt[::-1])))
     try:
         S = sk.Sounding(soundingdata=mydata)
         parcel = S.get_parcel('mu')
         P_lcl, P_lfc, P_el, CAPE, CIN = S.get_cape(*parcel)
     except AssertionError:
         print('dew_point = ', dwpt[::-1])
         print('height = ', height[::-1])
         print('pressures = ', P[::-1])
         print('Temp = ', Tkel[::-1])
         print('AssertionError: Use a monotonically increasing abscissa')
         print('Setting to np.nan')
         P_lcl, P_lfc, P_el, CAPE, CIN = [
             np.nan, np.nan, np.nan, np.nan, np.nan
         ]
     self.allvars['CAPE_P_lcl'].loc[idx] = P_lcl
     self.allvars['CAPE_P_lfc'].loc[idx] = P_lfc
     self.allvars['CAPE_P_el'].loc[idx] = P_el
     self.allvars['CAPE_CAPE'].loc[idx] = CAPE
     self.allvars['CAPE_CIN'].loc[idx] = CIN
    vert_x_array_km = vertgrid.x['data']/1000
    vert_y_array_km = vertgrid.y['data']/1000
    vert_z_array_km = vertgrid.z['data']/1000
    
    #assign grid lat/lon data to a variable
    vertlat = vertgrid.point_latitude['data']
    vertlon = vertgrid.point_longitude['data']
    vertalt = vertgrid.point_altitude['data']/1000 #in km

    #==============================================================================
    #Sounding data   
    #==============================================================================
    #read in sounding data
#    sndfile = '/Users/kurtispinkney/Desktop/MastersThesis/sounding_data/2016/'+snd_date+'_snd.txt'
    sndfile = '/Users/kurtispinkney/Desktop/MastersThesis/sounding_data/2015/'+snd_date+'.txt'
    sounding = SkewT.Sounding(sndfile)
    
    #assign temp and height data to variables
    stemp = sounding.soundingdata['temp']
    stemp = ma.getdata(stemp)
    shght = sounding.soundingdata['hght']
    shght = ma.getdata(shght)
    
    #find values below 15 km (size of grid in vertical)
    below15hght = shght[np.where(shght < 15000)]
    below15temp = stemp[np.where(shght < 15000)]
    
    #find important isotherms
    #0°C
    freezelayeridx = np.abs(0-below15temp).argmin()
    freezelayerhght = below15hght[freezelayeridx]/1000 #km
Exemple #5
0
def process_thermal_wx(thermal):

    print 'Calculating WX for {}'.format(thermal)

    lon = thermal.longitude
    lat = thermal.latitude

    terrain = retrieve_band(lat, lon)

    if terrain == -1:
        return

    df = pd.read_csv(thermal_file.format(thermal.thermal_id))

    if len(df.index) < 185:
        df.to_csv(home + "/RAP/CSV/{}.error".format(thermal.thermal_id))
        return

    df['paramId'] = pd.to_numeric(df.paramId, errors='coerce')
    df['value'] = pd.to_numeric(df.value, errors='coerce')
    df['level'] = pd.to_numeric(df.level, errors='coerce')

    # Geopotential Height
    df_hgt = df.loc[df['paramId'] == 156][0:37]
    df_hgt = df_hgt.rename(columns={'value': 'HGT'}).drop('paramId', 1)

    # Temperature
    df_tmp = df.loc[df['paramId'] == 130][0:37]
    df_tmp = df_tmp.rename(columns={'value': 'TMP_K'}).drop('paramId', 1)

    # Relative Humidity
    df_rh = df.loc[df['paramId'] == 157][0:37]
    df_rh = df_rh.rename(columns={'value': 'RH'}).drop('paramId', 1)

    # U component of wind
    df_uw = df.loc[df['paramId'] == 131][0:37]
    df_uw = df_uw.rename(columns={'value': 'W_U'}).drop('paramId', 1)

    # V component of windcd R
    df_vw = df.loc[df['paramId'] == 132][0:37]
    df_vw = df_vw.rename(columns={'value': 'W_V'}).drop('paramId', 1)

    # Ground Temperature
    # df_gtmp = df.loc[df['paramId'] == 167]

    dfs = [df_hgt, df_tmp, df_rh, df_uw, df_vw]

    df_snd = reduce(lambda left, right: pd.merge(left, right, on='level'), dfs)

    # Wind Speed
    df_snd['W_SPD_MS'] = (df_snd.W_U**2 + df_snd.W_V**2)**(0.5)
    df_snd['W_SPD_KTS'] = df_snd.W_SPD_MS * 1.94384

    # Wind Direction
    df_snd['W_DIR'] = np.arctan2(df_snd.W_U, df_snd.W_V) * (180. / np.pi)

    # Temperature in Celcius
    df_snd['TMP_C'] = df_snd.TMP_K - 273.15

    # Dewpoint Temperature
    dew_point(df_snd)

    # Get the lift parcel for the terrain altitude
    parcel = get_parcel_at_hgt(terrain, df_snd)
    df_snd = strip_to_terrain(df_snd, parcel)

    # Retrieve surface temperature
    print parcel
    base_tmp = parcel[1]
    base_hgt = parcel[4]

    thermal['ground_temp_c'] = base_tmp
    thermal['ground_elev'] = base_hgt
    thermal['ground_w_dir'] = parcel[5]
    thermal['ground_w_spd_kts'] = parcel[6]

    # Add the DALR

    df_snd['DALR'] = base_tmp - ((df_snd.HGT - base_hgt) / 1000) * 9.8

    # Virtual Temperature
    df_snd['VIRTT'] = (df_snd.TMP_K) / (1 - 0.379 * (6.11 * np.power(
        ((7.5 * df_snd.DEWP_C) /
         (237.7 + df_snd.DEWP_C)), 10)) / df_snd.level) - 273.15

    # Thermal Index
    df_snd['TI'] = df_snd.TMP_C - df_snd.DALR
    df_snd['TI_ROUND'] = df_snd['TI'].round()

    # Top of lift
    lift_top = np.NAN
    df_lift = df_snd.loc[df_snd['TI_ROUND'] <= 0]
    if len(df_lift.index > 0):
        lift_top = df_lift.iloc[-1]['HGT']

    thermal['lift_top'] = lift_top

    hght = df_snd[['HGT']].as_matrix().flatten()
    pres = df_snd[['level']].as_matrix().flatten()
    temp = df_snd[['TMP_C']].as_matrix().flatten()
    dwpt = df_snd[['DEWP_C']].as_matrix().flatten()
    sknt = df_snd[['W_DIR']].as_matrix().flatten()
    drct = df_snd[['W_SPD_KTS']].as_matrix().flatten()

    mydata = dict(
        zip(('hght', 'pres', 'temp', 'dwpt', 'sknt', 'drct'),
            (hght, pres, temp, dwpt, sknt, drct)))
    S = SkewT.Sounding(soundingdata=mydata)
    S.make_skewt_axes()
    S.add_profile()
    S.lift_parcel(*parcel[0:4])
    Plcl, Plfc, P_el, CAPE, CIN = S.get_cape(*parcel[0:4])
    # S.plot_skewt(title=thermal.time)
    plt.title('Test')
    plt.savefig(home + "/RAP/PNG/{}.png".format(thermal.thermal_id))
    Hlcl = calc_hgt(df_snd, Plcl)
    thermal['H_lcl'] = Hlcl

    Hlfc = Plfc
    if not (math.isnan(Plfc)):
        Hlfc = calc_hgt(df_snd, Plfc)
    thermal['H_lfc'] = Hlfc

    H_el = P_el
    if not (math.isnan(P_el)):
        H_el = calc_hgt(df_snd, P_el)
    thermal['H_el'] = H_el

    thermal['CAPE'] = CAPE
    thermal['CIN'] = CIN

    return thermal
Exemple #6
0
url = 'http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR=' + year + '&MONTH=' + month + '&FROM=' + day + hour + '&TO=' + day + hour + '&STNM=' + stn
content = urllib2.urlopen(url).read()

# 2)
# Remove the html tags
soup = BeautifulSoup(content)
data_text = soup.get_text()

# 3)
# Split the content by new line.
splitted = data_text.split("\n", data_text.count("\n"))

#4)
# Must save the processed data as a .txt file to be read in by the skewt module.
# Write this splitted text to a .txt document. Save in current directory.
Sounding_dir = './'
Sounding_filename = str(stn) + '.' + str(year) + str(month) + str(day) + str(
    hour) + '.txt'
f = open(Sounding_dir + Sounding_filename, 'w')
for line in splitted[4:]:
    f.write(line + '\n')
f.close()

#5)
# Add skewt data to plot
S = SkewT.Sounding(filename=Sounding_dir + Sounding_filename)
S.make_skewt_axes(tmin=-40., tmax=50., pmin=100., pmax=1050.)
S.add_profile(bloc=0)
parcel = S.get_parcel()
S.lift_parcel(*parcel)
wdir=wdir_CL4_G3

mydataG3=dict(zip(('hght','pres','temp','dwpt','drct','sknt','StationNumber','SoundingDate'),(height_m,pressure_pa,temperature_c,dewpoint_c,wdir,wsp,' ','Cluster 3')))
#C4
height_m=hght_CL4_G4
temperature_c=temp_CL4_G4
dewpoint_c=dewp_CL4_G4
wsp=wsp_CL4_G4*1.943844
wdir=wdir_CL4_G4

mydataG4=dict(zip(('hght','pres','temp','dwpt','drct','sknt','StationNumber','SoundingDate'),(height_m,pressure_pa,temperature_c,dewpoint_c,wdir,wsp,' ','Cluster 4')))



#Individuals
S1=SkewT.Sounding(soundingdata=mydataG1)
S1.plot_skewt(color='r')
plt.savefig(path_data_save + '4K_C1.png', format='png', dpi=1200)
S2=SkewT.Sounding(soundingdata=mydataG2)
S2.plot_skewt(color='r')
plt.savefig(path_data_save + '4K_C2.png', format='png', dpi=1200)
S3=SkewT.Sounding(soundingdata=mydataG3)
S3.plot_skewt(color='r')
plt.savefig(path_data_save + '4K_C3.png', format='png', dpi=1200)
S4=SkewT.Sounding(soundingdata=mydataG4)
S4.plot_skewt(color='r')
plt.savefig(path_data_save + '4K_C4.png', format='png', dpi=1200)

S=SkewT.Sounding(soundingdata=mydataG1)
S.make_skewt_axes()
S.add_profile(color='r',bloc=0)
Exemple #8
0
    zip(('hght', 'pres', 'temp', 'dwpt', 'drct', 'sknt', 'StationNumber',
         'SoundingDate'), (height_m, pressure_pa, temperature_c, dewpoint_c,
                           wdir, wsp, 'Cold Fronts 4K', 'C1')))
#DCF
temperature_c = temp_CL4_G1_DCF
dewpoint_c = dewp_CL4_G1_DCF
wsp = wsp_CL4_G1_DCF * 1.943844
wdir = wdir_CL4_G1_DCF

mydataG1_DCF = dict(
    zip(('hght', 'pres', 'temp', 'dwpt', 'drct', 'sknt', 'StationNumber',
         'SoundingDate'), (height_m, pressure_pa, temperature_c, dewpoint_c,
                           wdir, wsp, 'Cold Fronts 4K', 'C1')))

# #Individuals
S = SkewT.Sounding(soundingdata=mydataG1_CF)
S2 = SkewT.Sounding(soundingdata=mydataG1_DCF)
S.make_skewt_axes()
S.add_profile(color='r', bloc=0)
S.soundingdata = S2.soundingdata
S.add_profile(color='b', bloc=1)
plt.savefig(path_data_save + '4K_C1_CF_Dif.png', format='png', dpi=1200)

#*****************************************************************************\
# Cluster 2
#*****************************************************************************\

df_CL4_G2 = df_myclucfro[df_myclucfro['CL_4'] == 2]
df_CL4_G2_DCF = df_CL4_G2[np.isfinite(df_CL4_G2['Dist CFront'])]
df_CL4_G2_CF = df_CL4_G2[np.isnan(df_CL4_G2['Dist CFront'])]
print len(df_CL4_G2), len(df_CL4_G2_CF), len(df_CL4_G2_DCF)
    zip(('hght', 'pres', 'temp', 'dwpt', 'drct', 'sknt', 'StationNumber',
         'SoundingDate'), (height_m, pressure_pa, temperature_c, dewpoint_c,
                           wdir, wsp, 'Post Front', '')))

#Pre
temperature_c = temp_pref
dewpoint_c = dewp_pref
wsp = wsp_pref * 1.943844
wdir = wdir_pref

mydatapref = dict(
    zip(('hght', 'pres', 'temp', 'dwpt', 'drct', 'sknt', 'StationNumber',
         'SoundingDate'), (height_m, pressure_pa, temperature_c, dewpoint_c,
                           wdir, wsp, 'Pre Front', '')))

S1 = SkewT.Sounding(soundingdata=mydataposf)
S1.plot_skewt(color='r')
plt.savefig(path_data_save + 'sounding_postcoldfront.png',
            format='png',
            dpi=1200)
S2 = SkewT.Sounding(soundingdata=mydatapref)
S2.plot_skewt(color='r')
plt.savefig(path_data_save + 'sounding_precoldfront.png',
            format='png',
            dpi=1200)

S = SkewT.Sounding(soundingdata=mydataposf)
S.make_skewt_axes()
S.add_profile(color='r', bloc=0)
S.soundingdata = S2.soundingdata
S.add_profile(color='b', bloc=1)