4 import matplotlib
as mpl
7 from mpl_toolkits.basemap
import Basemap
9 import matplotlib.pyplot
as plt
13 import get_grib_field
as ggf
14 import get_spd_field
as gsf
27 '200_wind': {
'lev':
'200',
'pvar':
'wind',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
28 '200_temp': {
'lev':
'200',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
29 '500_hgt': {
'lev':
'500',
'pvar':
'gh',
'barbs':
True,
'hgt':
True,
'vc':
'isobaricInhPa'},
30 '500_temp': {
'lev':
'500',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
31 '500_vort': {
'lev':
'500',
'pvar':
'absv',
'barbs':
False,
'hgt':
False,
'vc':
'isobaricInhPa'},
32 '700_temp': {
'lev':
'700',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
33 '700_vvel': {
'lev':
'700',
'pvar':
'w',
'barbs':
False,
'hgt':
False,
'vc':
'isobaricInhPa'},
34 '850_hgt': {
'lev':
'850',
'pvar':
'gh',
'barbs':
True,
'hgt':
True,
'vc':
'isobaricInhPa'},
35 '850_temp': {
'lev':
'850',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
36 '850_rh': {
'lev':
'850',
'pvar':
'r', 'barbs': True, 'hgt': False, 'vc': 'isobaricInhPa'},
37 '2m_tmp': {
'lev':
'2',
'pvar':
'2t',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
38 '2m_dpt': {
'lev':
'2',
'pvar':
'2d',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
39 '10m_u': {
'lev':
'10',
'pvar':
'10u',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
40 '10m_v': {
'lev':
'10',
'pvar':
'10v',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
41 '10m_wind': {
'lev':
'10',
'pvar':
'10wind',
'barbs':
True,
'hgt':
False,
'vc':
'heightAboveGround'},
42 'prmsl': {
'lev':
'0',
'pvar':
'prmsl',
'pline':
True,
'barbs':
True,
'hgt':
False,
'vc':
'meanSea'},
43 'pwat': {
'lev':
'0',
'pvar':
'pwat',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'unknown'},
44 'prate': {
'lev':
'0',
'pvar':
'prate',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
45 'cprat': {
'lev':
'0',
'pvar':
'cprat',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
46 '6h_acpcp': {
'lev':
'0',
'pvar':
'acpcp',
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
47 '6h_apcp': {
'lev':
'0',
'pvar':
'tp',
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True}
57 moad_dataroot=os.getenv(
'MOAD_DATAROOT')
58 rotdir=os.getenv(
'ROTDIR')
59 date=os.getenv(
'START_TIME')
60 fhr=os.getenv(
'FCST_TIME')
61 grid_list=os.getenv(
'GRID_VX_LIST')
62 vx_grid=grid_list.split(
" ")
63 filename=
''.join([
'pgrbq', fhr,
'.gfs.', date,
'.grib2'])
64 gribin=
'/'.join([rotdir, filename])
65 user_def = os.getenv(
'USER_MAPS',
False)
68 outdir=
'/'.join([moad_dataroot,
'figprd'])
77 wind_rot = {
'G104':
'grid',
'G218':
'grid',
'G3':
'grid'}
81 newgrib =
''.join([
'pgrbq', fhr,
'.gfs.', date,
'_', grid,
'.grib2'])
82 newgrib =
'/'.join([outdir,newgrib])
83 if not os.path.exists(outdir):
97 plevels=[ 850, 700, 500, 200 ]
98 coord = [
"isobaricInhPa",
"isobaricInhPa",
"isobaricInhPa",
"isobaricInhPa" ]
103 for level
in plevels:
105 if plot_wind
and var ==
'wind':
106 u = ggf.get_ua_field(grib,level,coord,shortName=
'u')
107 v = ggf.get_ua_field(grib,level,coord,shortName='v')
109 elif plot_wind
and var ==
'10wind':
110 u = ggf.get_ua_field(grib,level,coord,shortName=
'10u')
111 v = ggf.get_ua_field(grib,level,coord,shortName=
'10v')
119 field=ggf.get_ua_field(grib,level,coord,shortname=var)
125 winds=winds, fhr=fhr)
128 mymap.save_figure(outdir)
134 acc_field=def_maps[fig].get(
'acc_field',
False)
135 if (acc_field
and fhr !=
'000')
or (
not acc_field):
136 level = def_maps[fig].get(
'lev')
137 var = def_maps[fig].get(
'pvar')
138 hgt = def_maps[fig].get(
'hgt')
139 plot_wind = def_maps[fig].get(
'barbs',
False)
140 plot_line = def_maps[fig].get(
'pline',
False)
141 coord = def_maps[fig].get(
'vc')
145 if plot_wind
and var ==
'wind':
146 u = ggf.get_ua_field(grib,level,coord,shortName=
'u')
147 v = ggf.get_ua_field(grib,level,coord,shortName='v')
149 elif plot_wind
and var ==
'10wind':
150 u = ggf.get_ua_field(grib,level,coord,shortName=
'10u')
151 v = ggf.get_ua_field(grib,level,coord,shortName=
'10v')
158 height = ggf.get_ua_field(grib,level,coord,shortName=
'gh')
161 if var !=
'wind' and var !=
'10wind':
162 field=ggf.get_ua_field(grib,level,coord,shortName=var)
164 winds=winds, plot_height=height,def_maps=def_maps)
167 mymap.save_figure(outdir)
171 spd=gsf.get_spd_field(grib,level,coord,outdir,outmap,fhr,var)
def set_def_maps()
This function defines a variable table to plot.