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
0 answers

Chi-square value from xarray polyfit

How can we derive the chi square values of the polynomial fit using xarray.Dataset.polyfit. From what I can see in he documentation, it returns residuals and covariance matrix. for example, I can calculate the 2nd order polynomial fit across dim1 of…
Vinod Kumar
  • 1,383
  • 1
  • 12
  • 26
0
votes
2 answers

Round and overwrite xarray data in place

I want to round all of the values in a xarray to 2 decimal places. I have tried the following: def round_dim(data_arr): data_arr.data = data_arr.data.round(decimals = 2) return data_arr I call it as such: data_values =…
0
votes
1 answer

how to extract values based upon month in xarray

I have an array of dimensions (9131,101,191). The first dimension is the days from 1/1/2075 till 31/12/2099. I want to extract all the days which are in the month of July. How can I do this in xarray? I have tried using loops and numpy but not…
Sohaib
  • 3
  • 2
0
votes
1 answer

Overlapping chunks in Xarray dataset for Kernel operations

I try to run a 9x9 pixel kernel across a large satellite image with a custom filter. One satellite scene has ~ 40 GB and to fit it into my RAM, I'm using xarrays options to chunk my dataset with dask. My filter includes a check if the kernel is…
eimes
  • 3
  • 2
0
votes
0 answers

NetCDF variable extraction at specific coordinates using arrays does not work - python

I am trying to extract two variables values of a netCDF file at specific coordinates. From what I have seen from various posts on StackOverflow, the best way to achieve that is to work with arrays. I have tried to use this method but it does not…
I.M.
  • 344
  • 3
  • 14
0
votes
0 answers

Bar plot and line plot shifts away from each other when using twinx()

I am dealing a CDF4 data using xarray to open it. I want to plot a line and a bar in just one figure, so I used twinx(). The problem is the xticks of the line and bar plot are not matched to each other. The xticks of the line plot is shifted one…
0
votes
1 answer

Xarray is cutting of values in a dataset

So what I am doing is downloading data from a data portal separated into variables, months and years (because it's faster to get the data this way). I have the data available on my drive and now want to stich it together. I did this successfully and…
Gabriel
  • 67
  • 5
0
votes
1 answer

Add nan buffer to xarray dataset

I have an xarray Dataset which will be acting as a mask to a different dataset. I'd like to create a buffer (of a configurable distance) from any nan values in the mask. I haven't seen anything that adds a buffer internally, instead of expanding the…
JackLidge
  • 391
  • 4
  • 16
0
votes
1 answer

Unable to open Netcdf variable in xarray

I am opening a dataset using xarray with this line: DS = xr.open_dataset(dataDIR). When I use DS.variables, I see that there's a variable named 'u-vel', however, when I try to open this variable using DS.u-vel, it returns me the…
brenovisk7
  • 35
  • 5
0
votes
0 answers

using xr.where to get 3D index:(time,lat,lon)

I want to use xr.where to get index: (time, lat, lon) which contain t<22 from let say this xarray dataset: import xarray as xr np.random.seed(0) t = 15 + 8 * np.random.randn(2, 2, 3) lon = [[-99.83, -99.32], [-99.79, -99.23]] lat = [[42.25, 42.21],…
Tugiyo
  • 31
  • 6
0
votes
0 answers

Reprojection from North Polar Stereo to Lat/Lon using Rioxarray causes dataset to become corrupted

I am attempting to reproject a CMC Snow Depth Map (in GeoTIFF format) from North Polar Stereo to Lat/Lon. The PROJ string of the file is: '+proj=stere +lat_0=90 +lat_ts=60 +lon_0=10 +x_0=0 +y_0=0 +R=6371200 +units=m +no_defs=True'. The data is…
0
votes
1 answer

xarray creates DataArray with shifted coordinates

I'm trying to create a dummy raster which I can later use as target for rioxarrays reproject_match() function. My area of interest (AOI) is exactly 3x3 degrees and my desired resolution is 0.00008. So the resolution fits exactly into the AOI with…
Corbjn
  • 276
  • 1
  • 10
0
votes
1 answer

How to collocate large datasets most efficiently, comparing time, latitude (x), and longitude (y)

I would like some help trying to efficiently collocate two datasets, one is let's say observations of rainfall, in terms of datetime, latitude and longitude. The other is meteorological data e.g. reanalysis given also in terms of datetime, latitude…
Dominic
  • 45
  • 7
0
votes
1 answer

using xr.where to get index:(lat,lon)

I want to use xr.where to get index:(lat,lon) which contain y<1 from this xarray dataset: import xarray as xr y = xr.DataArray( 0.1 * np.arange(12).reshape(3, 4), dims=["lat", "lon"], coords={"lat": np.arange(3), "lon": 10 +…
Tugiyo
  • 31
  • 6
0
votes
0 answers

Trying to install metpy in my machine but getting error

Metpy 1.4 got installed but when imported it is showing error even after update ModuleNotFoundError: No module named 'xarray.core.accessors'. I was trying to work with Metpy, although the installation was successful but when I imported it in my…
1 2 3
99
100