MCPcopy Create free account
hub / github.com/NCAR/wrf-python / make_result_file

Function make_result_file

test/ci_tests/make_test_file.py:90–160  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

88
89
90def make_result_file(opts):
91 infilename = os.path.expanduser(
92 os.path.join(opts.outdir, "ci_test_file.nc"))
93 outfilename = os.path.expanduser(
94 os.path.join(opts.outdir, "ci_result_file.nc"))
95
96 with Dataset(infilename) as infile, Dataset(outfilename, "w") as outfile:
97
98 for varname in WRF_DIAGS:
99 var = getvar(infile, varname)
100 add_to_ncfile(outfile, var, varname)
101
102 for interptype in INTERP_METHS:
103 if interptype == "interpline":
104 hts = getvar(infile, "z")
105 p = getvar(infile, "pressure")
106 hts_850 = interplevel(hts, p, 850.)
107
108 add_to_ncfile(outfile, hts_850, "interplevel")
109
110 if interptype == "vertcross":
111
112 hts = getvar(infile, "z")
113 p = getvar(infile, "pressure")
114
115 pivot_point = CoordPair(hts.shape[-1] // 2, hts.shape[-2] // 2)
116 ht_cross = vertcross(hts, p, pivot_point=pivot_point,
117 angle=90.)
118
119 add_to_ncfile(outfile, ht_cross, "vertcross")
120
121 if interptype == "interpline":
122
123 t2 = getvar(infile, "T2")
124 pivot_point = CoordPair(t2.shape[-1] // 2, t2.shape[-2] // 2)
125
126 t2_line = interpline(t2, pivot_point=pivot_point, angle=90.0)
127
128 add_to_ncfile(outfile, t2_line, "interpline")
129
130 if interptype == "vinterp":
131
132 tk = getvar(infile, "temp", units="k")
133
134 interp_levels = [200, 300, 500, 1000]
135
136 field = vinterp(infile,
137 field=tk,
138 vert_coord="theta",
139 interp_levels=interp_levels,
140 extrapolate=True,
141 field_type="tk",
142 log_p=True)
143
144 add_to_ncfile(outfile, field, "vinterp")
145
146 for latlonmeth in LATLON_METHS:
147 if latlonmeth == "xy":

Callers 1

mainFunction · 0.85

Calls 9

getvarFunction · 0.90
interplevelFunction · 0.90
CoordPairClass · 0.90
vertcrossFunction · 0.90
interplineFunction · 0.90
vinterpFunction · 0.90
ll_to_xyFunction · 0.90
xy_to_llFunction · 0.90
add_to_ncfileFunction · 0.85

Tested by

no test coverage detected