Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CMEC driver #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ start 31 1980 1 6 6
482 303 120.500000 -14.250000 9.987638e+04 1.464815e+01 0.000000e+00 1980 1 6 6
476 301 119.000000 -14.750000 9.981100e+04 1.398848e+01 0.000000e+00 1980 1 6 12
476 300 119.000000 -15.000000 9.953694e+04 1.369575e+01 0.000000e+00 1980 1 6 18

...
```

Expand Down Expand Up @@ -132,3 +132,27 @@ $> ./graphics-cymep.sh netcdf-files/netcdf_GLOB_rean_configs.nc
```

This will produce a suite of figures in various subfolders within `./fig/`.


### Run with CMEC driver

An alternative workflow is available with [cmec-driver](https://github.com/cmecmetrics/cmec-driver) and conda. This workflow uses conda to manage python environments. Follow the cmec-driver [installation instructions](https://github.com/cmecmetrics/cmec-driver#cmec-driver) to install cmec-driver in a conda environment. Then use the following workflow:
1. Clone the coastal-storm-metrics repository.
2. Use conda to install dependencies in an environment called "_CMEC_cymep". This can be done using the provided yml file:
`conda env create --file cymep.yml`
3. Register CyMeP in the cmec library:
`cmec-driver register <path to coastal-storm-metrics repo>`
- If you have not run cmec-driver before, you must also register your conda installation information:
`cmec-driver setup --conda_source <conda source executable> --env_dir <conda env location>`
For a standard anaconda or miniconda installation, this might look like:
`cmec-driver setup --conda_source ~/miniconda3/etc/profile.d/conda.sh --env_dir ~/miniconda3/envs/`
4. Create a "cmec-driver" folder *outside* of the coastal-storm-metrics repo. In the cmec-driver folder, create two subfolders: "model" and "output".
5. Add TempestExtremes ASCII trajectories to `cmec-driver/model`.
- For testing, copy `cymep/trajs/*` to `cmec-driver/model`
6. Create configuration csv in cmec-driver/model.
- For testing, copy `cymep/config-lists/rean_configs.csv` to `cmec-driver/model/rean_configs.csv`.
7. Edit user settings in ~/.cmec/cmec.json.
- For testing, use the default settings.
8. Run CyMeP module from the cmec-driver directory:
`cmec-driver run model/ output/ CyMeP`
9. Open `/output/CyMeP/index.html` to view results.
35 changes: 35 additions & 0 deletions coastal-storm-metrics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# This is the driver script for running CyMeP via cmec-driver
source $CONDA_SOURCE
conda activate $CONDA_ENV_ROOT/_CMEC_cymep

echo "Running Cyclone Metrics Package"
cymep_log=${CMEC_WK_DIR}/CyMeP.log.txt
echo "log:" $cymep_log
cd ${CMEC_CODE_DIR}/cymep
python cymep.py > $cymep_log

if [[ $? = 0 ]]; then
echo "Success in Cyclone Metrics Package"

echo "Generating graphics"

# Make figures for each netcdf
for file in ${CMEC_WK_DIR}/netcdf-files/*; do
echo "\n"$file >> $cymep_log
ncl ./plotting/plot-spatial.ncl 'out_type="png"' 'ncfile="'$file'"' >> $cymep_log
ncl ./plotting/plot-temporal.ncl 'out_type="png"' 'ncfile="'$file'"' >> $cymep_log
ncl ./plotting/plot-taylor.ncl 'out_type="png"' 'ncfile="'$file'"' >> $cymep_log

ncl ./plotting/plot-table.ncl plot_bias=False relative_performance=True invert_stoplight=False calc_deltas=False write_units=False 'out_type="png"' 'csvtype="spatial_corr"' 'ncfile="'$file'"' >> $cymep_log
ncl ./plotting/plot-table.ncl plot_bias=True relative_performance=False invert_stoplight=False calc_deltas=True write_units=True 'out_type="png"' 'csvtype="climo_mean"' 'ncfile="'$file'"' >> $cymep_log
ncl ./plotting/plot-table.ncl plot_bias=True relative_performance=False invert_stoplight=False calc_deltas=True write_units=True 'out_type="png"' 'csvtype="storm_mean"' 'ncfile="'$file'"' >> $cymep_log
ncl ./plotting/plot-table.ncl plot_bias=False relative_performance=True invert_stoplight=False calc_deltas=False write_units=False 'out_type="png"' 'csvtype="temporal_scorr"' 'ncfile="'$file'"' >> $cymep_log
done

# Document figures in output.json and create html page
python functions/write_cmec.py >> $cymep_log

else
echo "Failure in Cyclone Metrics Package"
fi
10 changes: 10 additions & 0 deletions cymep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: _CMEC_cymep
channels:
- conda-forge
dependencies:
- ncl
- netCDF4
- numpy
- pandas
- python>=3.6
- scipy
Loading