コード例 #1
0
def _read_diag_conv(fname, endian='big'):
    '''
    Helper function to read a conventional diagnostic file
    '''
    try:
        diag = _rd.diag_conv(fname, endian=endian)
        diag.read_obs()
    except:
        raise Exception('Error handling %s' % fname)

    return diag
コード例 #2
0
fig = plt.figure(figsize=(16, 8), dpi=100)
plt.subplots_adjust(top=0.9, bottom=0.1, right=0.98, left=0.02)
gs = gspec.GridSpec(1, 2)

ax = plt.subplot(gs[0])

plt.title("North Hemisphere - Polar")
m = Basemap(projection='npstere', boundinglat=55, lon_0=180, resolution='l')
m.drawmapboundary(fill_color='#A6CAE0', linewidth=0)
m.fillcontinents(color='grey', alpha=0.7, lake_color='grey', zorder=10)
m.drawcoastlines(linewidth=0.1, color="white")
m.drawparallels(np.asarray([80, 60]), labels=[1, 1, 0, 1])
m.drawmeridians(np.arange(-180, 180, 30), labels=[1, 1, 0, 1])

# read header
diag_conv = read_diag.diag_conv(obsfile, endian='big')
print('total number of obs = ', diag_conv.nobs)

# read data
diag_conv.read_obs()

#instrumentlist = ['  v','  u','  t','  q','gps']
instrumentlist = ['  v']
for instrument in instrumentlist:

    if instrument == '  v':
        obsname = 'V-Wind'
    elif instrument == '  u':
        obsname = 'U-Wind'
    elif instrument == '  t':
        obsname = 'Temperature'
コード例 #3
0
ファイル: test_read_diag.py プロジェクト: jswhit/py-ncepbufr
import read_diag
import numpy as np
obsfile = 'diag_conv_ges.2015102700'
diag_conv = read_diag.diag_conv(obsfile,endian='big')
print 'total number of obs = ',diag_conv.nobs
diag_conv.read_obs()
# print o-f stats for ps obs
# all ship ps obs used in assimilation
indxps = np.logical_and(diag_conv.obtype == ' ps', diag_conv.used == 1)
indxps = np.logical_and(indxps, diag_conv.code == 180)
nobsps = indxps.sum()
fitsq = ((diag_conv.hx[indxps]-diag_conv.obs[indxps])**2).mean()
print nobsps, np.sqrt(fitsq)
コード例 #4
0
pbins = np.zeros(nlevs + 1, np.float)
pbins[0:nlevs] = levs1
pbins[nlevs] = levs2[-1]
for nlev in range(18, nlevs):
    levs[nlev] = 0.5 * (levs1[nlev] + levs2[nlev])

rms_wind = np.zeros(len(levs), np.float)
rms_temp = np.zeros(len(levs), np.float)
bias_temp = np.zeros(len(levs), np.float)
count_temp = np.zeros(len(levs), np.int)
count_wind = np.zeros(len(levs), np.int)
for date in dates:
    obsfile = os.path.join(datapath,
                           '%s/diag_conv_ges.%s_%s' % (date, date, runid))
    print obsfile
    diag_conv = read_diag.diag_conv(obsfile, endian=endian)
    diag_conv.read_obs()
    if sondesonly:
        insitu_wind = np.logical_or(
            diag_conv.code == 220,  # sondes
            diag_conv.code == 232)  # drops
        insitu_wind = np.logical_or(insitu_wind,
                                    diag_conv.code == 221)  # pibals
    else:
        insitu_wind = np.logical_and(diag_conv.code >= 280,
                                     diag_conv.code <= 282)  #sfc
        # sones, pibals
        insitu_wind = np.logical_or(insitu_wind,\
                      np.logical_or(diag_conv.code == 220, diag_conv.code == 221))
        # aircraft, drops
        insitu_wind = np.logical_or(insitu_wind,\
コード例 #5
0
ファイル: obfits_diag.py プロジェクト: jswhit/py-ncepbufr
levs2[22] = 0.
levs1[0] = 1200.
pbins = np.zeros(nlevs+1,np.float)
pbins[0:nlevs] = levs1; pbins[nlevs] = levs2[-1]
for nlev in range(18,nlevs):
    levs[nlev] = 0.5*(levs1[nlev]+levs2[nlev])

rms_wind = np.zeros(len(levs),np.float)
rms_temp = np.zeros(len(levs),np.float)
bias_temp = np.zeros(len(levs),np.float)
count_temp = np.zeros(len(levs),np.int)
count_wind = np.zeros(len(levs),np.int)
for date in dates:
    obsfile = os.path.join(datapath,'%s/diag_conv_ges.%s_%s' % (date,date,runid))
    print obsfile
    diag_conv = read_diag.diag_conv(obsfile,endian=endian)
    diag_conv.read_obs()
    if sondesonly:
        insitu_wind = np.logical_or(diag_conv.code == 220, # sondes
                                    diag_conv.code == 232) # drops
        insitu_wind = np.logical_or(insitu_wind, diag_conv.code == 221) # pibals
    else:
        insitu_wind = np.logical_and(diag_conv.code >= 280, diag_conv.code <= 282) #sfc
        # sones, pibals
        insitu_wind = np.logical_or(insitu_wind,\
                      np.logical_or(diag_conv.code == 220, diag_conv.code == 221)) 
        # aircraft, drops
        insitu_wind = np.logical_or(insitu_wind,\
                      np.logical_and(diag_conv.code >= 230, diag_conv.code <= 235))
    if sondesonly:
        insitu_temp = np.logical_or(diag_conv.code == 120, # sondes