OpenDrift / trajan

Trajectory analysis package for simulated and observed trajectories
https://opendrift.github.io/trajan/
GNU General Public License v2.0
11 stars 5 forks source link

tips and tricks: export in a way compatible with thredds servers #99

Open jerabaul29 opened 2 weeks ago

jerabaul29 commented 2 weeks ago

Looks like thredds servers do not accept int64 variables :( . I got an error message, and this seems similar to: https://stackoverflow.com/questions/48895227/output-int32-time-dimension-in-netcdf-using-xarray .

To generate files that are compatible with thredds server, and be able to upload files to e.g. adc.met.no that is hosted on thredds, one needs to make the time variables 32 bit ints (which is ok if "seconds since" and the deployment time is not many 10s of years).

This can be done by exporting as the following for now (may need to expand to more time variables if there are more included in the future):

ds.to_netcdf("./SOME_FILENAME.nc", encoding={'time': {'dtype': 'i4'}, 'time_waves_imu': {'dtype': 'i4'}})
gauteh commented 2 weeks ago

You can also set this on the variables before saving. Setting a common reference is also necessary if you want to aggregate data.