Skip to content

Parse Date/Time/Timezone in samples/WQP #266

@ldecicco-USGS

Description

@ldecicco-USGS

Both the WQP and samples output have sets of columns:

Activity_StartDate, Activity_StartTime, Activity_StartTimeZone
Activity_EndDate, Activity_EndTime, Activity_EndTimeZone
LabInfo_AnalysisStartDate, LabInfo_AnalysisStartTime, LabInfo_AnalysisStartTimeZone

The Time column comes in as whatever time zone is set in the TimeZone column. The TimeZones are in things like "EST", "EDT", etc. In R those are not legit timezones so we created an hour offset table:
https://github.com/DOI-USGS/dataRetrieval/blob/main/R/dataRetrieval-package.R#200

In R, we look for sets of 3 columns that have the Date/Time/TimeZone suffix:
https://github.com/DOI-USGS/dataRetrieval/blob/main/R/importWQP.R#176

Then send those 3 columns to create a _DateTime column (that comes back in UTC):
https://github.com/DOI-USGS/dataRetrieval/blob/main/R/importWQP.R#245

Because of the trickiness with the timezones, it would be nice if we could run this:

discrete_data, md_qw = waterdata.get_samples(
  monitoringLocationIdentifier = "USGS-11455508",
  usgsPCode = "00631",
  activityStartDateLower = "2024-01-01",
  activityStartDateUpper = "2024-06-01",
  profile = "basicphyschem"
)

and see a column like this returned:

discrete_data['Activity_StartDate'][1]
'2024-01-09'
 discrete_data['Activity_StartTime'][1]
'10:00:00'
 discrete_data['Activity_StartTimeZone'][1]
'PST'

discrete_data['Activity_StartDateTime'][1]
Timestamp('2024-01-09 18:00:00')

(not sure if that's exactly how it's printed out...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions