Skip to content

Commit

Permalink
Fix start years (#123)
Browse files Browse the repository at this point in the history
* changing start year to 1959 for ERA5 and 1950 for ERA5-Land, removing ERA5-Land test for inaccecibility of the years prior to 1981

* changing version number, adding Liza to the list of authors

* revert CITATION.cff to the previous release date

Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>

* revert CITATION.cff to the previous number

Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>

* Removing Liza from era5cli/__version__.py

Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>

* Update era5cli/cli.py

Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>

* updating tests for --land and years out of range

* Update era5cli/__version__.py

Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>

* modifying message if ERA5-Land is used with the back extension

Co-authored-by: Elizaveta Malinina <elizaveta.malinina-rieger@ec.gc.ca>
Co-authored-by: Barbara Vreede <b.vreede@esciencecenter.nl>
  • Loading branch information
3 people authored Nov 29, 2022
1 parent 2b8e449 commit 5d6b67d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
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
5 changes: 5 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ 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
Expand Down
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
ERA5 data is available from 1959.
`--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
3 changes: 2 additions & 1 deletion era5cli/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def _build_name(self, variable):
if self.prelimbe:
if self.land:
raise ValueError(
"Back extension not (yet) available for ERA5-Land.")
"Back extension not available for ERA5-Land. "
"ERA5-Land data is available from 1950 on.")
name += "-preliminary-back-extension"
return name, variable

Expand Down
10 changes: 1 addition & 9 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_main_fetch(fetch):
assert cli._execute(args)

# should give an AssertionError if years are out of bounds
argv = ['hourly', '--startyear', '1950',
argv = ['hourly', '--startyear', '1949',
'--variables', 'total_precipitation', '--statistics',
'--endyear', '2007', '--ensemble']
args = cli._parse_args(argv)
Expand All @@ -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)


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

0 comments on commit 5d6b67d

Please sign in to comment.