python-xarray

Calculating percentile for each gridpoint in xarray

只愿长相守 提交于 2021-02-17 06:07:38
问题 I am currently using xarray to make probability maps. I want to use a statistical assessment like a “counting” exercise. Meaning, for all data points in NEU count how many times both variables jointly exceed their threshold. That means 1th percentile of the precipitation data and 99th percentile of temperature data. Then the probability (P) of join occurrence is simply the number of joint exceedances divided by the number of data points in your dataset. <xarray.Dataset> Dimensions: (latitude:

Calculating percentile for each gridpoint in xarray

你离开我真会死。 提交于 2021-02-17 06:03:56
问题 I am currently using xarray to make probability maps. I want to use a statistical assessment like a “counting” exercise. Meaning, for all data points in NEU count how many times both variables jointly exceed their threshold. That means 1th percentile of the precipitation data and 99th percentile of temperature data. Then the probability (P) of join occurrence is simply the number of joint exceedances divided by the number of data points in your dataset. <xarray.Dataset> Dimensions: (latitude:

How do I subdivide/refine a dimension in an xarray DataSet?

社会主义新天地 提交于 2021-02-17 01:59:33
问题 Summary: I have a dataset that is collected in such a way that the dimensions are not initially available. I would like to take what is essentially a big block of undifferentiated data and add dimensions to it so that it can be queried, subsetted, etc. That is the core of the following question. Here is an xarray DataSet that I have: <xarray.Dataset> Dimensions: (chain: 1, draw: 2000, rows: 24000) Coordinates: * chain (chain) int64 0 * draw (draw) int64 0 1 2 3 4 5 6 7 ... 1993 1994 1995 1996

How to process the Time variables of OCO-2/Tropomi NETCDF4 files using Xarray?

非 Y 不嫁゛ 提交于 2021-02-11 14:02:41
问题 I am working on Tropomi .nc files. When I open the dataset using xarray, it does not process the time dimension. In Tropomi files, the time dimension is named as 'sounding_dim'. Instead of decoding the time, the returned output is just the sounding number. I have tried on OCO-2 .nc files as well. In OCO-2, the time dimension is 'sounding_id'. In case of OCO-2, the time is returned as a floating number, not as a date. The code and the output is given by: import numpy as np import xarray as xr

Xarray: Loading several CSV files into a dataset

守給你的承諾、 提交于 2021-02-11 06:37:57
问题 I have several comma-separated data files that I want to load into an xarray dataset. Each row in each file represents a different spatial value of a field in a fixed grid, and every file represents a different point in time. The grid spacing is fixed and unchanging in time. The spacing of the grid is not uniform. The ultimate goal is to compute max_{x, y} { std_t[ value(x, y, t) * sqrt(y **2 + x ** 2)] } , where sqrt is the square root, std_t is standard deviation with respect to time and

Xarray: Loading several CSV files into a dataset

柔情痞子 提交于 2021-02-11 06:37:34
问题 I have several comma-separated data files that I want to load into an xarray dataset. Each row in each file represents a different spatial value of a field in a fixed grid, and every file represents a different point in time. The grid spacing is fixed and unchanging in time. The spacing of the grid is not uniform. The ultimate goal is to compute max_{x, y} { std_t[ value(x, y, t) * sqrt(y **2 + x ** 2)] } , where sqrt is the square root, std_t is standard deviation with respect to time and

Filter data array on multiple conditions

痴心易碎 提交于 2021-02-08 09:59:06
问题 From xarray's tutorial data, I want to extract a DataArray that contains number of warm days in month, defined as between 22 and 30 Celcius: airtemps = xr.tutorial.load_dataset('air_temperature') airtemps = airtemps.sel(time=slice('2013-01-01', '2013-12-31')) airtemps['air'] = airtemps.air - 273.15 air_day = airtemps.resample('1D', 'time', how='mean') # Define multiple conditions - How can this be done programatically? I am now looking for a way to create this map below programmatically, also

Filter data array on multiple conditions

99封情书 提交于 2021-02-08 09:57:34
问题 From xarray's tutorial data, I want to extract a DataArray that contains number of warm days in month, defined as between 22 and 30 Celcius: airtemps = xr.tutorial.load_dataset('air_temperature') airtemps = airtemps.sel(time=slice('2013-01-01', '2013-12-31')) airtemps['air'] = airtemps.air - 273.15 air_day = airtemps.resample('1D', 'time', how='mean') # Define multiple conditions - How can this be done programatically? I am now looking for a way to create this map below programmatically, also

dask performance apply along axis

廉价感情. 提交于 2021-02-07 09:35:25
问题 I am trying to compute the linear trend over time on a large high resolution ocean model dataset using dask. I have followed this example (Applying a function along an axis of a dask array) and found the syntax of apply_along_axis easier. I am currently using dask.array.apply_along_axis to wrap a numpy function on 1 dimensional arrays and then package the resulting dask array into an xarray Dataarray . Using top -u <username> suggest that the computation is not executed in parallel (~100% cpu

Create and write xarray DataArray to NetCDF in chunks

◇◆丶佛笑我妖孽 提交于 2021-02-07 03:27:33
问题 Is it also possible to create an out-of-core DataArray, and write it chunk-by-chunk to a NetCDF4 file using xarray? For example, I want to be able to do this in an out-of-core fashion when the dimensions are much bigger and I thus cannot store the whole array in memory: num_steps = 20 num_times = 100 #Create DataArray d = xr.DataArray(np.zeros([num_steps, num_times], np.float32), {'Step': np.arange(num_steps), 'Time': np.arange(num_times)}, ('Step', 'Time')) #Computatation for i in range(num