I have a number of coordinates (roughly 20000) for which I need to extract data from a number of NetCDF files each comes roughly with 30000 timesteps (future climate scenarios). Using the solution here is not efficient and the reason is the time spent at each i,j to convert “dsloc” to “dataframe” (look at the code below). ** an example
Tag: python-xarray
how to spatialy aggregate netcdf fields in python, CDO, or NCO?
I want to regrid population data from 0.05 degrees to 0.1 degrees. Because it is population, I should aggregate (sum) population values for resampling data to a coarser resolution. Although I thought that there going to be a simple answer to this question, I did find any yet. I think my question does not need sample data, but you may
Python – Selecting data from at one specific time per day
I’m quite new to Python and have a simple question (I think). I have an array with hourly data for an entire month. I want to make a new array with only data at a specific time every day (at 00:00 UTC). How do I do this? This is what the array looks like: Thank you for your help! Answer
Extract values from xarray dataset using geopandas multilinestring
I have a few hundred geopandas multilinestrings that trace along an object of interest (one line each week over a few years tracing the Gulf Stream) and I want to use those lines to extract values from a few other xarray datasets to know sea surface temperature, chlorophyll-a, and other variables along this path each week. I’m unsure though how
How to calculate the euclidian distance between a specified coordinate and 2-d xarray data at once
How to calculate the euclidian distance between a specified coordinate and 2-d xarray data at once (without for loop)? I wrote the following code. But if the data-size become larger, this script appears to be slow. How can I do the same thing without for loop ? Answer First things first, xarray_distance = data_xarray does not copy the object. Both
rioaxrray open netcdf file result is a list not an xarray
I am trying to open a netcdf file using rioarray: import rioxarray import xarray import raster xds = rioxarray.open_rasterio(file, crs=’+proj=latlong’, masked=True) but: type(xds) list and xds has none of the attributes or methods of an xarray. xds_lonlat = xds.rio.reproject(“epsg:4326”) AttributeError Traceback (most recent call last) in —-> 1 xds_lonlat = xds.rio.reproject(“epsg:4326”) AttributeError: ‘list’ object has no attribute ‘rio’ clipped =
How to avoid unsupported .nc file while reading from different directory
I have several folders in a directory containing .nc files. While reading, I am getting an error: NETCDF can not read unsupported file Since there are more than 5 thousand files, I don’t know which file is corrupted or unsupported. Is there any way to read files by jumping into another supported file? The code that I am using is:
Getting very slow iterations in a loop run over a Datarray using Xarray and Dask
I am trying to calculate windspeed from u and v components for 1 year data at hourly timestep and 0.1 x 0.1 Degree resolution for a total of 40 years. The individual u and v netcdf files for 1 year is about 5GB each. I have implemented a basic for loop where the u and v netcdf files for each
ValueError: cannot convert a DataFrame with a non-unique MultiIndex into xarray
These are the data I want to convert which are saved in CSV. And some of the longitude and latitude may are repeated, actually, they are extracted from a NetCDF file. So I want to convert them to xarray because I need the ‘pr’ to be 2D(with no repeated long or lat) like the following one. Here is my code:
How to make a sum in NetCDF4 by xarray
I would like to make a monthly sums of my NetCDF4 file from daily values for precipitation. However, I am quite not sure what I am doing wrong. It seems that something has changed from the code in this post: Sum a daily time series into a monthly time series with a NaN value threshold I didn’t find anything helpful