Repository navigation
Add MONTHS_PER_YEAR constant and use it in cplhist_monthly_clim - #4310
Open
michellejtan wants to merge 3 commits into
Open
michellejtan wants to merge 3 commits into
michellejtan wants to merge 3 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Adds a
MONTHS_PER_YEARconstant in a newpython/ctsm/constants.pyand uses it in place of three hard-codedrange(1, 13)month loops inpython/ctsm/cplhist/cplhist_monthly_clim.py(year_months(), the averaging step, and the step that joins the monthly files). The PFT constants that #1621 also mentions were already moved topython/ctsm/pft_utils.pyin June 2025, so I did not touch them.Two small leftovers from that earlier PFT work are fixed in
python/ctsm/site_and_regional/single_point_case.py, in their own commit so they are easy to drop if you would rather not have them here:num_pftdocstring said "78 pft, else 16 pft"; it now namesMAX_PFT_MANAGEDCROPSandMAX_PFT_GENERICCROPS.--dompfterror said "between 1 and 78", butcheck_dom_pft()accepts 0 (bare ground); it now usesMIN_PFT, so it says "between 0 and 78".I did not change
pft_utils.py, the"NETCDF4_CLASSIC"string that is repeated in several modules,NOLEAP_DAYS, therange(1, 13)calls in the test files, orend_month = 12inrun_tower.py.I asked on the issue where
MONTHS_PER_YEARshould live and did not get an answer.My proposal location: (
python/ctsm/constants.py). I am happy to move it.Before (
b4b-devat 0efa002):After:
Specific notes
Contributors other than yourself, if any:
CTSM issues resolved or otherwise addressed, if any:
If answers are expected to change, describe (delete this line otherwise):
Not applicable: no answers change (python tools only).
Any user interface changes (namelist or namelist defaults changes)?
No namelist changes. The only user-visible change is the wording of the
--dompfterror insubset_data(it now says "between 0 and 78" instead of "between 1 and 78").Testing planned or performed, if any:
test_unit_constants.py(ImportError beforeconstants.pyexisted) andtest_check_dom_pft_message_lower_bound("...between 0 and" does not match "...between 1 and 78."before the fix).test_noleapDaysMatchMonthsPerYear, checks thatNOLEAP_DAYSandyear_months()haveMONTHS_PER_YEARentries. It passes before and after; it guards against drift.python/:./run_ctsm_py_tests -uin thectsm_pylibconda environment: 680 passed (677 passed onb4b-devbefore my changes, plus my 3).make -C python black: 182 files left unchanged.make -C python lint: 10.00/10.test_sys_aero_1850_monthly_clim.py(the one that exercisescplhist_monthly_clim) all 5 tests were skipped because NCO (ncra,ncrcat,ncatted) is not installed on my machine.AI disclosure
Requirements before merge:
ctsm_pylibconda environment on Ubuntu (WSL2), Python 3.13.13.doc/for the old error text and for--dompft; the single-point user guide mentions--dompftbut not its range or the error message, and the Tech Note has no mention of these tools, so nothing needs to change.