Created
April 3, 2024 11:41
-
-
Save phinate/2cd53517f91845fbdd010776a1f11551 to your computer and use it in GitHub Desktop.
load slice of era5 for local use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray | |
variables = [ | |
'u_component_of_wind', | |
'v_component_of_wind', | |
'geopotential', | |
'temperature', | |
# ... full list of variables here: https://console.cloud.google.com/storage/browser/gcp-public-data-arco-era5/ar/1959-2022-full_37-1h-0p25deg-chunk-1.zarr-v2;tab=objects?pli=1&prefix=&forceOnObjectsSortingFiltering=false | |
] | |
# Loading ERA5 data from Google Cloud arco project | |
era5_path = 'gs://gcp-public-data-arco-era5/ar/full_37-1h-0p25deg-chunk-1.zarr-v3' | |
full_era5_ds = xarray.open_zarr(era5_path, chunks=None) | |
full_era5_ds = full_era5_ds[variables] | |
start_time = '2020-02-14' | |
end_time = '2020-02-18' | |
data_inner_steps = 12 # process every 12th hour | |
era5_ds = full_era5_ds.sel(time=slice(start_time, end_time)) | |
era5_ds = era5_ds.thin(time=data_inner_steps) | |
# here, era5_ds will be much smaller, and you can then materialize it/save it/etc. | |
era5_ds.to_netcdf(f'{start_time}_{end_time}_era5_slice.nc') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
name: era5
channels:
dependencies: