python-xarray

Xarray find lat/lon coordinates for maximum/minimum values for each timestep

Xarray find lat/lon coordinates for maximum/minimum values for each timestep Question: As the title says, supposing I have a ds with coords: [time lat lon], how can I obtain for each timestep in time the pair of [‘lat’,’lon’] in which the maximum(or minimum) value for a given variable is located. Asked By: Henrique || Source …

Total answers: 1

Python 3.10.6 – Find the element-wise maxima of overlaid xarray datasets

Python 3.10.6 – Find the element-wise maxima of overlaid xarray datasets Question: I’m working with gridded data, specifically netcdf data, trying to find the maximum grid point value for overlaying pixels of each netcdf file in a directory, ignoring null values. If you’re familiar with ArcGIS, this is the same as running the maximum function …

Total answers: 1

xarray mask outside list of coordinates

xarray mask outside list of coordinates Question: I have an Xarray DataArray with values over rectangular 2D grid, and a list of points (pairs of coordinate values) from an arbitrary subset of that grid contained in a pandas Dataframe. How do I mask out values (i.e. set equal to NaN) in the DataArray whose grid …

Total answers: 1

Creating netcdf file from csv using xarray with 3d var

Creating netcdf file from csv using xarray with 3d var Question: I’m trying to transform a csv file with year, lat, long and pressure into a 3 dimensional netcdf pressure(time, lat, long). However, my list is with duplicate values ​​as below: year,lon,lat,pressure 1/1/00,79.4939,34.4713,11981569640 1/1/01,79.4939,34.4713,11870476671 1/1/02,79.4939,34.4713,11858633008 1/1/00,77.9513,35.5452,11254617090 1/1/01,77.9513,35.5452,11267424230 1/1/02,77.9513,35.5452,11297377976 1/1/00,77.9295,35.5188,1031160490 I have the same year, lon, …

Total answers: 2

How to do a left-join on a data variable's values using xarray?

How to do a left-join on a data variable's values using xarray? Question: Imagine having a dataset of shipments where every shipID can contain multiple products: In [2]: shipDS Out[2]: <xarray.Dataset> Dimensions: (shipID: 6) Coordinates: * shipID (shipID) int64 1 1 2 3 4 4 Data variables: prodID (shipID) int64 90 91 92 90 90 …

Total answers: 1

Downsampling geospatial xarrays too large for memory

Downsampling geospatial xarrays too large for memory Question: I have a very large (86400×43200) xarray dataset with geospatial coordinates (lat, lon) and elevation and would like to downsize this map to have one twentieth the resolution per dimension (4320, 2160, which is equivalent to 1/12th degree). I at first used the interp method directly, but …

Total answers: 1

Combine xarray Datasets on stacked coordinate

Combine xarray Datasets on stacked coordinate Question: I have two datasets, where they share a coordinate. But, in the first set that coordinate is stacked. I want to merge the two dataset, so that the second set is also indexed by the stacked coordinate. I’ve managed to get this working by manually restructuring the second …

Total answers: 1

How to create and return a Zarr file from xarray Dataset?

How to create and return a Zarr file from xarray Dataset? Question: How would I go about creating and return a file new_zarr.zarr from a xarray Dataset? I know xarray.Dataset.to_zarr() exists but this returns a ZarrStore and I must return a bytes-like object. I have tried using the tempfile module but am unsure how to …

Total answers: 1

replace value at specific coordinate with mean of sorrounding cells in Xarray

replace value at specific coordinate with mean of sorrounding cells in Xarray Question: I’ve been trying to replace the value of a cell (meaning, a point with an specific latitude and longitude) in a xarray dataset. The coordinares of my Dataset are lon, lat and time. I want to replace the value of certain lat …

Total answers: 1

How to convert float64 time to datetime object

How to convert float64 time to datetime object Question: I am working on Berkeley Earth Surface Temperature data. I have a monthly NetCDF file from 1753-recent. The date axis is float64 and when I convert to DateTime format it only returns the first day and month of each year. Below is the time documentation from …

Total answers: 1