-
Notifications
You must be signed in to change notification settings - Fork 15
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 PCMDI Diags to zppy #647
base: main
Are you sure you want to change the base?
Conversation
How I generated this PR, following up #640: git remote -v
# Add fork to my list of remotes
git remote add zhangshixuan1987 [email protected]:zhangshixuan1987/zppy.git
git remote -v
# Fetch the branch from https://github.com/E3SM-Project/zppy/pull/640
git fetch zhangshixuan1987 zppy_pcmdi
git checkout -b zppy_pcmdi zhangshixuan1987/zppy_pcmdi
git log
# It looks like alot of "new" commits include commits on `main`
# Let's clean up the commit history,
# so we're only looking at relevant changes in the PR
# The first commit in https://github.com/E3SM-Project/zppy/pull/640/commits is:
# Modify time series processing to include 3D model variables (9e2488cd8f14d4a9b2a016497de14096979ce4f0)
# The last commit before that was: Add PR template (#618) (7c7a8e987fab11ce6ac933e25c2880d5a66c4c6d)
# Rebase off that
git rebase -i 7c7a8e987fab11ce6ac933e25c2880d5a66c4c6d
# Pick (p) the first commit: Modify time series processing to include 3D model variables (9e2488cd8f14d4a9b2a016497de14096979ce4f0)
# Fixup (f) the rest
git log
# commit a4130d3c030b802c2b62359e74a56870472d22bf (HEAD -> zppy_pcmdi)
# Author: ShixuanZhang <[email protected]>
# Date: Mon Sep 16 17:55:18 2024 -0500
# Modify time series processing to include 3D model variables
# The modification attemts to interpolate the 3D model level data to
# standard pressure level specified by vrt_remap_plev19.nc. This is
# needed by e3sm_to_cmip to convert these variables into cmip type
# commit 7c7a8e987fab11ce6ac933e25c2880d5a66c4c6d
# Author: forsyth2 <[email protected]>
# Date: Wed Aug 21 11:09:17 2024 -0700
# Add PR template (#618)
# Now, we can rebase off the latest `main`
git fetch upstream main
git rebase upstream/main
# We get merge conflicts
git status
# Unmerged paths:
# (use "git restore --staged <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
# both modified: conda/dev.yml
# both modified: tests/integration/generated/test_min_case_add_dependencies_chrysalis.cfg
# both added: tests/integration/generated/test_min_case_carryover_dependencies_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_depend_on_climo_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_depend_on_climo_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_depend_on_ts_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_depend_on_ts_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_diurnal_cycle_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_diurnal_cycle_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_lat_lon_land_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_streamflow_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_streamflow_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_tc_analysis_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_tc_analysis_mvm_2_chrysalis.cfg
# both added: tests/integration/generated/test_min_case_e3sm_diags_tc_analysis_parallel_chrysalis.cfg
# both modified: tests/integration/generated/test_min_case_e3sm_diags_tropical_subseasonal_mvm_2_chrysalis.cfg
# both modified: tests/integration/generated/test_weekly_bundles_chrysalis.cfg
# both modified: tests/integration/generated/test_weekly_comprehensive_v2_chrysalis.cfg
# both modified: tests/integration/generated/test_weekly_comprehensive_v3_chrysalis.cfg
# both modified: tests/integration/template_weekly_comprehensive_v2.cfg
# both modified: tests/integration/test_weekly.py
# both modified: tests/integration/utils.py
# both modified: tests/test_sections.py
# both added: tests/test_zppy_e3sm_diags.py
# both added: tests/test_zppy_global_time_series.py
# both added: tests/test_zppy_ilamb.py
# both added: tests/test_zppy_utils.py
# both modified: zppy/__main__.py
# both modified: zppy/defaults/default.ini
# both modified: zppy/global_time_series.py
# deleted by us: zppy/templates/coupled_global.py
# added by them: zppy/templates/inclusions/e3sm_to_cmip/vrt_remap_plev19.nc
# both modified: zppy/utils.py
# Went through all conflicted files.
# Mostly I resolved conflicts by using "current change" (i.e., what's on `main`, not what's on this PR),
# Because in most cases, the changes from this PR were erronously including the contents from commits outside the PR's scope.
# Cases where "incoming changes" (i.e., changes from the PR) were used:
# zppy/__main__.py: existing_bundles = pcmdi_diags(config, scriptDir, existing_bundles, job_ids_file)
# => had to change scriptDir to script_dir
# zppy/defaults/default.ini:
# cmip_metadata = string(default="e3sm_to_cmip/default_metadata.json")
# cmip_plevdata = string(default="e3sm_to_cmip/vrt_remap_plev19.nc")
# => had to change to include `inclusions/`
# Check for any remaining conflicts
git grep -n "<<<<<<< HEAD"
# No appearances of "<<<<<<< HEAD", so there are no remaining conflicts
git add -A
git rebase --continue
# Update auto-generated files
python tests/integration/utils.py
git status
# No changes, so we updated everything in the generated/ subdir correctly.
# Let's give the commit a new name
git commit --amend
# Let's push the changes to GitHub
git push upstream zppy_pcmdi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial review, visual inspection only. I've included notes on how to split this PR up into zppy & zppy-interfaces now these have been separated out.
@@ -1,5 +1,5 @@ | |||
exclude: "docs|node_modules|migrations|.git|.tox" | |||
default_stages: [commit] | |||
default_stages: [pre-commit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this changed.
@@ -0,0 +1,34 @@ | |||
name: zppy_dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of this file should be included into https://github.com/E3SM-Project/zppy-interfaces/blob/main/conda/dev.yml
# Need to pin docutils because 0.17 has a bug with unordered lists | ||
# https://github.com/readthedocs/sphinx_rtd_theme/issues/1115 | ||
- docutils=0.16 | ||
prefix: /home/ac.szhang/.conda/envs/zppy_dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no dependency on any one user here.
@@ -107,9 +107,11 @@ input_component = string(default="") | |||
[ts] | |||
area_nm = string(default="area") | |||
cmip_metadata = string(default="inclusions/e3sm_to_cmip/default_metadata.json") | |||
cmip_plevdata = string(default="inclusions/e3sm_to_cmip/vrt_remap_plev19.nc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
du -sh vrt_remap_plev19.nc
# 512 vrt_remap_plev19.nc
du -sh default_metadata.json
# 8.0K default_metadata.json
I can't tell the units of the du
measurement here; I think it's just bytes. How big is this file? Less than a kilobyte? I guess that's ok, but we typically avoid including nc
files in the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty small, so should be ok to include in the repo -- or we could add this file to the mapping directory, for consistency.
@@ -0,0 +1,158 @@ | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend taking a look at https://github.com/E3SM-Project/zppy/blob/main/zppy/e3sm_diags.py or https://github.com/E3SM-Project/zppy/blob/main/zppy/global_time_series.py for examples of how to better modularize this code.
@@ -0,0 +1,872 @@ | |||
# Script to plot some global atmosphere and ocean time series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it got added back in for some reason in the rebase. Delete this; it's in zppy-interfaces now.
{%- endif %} | ||
|
||
# script for pcmdi pre-processing | ||
cat > collect_data.py << EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking this .py
file should be moved over to zppy-interfaces. The goal is for the .bash
file to be extremely light. Ideally, it's zppy calling some other package (e.g., e3sm_diags
or zi-global-time-series
, which is the global-time-series command in zppy-interfaces) with the proper arguments, and that's pretty much it.
@@ -0,0 +1,121 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pcmdi_diags
subdirectory should be moved under inclusions/
and paths should be updated accordingly.
do | ||
if [ -f ${file} ]; then | ||
#ncks --rgr xtr_mth=mss_val --vrt_fl='{{cmip_plevdata}}' ${file} ${file}.plev | ||
ncremap -p mpi --vrt_ntp=log --vrt_xtr=mss_val --vrt_out='{{cmip_plevdata}}' ${file} ${file}.plev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this block uses NCO rather than e3sm_to_cmip
and should thus be moved before the change of environment ({{ e3sm_to_cmip_environment_commands }}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also look at implementing #467 (as a separate PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include vertical remapping with the already-implemented horizontal remapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also check if vertical remapping is already covered by ncclimo
import os | ||
import sys | ||
|
||
import cdms2 as cdm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should try our best to not use cdms
. I think PMP team is working on migrating to xarray/xcdat as well. maybe there is an updated version?
If we do decide on adding a Viewer for PCMDI diags, check out E3SM-Project/zppy-interfaces#9 and #648 for seeing how global time series implements the Viewer. Ideally, we can use the same Viewer code for both global time series and PCMDI diags. |
Issue resolution
Select one: This pull request is...
1. Does this do what we want it to do?
Objectives:
Required:
If applicable:
2. Are the implementation details accurate & efficient?
Required:
If applicable:
zppy/conda
, not just animport
statement.3. Is this well documented?
Required:
4. Is this code clean?
Required:
If applicable: