-
Notifications
You must be signed in to change notification settings - Fork 320
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
Toolchain part2: ./mkmap_data.py
#1430
Conversation
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.
@negin513 thank you for your nice work on the toolchain! Also, thank you for giving me a tour of the PR this morning.
I have a very important general comment that I realized after we spoke:
According to the design that the group adopted (slide 5 in this presentation), this piece of code should also generate the "old" namelist (the one that the fortran code reads). The "old" namelist has what the new namelist contains PLUS the list of map_ files. I think that's all.
|------------------------------------------------------------------| | ||
|--------------------- Instructions -----------------------------| | ||
|------------------------------------------------------------------| | ||
This Python script is part of the simplified toolchain for creating |
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 Python script is part of the simplified toolchain for creating | |
This Python script is STEP 2 of the simplified toolchain for creating |
|
||
3. Check if the weight (mapping file) already exists or not. | ||
|
||
4. If it does not exist, it creates the mapping (weight) file. |
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.
Steps 3 and 4 are not different from mkmapdata.sh. For this documentation to be clear, you should add at the end of 3 and 4 something in parentheses that says (same as mkmapdata.sh).
To run the script: | ||
./mkmap_data.py --namelist ${namelist from ./gen_mksurf_namelist.py} | ||
|
||
To remove NPL from your environment on Cheyenne/Casper: |
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.
To remove NPL from your environment on Cheyenne/Casper: | |
To remove NPL (ncar_pylib) from your environment on Cheyenne/Casper: |
from datetime import datetime | ||
from getpass import getuser | ||
|
||
# from gen_mksurf_namelist import get_parser, build_nl |
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.
is this a placeholder or can be deleted?
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.
is this a placeholder to address the generation of the "old" namelist?
|
||
parser.add_argument( | ||
"--namelist", | ||
help="namelist for the ctsm case created by gen_mksurf_namelist.py ", |
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.
help="namelist for the ctsm case created by gen_mksurf_namelist.py ", | |
help="namelist created by gen_mksurf_namelist.py ", |
if "SCRIP" in self.mesh_file: | ||
self.mesh_type = "SCRIP" | ||
# else: | ||
# TODO: TALK to SAM about thi |
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 function may be going away, as discussed elsewhere.
logging.debug("\n dst_mesh :") | ||
logging.debug(dst_mesh) | ||
|
||
# -- src mesh files |
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.
# -- src mesh files | |
# -- raw dataset files containing corresponding src mesh file names |
logging.debug(dst_mesh) | ||
|
||
# -- src mesh files | ||
src_flist = [ |
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.
How about cycling through everything in the namelist with the prefix "mksrf_"
instead of hardwiring this whole list?
logging.debug("\n" + src_file + " : " + src_fname) | ||
|
||
# -- check if src_file exist | ||
if not os.path.isfile(src_fname): |
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 think you already do this in class MeshType def __init__
so you could delete this if section and keep the else.
|
||
mapping_fname: str | ||
Mapping /weight filename, if not explicitly given the | ||
class will create one based on src_mesh and dst_mesh information. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@negin513 recommended that it would be cleaner to put the function of creating the old namelist in a separate script that we call gen_old_namelist.py. See updated slides (same link). Also gen_old_namelist.py will be a step that's transparent to the user and will be run by the wrapper script. The wrapper script will be a new pull request (part 3 in this series of PRs). |
With the work on the parallel mksurfdata_map, this PR will likely be closed without coming in. |
With the work in #1663 this work becomes obsolete so I'm closing. Some of the python code in here might still be useful examples that we keep in mind. One thing in here is one of our examples of interacting with the batch system. |
Description of changes
This Python script is the second part of the simplified toolchain for creating surface datasets for global ctsm cases (#644 ).
After creating the namelist/control file with
./gen_mksurf_namelist.py
(PR #1419) using the options for your desired case, you should run :to create mapping/weight files.
This python script is the alternative code to mkmapdata.sh with few differences:
It reads namelist file for DST mesh file.
For raw dataset in the namelist it finds their SRC mesh file and mask from
the necdf metadata.
Check if the weight (mapping file) already exists or not.
If it does not exist, it creates the mapping (weight) file.
Specific notes
Contributors other than yourself, if any: @slevisconsulting
CTSM Issues Fixed (include github issue #):
Are answers expected to change (and if so in what way)?
Any User Interface Changes (namelist or namelist defaults changes)?
./mkmap_data.py
has the following interface:Testing performed, if any: @slevisconsulting