Skip to content

Runoff sensitivities#781

Open
hanjunkim0617 wants to merge 17 commits intoNOAA-GFDL:mainfrom
hanjunkim0617:runoff_sensitivities
Open

Runoff sensitivities#781
hanjunkim0617 wants to merge 17 commits intoNOAA-GFDL:mainfrom
hanjunkim0617:runoff_sensitivities

Conversation

@hanjunkim0617
Copy link
Copy Markdown

@hanjunkim0617 hanjunkim0617 commented Apr 9, 2025

Description
Runoff sensitivity diagnostic package

How Has This Been Tested?
I had to add the variable 'mrro' in the filedlist, so I added a few lines to "data/fieldlist_CMIP.jsonc".
The diagnostic was tested by Dani Coleman from NCAR as well.
In Ubuntu 20.04.6 LTS, it takes ~7 min. to run.

The sample output figure is attached. Please see HTML page:
MDTF_CESM2.historical.v18.r10i1p1f1_1850_2014.Zip

In addition, pre-digested observational data is attached here (inputdata/obs_data):
obs_data.Zip

Please contact hk764@cornell.edu for further questions.

Thank you!
Best regards,
Hanjun

Checklist:

  • My branch is up-to-date with the NOAA-GFDL main branch, and all merge conflicts are resolved
  • The scripts are written in Python 3.12 or above (preferred; required if funded by a CPO grant), NCL, or R
  • All of my scripts are in the diagnostics/[POD short name] subdirectory, and include a main_driver script, template html, and settings.jsonc file
  • I have made corresponding changes to the documentation in the POD's doc/ subdirectory
  • I have requested that the framework developers add packages required by my POD to the python3, NCL, or R environment yaml file if necessary, and my environment builds with conda_env_setup.sh
  • I have added any necessary data to input_data/obs_data/[pod short name] and/or input_data/model/[pod short name]
  • My code is portable; it uses MDTF environment variables, and does not contain hard-coded file or directory paths
  • I have provided the code to generate digested data files from raw data files
  • Each digested data file generated by the script contains numerical data (no figures), and is 3 GB or less in size
  • I have included copies of the figures generated by the POD in the pull request
  • The repository contains no extra test scripts or data files

Hanjun Kim and others added 12 commits October 26, 2023 12:41
The calculation of runoff sensitivities is updated. It is now using 5-year averaged anomalies to estimate runoff sensitivities, whereas the original code used the inter-annual variations.
Add exit command. Otherwise warning like below occur:

INFO: <#1NYy:CESM2.historical.r10i1p1f1.runoff_sensitivities> terminated, but the subprocess did not yield a return code. This does not necessarily indicate a failure.
Updated description of html page.
@hanjunkim0617 hanjunkim0617 marked this pull request as ready for review April 9, 2025 16:45
@wrongkindofdoctor wrongkindofdoctor self-assigned this Apr 9, 2025
@wrongkindofdoctor wrongkindofdoctor added the diagnostic Issue pertains to a contributed diagnostic label Apr 9, 2025
Comment on lines +13 to +15
"pod_env_vars" : {
"EXAMPLE_FAV_COLOR": "blue"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete unused pod_env_vars block

nlon = len(lonm)
nt = len(time)
nyr = int(nt/12)
syr_model = int(os.environ["FIRSTYR"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with upated environment variable 'startdate'

nt = len(time)
nyr = int(nt/12)
syr_model = int(os.environ["FIRSTYR"])
eyr_model = int(os.environ["LASTYR"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with updated environment variable 'enddate'

### 4) Saving output data: ##########################
#####################################################
## save runoff sensitivity data in netCDF4 file
out_path = "{WK_DIR}/model/netCDF/runoff_sensitivities_{CASENAME}.nc".format(**os.environ)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace 'WK_DIR' with 'WORK_DIR'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitterbark @hanjunkim0617 was it changed to WORKING_DIR? Change it to WORK_DIR.

"settings" : {
"driver" : "runoff_sensitivities_diag.py",
"long_name" : "diagnostic for the runoff sensitivities",
"realm" : ["atmos","land"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move realm to a data block:

data": {
    "realm": ["atmos", "land"]
}

import time as time
import numpy as np # python library for dealing with data array
import cartopy.io.shapereader as shpreader # cartopy library for loading with shapefiles
import matplotlib

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'matplotlib' is not used.
## figures for P sensitivity ##
bins=[-3.5, -3, -2.5, -2, -1.6, -1.2, -0.8, -0.4, 0, 0.4, 0.8, 1.2, 1.6, 2, 2.5, 3, 3.5];
bins2=[-100, -3, -2.5, -2, -1.6, -1.2, -0.8, -0.4, 0, 0.4, 0.8, 1.2, 1.6, 2, 2.5, 3, 100];
plot_colormap = [(0.4000, 0, 0, 1), (0.7316, 0, 0, 1), (0.9975, 0.0306, 0.0078, 1), (0.9845, 0.1915, 0.0484, 1), (0.9715, 0.3525, 0.0890, 1), (0.9776, 0.5636, 0.0700, 1), (0.9891, 0.7889, 0.0338, 1), (1.0000, 1.0000, 0.0263, 1), (1.0000, 1.0000, 0.4408, 1), (1.0000, 1.0000, 1.0000, 1), (1.0000, 1.0000, 1.0000, 1), (0.7325, 0.8651, 0.9386, 1), (0.5342, 0.7652, 0.8931, 1), (0.3359, 0.6652, 0.8476, 1), (0.1375, 0.5652, 0.8020, 1), (0.0477, 0.4727, 0.7506, 1), (0.0563, 0.3870, 0.6938, 1), (0.0651, 0.3013, 0.6370, 1), (0.0368, 0.1575, 0.5250, 1), (0, 0, 0.4000, 1)]

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'plot_colormap' is unnecessary as it is
redefined
before this value is used.
nfoc=r2_obs_pred.shape[0]; nens=r2_obs_pred.shape[1];
hval_r2_ia_gobs=np.full(nb,False);
hval_r2_ia_hist6=np.full(nb,False);
hval_r2_ia_model=np.full(nb,False);

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'hval_r2_ia_model' is unnecessary as it is
redefined
before this value is used.
@hanjunkim0617
Copy link
Copy Markdown
Author

hanjunkim0617 commented Apr 10, 2025 via email

@wrongkindofdoctor
Copy link
Copy Markdown
Contributor

wrongkindofdoctor commented Apr 10, 2025

Hi, @hanjunkim0617. All you need to do is update the files with the requested changes on your local development branch on your workstation, then commit and push the updates to your remote fork. The PR will automatically update and rerun the checks.

I saw the obs data file in the initial message, and have a copy now.

## import libraries
import os
import numpy as np
import cartopy.io.shapereader as shpreader

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'shpreader' is not used.
@bitterbark
Copy link
Copy Markdown
Collaborator

@wrongkindofdoctor I have the obs data tar ball already.

@wrongkindofdoctor
Copy link
Copy Markdown
Contributor

@bitterbark Great! Thanks for letting me know. I'll update the review request.

@bitterbark
Copy link
Copy Markdown
Collaborator

I just started looking at this but I can't see what change Jess requested in the last message. Is it resolved?

@bitterbark
Copy link
Copy Markdown
Collaborator

I can't see the change requested by Jess in the last message. Has it been resolved?

@aradhakrishnanGFDL
Copy link
Copy Markdown
Collaborator

I can't see the change requested by Jess in the last message. Has it been resolved?

It looks like there are just a few things that need to be fixed, like removing unused imports, moving realm to the data block, etc. https://github.com/NOAA-GFDL/MDTF-diagnostics/pull/781/files/6170feed6e51d2557e02fc632593f9966339d5f1#r2036044413
It's way up this PR.

@wrongkindofdoctor
Copy link
Copy Markdown
Contributor

@hanjunkim0617 @aradhakrishnanGFDL @bitterbark I requested that the realm entry in the settings file be moved to a data block like so:

data": { "realm": ["atmos", "land"] }

The POD runtime config file also needs to be removed from the src directory. It can be placed in the POD subdirectory for reference if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostic Issue pertains to a contributed diagnostic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants