Skip to content

Commit

Permalink
Update develop-ref after PR #1354 (#1367)
Browse files Browse the repository at this point in the history
* Feature 1091 extent cycloneplotter (#1218)

* Github #1091 add support to define plot's extent

* Github #1091 Add support for defining plot's extent

* Github #1091 add support for defining plot extent

* GitHub #1091 Provide support to define plotting a bounding box of interest and replace deprecated cartopy attributes.

* Github Issue #1091 Add configuration support to define the bounding box defining the area of interest to plot.

* Github Issue #1091 provide support to define bounding box defining the area of interest to plot.

* Github Issue #1091 Removed unused shapely imports

* GItHub Issue #1091 

Removed duplicate CYCLONE_PLOTTER_GLOBAL_PLOT

* Github #1091 Include config settings needed to indicate the region of interest to be plotted.

* Github Issue #1091 Keep only the North Hemisphere lon and lats in the config file to serve as example for plotting a specific area of the map.

* convert file back to unix format via dos2unix and added change that was lost in merge

* return None from function instead of exiting so that METplus clean up functionality will still run

* fixed indentation

* fixed indentation - for loop should not be nested inside other for loop

* fixed check for failure in retrieve_data function

* feature 1223 error if file not found (#1238)

* feature 1252 allow dictionary value for time_summary.width (#1253)

* feature 1213 obs_quality_inc/exc (#1260)

* Feature 1203 ioda2nc (#1262)

* Add default title for the new use case issue template.

* Feature 1019 harmonic preprocessing (#1272)

Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>

* Feature 1266 gen ens prod missing ensembles (#1275)

* Feature 1049 statistics list (#1271)

* first attempt at a table #1049

* 2nd attempt, smaller, different formatting table #1049

* trying to get rid of git error message by adding this to the index #1049

* alignment #1049

* trying to text wrap in a table #1049

* attempting to create text wrapping in tables #1049

* removing role, trying to wrap text #1049

* removing html break, trying to wrap text #1049

* adding code to wrap text #1049

* removing code to wrap text #1049

* fixing naming typo #1049

* hitting returns in table #1049

* removing typo file, removing line breaks #1049

* attempting a simple table for text wrapping #1049

* attempting to bold header row in simple table #1049

* simple table line break attempt #1049

* simple table line break attempt #2 #1049

* simple table line break attempt #3 #1049

* trying another | #1049

* 2 trying another | #1049

* 3 trying another | #1049

* trying a blank line #1049

* trying reformating grid #1049

* 2 trying reformating grid #1049

* 3 trying reformating grid #1049

* 4 trying reformating grid #1049

* adding in one more table row #1049

* adding more text #1049

* trying glossary format #1049

* 2 trying glossary format #1049

* 3 trying glossary format #1049

* 4 trying glossary format #1049

* adding glossary format 2D objects #1049

* fixing glossary format 2D objects #1049

* adding glossary items #1049

* fixing glossary format #1049

* hopefully all examples are working #1049

* changing reference to tool

* removing 2D object examples

* removing the unwrapped table

* adding ACC into the example

* fixing formatting #1049

* fixing formatting take 2 #1049

* fixing formatting take 3 #1049

* bolding and language change #1049

* fixing spacing #1049

* fixing spacing again #1049

* changing title #1049

* trying superscript #1049

* superscript glossary #1049

* removing quotes #1049

* fixing spacing #1049

* Tara has decided to go with the glossary format.  Removing table example. #1049

* Adding 2D objects #1049

* 2D objects fix #1049

* 2D objects fix attempt 2 #1049

* 2D objects fix attempt 3 #1049

* 2D objects fix attempt 4 #1049

* 2D objects fix attempt 5 #1049

* 2D objects fix attempt 7 #1049

* 2D objects fix attempt 8 #1049

* ABR added #1049

* adding remaining AB items to list #1049

* adding remaining ACC_ items to list #1049

* ADLAND & AFSS entries #1049

* A entries #1049

* fixing formatting #1049

* fixing formatting #2 #1049

* removing new entries to make it run #1049

* adding a couple back in #1049

* adding a couple more back in #1049

* tool key at the bottom #1049

* spacing changes #1049

* spacing changes another try #1049

* fixing spacing #1049

* fixing spacing attempt 2 #1049

* fixing spacing attempt 3 #1049

* through AREA items #1049

* AMODEL listed twice but it's not #1049

* AMODEL listed twice but it's not #2 #1049

* AMODEL added question marks so it will run #1049

* final A entries #1049

* naming the glossary statistics in hopes of not conflicting with original glossary #1049

* removing glossary statistics space #1049

* Testing multiple glossary names

* Per #1067, working on attempts to have multiple glossaries with the same term

* Per #1067, working on attempts to have multiple glossaries with the same term

* Per #1067, working on attempts to have multiple glossaries with the same term

* Per #1067, removing code with attempts at mutiple glossaries

* Per #1067, adding back three question marks due to duplicate term

* paring down list, adding a table for review

* problems with table

* still trying to get it to publish

* still trying to get a second line in the table

* still trying to get a second line in the table 2

* testing different formatting

* testing different formatting

* trying to comment out the glossary inner workings

* formatting again

* line breaks in table #1049

* adding in some more for an example #1049

* adding new entries in through AREA #1049

* fixing line breaks #1049

* fixing line breaks #1049 #2

* fixing line breaks and warning messages #1049

* fixing line breaks #1049

* adding AREA_RATIO through ASPECT_DIFF

* fixing typo #1049

* fixing typo #1049

* fixing typo #1049 take 2

* adding AXIS_ANG to BCMSE #1049

* adding spacing #1049

* adding spacing removing commas #1049

* removing comma #1049

* BOUNDARY_DIST thru BSS_SMPL #1049

* BOUNDARY_DIST splitting across 2 lines #1049

* cleaning up typos #1049

* calibration thru centriod_dist #1049

* centriod_lat thru centroid_y #1049

* fixing spacing #1049

* removing test glossary #1049

* climo_mean thru crtk_err #1049

* fixing crtk_err spacing #1049

* fixing spacing #1049

* CSI to CURVATURE_Y #1049

* CURVATURE_X & Y spacing #1049

* DEV_CAT to DURATION_DIFF #1049

* EC_VALUE to F #1049

* F_RATE TO FBS #1049

* Fixing spacing #1049

* fcst_clus thru fcst_conv_radius #1049

* removing CTOP_PRS #1049

* fixing the order of tools for FBAR and FBIAS #1049

* fixing spacing #1049

* adding grid-stat to all point-stat entries #1049

* adding fixing spacing #1049

* adding fixing spacing take 2  #1049

* adding fixing spacing take 3  #1049

* adding fixing spacing take 4  #1049

* adding fixing spacing take 5  #1049

* adding fixing spacing take 6  #1049

* adding fixing spacing take 7  #1049

* fixing spacing with a period take 7  #1049

* first attempt fcst_  #1049

* fixing typos #1049

* thru FOBAR #1049

* thru end of F #1049

* g thru h #1049

* i thru intensity #s #1049

* fixing typos #1049

* capturing example for Julie #1049

* thru k #1049

* fixing typos #1049

* thru L #1049

* thru MG #1049

* thru N_ENS #1049

* thru all N #1049

* fixing FBIAS alignment #1049

* fixing ME and MSE alignment #1049

* fixing ME alignment take 2 #1049

* thru OBS_E #1049

* fixing alignment #1049

* fixing alignment n_thresh #1049

* thru OBS_thresh #1049

* thru O #1049

* fixing OOBAR formating #1049

* thru PR_CORR #1049

* commented lines out with line total info #1049

* commented lines out with line total info take 2 #1049

* thru R #1049

* thru SPEED #1049

* thru S #1049

* thru T #1049

* thru U #1049

* thru V #1049

* thru V #1049

* thru Z #1049

* Update statistics_list.rst

Tara is testing editing in UI

* Update statistics_list.rst

Updates through the A's

* Update statistics_list.rst

Cleaning up the A's

* Update statistics_list.rst

Standardizing MODE and MTD entries

* Update statistics_list.rst

Updating B's and C's

* Update statistics_list.rst

Testing adding TC-Stat and TCST to an entry

* Update statistics_list.rst

Clean up of a few A-Cs and then update of Ds

* Update statistics_list.rst

A few clean-ups and Es

* Update statistics_list.rst

Halfway through Fs...

* Update statistics_list.rst

A little clean up and the rest of Fs

* Update statistics_list.rst

G, H, I, Ks

* Update statistics_list.rst

L, M, Ns

* Update statistics_list.rst

A little clean-up and Os

* Update statistics_list.rst

A little clean-up and Os

* Update statistics_list.rst

Rs

* Update statistics_list.rst

S and Ts

* Update statistics_list.rst

The rest of the list

* Update statistics_list.rst

Removed Attr from Stat Type thru E

* Update statistics_list.rst

Remove Attr from Statistics Type through Gs

* Update statistics_list.rst

Remove Attr from Statistic Type through Rs

* Update statistics_list.rst

Remove Attr from Stat Type to the end

* Update statistics_list.rst

Cleaned up some Line Type typos

* Update statistics_list.rst

Still more Attr cleanup

Co-authored-by: Julie Prestopnik <jpresto@seneca.rap.ucar.edu>
Co-authored-by: TaraJensen <jensen@ucar.edu>

* Feature 1263 v4.1.0 beta4 (#1277)

* update version to note development towards beta5

* Feature 934 release stage doc (#1235)

* Per #934 add stages of the METplus release cycle.

* Per #934, adding link to descriptions of the release cycle in the User's Guide.

* Per #934, made corrections

* Per #934, changed Beta and Release Candidate (rc) from bold to subsubsections.

* Update index.rst

Co-authored-by: Julie Prestopnik <jpresto@seneca.rap.ucar.edu>

* Feature 344 met util refactor (#1292)

* removed deprecated sections from config examples

* minor change to METplus release guide to add a link to the PDF of the User's Guide instead of downloading it and attaching it to the release

* Feature 1285 extract tiles mtd times (#1315)

* Feature 896 more met config (#1322)

* removed incorrect search keyword

* added workflow_dispatch event so workflow can be triggered by an external repository such as MET to test to ensure that changes from that repo will break anything in METplus

* added another input argument for workflow_dispatch event

* added job with name that shows the event name or the repository name if triggered by an external repository such as MET

* GHA: add username that triggered external event to event info job name

* added required input argument for external trigger that contains the commit hash of the push event that triggered in the other repo

* change event info to show commit hash instead of username that merged the PR

* changed input names to match names of event in repository that triggered workflow

* feature 1320 OMP_NUM_THREADS (#1338)

* Feature 1183 memory documentation (#1340)

Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>

* add email address of user who triggered push event to job name

* Feature 1166 series analysis field info (#1353)

* Feature 1116 usecase smos (#1348)

Co-authored-by: Mrinal Biswas <biswas@ucar.edu>

* turn off new use case from every push

* feature 1236 Control Members in EnsembleStat and GenEnsProd (#1357)

* added optional argument to change the directory to untar new input data into so the same Dockerfile can be used to add data for other METplus components such as MET

* feature 1358 v4.1.0-beta5 release (#1359)

* update version for next development cycle

* Feature 1216 usecase smap (#1361)

* Adding a conf file for SMAP

* Adding a directory to host the read file

* Removing temp file

* Updated the valid dates to match Todd's code

* Adding documentation for SMAP case

* Updates the valis dates to match Todd's code

* Removing a tmp file

* Typo in file name

* Updating the input RTOFS to have the init time instead of the valid time ii the file name

* updated file paths, tesing

* updated use case descriptions, rearranged use case group testing

* put new use case into its own group so that the diff logic can evaluate marine_and_cryosphere:3. The truth data for 3-4 does not exist yet so the diff fails.

Co-authored-by: Mrinal Biswas <biswas@ucar.edu>
Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>

* updated marine_and_cryo grouping

* Feature 1230 stratosphere metrics (#1354)

* Initial checkin for Meridial Mean use case

* Changed the name and directories

* Added some documentation

* Fixed config variables

* Issue 1230 Stratospheric metrics (zonal/meridional use case) put INPUT_BASE in the user_env_vars so the user doesn't need to set the INPUT_BASE environment in the current working shell

* Issue #1230 remove import of metplotpy-this isn't called

* Issue #1230_stratosphere_metric Add use case to the list of use cases to be run for testing

* Issue 1230 Remove the INPUT_BASE from the user_env_vars section

* Issue #1230 redundant files

* Issue #1230 redundant files

* Issue #1230 redundant files

* Issue #120 replace INPUT_BASE with INPUT_FILE_NAME

* Issue #1230 remove entry for INPUT_FILE_NAME, this goes in the system.conf

* Update all_use_cases.txt

Copy and pasted #11 from s2s use case for the Stratosphere use case but forgot to update the index to 12.

* Update use_case_groups.json

added use case #12 from s2s to test stratosphere use case

* Issue #1230 put INPUT_FILE_NAME back under the user_env_vars

* Issue #1230 forgot to include the filename

* Issue #1230 clean up config file, remove uneccessary comments, group related entries in the user_env_vars

* Issue #1230 remove extraneous and incorrect path to the input_filename setting

* Removed pingouin dependency

* Issue #1230 another cut and paste error fixed for the Stratosphere use case

* Issue #1230 type in name, obs_Only should be obsOnly

* Issue #1230 added the metdatadb to the env, code imports metdatadb and may require some of these dependencies

* issue #1230 removed pingouin dependency from comment to reduce any confusion

* issue #1230 turn off the test for the Stratosphere metrics use case

* Added use case image

Co-authored-by: Hank Fisher <fisherh@kiowa.rap.ucar.edu>
Co-authored-by: Minna Win <minnawin@kiowa.rap.ucar.edu>
Co-authored-by: bikegeek <3753118+bikegeek@users.noreply.github.com>
Co-authored-by: Christina Kalb <kalb@kiowa.rap.ucar.edu>

Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>
Co-authored-by: johnhg <johnhg@ucar.edu>
Co-authored-by: Christina Kalb <kalb@ucar.edu>
Co-authored-by: lisagoodrich <33230218+lisagoodrich@users.noreply.github.com>
Co-authored-by: Julie Prestopnik <jpresto@seneca.rap.ucar.edu>
Co-authored-by: TaraJensen <jensen@ucar.edu>
Co-authored-by: jprestop <jpresto@ucar.edu>
Co-authored-by: j-opatz <59586397+j-opatz@users.noreply.github.com>
Co-authored-by: Mrinal Biswas <biswas@ucar.edu>
Co-authored-by: j-opatz <jopatz@ucar.edu>
Co-authored-by: Hank Fisher <fisherh@ucar.edu>
Co-authored-by: Hank Fisher <fisherh@kiowa.rap.ucar.edu>
Co-authored-by: Minna Win <minnawin@kiowa.rap.ucar.edu>
Co-authored-by: Christina Kalb <kalb@kiowa.rap.ucar.edu>
  • Loading branch information
15 people authored Jan 21, 2022
1 parent c530e51 commit bb1e6ea
Show file tree
Hide file tree
Showing 9 changed files with 292 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/parm/use_case_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
"index_list": "11",
"run": false
},
{
"category": "s2s",
"index_list": "12",
"run": false
},
{
"category": "space_weather",
"index_list": "0-1",
Expand Down
2 changes: 0 additions & 2 deletions ci/docker/docker_env/scripts/metplotpy_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# matplotlib==3.3.0
# scipy==1.5.1
# plotly==4.9.0
# pingouin==0.3.8
# cartopy==0.18.0
# eofs==1.3.0
# cmocean==2.0
Expand All @@ -34,7 +33,6 @@ conda create -y --clone ${BASE_ENV} --name ${ENV_NAME}
conda install -y --name ${ENV_NAME} -c conda-forge matplotlib==3.3.0
conda install -y --name ${ENV_NAME} -c conda-forge scipy==1.5.1
conda install -y --name ${ENV_NAME} -c conda-forge plotly==4.9.0
conda install -y --name ${ENV_NAME} -c conda-forge pingouin==0.3.8
conda install -y --name ${ENV_NAME} -c conda-forge cartopy==0.18.0
conda install -y --name ${ENV_NAME} -c conda-forge eofs==1.3.0
conda install -y --name ${ENV_NAME} -c conda-forge cmocean==2.0
Expand Down
Binary file added docs/_static/s2s-zonal_means.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
"""
UserScript: Make zonal and meridonial means
========================================================================
model_applications/
s2s/
UserScript_obsERA_obsOnly_Stratosphere.py
"""

##############################################################################
# Scientific Objective
# --------------------
#
# This use case calls functions in METcalcpy to create zonal and meridonial
# means
#

##############################################################################
# Datasets
# --------
#
# SSWC_v1.0_varFull_ERAi_d20130106_s20121107_e20130307_c20160701.nc

##############################################################################
# METplus Components
# ------------------
#
# This use case runs the UserScript wrapper tool to run a user provided script,
# in this case, meridonial.py.
#

##############################################################################
# METplus Workflow
# ----------------
#
# This use case does not loop but plots the entire time period of data
#
# UserScript
# This uses data from 20130106,20121107,20130307,20160701
#
#

##############################################################################
# METplus Configuration
# ---------------------
#
# METplus first loads all of the configuration files found in parm/metplus_config,
# then it loads any configuration files passed to METplus via the command line
# with the -c option, i.e. -c parm/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere.conf
#
# .. highlight:: bash
# .. literalinclude:: ../../../../parm/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere.conf
#

#############################################################################
# MET Configuration
# ---------------------
#
# There are no MET tools used in this use case.
#

##############################################################################
# Python Embedding
# ----------------
#
# There is no python embedding in this use case
#

##############################################################################
# Running METplus
# ---------------
#
# This use case can be run two ways:
#
# 1) Passing in meridonial_means.conf,
# then a user-specific system configuration file::
#
# run_metplus.py \
# -c /path/to/METplus/parm/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere.conf \
# -c /path/to/user_system.conf
#
# 2) Modifying the configurations in parm/metplus_config, then passing in meridonial.conf::
#
# run_metplus.py \
# -c /path/to/METplus/parm/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere.conf
#
# The former method is recommended. Whether you add them to a user-specific configuration file or modify the metplus_config files, the following variables must be set correctly:
#
# * **INPUT_BASE** - Path to directory where sample data tarballs are unpacked (See Datasets section to obtain tarballs). This is not required to run METplus, but it is required to run the examples in parm/use_cases
# * **OUTPUT_BASE** - Path where METplus output will be written. This must be in a location where you have write permissions
# * **MET_INSTALL_DIR** - Path to location where MET is installed locally
#
# and for the [exe] section, you will need to define the location of NON-MET executables.
# If the executable is in the user's path, METplus will find it from the name.
# If the executable is not in the path, specify the full path to the executable here (i.e. RM = /bin/rm)
# The following executables are required for performing series analysis use cases:
#
# Example User Configuration File::
#
# [dir]
# INPUT_BASE = /path/to/sample/input/data
# OUTPUT_BASE = /path/to/output/dir
# MET_INSTALL_DIR = /path/to/met-X.Y
#
# [exe]
# RM = /path/to/rm
# CUT = /path/to/cut
# TR = /path/to/tr
# NCAP2 = /path/to/ncap2
# CONVERT = /path/to/convert
# NCDUMP = /path/to/ncdump
#

##############################################################################
# Expected Output
# ---------------
#
# A successful run will output the following both to the screen and to the logfile::
#
# INFO: METplus has successfully finished running.
#

##############################################################################
# Keywords
# --------
#
# .. note::
#
# * UserScriptUseCase
# * S2SAppUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
#
#
# sphinx_gallery_thumbnail_path = '_static/s2s-zonal_means.png'
1 change: 1 addition & 0 deletions internal_tests/use_cases/all_use_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Category: s2s
9:: UserScript_obsERA_obsOnly_OMI:: model_applications/s2s/UserScript_obsERA_obsOnly_OMI.conf:: spacetime_env, metdatadb
10:: UserScript_obsERA_obsOnly_RMM:: model_applications/s2s/UserScript_obsERA_obsOnly_RMM.conf:: spacetime_env, metdatadb
11:: UserScript_fcstGFS_obsERA_WeatherRegime:: model_applications/s2s/UserScript_fcstGFS_obsERA_WeatherRegime.conf:: weatherregime_env,cartopy,metplus
12:: UserScript_obsERA_obsOnly_Stratosphere:: model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere.conf:: metplotpy_env,metdatadb,metplus

Category: space_weather
0::GridStat_fcstGloTEC_obsGloTEC_vx7:: model_applications/space_weather/GridStat_fcstGloTEC_obsGloTEC_vx7.conf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

[config]

# time looping - options are INIT, VALID, RETRO, and REALTIME
# If set to INIT or RETRO:
# INIT_TIME_FMT, INIT_BEG, INIT_END, and INIT_INCREMENT must also be set
# If set to VALID or REALTIME:
# VALID_TIME_FMT, VALID_BEG, VALID_END, and VALID_INCREMENT must also be set
LOOP_BY = REALTIME

# %Y = 4 digit year, %m = 2 digit month, %d = 2 digit day, etc.
# see www.strftime.org for more information
# %Y%m%d%H expands to YYYYMMDDHH
VALID_TIME_FMT = %Y%m%d%H

# BLank for this usecase but the parameter still needs to be there
VALID_BEG =

# BLank for this usecase but the parameter still needs to be there
VALID_END =

# BLank for this usecase but the parameter still needs to be there
VALID_INCREMENT =

# List of forecast leads to process for each run time (init or valid)
# In hours if units are not specified
# If unset, defaults to 0 (don't loop through forecast leads)
LEAD_SEQ =

# Order of loops to process data - Options are times, processes
# Not relevant if only one item is in the PROCESS_LIST
# times = run all wrappers in the PROCESS_LIST for a single run time, then
# increment the run time and run all wrappers again until all times have
# been evaluated.
# processes = run the first wrapper in the PROCESS_LIST for all times
# specified, then repeat for the next item in the PROCESS_LIST until all
# wrappers have been run
LOOP_ORDER = processes

PROCESS_LIST = UserScript

USER_SCRIPT_RUNTIME_FREQ = RUN_ONCE

USER_SCRIPT_COMMAND = {PARM_BASE}/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere/meridonial_mean.py


[user_env_vars]
INPUT_FILE_NAME = {INPUT_BASE}/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere/SSWC_v1.0_varFull_ERAi_d20130106_s20121107_e20130307_c20160701.nc
YAML_CONFIG_NAME = {METPLUS_BASE}/parm/use_cases/model_applications/s2s/UserScript_obsERA_obsOnly_Stratosphere/meridonial_mean.yaml


LOG_FILE = "Meridonial_means.log"

LOG_LEVEL = "INFO"

OUTPUT_DIR = {OUTPUT_BASE}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
These files are a use case to show how to compute meridial and zonal means

You need METcalcpy and METdatadb in your python path or your conda environment
i.e.
export PYTHONPATH=<path>/METdatadb:<path>/METcalcpy

The file SSWC_v1.0_varFull_ERAi_d20130106_s20121107_e20130307_c20160701.nc needs to be
on disk somewhere on your computer and referenced correctly in the file
meridial_mean.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env python3

"""
Create meridonial mean statistics
"""
import os
import sys
import logging
import yaml
import xarray as xr # http://xarray.pydata.org/
import metcalcpy.util.read_env_vars_in_config as readconfig
import metcalcpy.pre_processing.directional_means as directional_means
import METreadnc.util.read_netcdf as read_netcdf


def main():
"""
Use existing default meridonial mean config file found in METcalcpy to
grab the test file
"""


"""
Read Meridial Mean YAML configuration file
user can use their own, if none specified at the command line,
use the "default" example YAML config file, spectra_plot_coh2.py
Using a custom YAML reader so we can use environment variables
"""

try:
input_config_file = os.getenv("YAML_CONFIG_NAME","meridonial_mean.yaml")
config = readconfig.parse_config(input_config_file)
logging.info(config)
except yaml.YAMLError as exc:
logging.error(exc)

"""
Read METplus config file paramaters
"""
#input_file_name = os.environ.get("INPUT_FILE_NAME","SSWC_v1.0_varFull_ERAi_d20130106_s20121107_e20130307_c20160701.nc")
input_file = config["input_filename"]

"""
Setup logging
"""
logfile = "meridonial_mean.log"
logging_level = os.environ.get("LOG_LEVEL","logging.INFO")
logging.basicConfig(stream=logfile, level=logging_level)

"""
Read dataset
"""
try:
logging.info('Opening ' + input_file[0])
file_reader = read_netcdf.ReadNetCDF()

#file_reader returns a list of xarrays even if there is only one file requested to be read
#so we change it from a list to a single
ds = file_reader.read_into_xarray(input_file)[0]
except IOError as exc:
logging.error('Unable to open ' + input_file)
logging.error(exc)
sys.exit(1)
logging.debug(ds)
ds = ds[['uwndFull_TS','vwndFull_TS','tempFull_TS','geopFull_TS']]
ds = ds.rename({'timeEv60':'time',
'lat':'latitude', # pyzome currently expects dimensions named latitude and longitude
'lon':'longitude',
'uwndFull_TS':'u',
'vwndFull_TS':'v',
'tempFull_TS':'T',
'geopFull_TS':'Z'})

uzm = directional_means.zonal_mean(ds.u)
Tzm = directional_means.zonal_mean(ds.T)
T_6090 = directional_means.meridional_mean(Tzm, 60, 90)

print(T_6090)

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
input_filename:
- !ENV '${INPUT_FILE_NAME}'

0 comments on commit bb1e6ea

Please sign in to comment.