bwiggs / go-nexrad

NEXRAD Data Processing with Go
https://bwiggs.com/projects/go-nexrad/
MIT License
26 stars 12 forks source link

Fix timestamp conversion & add to Message31Header #3

Closed phemmer closed 2 years ago

phemmer commented 4 years ago

This fixes the conversion from modified julian date to provide the correct value. You could change the epoch date instead, but subtracting 1 is the same method used by the NetCDF library (https://github.com/Unidata/netcdf-java/blob/3ce72c0cd167609ed8c69152bb4a004d1daa9273/cdm/radial/src/main/java/ucar/nc2/iosp/nexrad2/Level2Record.java#L381-L383), so I opted for consistency.

This PR also adds a Date() function to Message31Header so users don't have to perform calculation manually.

As an example of the fix, here's a Level-II archive as reported by the official NOAA toolkit: image

Before change, the time was reported as 2020-06-01 03:02:27.127 +0000 UTC. After change, the time is reported as 2020-05-31 03:02:27.127 +0000 UTC.

Also as a nitpick, `Add(time.Hour24time.Duration(days) + time.Duration(ms)time.Millisecond)` would be a lighter method of adding the days. But that's just personal preference, and won't make much difference unless it's called a ton.*

bwiggs commented 2 years ago

Thank you! sorry for the massive delay on this.