I'm trying to extract a time series csv from a netcdf file. I have a tried a few options and it seems that using xarray is the simplest one.
My variables I want are 'time' 'stage' and I want to specify the coords of 'x' and 'y' Time happens to be in seconds, which messed me up when I tried the netCDF4 answers on this site.
I tried the following
import xarray as xr
ds = xr.open_dataset('boundary_conditions.sts')
xi = 125285.25; yi = 42519.85
dsloc = ds.sel(x=xi, y=yi, method='nearest')
dsloc['stage'].plot()
But I don't get past the 'dsloc' section as it says x is not defined.
Ideally I would also like to export it as a csv.
I'm sure it's an easy fix but I don't know what it is...
please help
This is the file if it helps
https://www.dropbox.com/s/dr3k7zynt54joti/boundary_conditions.sts?dl=0
Ideally, you would provide a reproducible example, but the following code should probably replace your final line:
dsloc.stage.plot()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.