Substitute dataset coordinates in xarray (Python) -


i have dataset stored in netcdf4 format consists of intensity values 3 dimensions: loop, delay , wavelength. named coordinates same dimensions (i don't know if it's or bad...)

i'm using xarray (formerly xray) in python load dataset:

import xarray xr ds = xr.open_dataset('test_data.netcdf4') 

now want manipulate data while keeping track of original data. instance, would:

  1. apply offset delay coordinates , keep original delay dataarray untouched. seems done with:

    ds_ = ds.assign_coords(delay_corr=ds_.delay.copy(deep=true) + 25)

  2. substitute coordinates delay delay_corr relevant dataarrays in dataset. however, have no clue how , didn't find in documentation.

would know how perform item #2?

to download netcdf4 file test data: http://1drv.ms/1qhqtry

the method you're looking xr.swap_dims() method:

ds.coords['delay_corr'] = ds.delay + 25  # use assign_coords ds2 = ds.swap_dims({'delay': 'delay_corr'}) 

see this section of xarray docs full example.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -