1 | from viz.utils import peek |
---|
2 | from viz.utils import cardinal_2_month |
---|
3 | import pylab as p |
---|
4 | import matplotlib.numerix.ma as ma |
---|
5 | import numpy as n |
---|
6 | from string import zfill |
---|
7 | |
---|
8 | def plot_soilw_from_gfs(file_name, cntr_lvl=None): |
---|
9 | file, vars = peek(file_name, show_vars=False) |
---|
10 | lon = vars['lon_3'].get_value() |
---|
11 | lat = vars['lat_3'].get_value() |
---|
12 | soilw_var = vars['SOILW_3_DBLY_10'] |
---|
13 | soilw = soilw_var.get_value() |
---|
14 | soilw_m = ma.masked_where(soilw == soilw_var._FillValue, soilw) |
---|
15 | for lvl_idx in range(len(soilw)): |
---|
16 | p.figure() |
---|
17 | if cntr_lvl is not None: |
---|
18 | p.contourf(lon,lat,soilw_m[lvl_idx],cntr_lvl) |
---|
19 | else: |
---|
20 | p.contourf(lon,lat,soilw_m[lvl_idx]) |
---|
21 | p.colorbar() |
---|
22 | # flip the y-axis |
---|
23 | p.ylim((lat[-1], lat[0])) |
---|
24 | p.ylabel('degrees North') |
---|
25 | p.xlabel('degrees East') |
---|
26 | lvl_bounds = vars['lv_DBLY5_l' + str(lvl_idx)] |
---|
27 | valid_when = soilw_var.initial_time |
---|
28 | valid_when = valid_when[3:5] + ' ' \ |
---|
29 | + cardinal_2_month(int(valid_when[:2])) + ' ' + valid_when[6:10] \ |
---|
30 | + ' ' + valid_when[12:17] + ' UTC' |
---|
31 | title_string = 'Volumetric soil moisture (fraction) valid at ' \ |
---|
32 | + '\n' + valid_when + ' ' \ |
---|
33 | + str(lvl_bounds[0]) + '-' + str(lvl_bounds[1]) + ' cm from GFS' |
---|
34 | p.title(title_string) |
---|
35 | return |
---|
36 | |
---|
37 | def plot_soilt_from_gfs(file_name, cntr_lvl=None): |
---|
38 | file, vars = peek(file_name, show_vars=False) |
---|
39 | lon = vars['lon_3'].get_value() |
---|
40 | lat = vars['lat_3'].get_value() |
---|
41 | soilt_var = vars['TMP_3_DBLY_10'] |
---|
42 | soilt = soilt_var.get_value() |
---|
43 | soilt_m = ma.masked_where(soilt == soilt_var._FillValue, soilt) |
---|
44 | for lvl_idx in range(len(soilt)): |
---|
45 | p.figure() |
---|
46 | if cntr_lvl is not None: |
---|
47 | p.contourf(lon,lat,soilt_m[lvl_idx],cntr_lvl) |
---|
48 | else: |
---|
49 | p.contourf(lon,lat,soilt_m[lvl_idx]) |
---|
50 | p.colorbar() |
---|
51 | # flip the y-axis |
---|
52 | p.ylim((lat[-1], lat[0])) |
---|
53 | p.ylabel('degrees North') |
---|
54 | p.xlabel('degrees East') |
---|
55 | lvl_bounds = vars['lv_DBLY5_l' + str(lvl_idx)] |
---|
56 | valid_when = soilt_var.initial_time |
---|
57 | valid_when = valid_when[3:5] + ' ' \ |
---|
58 | + cardinal_2_month(int(valid_when[:2])) + ' ' + valid_when[6:10] \ |
---|
59 | + ' ' + valid_when[12:17] + ' UTC' |
---|
60 | title_string = 'Soil temperature (K) valid at ' \ |
---|
61 | + '\n' + valid_when + ' ' \ |
---|
62 | + str(lvl_bounds[0]) + '-' + str(lvl_bounds[1]) + ' cm from GFS' |
---|
63 | p.title(title_string) |
---|
64 | return |
---|
65 | |
---|
66 | # plot_temp_from_gfs |
---|
67 | # plot_wind_from_gfs |
---|
68 | # plot_mr_from_gfs |
---|
69 | # plot_ght_from_gfs |
---|
70 | # plot_sfc_temp_from_gfs |
---|
71 | # plot_sfc_wind_from_gfs |
---|
72 | # plot_sfc_mr_from_gfs |
---|
73 | # plot_mslp_from_gfs |
---|
74 | # plot_sfc_press_from_gfs |
---|
75 | # plot_land_from_gfs |
---|
76 | # plot_terrain_from_gfs |
---|
77 | # plot_skin_temp_from_gfs |
---|