pressure = wrfOutputFile.variables["P"][:] + wrfOutputFile.variables["PB"][:] qvapor = wrfOutputFile.variables["QVAPOR"][:] qvapor = numpy.ma.masked_where(qvapor < 0.00002, qvapor) T0 = 273.15 referencePressure = 100000.0 # [Pa] epsilon = 0.622 # Rd / Rv # Temperatures in Celsius temperature = theta * numpy.power((pressure / referencePressure), 0.2854) - T0 vaporPressure = pressure * qvapor / (epsilon + qvapor) dewPointTemperature = 243.5 / ( (17.67 / numpy.log(vaporPressure * 0.01 / 6.112)) - 1.0) # In celsius dewPointTemperature = numpy.ma.masked_invalid(dewPointTemperature) # Now we have the pressure, temperature and dew point temperature in the whole domain # Select one vertical column , t =0 , x=30, y=30 inputData = dict( pressure=pressure[0, :, 30, 30] / 100, temperature=temperature[0, :, 30, 30], dewPointTemperature=dewPointTemperature[0, :, 30, 30], ) mySounding = sounding(inputData) mySounding.quickPlot()
def calculate_radar_hid(radar, sounding_names, radar_band="S"): """ Use radar and sounding data to calculate: - Temperature and height profiles - Hydrometeor classification with CSU_RadarTools - Liquid and ice water masses, ice fraction Parameters ---------- radar: Py-ART radar data sounding_names: list of sounding data filenames radar_band: radar band Returns ------- file: radar data with HID and water masses """ # Getting date for sounding - optional # radar_date = pd.to_datetime(radar.time['units'][14:]) # Interpolating with sounding soundings = sounding(sounding_names) # - optional: sounding_names.loc[str(radar_date.date())].item() radar_T, radar_z = interpolate_sounding_to_radar(soundings, radar) # Extracting necessary variables z_corrected = radar.fields["corrected_reflectivity"]["data"] zdr = radar.fields["differential_reflectivity"]["data"] kdp = radar.fields["specific_differential_phase"]["data"] rho_hv = radar.fields["cross_correlation_ratio"]["data"] # Classifying scores = csu_fhc.csu_fhc_summer( weights={ "DZ": 1, "DR": 1, "KD": 1, "RH": 1, "LD": 1, "T": 1 }, dz=z_corrected, zdr=zdr, kdp=kdp, rho=rho_hv, use_temp=True, T=radar_T, band=radar_band, verbose=True, method="hybrid", ) fh = np.argmax(scores, axis=0) + 1 # - Adding to radar file radar = add_field_to_radar_object(fh, radar, standard_name="Hydrometeor ID") # - Calculating liquid and ice mass mw, mi = csu_liquid_ice_mass.calc_liquid_ice_mass(z_corrected, zdr, radar_z / 1000.0, T=radar_T) # - Adding to radar file file = add_field_to_radar_object( mw, radar, field_name="MW", units=r"$g\ m^{-3}$", long_name="Liquid Water Mass", standard_name="Liquid Water Mass", ) file = add_field_to_radar_object( mi, file, field_name="MI", units=r"$g\ m^{-3}$", long_name="Ice Water Mass", standard_name="Ice Water Mass", ) return file
""" Simple SkewT Figure example from Sounding """ # For python2.7 compatibility from __future__ import print_function, division # Load the sounding class from the package from SkewTplus.sounding import sounding # Load the sounding datas mySounding = sounding("./exampleSounding.txt") # Show the SkewT diagram of the Sounding mySounding.quickPlot()
""" Simple SkewT Figure example from Sounding """ from __future__ import print_function, division from SkewTplus.skewT import figure from SkewTplus.sounding import sounding # Load the sounding data mySounding = sounding("./armSoundingExample.cdf") # Create a Figure Manager mySkewT_Figure = figure() # Add an Skew-T axes to the Figure mySkewT_Axes = mySkewT_Figure.add_subplot(111, projection="skewx") # Extract the data from the Sounding # The getCleanSounding method remove levels where invalid temperatura or pressure # values are present pressure, temperature, dewPointTemperature = mySounding.getCleanSounding() # Add a profile to the Skew-T diagram mySkewT_Axes.addProfile( pressure, temperature, dewPointTemperature, hPa=True,
''' Plot two soundings in the same Skew-T diagram with out any parcel analysis ''' from __future__ import print_function, division from SkewTplus.skewT import figure from SkewTplus.sounding import sounding #Load the sounding data mySounding1 = sounding("./bna_day1.txt") mySounding2 = sounding("./bna_day2.txt") # Create a Figure Manager with a suitable size for both plots mySkewT_Figure = figure(figsize=(5, 6)) # Add the Skew-T axes to the Figure mySkewT_Axes1 = mySkewT_Figure.add_subplot(111, projection='skewx', tmin=-40) # Add one profile to the Skew-T diagram # The line style is set to be a solid line and a label is added # to the plot. Since the label is not None, a legend will be added # automatically to the plot mySkewT_Axes1.addProfile(*mySounding1.getCleanSounding(), hPa=True, celsius=True, parcel=False, label='Day 1', linestyle='-') # Add a second profile to the Skew-T diagram
from netCDF4 import Dataset import numpy from SkewTplus.skewT import figure from SkewTplus.sounding import sounding from SkewTplus.thermodynamics import parcelAnalysis, liftParcel import matplotlib.pyplot as plt # Read the examples soundings # Load the sounding class from the package #Load the sounding data print("Testing TXT reader") assert(sounding("./exampleSounding.txt")['pressure'][-1]==34.0) assert(sounding("./94610.2010032200.txt")['pressure'][-1]==8.8) assert(sounding("./94866.2010030600.txt")['pressure'][-1]==37.6) assert(sounding("./94975.2013070900.txt")['pressure'][-1]==57.0) assert(sounding("./94975.2013070900.txt")['pressure'][-1]==57.0) assert(sounding("./bna_day1.txt")['pressure'][-1]==100.0) assert(sounding("./bna_day2.txt")['pressure'][-1]==100.0) assert(sounding("./sounding_high_tropo.txt")['pressure'][-1]==14.7) # Show the SkewT diagram of the Sounding mySounding = sounding("./exampleSounding.txt") mySounding.quickPlot() ''' Simple SkewT Figure example from Sounding
qvapor = wrfOutputFile.variables['QVAPOR'][:] qvapor = numpy.ma.masked_where(qvapor < 0.00002, qvapor) T0 = 273.15 referencePressure = 100000.0 # [Pa] epsilon = 0.622 # Rd / Rv # Temperatures in Celsius temperature = theta * numpy.power((pressure / referencePressure), 0.2854) - T0 vaporPressure = pressure * qvapor / (epsilon + qvapor) dewPointTemperature = 243.5 / ( (17.67 / numpy.log(vaporPressure * 0.01 / 6.112)) - 1.) #In celsius dewPointTemperature = numpy.ma.masked_invalid(dewPointTemperature) # Now we have the pressure, temperature and dew point temperature in the whole domain # Select one vertical column , t =0 , x=30, y=30 mySounding = sounding() # Create an empty sounding #Add fields mySounding.addField('pressure', pressure[0, :, 30, 30], "Pressure", "Pa") mySounding.addField('temperature', temperature[0, :, 30, 30], "Temperature", "C") mySounding.addField('dewPointTemperature', dewPointTemperature[0, :, 30, 30], "Dew Point Temperature", "C") mySounding.quickPlot()
""" Created on Apr 22, 2017 @author: aperez """ from SkewTplus.sounding import sounding mySounding = sounding() mySounding.fetchFromWeb("20170410:00", "OAX") mySounding.quickPlot() mySounding = sounding("20170410:00", fileFormat="web", stationId="OAX") mySounding.quickPlot()