示例#1
0
from pyhdf import VS
import pyhdf
import pyhdf.HDF as HDF
import pyhdf.SD
import numpy as np
from readcloudsat import get_geo
import matplotlib.pyplot as plt

if __name__=="__main__":
    ecmwfname='2008291181813_13156_CS_ECMWF-AUX_GRANULE_P_R04_E02.hdf'
    lat,lon,time_utc,prof_seconds,dem_elevation=get_geo(ecmwfname)
    hdffile=HDF.HDF(ecmwfname,HDF.HC.READ)
    vs=hdffile.vstart()
    the_vs_data=vs.attach('EC_height')
    nrecs=the_vs_data._nrecs
    height=the_vs_data.read(nRec=nrecs)
    height=np.array(height).squeeze()
    the_vs_data.detach()
    readonly=pyhdf.SD.SDC.READ
    sdfile=pyhdf.SD.SD(ecmwfname,readonly)
    temp_soundings=sdfile.select('Temperature')
    temp_array=temp_soundings.get()
    sdfile.end()
    start=20000
    stop=22000
    temp_array=temp_array[start:stop,:]
    temp_avg=temp_array.mean(axis=0)
    fig1=plt.figure(1)
    fig1.clf()
    axis1=fig1.add_subplot(1,1,1)
    axis1.plot(temp_avg,height/1.e3)
示例#2
0
""" modified 2012/11/23 to eliminate need for matlab"""
import matplotlib
import datetime
import dateutil.tz as tz
import numpy as np
import matplotlib.dates as mpldates 
import matplotlib.pyplot as plt
import h5py
import sys
from readcloudsat import get_geo,convert_field

if __name__=="__main__":
    #http://www.cloudsat.cira.colostate.edu/dataSpecs.php?prodid=9
    rainfilename='2010247105814_23156_CS_2C-RAIN-PROFILE_GRANULE_P_R04_E03.h5'
    #rainfilename='2009197050922_17109_CS_2C-RAIN-PROFILE_GRANULE_P_R04_E02.h5'
    lat,lon,time_utc,prof_seconds,dem_elevation=get_geo(rainfilename)
    with h5py.File(rainfilename,'r') as f:
        rain_rate=f['2C-RAIN-PROFILE']['Data Fields']['rain_rate'].value
        rain_rate=[item[0] for item in rain_rate]
        rain_rate=np.array(rain_rate)
    #rain_rate[rain_rate < -9000]=np.nan
    plt.close('all')
   
    fig1=plt.figure(1)
    fig1.clf()
    axis1=fig1.add_subplot(1,1,1)
    axis1.plot(rain_rate)
    axis1.set_xlabel('index value')
    axis1.set_ylabel('rain rate (mm/hour)')
    axis1.set_title('rain rate for all times')
    axis1.set_ylim([0,10])