2,451 questions
1
vote
0
answers
39
views
Error "InvalidVersion: Invalid version: 'unknown'" when triying to load netcdf files using xarray
I'm trying to load some .nc files this way:
ds = xr.open_dataset('path/to/file.nc')
At first I get no error message, but when I try to operate or simply visualize the data I get this really long ...
2
votes
1
answer
99
views
How to calculate the mean value of a variable on a specific day of the year over several years
I have an xarray DataArray that contains daily data for every day from 1970 to 2023 for the months October through March, and I want to calculate the average value of the variable for each day (e.g. ...
3
votes
0
answers
91
views
How to optimize NetCDF files and dask for processing long-term climataological indices with xclim (ex. SPI using 30-day rolling window)?
I am trying to analyze the 30 day standardized precipitation index for a multi-state range of the southeastern US for the year 2016. I'm using xclim to process a direct pull of gridded daily ...
3
votes
1
answer
830
views
How can I resolve xarray "unrecognized engine cfgrib"?
An example HRRR file I'm trying to open with xarray: https://storage.googleapis.com/high-resolution-rapid-refresh/hrrr.20250427/conus/hrrr.t18z.wrfprsf06.grib2
When trying to open the dataset with ...
0
votes
1
answer
98
views
Reading multiple GRIB files using Xarray with cfgrib engine with index files in custom location
I am trying to read multiple ERA5 GRIB files using the Python Xarray's xr.mfopen_dataset() method. My ERA5 input files are on a server in a location where I only have read permission for. Therefore, I ...
0
votes
2
answers
70
views
Looking to find the index of the nearest low-resolution grid cell for each of the lat/lon pairs in a high resolution dataset
I have 2 elevation datasets -- one is a low resolution dataset (~0.1 degree resolution), and another is a high resolution dataset (~0.001 degree resolution). Let's assume that the datasets look ...
0
votes
1
answer
65
views
How to add crs to a xarray dataset
I am wondering how to add the crs to xarray dataset. For example if we have a min and max dataset and compute the mean. How can we set the mean dataset to have the same CRS as the min or max datasets ?...
0
votes
0
answers
30
views
Introducing new dimension in xarray apply_ufunc
There has been at least one other question regarding the introduction of new dimensions in the output of xarray.apply_ufunc; I have two problems with this answer: First, I feel like the answer avoids ...
1
vote
2
answers
342
views
Is there a python xarray function, like interp, to lookup the closest coordinate value that matches a variable value?
I am looking for a way to return the interpolated coordinate value of a variable at a query variable value. I think it is the opposite use to a normal interpolation/table-look up.
For example, here is ...
0
votes
0
answers
97
views
Coarsening the resolution of a xarray dataset
Very new to python! I am trying to model bottom water temperatures over time and need to reduce the resolution of my model from 1/20º to 1º. My ultimate goal is to map this and select specific grid ...
2
votes
0
answers
90
views
How to drop rows with a boolean mask in xarray/dask without .compute() blowing up memory?
I’m trying to subset a large xarray.Dataset backed by Dask and save it back to Zarr, but I’m running into a major memory problem when attempting to drop rows with a boolean mask.
Here’s a minimal ...
19
votes
5
answers
7k
views
How to apply linear regression to every pixel in a large multi-dimensional array containing NaNs?
I have a 1D array of independent variable values (x_array) that match the timesteps in a 3D numpy array of spatial data with multiple time-steps (y_array). My actual data is much larger: 300+ ...
2
votes
2
answers
128
views
Convert existing dataset to rioxarray object
I have a dataset that I need to convert into a rioxarray dataset so I can use regridding features but I can't work out how to convert an already existing xarray object to rioxarray.
Unfortunately I ...
0
votes
1
answer
81
views
how to quickly pull values from an xarray using indices
I'm working in a Jupyter Notebook using Python 3.12. I have a 2D xarray (in reality, it's 3D, but we can treat it as 2D). I want to pull out the values based on indices I acquire elsewhere, and then ...
3
votes
2
answers
2k
views
h5netcdf as default xarray engine
The default backend engine for xarray is set to netcdf4 in this function
What is the best way to make h5netcdf the default engine in xarray?