2,451 questions
28
votes
6
answers
36k
views
xarray select nearest lat/lon with multi-dimension coordinates
I have a xarray dataset with irregular spaced latitude and longitudes coordinates. My goal is to find the value of a variable at the point nearest a certain lat/lon.
Since the x and y dimensions are ...
28
votes
5
answers
17k
views
How to get the coordinates of the maximum in xarray?
Simple question: I don't only want the value of the maximum but also the coordinates of it in an xarray DataArray. How to do that?
I can, of course, write my own simple reduce function, but I wonder ...
26
votes
2
answers
26k
views
Is it possible to append to an xarray.Dataset?
I've been using the .append() method to concatenate two tables (with the same fields) in pandas. Unfortunately this method does not exist in xarray, is there another way to do it?
25
votes
3
answers
26k
views
Extract coordinate values in xarray
I would like to extract the values of the coordinate variables.
For example I create a DataArray as:
import xarray as xr
import numpy as np
import pandas as pd
years_arr=range(1982,1986)
time = pd....
23
votes
2
answers
45k
views
How can I get a list with the variable names of my xarray.Dataset?
I am looking for a way of extracting a list of the data variable names (strings) from a xarray.DataSet object.
I have used xr_object.data_vars and xr_object.data_vars.keys() but they don't seem to ...
23
votes
5
answers
275k
views
TypeError: cannot unpack non-iterable int objec
How can I solve this error After running my code as follows . I am using the function below and implementin running window for loop on it but end up getting the error below. The for loop works and ...
22
votes
1
answer
9k
views
When to use multiindexing vs. xarray in pandas
The pandas pivot tables documentation seems to recomend dealing with more than two dimensions of data by using multiindexing:
In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: import ...
22
votes
1
answer
33k
views
replace values in xarray dataset with None
I want to replace values in a variable in an xarray dataset with None. I tried this approach but it did not work:
da[da['var'] == -9999.]['var'] = None
I get this error: *** TypeError: unhashable ...
21
votes
1
answer
17k
views
Join/merge multiple NetCDF files using xarray
I have a folder with NetCDF files from 2006-2100, in ten year blocks (2011-2020, 2021-2030 etc).
I want to create a new NetCDF file which contains all of these files joined together. So far I have ...
19
votes
3
answers
13k
views
Speeding up reading of very large netcdf file in python
I have a very large netCDF file that I am reading using netCDF4 in python
I cannot read this file all at once since its dimensions (1200 x 720 x 1440) are too big for the entire file to be in memory ...
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+ ...
19
votes
1
answer
22k
views
What is the pandas.Panel deprecation warning actually recommending?
I have a package that uses pandas Panels to generate MultiIndex pandas DataFrames. However, whenever I use pandas.Panel, I get the following DeprecationError:
DeprecationWarning:
Panel is ...
17
votes
4
answers
42k
views
Drop coordinate from an xarray DataArray
I have an xarray DataArray that looks like this below with shape (1,5,73,144,17) and I'm trying to drop or delete the "level" coordinates. So, ultimately, i need the variable to have shape = ...
17
votes
3
answers
4k
views
combining spatial netcdf files using xarray python
Is there a way to merge 2 or more netCDF files with the same time dimension but different spatial domains into a single netCDF file? The spatial domains are specified by latitude and longitude ...
16
votes
3
answers
50k
views
what does this mean? xarray error: cannot handle a non-unique multi-index
I am trying to convert a dataframe to xarray. The head is like this:
z Class DA x y iline xline idz
2 ...