sensortoolkit.reference._ref_api_query

This module contains methods for querying reference data APIs, including the AirNow and Air Quality System (AQS) API services.

These services are operated by the U.S. EPA, and users should have previously registered with either service before submitting queries (authentication tokens are required for each service to validate query requests).

Resources


@Author:
Samuel Frederick, NSSC Contractor (ORAU)
U.S. EPA / ORD / CEMM / AMCD / SFSB
Created:

Mon May 3 12:56:38 2021

Last Updated:

Wed Jul 14 14:27:21 2021

Functions

date_range_selector

Generate two arrays (month_starts and month_ends) for which queries will be constructed in consecutive monthly segments.

ingest_airnow

Convert AirNow query data to SDFS formatted datasets.

ingest_aqs

Convert AQS query data to SDFS formatted datasets.

modify_ref_cols

Modify the data type of columns in reference data and reorder columns.

modify_ref_method_str

Subroutine for Ref_API_Query tha replaces various characters in data columns containing text, including the method name and the parameter units.

parse_sample_data

Helper function for ingesting AQS 'sampleData' queries.

query_airnow

Construct an AirNow API query request and parse response.

query_aqs

Construct an AQS API query request and parse response.

query_periods

Generate a dictionary with consecutive monthly intervals to query where dates are formatted a little differently depending on the API to query.

ref_api_query

Wrapper function for sending an API data query to either the AQS or AirNow API for a specified parameter (param).

save_api_dataset

Save processed datasets at regular monthly intervals.

select_poc

Ask the user for a single POC if multiple codes present in dataset.