-
Notifications
You must be signed in to change notification settings - Fork 7
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
Download subregion #66
Conversation
Hey @aytacpacal welcome and cheers for opening this PR! I added a link to a corresponding issue (#44). |
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.
Hi @aytacpacal ,
Thank you very much for contribution this PR to era5cli! This is much appreciated.
I have left a couple of comments and suggestions, to improve the code but mostly to make sure it is well documented. Additionally, I have the following suggestions:
- It would be good to add a check in the
cli.py
file and raise an error if invalid coordinates are passed. - It would be good to also add a test for this new argument (see
tests/test_cli.py
) - Please add your details to the
citation.cff
and.zenodo.json
files if you would like to be recognized for your contributions.
Let me know if you need help with any of these recommendations. I'm happy to help.
@@ -144,6 +144,20 @@ def _build_parser(): | |||
''') | |||
) | |||
|
|||
rgn = argparse.ArgumentParser(add_help=False) |
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.
Do we need a new parser? Why not just add the area
argument to common
?
Coordinates to download data for. Defaults to whole | ||
available region. For subregion extraction, provide coordinates | ||
as {ymax,xmin,ymin,xmax} |
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.
Maybe this provides some extra help as to how the list can be specified on the command line:
Coordinates to download data for. Defaults to whole | |
available region. For subregion extraction, provide coordinates | |
as {ymax,xmin,ymin,xmax} | |
Use this argument to specify a subregion for which to | |
download the data. Coordinates should be provided as | |
a space separated list as {ymax, xmin, ymin, xmax}. | |
Defaults to `--area 90 -180 -90 180`, i.e. the whole globe. |
@@ -187,7 +201,7 @@ def _build_parser(): | |||
) | |||
|
|||
hourly = subparsers.add_parser( | |||
'hourly', parents=[common, mnth, day, hour], | |||
'hourly', parents=[common, rgn, mnth, day, hour], |
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 not necessary if we just add it to the common
group
@@ -211,7 +225,7 @@ def _build_parser(): | |||
) | |||
|
|||
monthly = subparsers.add_parser( | |||
'monthly', parents=[common, mnth], | |||
'monthly', parents=[common, rgn, mnth], |
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.
similar
area: list(float) | ||
Lon-lat values to download data for. (-180 and 180, -90 and 90) |
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.
Let's try to be very clear about how to represent the range, as I think this order can be quite confusing.
area: list(float) | |
Lon-lat values to download data for. (-180 and 180, -90 and 90) | |
area: list(float) | |
Coordinates to extract a subregion. Specified as {ymax, xmin, ymin, xmax} | |
with x and y in the range -180, +180 and -90, +90, respectively. |
@@ -84,6 +86,8 @@ def __init__(self, years: list, months: list, days: list, | |||
"""list(int): List of pressure levels.""" | |||
self.variables = variables | |||
"""list(str): List of variables.""" | |||
self.area = area | |||
"""list(int): List of coordinates""" |
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.
In the argparse options I think this was a float, no?
"""list(int): List of coordinates""" | |
"""list(float): Coordinates specifying the subregion that will be extracted.""" |
@@ -186,4 +186,4 @@ def _append_netcdf_history(ncfile: str, appendtxt: str): | |||
{}'''.format(appendtxt, ncfile.history)) | |||
except AttributeError: | |||
ncfile.history = appendtxt | |||
ncfile.close() | |||
ncfile.close() |
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.
Please use flake8 to see whether the code adheres to the PEP8 python style guidelines.
Hello @aytacpacal , |
Hi @Peter9192, yes, thanks for your comments. Unfortunately, I did not have time to look. I plan to continue but do not know when it will be :( |
Okay thanks for the reply. It's good to know this is still on your radar. Cheers! |
Hello again @aytacpacal how are you doing? Can you give another update about your plans regarding this PR? If you don't have the time, we might be able to help out and finish the work on this one. Let me know what option you prefer :-) |
Hi @Peter9192, yeah I am struggling with my time management, so it will be better if someone else takes a look :( |
Hi @aytacpacal thanks again so much for opening this PR! 🎉 With your permission, I'll continue work on implementing the subregion download. There are a few ways we can do this: as you may have noticed, I've copied your subregion branch to this repository, as I didn't have access to your forked repo. I am currently working on this branch. Option 1: I can open a new PR with this branch. Working with a new PR (option 1) will be easier for me and wouldn't need your continuous attention, but while you would remain as the commit author for the commits already made on the branch, you wouldn't be the author of the PR itself. Should you want to add anything to the PR, option 2 is better, as you have no direct access to the branch on this repository. Could you let me know which option you prefer? Regarding recognition for your work: if you want, we can add your details to the citation.cff and .zenodo.json files, and I'm fairly certain you would be listed as a contributor on the github page as a commit author. And of course you will have our eternal gratitude ;) Thanks again! |
Hi @bvreede, you can use whichever is easier for you :) I thank you for creating this software, your eternal gratitude is enough for me 🤗 |
Hi @aytacpacal just to let you know, @Peter9192 just closed #70, and subregion support has been added! And you're now an official contributor to this repository :) Thanks much, all the best! |
Added ability to download subregion
closes #44