tsutterley / pyTMD

Python-based tidal prediction software
https://pytmd.readthedocs.io
MIT License
125 stars 39 forks source link

Netcdf time needs to be double #161

Open bjarnebuchmann opened 1 year ago

bjarnebuchmann commented 1 year ago

When compute_tidal_elevations.py is used to create netcdf output, time is defined as a float (4-byte, NCFLOAT), using units: time:units = "days since 1992-01-01T00:00:00" ; Unfortunately, the default float does not contain enough accuracy for this process. At present time (>30 years after 1992-01-01), most of the significant digits are used on the days-part (integer part), leaving only about 2 digits for time-of-day. For instance, when I define (input) time as every 10 minutes for an hour of 2023-01-30 (using another time:units), the values are correctly read and converted, but upon output the time values are: time = 10622, 10622.01, 10622.01, 10622.02, 10622.03, 10622.04, 10622.04 ; There is a clear loss of accuracy going on. Other coordinate variables (x,y) are already defined as double. It is necessary that time be defined as double as well.

Thank you, Bjarne

bjarnebuchmann commented 1 year ago

If possible, take the time kind and units from the input netcdf file and use same in output. The actual values are already present, so they do not need to be converted back from the internal units, as long as they are not thrown away during the process.