Skip to content

Commit

Permalink
Feature 385 stratosphere qbo (#387)
Browse files Browse the repository at this point in the history
* Fixed bug in zonal mean code

* Updates to write_mpr

* Updating documentation for write_mpr
  • Loading branch information
CPKalb authored Jun 28, 2024
1 parent d7631db commit 7201e39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/Users_Guide/write_mpr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Example
Examples for how to use this script can be found in the driver scripts of the use cases
listed below.

* `Stratosphere Polar <https://metplus.readthedocs.io/en/latest/generated/model_applications/s2s/UserScript_fcstGFS_obsERA_StratospherePolar.html#sphx-glr-generated-model-applications-s2s-userscript-fcstgfs-obsera-stratospherepolar-py>`_
* `Blocking <https://metplus.readthedocs.io/en/latest/generated/model_applications/s2s_mid_lat/UserScript_fcstGFS_obsERA_Blocking.html#sphx-glr-generated-model-applications-s2s-mid-lat-userscript-fcstgfs-obsera-blocking-py>`_
* `Weather Regime <https://metplus.readthedocs.io/en/latest/generated/model_applications/s2s_mid_lat/UserScript_fcstGFS_obsERA_WeatherRegime.html#sphx-glr-generated-model-applications-s2s-mid-lat-userscript-fcstgfs-obsera-weatherregime-py>`_
* `Stratosphere Polar <https://metplus.readthedocs.io/en/latest/generated/model_applications/s2s/UserScript_fcstGFS_obsERA_StratospherePolar.html#sphx-glr-generated-model-applications-s2s-userscript-fcstgfs-obsera-stratospherepolar-py>`_
* `Stratosphere QBO <https://metplus.readthedocs.io/en/latest/generated/model_applications/s2s/UserScript_fcstGFS_obsERA_StratosphereQBO.html#sphx-glr-generated-model-applications-s2s-userscript-fcstgfs-obsera-stratosphereqbo-py>`_

Information about Input Data
============================
Expand Down Expand Up @@ -52,7 +53,7 @@ INTERP_PNTS = 1, and OBTYPE = ADPUPA.
observation valid time
mod_name: string
output model name (the MODEL column in MET)
desc: string
desc: 1D array string
output description (the DESC column in MET)
fcst_var: 1D array string
forecast variable name
Expand Down
4 changes: 2 additions & 2 deletions metcalcpy/pre_processing/directional_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ def meridional_mean(dat, lat1, lat2, dimvar='latitude'):
elif lat1 == lat2:
raise ValueError('lat1 is equal to lat2, but it must be less than lat2')

wgts = np.cos(np.deg2rad(dat[dimvar].where((dat[dimvar] >= 60) & (dat[dimvar] <= 90),drop=True)))
wgts = np.cos(np.deg2rad(dat[dimvar].where((dat[dimvar] >= lat1) & (dat[dimvar] <= lat2),drop=True)))

return dat.where((dat[dimvar] >= 60) & (dat[dimvar] <= 90),drop=True).weighted(wgts).mean(dimvar)
return dat.where((dat[dimvar] >= lat1) & (dat[dimvar] <= lat2),drop=True).weighted(wgts).mean(dimvar)
6 changes: 3 additions & 3 deletions metcalcpy/util/write_mpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def write_mpr_file(data_fcst,data_obs,lats_in,lons_in,fcst_lead,fcst_valid,obs_l
observation valid time
mod_name: string
output model name (the MODEL column in MET)
desc: string
desc: 1D array string
output description (the DESC column in MET)
fcst_var: 1D array string
forecast variable name
Expand Down Expand Up @@ -69,7 +69,7 @@ def write_mpr_file(data_fcst,data_obs,lats_in,lons_in,fcst_lead,fcst_valid,obs_l
Get the length of the model, FCST_VAR, FCST_LEV, OBS_VAR, OBS_LEV, VX_MASK, etc for formatting
"""
mname_len = str(max([5,len(mod_name)])+3)
desc_len = str(max([4,len(desc)])+3)
desc_len = str(max([4,max([len(l) for l in desc])])+3)
mask_len = str(max([7,len(maskname)])+3)
fvar_len = str(max([8,max([len(l) for l in fcst_var])])+3)
funit_len = str(max([8,max([len(l) for l in fcst_unit])])+3)
Expand Down Expand Up @@ -114,7 +114,7 @@ def write_mpr_file(data_fcst,data_obs,lats_in,lons_in,fcst_lead,fcst_valid,obs_l
'OBS_THRESH', 'COV_THRESH', 'ALPHA', 'LINE_TYPE'))
for dpt in range(dlength):
# Write the data
mf.write(format_string2 % ('V9.1',mod_name,desc,fcst_lead[dpt],fcst_valid[dpt],fcst_valid[dpt],
mf.write(format_string2 % ('V9.1',mod_name,desc[dpt],fcst_lead[dpt],fcst_valid[dpt],fcst_valid[dpt],
obs_lead[dpt],obs_valid[dpt],obs_valid[dpt],fcst_var[dpt],fcst_unit[dpt],fcst_lev[dpt],
obs_var[dpt],obs_unit[dpt],obs_lev[dpt],'ADPUPA',maskname,'NEAREST','1','NA','NA','NA','NA','MPR',
str(dlength),str(index_num[dpt]),'NA',lats_in[dpt],lons_in[dpt],obsslev[dpt],'NA',data_fcst[dpt],
Expand Down

0 comments on commit 7201e39

Please sign in to comment.