Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
[bumpversion]
current_version = 2.0.0
current_version = 2.0.1

[comment]
comment = The contents of this file cannot be merged with that of pyproject.toml until https://github.com/c4urself/bump2version/issues/42 is resolved

[bumpversion:file:era5cli/__version__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:CITATION.cff]
search = version: "{current_version}"
replace = version: "{new_version}"
1 change: 0 additions & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ 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: "2.0.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
>
> To continue using era5cli, you will need to re-register at ECMWF and get a new API key,
> and transition to era5cli version 2. This can be installed with:
> `pip install era5cli==2.0.0`
> `pip install era5cli==2.0.1`

> [!WARNING]
> netCDF files from the new Climate Data Store Beta are not formatted the same as the
Expand Down
10 changes: 10 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

# 2.0.1 - 2025-04-04

Changes since v2.0.0:

**Changed:**
- Threads are set to 1 by default, as the new CDS is not faster if you use multiple threads.

**Fixed:**
- The cdsapi changed how wants the request formatted for getting netCDF files, netCDF files weren't properly downloaded anymore.

# 2.0.0 - 2025-02-12

Changes since v1.4.2:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A command line interface to download ERA5 data from the [Copernicus Climate Data

To continue using era5cli, you will need to re-register at ECMWF and get a new API key,
and transition to the era5cli v2 beta. This can be installed with:
`pip install era5cli>=2.0.0`
`pip install era5cli>=2.0.1`

???+ warning
netCDF files from the new Climate Data Store Beta are not formatted the same as the
Expand Down
2 changes: 1 addition & 1 deletion era5cli/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"Bart Schilperoort",
)
__email__ = "ewatercycle@esciencecenter.nl"
__version__ = "2.0.0"
__version__ = "2.0.1"
2 changes: 1 addition & 1 deletion era5cli/args/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def add_common_args(argument_parser: ArgumentParser) -> None:
type=int,
choices=range(1, 7),
required=False,
default=None,
default=1,
help=textwrap.dedent(
"""
Number of parallel threads to use when
Expand Down
1 change: 1 addition & 0 deletions era5cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _execute(input_args: argparse.Namespace) -> True:
land=input_args.land,
overwrite=input_args.overwrite,
dashed_vars=input_args.dashed_varname,
dryrun=input_args.dryrun,
)
era5.fetch(dryrun=input_args.dryrun)
return True
Expand Down
14 changes: 10 additions & 4 deletions era5cli/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def __init__(
land=False,
overwrite=False,
dashed_vars=False,
dryrun=False,
):
"""Initialization of Fetch class."""
self._get_login() # Get login info from config file.
self._get_login(dryrun=dryrun) # Get login info from config file.

self.months = era5cli.utils._zpad_months(months)
"""list(str): List of zero-padded strings of months
Expand Down Expand Up @@ -194,7 +195,10 @@ def __init__(
"\n For more info see 'era5cli hourly --help'."
)

def _get_login(self):
def _get_login(self, dryrun=False):
if dryrun: # Don't check keys on dry run
return None

# First check if the config exists, and guide the user if it does not.
key_management.check_era5cli_config()
# Only then load the keys (as they should be there now).
Expand Down Expand Up @@ -463,7 +467,10 @@ def _build_request(self, variable, years, months=None):
"year": years,
"month": self.months if months is None else months,
"time": self.hours,
"format": self.outputformat,
"data_format": self.outputformat,
"download_format": (
"unarchived" if self.outputformat.lower() == "netcdf" else "zip"
),
}

if "pressure-levels" in name:
Expand All @@ -487,7 +494,6 @@ def _exit(self):
def _getdata(self, variables: list, years: list, outputfile: str, months=None):
"""Fetch variables using cds api call."""
name, request = self._build_request(variables, years, months)

if self.dryrun:
print(name, request, outputfile)
else:
Expand Down
2 changes: 1 addition & 1 deletion era5cli/key_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def attempt_cds_login(url: str, key: str) -> True:
"product_type": "reanalysis",
"date": "2012-12-01",
"time": "14:00",
"format": "netcdf",
"data_format": "netcdf",
},
)
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_parse_args():
assert not args.merge
assert args.startyear == 2008
assert args.statistics
assert not args.threads
assert args.threads == 1
assert args.variables == ["total_precipitation"]
assert args.land
assert not args.area
Expand Down
9 changes: 6 additions & 3 deletions tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ def test_build_request():
"month": ALL_MONTHS,
"day": ALL_DAYS,
"time": ALL_HOURS,
"format": "netcdf",
"data_format": "netcdf",
"download_format": "unarchived",
}
assert request == req

Expand All @@ -486,7 +487,8 @@ def test_build_request():
"product_type": "monthly_averaged_ensemble_members",
"month": ALL_MONTHS,
"time": ALL_HOURS,
"format": "netcdf",
"data_format": "netcdf",
"download_format": "unarchived",
}
assert request == req

Expand All @@ -503,7 +505,8 @@ def test_build_request():
"product_type": "monthly_averaged_reanalysis",
"month": ALL_MONTHS,
"time": ["00:00"],
"format": "netcdf",
"data_format": "netcdf",
"download_format": "unarchived",
}
assert request == req

Expand Down
11 changes: 7 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def my_thing_mock():
'03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00',
'10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00',
'17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
'format': 'netcdf', 'product_type': 'reanalysis', 'day': ['01',
'data_format': 'netcdf', 'download_format': 'unarchived',
'product_type': 'reanalysis', 'day': ['01',
'02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23',
'24', '25', '26', '27', '28', '29', '30', '31']}
Expand All @@ -55,7 +56,8 @@ def my_thing_mock():
'03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00',
'10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00',
'17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
'format': 'netcdf', 'pressure_level': [1, 2, 3, 5, 7, 10, 20, 30,
'data_format': 'netcdf', 'download_format': 'unarchived',
'pressure_level': [1, 2, 3, 5, 7, 10, 20, 30,
50, 70, 100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500,
550, 600, 650, 700, 750, 775, 800, 825, 850, 875, 900, 925, 950,
975, 1000], 'product_type': 'reanalysis', 'day': ['01', '02', '03',
Expand All @@ -77,8 +79,9 @@ def my_thing_mock():
"""\
reanalysis-era5-land-monthly-means {'variable': 'snow_cover',
'year': 2008, 'month': ['01', '02', '03', '04', '05', '06', '07',
'08', '09', '10', '11', '12'], 'time': ['00:00'], 'format':
'netcdf', 'product_type': 'monthly_averaged_reanalysis'}
'08', '09', '10', '11', '12'], 'time': ['00:00'], 'data_format': 'netcdf',
'download_format': 'unarchived',
'product_type': 'monthly_averaged_reanalysis'}
era5-land_snow_cover_2008_monthly.nc"""
),
},
Expand Down