Esempio n. 1
0
        mean_ce_hind[i] = points_over_ce_hind[i, :, :].mean()
        mean_ce_obs[i] = points_over_ce_obs[i, :, :].mean()

    #~ sig_membs_ce = cs.ProbMemb(fcst_month="out", fcst_year="2015",
                            #~ target_year="2015", target_months="OND",
                            #~ hind_period="8110", nyears=n_years,
                            #~ shapef='/home/marcelo/FSCT-ECHAM46/pontos_ce.txt')

    #~ print sig_membs_ce
    #~ print f_signal_ce

    figname_curvace = '{5}/prob_echam46_issue_{0}{1}_target_{2}{3}_{4}_curve_ce_median.png' \
                      .format(fcst_month, fcst_year, target_months, target_year, hind_period, outdir)
    below_ce, normal_ce, above_ce, f_signal_ce, f_std_ce, o_pad_ce, fcst_sig_anom = cs.compute_probability(mean_ce_fcst, mean_ce_hind, mean_ce_obs, n_years)
    pm.plotnorm(f_signal_ce, f_std_ce, o_pad_ce, title_xlabel=u"Precipitação Normalizada",
                title_ylabel="Probabilidade", fig_name=figname_curvace,
                fig_title='')
                #~ fig_title='', plotmem=sig_membs_ce)
    #~ pm.plotnorm(f_signal_ce, f_std_ce, o_pad_ce, title_xlabel=u"Standardized Precipitation",
    #~ title_ylabel="Probability", fig_name=figname_curvace, fig_title='')

    background = Image.open(figname_curvace)
    foreground = Image.open("/home/marcelo/FSCT-ECHAM46/FUNCEME_LOGO.png")
    foreground = foreground.resize((90, 70), Image.ANTIALIAS)
    background.paste(foreground, (630, 469), foreground)
    background.save(figname_curvace, optimize=True, quality=95)

    figout = "{5}/bra_precip_persistida_{1}_{2}-{3}_{4}_{0}_echam46_1dg_cmap_tercilmaisprovavel_median.png".format(n_fcst_month, hind_period_name, target_year, target_months, fcst_year, outdir)
    figtitle = "ECHAM4.6 - {0}/{1} - {2}/{3}\nPROB PREC (%) ({4})".format(fcst_month.upper(), fcst_year, target_months, target_year, hind_period_name)
    #~ figtitle = "ECHAM4.6 - OCT/{1} - {2}/{3}\nPROB PREC (%) ({4})".format(fcst_month.upper(), fcst_year, target_months, target_year, hind_period_name)
    #~ shapefile="/home/marcelo/Anaconda/lib/python2.7/site-packages/PyFuncemeClimateTools-0.1.1-py2.7.egg/PyFuncemeClimateTools/shp/brazil"
Esempio n. 2
0
# lons = read_fcst_file.variables['lon'][:]
# read_fcst_file.close()

# hind_file = "/home/marcelo/FSCT-ECHAM46/APR2015_HIND89-08-1DG/pcp-daily-total-ec4amip_89-08MJJ.1.0dg.fix.nc"
# read_hind_file = pupynere.NetCDFFile(hind_file, 'r')
# hind = read_hind_file.variables['pcp'][:, :, :]
# read_hind_file.close()
#
# obs_file = "/home/marcelo/FSCT-ECHAM46/APR2015_HIND89-08-1DG/cmap.89-08-MJJ-1.0dg.fix.nc"
# read_obs_file = pupynere.NetCDFFile(obs_file, 'r')
# obs = read_obs_file.variables['pcp'][:, :, :]
# read_obs_file.close()

if myopt == "p":
    n_lon, n_lat, i_lon, i_lat = dg.gridpoint(lons, lats, mylon, mylat)
    myfcst = fsct[0, i_lat, i_lon]
    myhind = hind[:, i_lat, i_lon]
    myobs = obs[:, i_lat, i_lon]
    below, normal, above, fsignal, fstd, opad = cs.compute_probability(myfcst, myhind, myobs)
    fsignal = np.expand_dims(fsignal, axis=0)
    figname = "curve_prob_%s_%s.png" % (mylon, mylat)
    pm.plotnorm(fsignal, fstd, opad, fig_name=figname, fig_title='')

elif myopt == "a":
    print 't1'
    pass

else:
    print 't2'
    pass
Esempio n. 3
0
# obs_ce = obs_file.variables['pcp'][:, 53:58, 49:53]
# obs_mean_ce = np.apply_over_axes(np.mean, obs_ce, [1, 2])

# obs_ce = obs_file.variables['pcp'][:, 52:54, 51:53]
# obs_mean_ce = np.apply_over_axes(np.mean, obs_ce, [1, 2])
obs_ce = obs_file.variables['pcp'][:, 52:53, 53:54]
obs_mean_ce = np.apply_over_axes(np.mean, obs_ce, [1, 2])

# Longitude e latitude
lons = fsct_file.variables['lon'][:]
lats = fsct_file.variables['lat'][:]


# Curva de probabilidade
below_ce, normal_ce, above_ce, f_signal_ce, f_std_ce, o_pad_ce = cm.compute_probability(fsct[:, 0, 0], hind[:, 0, 0], obs[:, 0, 0])
pm.plotnorm(f_signal_ce, f_std_ce, o_pad_ce, fig_name='prob.echam46+nmme.curve.ce.png', fig_title='')

# below, normal, above, f_signal, f_std, o_pad = cm.compute_probability(fsct, hind, obs)
# cn.create_netcdf_probs(below, normal, above, lats, lons, fileout="prob_nmme+echam46_issue_jan2015_target_fma2015.nc")

# Anomalia
# anomaly, anomaly_pad = cm.compute_anomaly(fsct, hind)

# Shift na longitude e nos dados do modelo
# Isso é necessário pois a longitude do NetCDF é no formato 0 - 360
# a função aceita valores de longitude no formato -180 - +180
# Chefinho quer ver todos os oceanos
# anomaly, fsct_lon = shiftgrid(30., anomaly, fsct_lon, start=False)
# anomaly, lons_anom_aux = shiftgrid(180., anomaly, lons, start=False)

# Plot map anomalia globo
Esempio n. 4
0
        pcp_obs_ce = obs_file['pcp'][:, 29:31, 114]
        obs_ce = np.asarray(pcp_obs_ce)

        # Média sobre o CE
        fsct_aux_ce = np.apply_over_axes(np.mean, fsct_ce, [1, 2])
        hind_aux_ce = np.apply_over_axes(np.mean, hind_ce, [1, 2])
        obs_aux_ce = np.apply_over_axes(np.mean, obs_ce, [1, 2])

        outdir = "%s%s_HIND%s" % (fcst_month.upper(), fcst_year, hind_period)
        if not os.path.exists(outdir):
            os.makedirs(outdir)

        # Curva de probabilidade para o CE
        figname = outdir + '/' + 'prob_echam46_issue_%s%s_target_%s%s_%s_curve_ce.png' % (fcst_month, fcst_year, target_months, target_year, hind_period)
        below_ce, normal_ce, above_ce, f_signal_ce, f_std_ce, o_pad_ce = cs.compute_probability(fsct_aux_ce[:, 0, 0], hind_aux_ce[:, 0, 0], obs_aux_ce[:, 0, 0])
        pm.plotnorm(f_signal_ce, f_std_ce, o_pad_ce, fig_name=figname, fig_title='')

        ### Fim Bloco Curva para o CE ###


        # Tercil mais provável para toda a região do globo
        file_out = outdir + '/' + "prob_echam46_issue_%s%s_target_%s%s_%s.nc" % (fcst_month, fcst_year, target_months, target_year, hind_period)
        below, normal, above, f_signal, f_std, o_pad = cs.compute_probability(fsct, hind, obs)
        cn.create_netcdf_probs(below, normal, above, lats, lons, fileout=file_out)
        # ferret_command = "/home/marcelo/pyferret-0.0.9/bin/pyferret.sh -nojnl -gif -script plot_tercis_ensemble.jnl {0}".format(file_out)
        # os.system(ferret_command)

        # Correlacao
        correl = cs.corr_pearson(hind, obs)

        correl, lons_correl_aux = shiftgrid(180., correl, lons, start=False)
Esempio n. 5
0
    if not os.path.exists(figrealname):

        print "entrooou... delicia! =)"

        fcst, hind, obs = readdata(myhind, myfmon, myfyear, mytyear, mytseason)

        if not os.path.exists("img"):
            os.makedirs("img")

        below, normal, above, fsignal, fstd, opad, fs_anom = cs.compute_probability(
            fcst[0, i_lat, i_lon], hind[:, i_lat, i_lon], obs[:, i_lat, i_lon], lenhind
        )

        fsignal = np.expand_dims(fsignal, axis=0)

        pm.plotnorm(fsignal, fstd, opad, fig_name=figname, fig_title="")

        shutil.copy2(figname, figrealname)

    else:

        print "nao entrou =("

        # se a imagem ja tiver sido gerada, apenas faz copia para exibir no site
        shutil.copy2(figrealname, figname)

elif myopt == "a":

    fcst, hind, obs = readdata(myhind, myfmon, myfyear, mytyear, mytseason)

    lonlat = dg.getvertbd(myregion, filetxtout=False, figout=False)