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

First pass at subsetter.py #93

Merged
merged 35 commits into from
Mar 5, 2023
Merged

First pass at subsetter.py #93

merged 35 commits into from
Mar 5, 2023

Conversation

dwfncar
Copy link
Collaborator

@dwfncar dwfncar commented Aug 10, 2022

This script is intended as a stand-alone pre-processor to invoke NCO operators
for subsetting model datasets.
It uses the the same control file as driver.py.

Documentation will be added after early reviews and modifications.

@dwfncar
Copy link
Collaborator Author

dwfncar commented Aug 10, 2022

Warning, treated as error:
[autosummary] failed to import melodies_monet.subsetter.
Possible hints:

  • SystemExit: 2
  • ImportError:
  • AttributeError: Module 'melodies_monet' has no attribute 'subsetter'
    Error: Process completed with exit code 2.

Not sure how to resolve.

@zmoon
Copy link
Collaborator

zmoon commented Aug 10, 2022

@dwfncar I think you have to add it to the top-level __init__.py, because I made submodule imports lazy (to make the CLI more responsive), which is based on an explicit list.

Alternatively, if you prepend _ to the file name, the auto API docs should ignore it.

@zmoon
Copy link
Collaborator

zmoon commented Aug 15, 2022

Just noting expandvars (#91) should be merged before this.

Copy link
Collaborator

@zmoon zmoon left a comment

Choose a reason for hiding this comment

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

Looks good, just a few suggestions.

scripts/subsetter.py Outdated Show resolved Hide resolved
scripts/subsetter.py Outdated Show resolved Hide resolved
scripts/subsetter.py Outdated Show resolved Hide resolved
file_out = '/'.join(file_subdirs)
command = 'ncks -O ' + var_str + ' ' + file_in + ' ' + file_out
logging.info(command)
os.system(command)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using subprocess.run is recommended over os.system. Note that you have to give the command as a list of parts in that case. Can use check=True so exception is raised if the command gives nonzero exit code.

Comment on lines +53 to +56
for var in control['model'][model]['variables']:
var_str += var + ','

var_str = var_str.strip(',')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like could use ','.join(...) instead

examples/subset/run.py Outdated Show resolved Hide resolved
examples/subset/run.py Outdated Show resolved Hide resolved
examples/subset/run.py Outdated Show resolved Hide resolved
scripts/subsetter.py Outdated Show resolved Hide resolved
scripts/subsetter.py Outdated Show resolved Hide resolved
@colin-harkins
Copy link
Collaborator

Other than addressing my comment above about the deflation level I think this looks good. I agree with the suggestions that @zmoon made.

dwfncar and others added 2 commits February 7, 2023 10:11
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
dwfncar and others added 9 commits February 7, 2023 10:13
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
@colin-harkins
Copy link
Collaborator

@dwfncar I saw you added the compression level argument and it seems like the other comments have been addressed. Is this finished? If so I'll go ahead and approve it.

@dwfncar
Copy link
Collaborator Author

dwfncar commented Feb 21, 2023

I have one more change to make ... will have ready by this evening.

@@ -18,9 +18,11 @@
parser.add_argument('--outdir', type=str,
default=None,
help='output directory')
parser.add_argument('--compress_level', type=int,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
parser.add_argument('--compress_level', type=int,
parser.add_argument('--compress-level', type=int,

Personally, I prefer this style, but up to you.

@rschwant
Copy link
Collaborator

rschwant commented Mar 2, 2023

@zmoon and @dwfncar is this ready to add to develop now?

@dwfncar
Copy link
Collaborator Author

dwfncar commented Mar 2, 2023

This is ready to merge ...

@colin-harkins
Copy link
Collaborator

@dwfncar I think you may need to merge in the updates to develop to your branch because they fix the tests (#162 ).

https://stackoverflow.com/questions/70905779/github-pr-still-fails-test-after-another-merged-pr-fixed-the-failing-problem

Copy link
Collaborator

@zmoon zmoon left a comment

Choose a reason for hiding this comment

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

actually can you change this first?

examples/subset/airnow_wrfchem.yaml Outdated Show resolved Hide resolved
@dwfncar dwfncar requested a review from zmoon March 3, 2023 21:58
Co-authored-by: Zachary Moon <zmoon92@gmail.com>
@dwfncar dwfncar merged commit dfe71ab into develop Mar 5, 2023
@dwfncar dwfncar deleted the develop_subsetter branch March 5, 2023 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants