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

Fix start years #123

Merged
merged 9 commits into from
Nov 29, 2022
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"affiliation": "Netherlands eScience Center",
"name": "Verhoeven, Stefan",
"orcid": "0000-0002-5821-2060"
},
{
"affiliation": "Environment and Climate Change Canada",
"name": "Malinina, Elizaveta",
"orcid": "0000-0002-4102-2877"
}
],
"description": "A command line interface to download ERA5 data from the Climate Data Store.\n",
Expand Down
9 changes: 7 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,19 @@ authors:
family-names: Verhoeven
given-names: Stefan
orcid: https://orcid.org/0000-0002-5821-2060
-
affiliation: "Environment and Climate Change Canada"
family-names: Malinina
given-names: Elizaveta
orcid: https://orcid.org/0000-0002-4102-2877

cff-version: 1.2.0
date-released: 2021-11-30
date-released: 2022-10-04
malininae marked this conversation as resolved.
Show resolved Hide resolved
doi: 10.5281/zenodo.3252665
keywords:
- "ERA5"
license: Apache-2.0
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/ewatercycle/era5cli"
title: era5cli
version: 1.3.1
version: 1.3.2
malininae marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions era5cli/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
'Niels Drost', 'Fakhereh Alidoost', 'Bouwe Andela',
'Jerom Aerts', 'Berend Weel', 'Rolf Hut', 'Klaus Zimmermann',
'Peter Kalverla', 'Barbara Vreede', 'Aytaç Paçal', 'Stef Smeets',
'Stefan Verhoeven')
'Stefan Verhoeven', 'Elizaveta Malinina')
malininae marked this conversation as resolved.
Show resolved Hide resolved
__email__ = 'ewatercycle@esciencecenter.nl'
__version__ = '1.3.1'
__version__ = '1.3.2'
malininae marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 7 additions & 6 deletions era5cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def _build_parser():
Whether to download the preliminary back extension
(1950-1978). Note that when `--prelimbe` is used,
`--startyear` and `--endyear` should be set
between 1950 and 1978.
between 1950 and 1978. Please, be aware that
from 1959 ERA5 data is available.
malininae marked this conversation as resolved.
Show resolved Hide resolved
`--prelimbe` is incompatible with `--land`.

''')
Expand All @@ -159,7 +160,7 @@ def _build_parser():
help=textwrap.dedent('''\
Whether to download data from the ERA5-Land
dataset. Note that the ERA5-Land dataset starts in
1981.
1950.
`--land` is incompatible with the use of
`--prelimbe` and `--ensemble`.

Expand Down Expand Up @@ -343,12 +344,12 @@ def _construct_year_list(args):
'year should be between 1950 and 1978'
)
elif args.land:
assert 1981 <= year <= datetime.now().year, (
'for ERA5-Land, year should be between 1981 and present'
assert 1950 <= year <= datetime.now().year, (
'for ERA5-Land, year should be between 1950 and present'
)
else:
assert 1979 <= year <= datetime.now().year, (
'year should be between 1979 and present'
assert 1959 <= year <= datetime.now().year, (
'year should be between 1959 and present'
)

assert endyear >= args.startyear, (
Expand Down
8 changes: 0 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@ def test_main_fetch(fetch):
args = cli._parse_args(argv)
cli._execute(args)

# no land available for back extension
argv = ['monthly', '--startyear', '1980', '--endyear', '1980',
'--variables', 'total_precipitation', '--synoptic',
'--ensemble', '--land']
args = cli._parse_args(argv)
with pytest.raises(AssertionError):
cli._execute(args)

Comment on lines -163 to -170
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this test was a bit ill-described, I do think it is important to keep it, in a slightly modified form. We need to raise an error if the --land and --prelimbe flags are used together, as there is no back extension for era5-land.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Peter9192, thanks for the suggestion, I looked into it. So, if I understand correctly this particular test was more about --land being incompatible with the years prior to 1981, not back extension as comment says. The incompatibility of --prelimbe and --land are tested in test_fetch.py, because it is the place that gives you the ValueError, if those two tags are used together. As highlighted in #130, the request with --ensemble and --land actually goes through but fails on the cdsapi end. My suggestion is, for this pull request delete this test, and I will open a new PR with adding the AssertionError in case --ensemble and --land are used together. Then, I will re-add this test, but testing the --ensemble and --land. What do you think? @bvreede what's your opinion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right! So I did notice that there was a discrepancy between the description (land and back extension not compatible) and the actual test (land not available for years prior to 1981). But you're right, I overlooked that there's also the issue of --land and --ensemble being incompatible. Your suggested approach sounds good to me 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

btw @bvreede is on holiday until next week

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for figuring this out; indeed, that's a good idea, let's do it!


@mock.patch("era5cli.info.Info", autospec=True)
def test_main_info(info):
Expand Down