ioos / pyoos

A Python library for collecting Met/Ocean observations
GNU Lesser General Public License v3.0
34 stars 33 forks source link

USGS REST Collector #82

Open DanRamage opened 7 years ago

DanRamage commented 7 years ago

Internally the Usgs collector puts the date/time into UTC, however I do not think the formatted REST request is correct for that type of query. Looking at the documentation on the USGS test service, they define the date formats as such(using the start time as example):

URL argument name is startDT. Use the ISO-8601 date format External Link. Examples: &startDT=2010-07-01T12:00 (site local time), &startDT=2010-07-01T12:00-05:00 (Eastern Standard Time), &startDT=2010-07-01T12:00Z (Universal Time) or startDT=2010-07-01. If you do not specify an hour, T00:00 for the start date is assumed.

A + timezone offset must be coded as %2B in the URL. The TestTool here will do this automatically for you. Example: To indicate T15:00+01:00 Use &startdt=2015-05-01T15:00%2B01:00.

With Start Date and End Date you can express an absolute site time period for retrieval. Real time data typically lag 0-4 hours behind the current time. Start Date and End Date values are inclusive. For example, if you specify a Start Date of 2009-06-15T22:15 and a reading is available for this time, it will appear in the results. For multi-site retrievals, only data since October 1, 2007 are available.

In the collector in the setup_params function, I made the following changes and it appears to now return me the date/times I expec, note the "Z" added to the end of the string formating:

        if self.start_time is not None:
            params["startDT"] = self.start_time.strftime('%Y-%m-%dT%H:%MZ')
        if self.end_time is not None:
            params["endDT"] = self.end_time.strftime('%Y-%m-%dT%H:%MZ')