ntrimetres = range(1, 9)
itime      = 31 * len(ntrimetres)
myvars     = [ "tmphag", "spfhhag", "dswrfsfc" ]


for var in myvars:

    for year in nyear:

        data_all, lats, lons = post.PostModel(fcst_month, 
        ntrimetres, year, nvar=var, model='RSM97')

        print data_all.shape

        data_all = np.swapaxes(data_all, 1, 2).reshape(itime, 20, 72, 109)

        # Remove valores nan
        daily = data_all[~np.isnan(data_all[:, 0, 0, 0]), :, :, :]

        daily = np.swapaxes(daily, 0, 1)

        print daily.shape

        # Usado no forecast
        fname = '{4}.daily.rsm97.hind8110.{0}{1}.' \
                '{1}0{2}-{1}0{3}.nc' \
                .format(fcst_month, year, ntrimetres[0], 
                ntrimetres[-1], var)

        writenc4(daily, lats, lons, fname, daily.shape[1], year)
示例#2
0
    # Kelvin -> Celsius
    tmphag = tmphag - 273.15

    # Equação de Clausius Clapeyron
    # Pressão de vapor de saturação em pascal
    es = 0.6108 * np.exp((17.27 * tmphag) / (tmphag + 237.3))

    # Rogers & Yau. A short course in Cloud Physics
    # http://www.eol.ucar.edu/projects/ceop/dm/documents/refdata_report/eqns.html
    # Pressão em Pa = 100000.
    ur = (100 * (100000. / 0.622) * (spfhhag / es)) / 1000

    fname = 'ur.daily.rsm97.hind8110.jan{0}.{0}01-{0}08.nc' \
        .format(y)

    writenc4(ur, lat, lon, fname, ur.shape[1], y)

    print fname

# Ver também:
# http://earthscience.stackexchange.com/questions/2360/how-do-i-convert-specific-humidity-to-relative-humidity

# writenc4(ur, lat, lon, 'out.nc', ur.shape[1], y)

### Escreve em um arquivo txt ###
# for m in xrange(0, 20):

# 		nt, ny, nx = ur[m, :, :, :].shape

# 		nvar = np.reshape(ur[m, :, :, :], [nt, nx*ny], order='F').T