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

Retrieving data across a year boundary as a single file? #121

Open
rsignell-usgs opened this issue Aug 17, 2022 · 2 comments
Open

Retrieving data across a year boundary as a single file? #121

rsignell-usgs opened this issue Aug 17, 2022 · 2 comments

Comments

@rsignell-usgs
Copy link

rsignell-usgs commented Aug 17, 2022

Is it possible to retrieve data across a year boundary as a single file?

For example, a single retrieval that results in a file containing hourly data from Dec 25, 2021 to Jan 5, 2022?

@Peter9192
Copy link
Collaborator

I think the closest you can get is something like this:

era5cli hourly --variables 2m_temperature --startyear 2010 --endyear 2011 --months 1 12 --days 1 2 3 4 5 25 26 27 28 29 30 31 --merge

The --merge option can be used to specify that outputs should be combined in a single file. However, it is currently not possible to specify different days for different months.

Being able to specify a date range would be a nice feature request. Not sure if/when we'll have time for it, but code contributions are of course always welcome.

Updating the documentation is high on our list, by the way

@rsignell-usgs
Copy link
Author

rsignell-usgs commented Aug 19, 2022

Thanks @Peter9192! I did eventually figure out how to do this using the cdsapi. This works:

import cdsapi
c = cdsapi.Client()

def get_chunk(start_date, stop_date):
    local_ncfile = f'era5land_{start_date}.nc'
    c.retrieve(
        'reanalysis-era5-land',
        {
            'variable': var_list, 
            'area'    : f'{north}/{west}/{south}/{east}', 
            'date'    : f'{start_date}/{stop_date}',
            'time': ['00:00', '01:00', '02:00', '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'
        },
        local_ncfile)

# CONUS
north = 49.3457868 
west = -124.7844079 
east = -66.9513812 
south =  24.7433195 
get_chunk('2020-12-28', '2021-01-03')

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

No branches or pull requests

2 participants