Questions tagged [python-xarray]

Xarray - N-D labeled arrays and datasets in Python

Xarray is an open source project and Python package that introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, which allows for more intuitive, more concise, and less error-prone user experience.

Xarray includes a large and growing library of domain-agnostic functions for advanced analytics and visualization with these data structures.

Resources

2296 questions
0
votes
1 answer

xarray dataset extract values select

I have a xarray dataset from which I would like to extract points based on their coordinates. When sel is used for two coordinates it returns a 2D array. Sometimes this is what I want and it is the intended behavior, but I would like to extract a…
3dSpatialUser
  • 2,034
  • 1
  • 9
  • 18
0
votes
1 answer

How to open multiple files in a path skiiping files with a determined name

I have a folder with files whose name goes from f000 to f168, and I would like to select only files above f000, that is, from f003, f006, to f168. How can I do this ? The file name starts like this: gfs.0p25.2020010100.f000.WE.grib2
0
votes
1 answer

Xarray mfdataset combining files with different variables using cfgrib engine

I have a folder with several files in .grib2 extension and some of them have the tcc variable (cloud cover) and others don't. I would like to open all files in a single array with this variable but it gives an error. I can only open a single file…
0
votes
0 answers

Using .isel() to select noncontinuous range of data with xarray

I'm working with MERRA-2 data using xarray, and I'm attempting to plot data only over the Pacific Ocean. However, my data are in units of degrees East, such that the International Dateline is represented with index 0 and a value of -180, and the…
Logan
  • 95
  • 7
0
votes
0 answers

How to convert a structured numpy array to xarray.DataArray?

I have a structured numpy array, containing sampled data from several measurement series: Each series samples m as a function of l, and differs from the other series by a. l is not sampled at constant values, and there is a different number of…
Zak
  • 3,063
  • 3
  • 23
  • 30
0
votes
1 answer

How to prevent `to_zarr` method in xarray from writing all nan chunks to disk?

I want to save a very large zarr file (2 dimensional) chunked equally along both dimensions (X, X) occationally containing chunks made of all nans. To reduce the amount of chunks written to disk, I want xarray's to_zarr method to skip writing this…
0
votes
2 answers

How does dtype of Numpy array affect memory usage when calling .tolist()?

I'm wondering how different dtype of numpy arrays affect the memory usage in Python when calling .tolist() on the array. I want to conserve as much memory as possible. If I am correct, using float16 shoudl allow me to carry double the amount of…
0
votes
0 answers

using a zarr store as a fixed-size buffer

I'm trying to use a zarr store as a fixed-size buffer (i.e. new data is appended to the end, and the same amount of data is removed from the beginning when a certain size is reached). The store is huge (20 TB), and contains a 2D matrix (positions…
bluppfisk
  • 2,538
  • 3
  • 27
  • 56
0
votes
0 answers

How can I convert a multiband geotiff to a timeseries netcdf file in xarray

I am trying to create a time series object from extracted climate data (NEX-GDDP) using the Google Earth Engine (GEE). The data is daily metrological data, and in the attached file, the data for January, 2005, is collected over an area of interest.…
0
votes
0 answers

Cant paralellize process with xarray.apply_ufunc()

I have one xr.DataArray with dims lon,lat,time. Id like to compute a multiple linear regression for each gridpoint using two predictors, x1 and x2, both with only a time dimension. Im using the library statsmodel, to easily get the pvalue. The…
0
votes
1 answer

How to loop through axis for subplots in a while loop?

How can i use my while loop conditions to loop through axis of subplots. I am very new to python. I have written a code where i plot the data based on some conditions in a while loop. The code works fine for plotting individual plots but when i have…
0
votes
0 answers

How to perform band math and add extra bands to tif with rioxarray

I'm trying to work out how to open a raster, determine the name of the existing band(s), then use that bands value in math to create a new band. I believe the data is being loaded to a DataArray. I'm outputting that DataArray back to a tif, hopping…
anakaine
  • 1,188
  • 2
  • 14
  • 30
0
votes
1 answer

Removing points from an array on a data map between two historical timepoints

I currently have 2 "data maps" for different time periods (1901-2021, 1979-2021). I would like to subtract the gridded points in the maps to show a difference between where areas have had more precipitation. I am unsure what I can look up to…
0
votes
0 answers

Python 3 Spyder Xarray: Why is the same NetCDF file loaded everytime (within a loop, and defining different variables)

I want to load the files here: https://thredds.aodn.org.au/thredds/catalog/IMOS/SRS/SST/ghrsst/L3S-3d/day/1992/catalog.html and store them in a list using xarray. But instead of being on thredds, the files are saved on a remote server that I mount…
UpperEastSide
  • 117
  • 1
  • 16
0
votes
0 answers

map dependend xarray coordinates

I have an xarray with dimensions in x,y which also has coordinates in lat,lon. Since these are shifted grids the lat and lon are both dependend on x,y. I want to convert my coordinate system to lat, lon but I am unsure how to achieve this. I have…
EricLeer
  • 41
  • 4