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
26 '200_wind': {
'lev':
'200',
'pvar':
'wind',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
27 '200_temp': {
'lev':
'200',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
28 '500_hgt': {
'lev':
'500',
'pvar':
'gh',
'barbs':
True,
'hgt':
True,
'vc':
'isobaricInhPa'},
29 '500_temp': {
'lev':
'500',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
30 '500_vort': {
'lev':
'500',
'pvar':
'absv',
'barbs':
False,
'hgt':
False,
'vc':
'isobaricInhPa'},
31 '700_temp': {
'lev':
'700',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
32 '700_vvel': {
'lev':
'700',
'pvar':
'w',
'barbs':
False,
'hgt':
False,
'vc':
'isobaricInhPa'},
33 '850_hgt': {
'lev':
'850',
'pvar':
'gh',
'barbs':
True,
'hgt':
True,
'vc':
'isobaricInhPa'},
34 '850_temp': {
'lev':
'850',
'pvar':
't',
'barbs':
True,
'hgt':
False,
'vc':
'isobaricInhPa'},
35 '850_rh': {
'lev':
'850',
'pvar':
'r', 'barbs': True, 'hgt': False, 'vc': 'isobaricInhPa'},
36 '2m_tmp': {
'lev':
'2',
'pvar':
'2t',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
37 '2m_dpt': {
'lev':
'2',
'pvar':
'2d',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
38 '10m_u': {
'lev':
'10',
'pvar':
'10u',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
39 '10m_v': {
'lev':
'10',
'pvar':
'10v',
'barbs':
False,
'hgt':
False,
'vc':
'heightAboveGround'},
40 '10m_wind': {
'lev':
'10',
'pvar':
'10wind',
'barbs':
True,
'hgt':
False,
'vc':
'heightAboveGround'},
41 'prmsl': {
'lev':
'0',
'pvar':
'prmsl',
'pline':
True,
'barbs':
True,
'hgt':
False,
'vc':
'meanSea'},
42 'pwat': {
'lev':
'0',
'pvar':
'pwat',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'unknown'},
43 'prate': {
'lev':
'0',
'pvar':
'prate',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
44 'cprat': {
'lev':
'0',
'pvar':
'cprat',
'pline':
False,
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
45 '6h_acpcp': {
'lev':
'0',
'pvar':
'acpcp',
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True},
46 '6h_apcp': {
'lev':
'0',
'pvar':
'tp',
'barbs':
False,
'hgt':
False,
'vc':
'surface',
'acc_field':
True}
56 moad_dataroot=os.getenv(
'MOAD_DATAROOT')
57 rotdir=os.getenv(
'ROTDIR')
58 date=os.getenv(
'START_TIME')
59 fhr=os.getenv(
'FCST_TIME')
60 grid_list=os.getenv(
'GRID_VX_LIST')
61 vx_grid=grid_list.split(
" ")
62 filename=
''.join([
'pgrbq', fhr,
'.gfs.', date,
'.grib2'])
63 gribin=
'/'.join([rotdir, filename])
64 user_def = os.getenv(
'USER_MAPS',
False)
67 outdir=
'/'.join([moad_dataroot,
'figprd'])
76 wind_rot = {
'G104':
'grid',
'G218':
'grid',
'G3':
'grid'}
80 newgrib =
''.join([
'pgrbq', fhr,
'.gfs.', date,
'_', grid,
'.grib2'])
81 newgrib =
'/'.join([outdir,newgrib])
82 if not os.path.exists(outdir):
96 plevels=[ 850, 700, 500, 200 ]
97 coord = [
"isobaricInhPa",
"isobaricInhPa",
"isobaricInhPa",
"isobaricInhPa" ]
102 for level
in plevels:
104 if plot_wind
and var ==
'wind':
105 u = ggf.get_ua_field(grib,level,coord,shortName=
'u') 106 v = ggf.get_ua_field(grib,level,coord,shortName='v')
108 elif plot_wind
and var ==
'10wind':
109 u = ggf.get_ua_field(grib,level,coord,shortName=
'10u')
110 v = ggf.get_ua_field(grib,level,coord,shortName=
'10v')
118 field=ggf.get_ua_field(grib,level,coord,shortname=var)
124 winds=winds, fhr=fhr)
127 mymap.save_figure(outdir)
133 acc_field=def_maps[fig].get(
'acc_field',
False)
134 if (acc_field
and fhr !=
'000')
or (
not acc_field):
135 level = def_maps[fig].get(
'lev')
136 var = def_maps[fig].get(
'pvar')
137 hgt = def_maps[fig].get(
'hgt')
138 plot_wind = def_maps[fig].get(
'barbs',
False)
139 plot_line = def_maps[fig].get(
'pline',
False)
140 coord = def_maps[fig].get(
'vc')
144 if plot_wind
and var ==
'wind':
145 u = ggf.get_ua_field(grib,level,coord,shortName=
'u') 146 v = ggf.get_ua_field(grib,level,coord,shortName='v')
148 elif plot_wind
and var ==
'10wind':
149 u = ggf.get_ua_field(grib,level,coord,shortName=
'10u')
150 v = ggf.get_ua_field(grib,level,coord,shortName=
'10v')
157 height = ggf.get_ua_field(grib,level,coord,shortName=
'gh')
160 if var !=
'wind' and var !=
'10wind':
161 field=ggf.get_ua_field(grib,level,coord,shortName=var)
163 winds=winds, plot_height=height,def_maps=def_maps)
166 mymap.save_figure(outdir)
170 spd=gsf.get_spd_field(grib,level,coord,outdir,outmap,fhr,var)
def set_def_maps()
This function sets up a variable table to plot (map_confs) using key/value pairs. ...