Пример #1
0
def mapa_show(data3d, lat, lon):

    y1, y2, x1, x2 = -25, 0, -52, -34
    cor1 = ('#750000', '#ff0000', '#ff8000', '#fcd17d', '#ffff00', '#ffffff',
            '#00ffff', '#7dd1fa', '#0080ff', '#0000ff', '#000075')  # Colors
    lev1 = (-2., -1.6, -1.3, -0.8, -0.5, 0.5, 0.8, 1.3, 1.6, 2.)

    pm.plotmap(data3d[0, :, :],
               lat,
               lon,
               latsouthpoint=y1,
               latnorthpoint=y2,
               lonwestpoint=x1,
               loneastpoint=x2,
               ocean_mask=0,
               fig_name="figou1_teste.png.",
               barcolor=cor1,
               barlevs=lev1,
               barinf='both',
               barloc='right')
Пример #2
0
        caso_shape_so_plot('/estados/sergipe/sergipe.txt')

        y1, y2, x1, x2 = -20, 0, -50, -34
        cor1 = ('#750000', '#ff0000', '#ff8000', '#fcd17d', '#ffff00',
                '#ffffff', '#00ffff', '#7dd1fa', '#0080ff', '#0000ff',
                '#000075')  # Paleta
        lev1 = (-2., -1.6, -1.3, -0.8, -0.5, 0.5, 0.8, 1.3, 1.6, 2.)

        figou1 = 'ESI_Regiao_NEB_4WK_{0}_{1}.png'.format(mes[i], ANO)
        title1 = u'Índice de Estresse Evaporativo \n{0} - {1}'.format(
            mes[i], ANO)

        pm.plotmap(Dmasked[0, :, :],
                   lats,
                   lons,
                   latsouthpoint=y1,
                   latnorthpoint=y2,
                   lonwestpoint=x1,
                   loneastpoint=x2,
                   ocean_mask=1,
                   shapefile=None,
                   fig_name=figou1,
                   fig_title=title1,
                   barcolor=cor1,
                   barlevs=lev1,
                   barinf='both',
                   barloc='right')

        plt.close('all')
        plt.cla()
    # y1, y2, x1, x2 = -40., 40., -150., 70.  # Globo
    #~ y1, y2, x1, x2 = -89., 89., -178., 178.  # Globo
    #~ y1, y2, x1, x2 = -23., 9., -75., -34.  # Região Reliability
    y1, y2, x1, x2 = -21.3, 7., -55.6, -34  # América do sul

    ###########  CORRELAÇÃO  ###########
    correl = cs.compute_pearson(hind, obs, n_years)
    figtitle = u'RSM97 x UTEXAS - {0}/{1} ({2})\nCorrelação - Precip Acum'.format(fcst_month_name, target_months, hind_period_name)
    figname = "{3}/bra_precip_persistida_{0}_null-{1}_null_{2}_rsm97_1dg_utexas_correlacao.png".format(hind_period_name, target_months, n_fcst_month, outdir)
    levs = (-1.0, -0.9, -0.7, -0.5, -0.3,
             0.3,  0.5,  0.7,  0.9,  1.0) #10
    my_colors = ('#2372c9', '#3498ed', '#4ba7ef', '#76bbf3', '#93d3f6',
                 '#b0f0f7', '#ffffff', '#fbe78a', '#ff9d37', '#ff5f26',
                 '#ff2e1b', '#ff0219', '#ae000c') #13
    pm.plotmap(correl, obs_lats-0.54/2., obs_lons-0.54/2., latsouthpoint=y1, latnorthpoint=y2,
        lonwestpoint=x1, loneastpoint=x2, fig_name=figname, barloc='right',
        barcolor=my_colors, barlevs=levs, fig_title=figtitle, barinf='neither', ocean_mask=1)
    background = Image.open(figname)
    foreground = Image.open("/home/marcelo/FSCT-ECHAM46/FUNCEME_LOGO.png")
    foreground = foreground.resize((90, 70), Image.ANTIALIAS)
    background.paste(foreground, (313, 460), foreground)
    background.save(figname, optimize=True, quality=95)

    # ###########  RMSE  ###########
    # error_rmse = cs.compute_rmse(hind, obs)
    # rmse_title = u'ECHAM4.6 x CMAP - {0}/{1} ({2})\nRMSE (mm) - Precip Acum'.format(fcst_month_name, target_months, hind_period_name)
    # fig_rmse = '{3}/bra_precip_persistida_{0}_null-{1}_null_{2}_echam46_1dg_cmap_rmse.png'.format(hind_period_name, target_months, n_fcst_month, outdir)
    # levs = (0., 50., 100., 200., 400., 600., 800.)  #7
    # my_colors = ('#ffffff', '#E1FFFF', '#B4F0FA', '#96D2FA', '#78B9FA',
                 # '#50A5F5', '#3C96F5', '#2882F0')  #8
    # pm.plotmap(error_rmse, newlats-1./2., newlons-1./2., latsouthpoint=y1, latnorthpoint=y2,
    #~ y1, y2, x1, x2 = -89., 89., -178., 178.  # Globo
    #~ y1, y2, x1, x2 = -23., 9., -75., -34.  # Região Reliability
    y1, y2, x1, x2 = -60., 15., -90., -30.  # América do sul

    ###########  CORRELAÇÃO  ###########
    correl = cs.compute_pearson(hind, obs, n_years)
    figtitle = u'ECHAM4.6 x CMAP - {0}/{1} ({2})\nCorrelação - Precip Acum'.format(fcst_month_name, target_months, hind_period_name)
    #~ figtitle = u'ECHAM4.6 x CMAP - {0}/{1} ({2})\nCorrelation - Precip Accum'.format(fcst_month_name, target_months, hind_period_name)
    figname = "{3}/bra_precip_persistida_{0}_null-{1}_null_{2}_echam46_1dg_cmap_correlacao.png".format(hind_period_name, target_months, n_fcst_month, outdir)
    levs = (-1.0, -0.9, -0.7, -0.5, -0.3,
             0.3,  0.5,  0.7,  0.9,  1.0) #10
    my_colors = ('#2372c9', '#3498ed', '#4ba7ef', '#76bbf3', '#93d3f6',
                 '#b0f0f7', '#ffffff', '#fbe78a', '#ff9d37', '#ff5f26',
                 '#ff2e1b', '#ff0219', '#ae000c') #13
    pm.plotmap(correl, newlats-1./2., newlons-1./2., latsouthpoint=y1, latnorthpoint=y2,
        lonwestpoint=x1, loneastpoint=x2, fig_name=figname, barloc='right',
        barcolor=my_colors, barlevs=levs, fig_title=figtitle, barinf='neither', ocean_mask=1)
    background = Image.open(figname)
    foreground = Image.open("FUNCEME_LOGO.png")
    foreground = foreground.resize((90, 70), Image.ANTIALIAS)
    background.paste(foreground, (334, 461), foreground)
    background.save(figname, optimize=True, quality=95)

    ###########  RMSE  ###########
    error_rmse = cs.compute_rmse(hind, obs)
    rmse_title = u'ECHAM4.6 x CMAP - {0}/{1} ({2})\nRMSE (mm) - Precip Acum'.format(fcst_month_name, target_months, hind_period_name)
    fig_rmse = '{3}/bra_precip_persistida_{0}_null-{1}_null_{2}_echam46_1dg_cmap_rmse.png'.format(hind_period_name, target_months, n_fcst_month, outdir)
    levs = (0., 50., 100., 200., 400., 600., 800.)  #7
    my_colors = ('#ffffff', '#E1FFFF', '#B4F0FA', '#96D2FA', '#78B9FA',
                 '#50A5F5', '#3C96F5', '#2882F0')  #8
    pm.plotmap(error_rmse, newlats-1./2., newlons-1./2., latsouthpoint=y1, latnorthpoint=y2,
print zi.shape

# np.savetxt("zi.txt", zi)

for ilon in range(0, 109):
    for ilat in range(0, 72):
        print lonrsm[ilon], latrsm[ilat], zi[ilat, ilon]


exit()
# print zi

levs = [-2., -1.8, -1.3, -0.8, -0.5, 0.]
my_colors = ('#730000', '#E60000', '#FFAA00', '#FCD37F', '#FFFF00')
pm.plotmap(zi, latrsm-0.54/2., lonrsm-0.54/2., latnorthpoint=np.max(latrsm), latsouthpoint=np.min(latrsm),
           loneastpoint=np.max(lonrsm), lonwestpoint=np.min(lonrsm), barlevs=levs, barcolor=my_colors, barinf='min')

exit()

# inc = netCDF4.Dataset('/home/funceme/Downloads/pcp-seasonacc-echam46-hind8908-en51-jan2014_2014AMJ.ctl.nc')
# time = inc.variables['time'][:]
# latt42 = inc.variables['latitude'][:]
# lont42_360 = inc.variables['longitude'][:]
# pcpt42 = inc.variables['pcp'][0, :, :]
# pcpt42 , lont42_360 = addcyclic(pcpt42, lont42_360)
# pcpt42, lont42 = shiftgrid(180., pcpt42, lont42_360, start=False)
#
# inc = netCDF4.Dataset('/home/funceme/Downloads/pcp-seasonacc-echam46-hind8908-en51-jan2014_2014AMJ.ctl.1dg.nc')
# lat1dg = inc.variables['LAT'][:]
# lon1dg = inc.variables['LON'][:]
# pcp1dg = inc.variables['pcp'][0, :, :]
Пример #6
0
ltime = 5
levs = (270., 275., 280., 285., 290., 295., 300.) #7
my_colors = ('#ffffff', '#E5E5E5', '#CBCBCB', '#B2B2B2',
             '#989898', '#7F7F7F', '#666666', '#4E4E4E') #8

# LIQIANG
f1 = NetCDFFile('/home/marcelo/Downloads/sst-test/liq/obs.sst.2013.nc', 'r')
sstliq = f1.variables['sst'][:]
lons_sstliq = f1.variables['lon'][:]
lats_sstliq = f1.variables['lat'][:]
f1.close()
sstliq, lons_sstliq = shiftgrid(180., sstliq, lons_sstliq, start=False)
sstliq_title = u'TSM LIQ'
fig_sstliq = '/home/marcelo/Downloads/sst-test/tsmliq.png'
pm.plotmap(sstliq[ltime, :, :], lats_sstliq-2.8125/2., lons_sstliq-2.8125/2., latsouthpoint=y1, latnorthpoint=y2,
           lonwestpoint=x1, loneastpoint=x2,  fig_name=fig_sstliq, barloc='bottom', maptype='fillc',
           barcolor=my_colors, barlevs=levs, fig_title=sstliq_title, barinf='max', ocean_mask=0,
           meridians=np.arange(-160., 161., 30.), parallels=np.arange(-90., 91., 20.))


# NÃO INVERTIDO USANDO A LAT DO MENOR PARA O MAIOR
# f4 = NetCDFFile('/home/marcelo/Downloads/sst-test/nc3/obs.sst.2013.nc', 'r')
# sstnc3 = f4.variables['sst'][:, :, :]
# lons_sstnc3 = f4.variables['lon'][:]
# lats_sstnc3 = f4.variables['lat'][:]
# f4.close()
# sstnc3, lons_sstnc3 = shiftgrid(180., sstnc3, lons_sstnc3, start=False)
# sstliq_title = u'NÃO INVERTIDO USANDO A LAT DO MENOR PARA O MAIOR'
# fig_sstliq = '/home/marcelo/Downloads/sst-test/n3.png'
# pm.plotmap(sstnc3[ltime, :, :], lats_sstnc3-2.8125/2., lons_sstnc3-2.8125/2., latsouthpoint=y1, latnorthpoint=y2,
#            lonwestpoint=x1, loneastpoint=x2,  fig_name=fig_sstliq, barloc='bottom', maptype='fill',
#            barcolor=my_colors, barlevs=levs, fig_title=sstliq_title, barinf='max', ocean_mask=0,
Пример #7
0
#~ lat,lon = grb.latlons()
#~ 
#~ figtitle = 'TITULO DA FIGURA'
#~ figname_anom = 'atub1.png'
#~ levs = range(100, 420, 20)
#~ my_colors = ('#340003', '#ae000c', '#ff2e1b', '#ff5f26', '#ff9d37', '#fbe78a',
             #~ '#ffffff', '#b0f0f7', '#93d3f6', '#76bbf3', '#4ba7ef', '#3498ed', '#2372c9') #13
#~ pm.plotmap(aux1[0,217:231,130:280], lat[217:231,0], lon[0,130:280], fig_name=figname_anom, barloc='bottom',
           #~ barcolor=my_colors, barlevs=levs, fig_title=figtitle, 
           #~ barinf='both', ocean_mask=0)

print '---'

grb    = grbs.select(name='Potential temperature')[0]
data   = grb.values

print data[217:231,130:280]

exit()

figtitle = 'TITULO DA FIGURA 2'
figname_anom = 'atub2.png'
levs = range(100, 420, 20)
my_colors = ('#340003', '#ae000c', '#ff2e1b', '#ff5f26', '#ff9d37', '#fbe78a',
             '#ffffff', '#b0f0f7', '#93d3f6', '#76bbf3', '#4ba7ef', '#3498ed', '#2372c9') #13
pm.plotmap(data[217:231,130:280], lat[217:231,0], lon[0,130:280], fig_name=figname_anom, barloc='bottom',
           barcolor=my_colors, barlevs=levs, fig_title=figtitle, 
           barinf='both', ocean_mask=0)

Пример #8
0
for i in range(30):
    obs[i, ...] = interp(obs_aux[i, ...], lons_obs, lats_obs, x, y, order=1)

print(obs.shape)

###########  CORRELAÇÃO  ###########
correl = cs.compute_pearson(hind, obs)
figtitle = u'RSM2008 x INMET - JAN/{0} (8110)\nCORRELAÇÃO - PRECIP ACUM'.format(tri.upper())
figname = 'rsm.correl.{0}.png'.format(tri)
levs = (-1.0, -0.9, -0.7, -0.5, -0.3,
         0.3,  0.5,  0.7,  0.9,  1.0) #10
my_colors = ('#2372c9', '#3498ed', '#4ba7ef', '#76bbf3', '#93d3f6',
             '#b0f0f7', '#ffffff', '#fbe78a', '#ff9d37', '#ff5f26',
             '#ff2e1b', '#ff0219', '#ae000c') #13
pm.plotmap(correl, lats_hind, lons_hind, latsouthpoint=-38.27, latnorthpoint=13.63,
    lonwestpoint=-84.3, loneastpoint=-33., fig_name=figname, barloc='right',
    barcolor=my_colors, barlevs=levs, fig_title=figtitle, barinf='neither', ocean_mask=1)

###########  VIÉS  ###########
print(hind.shape)
print(obs.shape)

exit()
error_bias = cs.compute_bias(hind, obs)
error_bias[np.isinf(error_bias)] = 0
print(np.min(error_bias))
print(np.max(error_bias))

figtitle =u'RSM2008 x INMET - JAN/{0} (8110)\nVIÉS (mm) - PRECIP ACUM'.format(tri.upper())
figname = 'rsm.vies.{0}.png'.format(tri)
levs = (-4, -3, -2., -1., -0.5, 0.5, 1, 2, 3, 4)
Пример #9
0
    anom_diff = anom_exp - anom

    figtitle = u'Anom Diff (mm) (EXP - CONTROl)'

    figname_anom = '{0}/diff_anom_{1}.png'.format(directory, y)

    levs = (-300., -100., -50., -30., -15., -5.,
            5., 15., 30., 50., 100., 300.)  # 12

    my_colors = ('#340003', '#ae000c', '#ff2e1b', '#ff5f26', '#ff9d37',
                 '#fbe78a', '#ffffff', '#b0f0f7', '#93d3f6', '#76bbf3',
                 '#4ba7ef', '#3498ed', '#2372c9')  # 13

    pm.plotmap(anom_diff, nla, nlo,
               latsouthpoint=y1, latnorthpoint=y2, lonwestpoint=x1,
               loneastpoint=x2, fig_name=figname_anom, barloc='right',
               barcolor=my_colors, barlevs=levs, fig_title=figtitle,
               barinf='both', ocean_mask=1)

    # diff das anomalias percentual

    anom_diff_p = ((anom_exp - anom) / anom) * 100

    print(np.max(anom_diff_p))
    print(np.min(anom_diff_p))

    figtitle = u'Anom Diff Percentual (mm) (EXP - CONTROl)'

    figname_anom = '{0}/diff_anom_{1}_p.png'.format(directory, y)

    # 10
data = netCDF4.Dataset(path_in + name)
var = data.variables[
    'eto'][:, :, :]  # Declaring variable under study to calculate the
lats = data.variables['lat'][:]  # Declaring latitude
lons = data.variables['lon'][:]  # Declaring longitude

for m in range(0, var.shape[0]):
    print m, mes[m], dic[mes[m]]

    title1 = u'Evapotranspiração Potencial\n Desvio Padrão - {0}'.format(
        mes[m])

    figou1 = 'plot_STD_CRU_{0}.png'.format(mes[m])

    pm.plotmap(var[m, :, :] * dic[mes[m]],
               lats,
               lons,
               latsouthpoint=y1,
               latnorthpoint=y2,
               lonwestpoint=x1,
               loneastpoint=x2,
               ocean_mask=1,
               fig_name=figou1,
               fig_title=title1,
               barcolor=cor1,
               barlevs=lev1,
               barinf='max',
               barloc='right')

    print np.nanmax(var), np.nanmin(var)
Пример #11
0
    "#FFFFCC",
    "#CCFFCC",
    "#99FFCC",
    "#66FF66",
    "#00CC00",
    "#009900",
    "#003300",
)  # 11
pm.plotmap(
    diff,
    lat1dg - 1 / 2.0,
    lon1dg - 1 / 2.0,
    meridians=np.arange(-180.0, 180.0, 30.0),
    fig_name="cdobilinterp.png",
    barlevs=lev,
    barcolor=my_colors,
    latsouthpoint=-90.0,
    latnorthpoint=90.0,
    fig_title="cdo bili interp",
    lonwestpoint=-180.0,
    loneastpoint=180.0,
    barinf="max",
    ocean_mask=0,
)

exit()

lev = [0.0, 50.0, 100.0, 200.0, 300.0, 500.0, 700.0, 900.0, 1000.0]
my_colors = (
    "#CC3333",
    "#FF6633",
    "#FF9933",
        correl = cs.compute_pearson(hind, obs)
        figtitle = u'RSM97 x {3} - {0}/{1} ({2})\nCorrelação - Precip Acum' \
                   .format(fcst_month.upper(), target_months,
                   hind_period_name, obs_base.upper())
        figname = '{3}/neb_precip_persistida_{0}_null-{1}_null_{2}' \
                  '_rsm97_1dg_{4}_correlacao.png' \
                  .format(hind_period_name, target_months,
                          fcst_months[fcst_month], outdir, obs_base)
        levs = (-1.0, -0.9, -0.7, -0.5, -0.3, 0.3,  0.5,  0.7,  0.9,  1.0) #10
        my_colors = ('#2372c9', '#3498ed', '#4ba7ef', '#76bbf3', '#93d3f6',
                     '#b0f0f7', '#ffffff', '#fbe78a', '#ff9d37', '#ff5f26',
                     '#ff2e1b', '#ff0219', '#ae000c') #13
        pm.plotmap(correl, hind_lats, hind_lons,
                   latsouthpoint=y1, latnorthpoint=y2,
                   lonwestpoint=x1, loneastpoint=x2, fig_name=figname,
                   barloc='right', barcolor=my_colors, barlevs=levs,
                   fig_title=figtitle, barinf='neither', ocean_mask=1,
                   meridians=np.arange(-160., 161., 2.),
                   parallels=np.arange(-90., 91., 2.))
        # TODO: Colocar em uma funcao
        bx, by = 408, 460
        background = Image.open(figname)
        foreground = Image.open("FUNCEME_LOGO.png")
        foreground = foreground.resize((90, 70), Image.ANTIALIAS)
        background.paste(foreground, (bx, by), foreground)
        background.save(figname, optimize=True, quality=95)

        ###########  RMSE  ###########
        error_rmse = cs.compute_rmse(hind, obs)
        rmse_title = u'RSM97 x {3} - {0}/{1} ({2})\nRMSE (mm) - Precip Acum' \
                     .format(fcst_month.upper(), target_months,
        "#ffffff",
        "#fbe78a",
        "#ff9d37",
        "#ff5f26",
        "#ff2e1b",
        "#ff0219",
        "#ae000c",
    )  # 13
    pm.plotmap(
        correl,
        newlats,
        newlons,
        latsouthpoint=y1,
        latnorthpoint=y2,
        lonwestpoint=x1,
        loneastpoint=x2,
        fig_name=figname,
        barloc="right",
        barcolor=my_colors,
        barlevs=levs,
        fig_title=figtitle,
        barinf="neither",
        ocean_mask=1,
    )
    background = Image.open(figname)
    foreground = Image.open("FUNCEME_LOGO.png")
    foreground = foreground.resize((90, 70), Image.ANTIALIAS)
    background.paste(foreground, (334, 461), foreground)
    background.save(figname, optimize=True, quality=95)

    ###########  RMSE  ###########
    error_rmse = cs.compute_rmse(hind, obs)
Пример #14
0
img22.save("img22.png", quality=23)
os.remove(figname)

figname = "ABOVE.png"
my_colors = ('#b2b2f2', '#8484f2', '#4143f2', '#0006f2')
xlabel = 'ACIMA'
levs = (40., 50., 60, 70.)
myplot(abovep[0, :, :]-1000, lat-1./2., lon-1./2., my_colors, levs, xlabel, figname, y1, y2, x1, x2)

img3 = Image.open(figname)
img33 = img3.crop((250, 455, 700, 575))
# img33.show()
img33.save("img33.png", quality=23)
os.remove(figname)

levs = (   0.,   40.,   50.,   60,    70.,
         100.,  140.,  150.,  160.,  170.,
        1000., 1040., 1050., 1060., 1070., 1100 )

my_colors = ('#ffffff', '#ffed4c', '#f9bb34', '#f75026', '#dd2b28',
             '#ffffff', '#ccf2cc', '#abf2aa', '#57f255', '#16f200',
             '#ffffff', '#b2b2f2', '#8484f2', '#4143f2', '#0006f2')

figname, figtitle = "ECHAM4p6.png", "ECHAM4.6 - OUT/2015 - OND/2015\nPROB PREC (%) (89-08)"

pm.plotmap(finalp[0, :, :], lat-1./2., lon-1./2., latsouthpoint=y1, latnorthpoint=y2,
    lonwestpoint=x1, loneastpoint=x2, fig_name=figname, barloc='right',
    barcolor=my_colors, barlevs=levs, fig_title=figtitle, barinf='neither', ocean_mask=1)

concat("img11.png", "img22.png", "img33.png", figname, "echamprob.png")
                '#ffffff', '#00ffff', '#7dd1fa', '#0080ff', '#0000ff',
                '#000075')  # Paleta
        lev1 = (-2., -1.6, -1.3, -0.8, -0.5, 0.5, 0.8, 1.3, 1.6, 2.)

        fig = plt.figure()

        figou1 = 'ESI_Regiao_SA_4WK_{0}_{1}.png'.format(mes[i], ANO)
        title1 = u'Índice de Estresse Evaporativo \n{0} - {1}'.format(
            mes[i], ANO)

        txtbox(u'Fonte: NOAA/ESSIC and USDA-ARS\nElaboração: FUNCEME', 0.46,
               0.06, 8, (1, 1, 1))

        pm.plotmap(aux_in[0, :, :],
                   lat,
                   lon,
                   latsouthpoint=y1,
                   latnorthpoint=y2,
                   lonwestpoint=x1,
                   loneastpoint=x2,
                   ocean_mask=1,
                   fig_name=figou1,
                   fig_title=title1,
                   barcolor=cor1,
                   barlevs=lev1,
                   barinf='both',
                   barloc='right')

        plt.close('all')
        plt.cla()
Пример #16
0
        lonlat = np.array(polig)

    elif isinstance(polig, MultiPolygon):

        # Cria dicionario para os multipoligonos onde a chave do dicionário
        # é o número de vérticies do polígono
        poly = {}

        for poli in polig:

            xy = np.array(poli.exterior.coords)

            poly[xy.shape[0]] = xy

        lonlat = poly[max(poly)]

    # Salvar lonlat das regiões
    # fstr = "{0}.dat".format(sigla)
    # np.savetxt(fstr, lonlat,  fmt='%15.6f', delimiter=' ', newline='\n')

    # Plotar mapas
    # pl.plot(lonlat[:, 0], lonlat[:, 1])
    # pl.title(sigla)
    # pl.show()

points_grid, lonlat_grid, array_bool = pointinsidev2(lats1, lons1, lonlat)

pm.plotmap(array_bool, lats1-0.5, lons1-0.5)


Пример #17
0
def maptercisrsm97(filein, figtitle, figout, maskocean=1):

    # TODO: Tirar leitura do netcdf e passar dados via cabeçalho da função

    ncfile = Dataset(filein)
    lat = ncfile.variables['latitude'][:]
    lon = ncfile.variables['longitude'][:]
    above = ncfile.variables['above'][:]
    normal = ncfile.variables['normal'][:]
    below = ncfile.variables['below'][:]

    belowp = np.where(((below > normal) & (below > above)), below, 0)
    normalp = np.where(((normal > above) & (normal > below)), normal+100, 0)
    abovep = np.where(((above > normal) & (above > below)), above+1000, 0)
    finalp = (belowp + normalp + abovep)

    deltalat = np.nanmean(np.diff(lat))
    deltalon = np.nanmean(np.diff(lon))

    y1, y2, x1, x2 = -21.397, 8., -55.637, -34.

    figname = "BELOW.png"
    my_colors = ('#ffed4c', '#f9bb34', '#f75026', '#dd2b28')
    xlabel = 'ABAIXO'
    levs = (40., 50., 60, 70.)
    myplot(belowp[0, :, :], lat-deltalat/2., lon-deltalon/2., my_colors,
           levs, xlabel, figname, y1, y2, x1, x2)

    img1 = Image.open(figname)
    img11 = img1.crop((110, 455, 550, 575))
    # img11.show()
    img11.save("img11.png", quality=23)
    os.remove(figname)

    figname = "NORMAL.png"
    my_colors = ('#ccf2cc', '#abf2aa', '#57f255', '#16f200')
    xlabel = 'NORMAL'
    levs = (40., 50., 60, 70.)
    myplot(normalp[0, :, :]-100, lat-deltalat/2., lon-deltalon/2.,
           my_colors, levs, xlabel, figname, y1, y2, x1, x2)

    img2 = Image.open(figname)
    img22 = img2.crop((200, 455, 610, 575))
    # img22.show()
    img22.save("img22.png", quality=23)
    os.remove(figname)

    figname = "ABOVE.png"
    my_colors = ('#b2b2f2', '#8484f2', '#4143f2', '#0006f2')
    xlabel = 'ACIMA'
    levs = (40., 50., 60, 70.)
    myplot(abovep[0, :, :]-1000, lat-deltalat/2., lon-deltalon/2.,
           my_colors, levs, xlabel, figname, y1, y2, x1, x2)

    img3 = Image.open(figname)
    img33 = img3.crop((250, 455, 700, 575))
    # img33.show()
    img33.save("img33.png", quality=23)
    os.remove(figname)

    levs = (   0.,   40.,   50.,   60,    70.,
             100.,  140.,  150.,  160.,  170.,
            1000., 1040., 1050., 1060., 1070., 1100 )

    my_colors = ('#ffffff', '#ffed4c', '#f9bb34', '#f75026', '#dd2b28',
                 '#ffffff', '#ccf2cc', '#abf2aa', '#57f255', '#16f200',
                 '#ffffff', '#b2b2f2', '#8484f2', '#4143f2', '#0006f2')

    pm.plotmap(finalp[0, :, :], lat-deltalat/2., lon-deltalon/2.,
               latsouthpoint=y1, latnorthpoint=y2, lonwestpoint=x1,
               loneastpoint=x2, fig_name=figname, barloc='right',
               barcolor=my_colors, barlevs=levs, fig_title=figtitle,
               barinf='neither', ocean_mask=maskocean,
               meridians=np.arange(-160., 161., 5.),
               parallels=np.arange(-90., 91., 5.))

    concat("img11.png", "img22.png", "img33.png", figname, figout)
Пример #18
0
        figname_anom = '{5}/bra_precip_persistida_{0}_{1}-{2}_{3}_{4}_' \
                       'echam46_1dg_null_anom.png'.format(hind_period_name,
                       target_year, target_months, fcst_year,
                       n_fcst_month, outdir)

        levs = (-700., -500., -300., -100., -50., -30.,
                  30.,   50.,  100.,  300., 500., 700.)  #12

        my_colors = ('#340003', '#ae000c', '#ff2e1b', '#ff5f26', '#ff9d37',
                     '#fbe78a', '#ffffff', '#b0f0f7', '#93d3f6', '#76bbf3',
                     '#4ba7ef', '#3498ed', '#2372c9')  #13

        pm.plotmap(anomaly_corrigida[0, :, :], newlats, newlons,
                   latsouthpoint=y1, latnorthpoint=y2, lonwestpoint=x1,
                   loneastpoint=x2,  fig_name=figname_anom, barloc='right',
                   barcolor=my_colors, barlevs=levs, fig_title=figtitle,
                   barinf='both', ocean_mask=1)

        background = Image.open(figname_anom)
        foreground = Image.open("FUNCEME_LOGO.png")
        foreground = foreground.resize((90, 70), Image.ANTIALIAS)
        background.paste(foreground, (334, 461), foreground)
        background.save(figname_anom, optimize=True, quality=95)

        ###  Tercil mais provável para toda a região do globo  ###
        file_out = "{5}/prob_echam46_issue_{0}{1}_target_{2}{3}_{4}.nc" \
                   .format(fcst_month, fcst_year, target_months, target_year,
                   hind_period, outdir)

        # below, normal, above, f_signal, f_std, o_pad, fcst_sig_anom = \
Пример #19
0
    print " === OUTPUT DIR: {0} ===\n".format(outdir)

    # Limites do mapa para fazer o plot
    # y1, y2, x1, x2 = -40., 40., -150., 70.  # Globo
    # y1, y2, x1, x2 = -89., 89., -178., 178.  # Globo
    y1, y2, x1, x2 = -60., 15., -90., -30.  # América do sul

    ##########  Apenas um plot  ##########
    lev = [0., 50., 100., 200., 300., 500., 700., 900., 1000.]
    my_colors = ('#ffffff', '#E5E5E5', '#CBCBCB', '#B2B2B2',
                 '#989898', '#7F7F7F', '#666666', '#4E4E4E') #8
    figtitle = u'ECHAM4.6 - Precip Acum (mm)'
    figname = "{5}/bra_precip_persistida_{0}_{1}-{2}_{3}_{4}_echam46_1dg_null_precip_median.png" \
              .format(hind_period_name, target_year, target_months, fcst_year, n_fcst_month, outdir)
    pm.plotmap(fcst[0, :, :], newlats-1./2., newlons-1./2., latsouthpoint=-88., latnorthpoint=88.,
               lonwestpoint=-178., loneastpoint=178., fig_name=figname, fig_title=figtitle,
               barcolor=my_colors, ocean_mask=0, barlevs=lev, barinf='max',
               barloc='bottom', meridians=np.arange(-160., 161., 30.), parallels=np.arange(-90., 91., 20.))

    ##########  Anomalia corrigida metódo do Caio (regressão linear)  ##########
    below, normal, above, f_signal, f_std, o_pad, fcst_sig_anom = cs.compute_probability(fcst, hind, obs, n_years)
    hind_corrigido = cs.compute_setrighthind(hind, obs, n_years)
    anomaly_corrigida, anomaly_pad = cs.compute_anomaly(fcst_sig_anom, hind_corrigido)
    #~ figtitle = u'ECHAM4.6 x CMAP - OCT/{4} - {1}/{4}\nAnomaly (mm) - Precip Accum ({2})'\
    figtitle = u'ECHAM4.6 x CMAP - {0}/{3} - {1}/{4}\nAnomalia (mm) - Precip Acum ({2})'\
               .format(fcst_month_name, target_months, hind_period_name, fcst_year, target_year)
    figname_anom = "{5}/bra_precip_persistida_{0}_{1}-{2}_{3}_{4}_echam46_1dg_null_anom_median.png" \
              .format(hind_period_name, target_year, target_months, fcst_year, n_fcst_month, outdir)
    levs = (-700., -500., -300., -100., -50., -30., 30.,   50.,  100.,  300., 500., 700.) #12
    my_colors = ('#340003', '#ae000c', '#ff2e1b', '#ff5f26', '#ff9d37', '#fbe78a',
                 '#ffffff', '#b0f0f7', '#93d3f6', '#76bbf3', '#4ba7ef', '#3498ed', '#2372c9') #13
    pm.plotmap(anomaly_corrigida[0, :, :], newlats-1./2., newlons-1./2., latsouthpoint=y1, latnorthpoint=y2,
Пример #20
0
        figtitle = "RSM97 - Precip Acum (mm)"

        figname = "{5}/neb_precip_persistida_{0}_{1}-{2}_{3}_{4}_" "rsm97_1dg_null_precip.png".format(
            hind_period_name, target_year, target_months, fcst_year, fcst_months[fcst_month], outdir
        )

        pm.plotmap(
            fcst[0, :, :],
            fcst_lats,
            fcst_lons,
            latsouthpoint=y1,
            latnorthpoint=y2,
            lonwestpoint=x1,
            loneastpoint=x2,
            fig_name=figname,
            fig_title=figtitle,
            barcolor=my_colors,
            ocean_mask=0,
            barlevs=lev,
            barinf="max",
            barloc="bottom",
            meridians=np.arange(-160.0, 161.0, 2.0),
            parallels=np.arange(-90.0, 91.0, 2.0),
        )

        if obs_base == "inmet" or obs_base == "chirps" or obs_base == "cru":

            ###   Anomalia corrigida: metódo do Caio (regressão linear)   ###
            below, normal, above, f_signal, f_std, o_pad, fcst_sig_anom = cs.compute_probability(fcst, hind, obs)

            hind_corrigido = cs.compute_setrighthind(hind, obs)