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:
apply offset
delaycoordinates , keep originaldelaydataarray untouched. seems done with:ds_ = ds.assign_coords(delay_corr=ds_.delay.copy(deep=true) + 25)substitute coordinates
delaydelay_corrrelevant 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
Post a Comment