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

Download daily (hourly) ERA5-Land weather data #3

Open
ezwelty opened this issue Aug 19, 2023 · 0 comments
Open

Download daily (hourly) ERA5-Land weather data #3

ezwelty opened this issue Aug 19, 2023 · 0 comments

Comments

@ezwelty
Copy link

ezwelty commented Aug 19, 2023

@peter-shaw-benson et al.

In case this is helpful, here are some demo scripts for downloading ERA5-Land temperature data at higher temporal resolution.

Note: I suspect that it might actually be faster to retrieve daily data via Google Earth Engine, but I didn't experiment with this approach.

Download daily mean, min, max, or mid via the daily statistics calculator. Results in a 800 MB NetCDF file for each month (for global, full-resolution coverage).

import cdsapi
import requests

c = cdsapi.Client(timeout=300)
year = '2023'
month = '01'
response = c.service(
  'tool.toolbox.orchestrator.workflow',
  params={
    'realm': 'user-apps',
    'project': 'app-c3s-daily-era5-statistics',
    'version': 'master',
    'kwargs': {
      'dataset': 'reanalysis-era5-land',
      'product_type': 'reanalysis',
      'variable': '2m_temperature',
      'statistic': 'daily_mean',
      'year': year,
      'month': month,
      'time_zone': 'UTC+00:0',
      'frequency': '1-hourly',
      'grid': '0.1/0.1',
      'area': {'lat': [-90, 90], 'lon': [-180, 180]} 
    },
    'workflow_name': 'application'
  }
)
url = response[0]['location']
path = f'{year}_{month}.nc'
stream = requests.get(url, stream=True)
print(f'Writing data to {path}')
with open(path, 'wb') as file:
  for chunk in stream.iter_content(chunk_size=1024):
    file.write(chunk)

Download hourly via the original dataset. Results in a 3.6 GB GRIB or NetCDF file for each month (for global, full-resolution coverage).

import cdsapi

c = cdsapi.Client()
year = '2023'
month = '01'
result = c.retrieve(
  'reanalysis-era5-land',
  {
    'variable': '2m_temperature',
    'year': year,
    'month': month,
    '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',
    ],
    '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': 'grib',
  },
  f'{year}_{month}.grib'
)
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

1 participant