Unidata / ncWMS

Snapshots of ncWMS used by TDS
8 stars 7 forks source link

Remove broken legacy code for time axes. #8

Closed joanpau closed 9 years ago

joanpau commented 10 years ago

Ncwms produces an error when handling variables with a time coordinate when the reference date in the units attribute includes the valid time zone specifications Z or UTC. This can be checked in the example dataset 1. The removal of some legacy code fixes the issue.

Ncwms uses org.joda.time.DateTime as the type of time instants. The conversion from numeric values of time variable coordinates (time axes) in NetCDF datasets is done by the function CdmUtils.getTimesteps as follows:

  1. When a time axis uses the standard (gregorian) calendar the conversion is based on the CoordinateAxis1DTime.getCalendarDates method.
  2. Otherwise, the conversion falls back to some legacy code which does not parse correctly the units attribute. It fails when the time zone of the reference date is not specified exacty as HH, -HH, HH:MM or -HH:MM (for example UTC, or Z, or +HH:MM).

It seems that the reasons for this are historical. Probably the netcdf-java classes did not handle non-standard calendars properly when that code was written, and custom code based on the org.joda.time.Chronology type was developed for that cases.

However, it seems that this code has been already included in the netcdf-java classes, so the non-standard calendars are properly handled by the CoordinateAxis1DTime.getCalendarDates method, which does not suffer from the error parsing the reference date.

The proposal consists solely on the removal of that legacy code.

lesserwhirls commented 9 years ago

Again, sorry for the delay, and thanks for the pull request!