Configuration Options for EPA AQS Package

Module contains classes to describe the context in which AQS data is downloaded

class Parameter(*values)[source]

An Enum with mnemonic names for the most common EPA AQS Parameter Codes See more at https://www.epa.gov/aqs/aqs-code-list

NO2 = 42602

NO2

OZONE = 44201

ozone

PM25 = 88101

PM25

MAX_TEMP = 68104

maximum temperature

MIN_TEMP = 68103

minimum temperature

conjugate()

Returns self, the complex conjugate of any int.

bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

real

the real part of a complex number

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

denominator

the denominator of a rational number in lowest terms

class Aggregation(*values)[source]

An Enum used to specify how the data is aggregated in time

ANNUAL = 'annual'

annual aggregation

DAILY = 'daily'

daily aggregation

class AQSContext(doc=None)[source]

This class is part of EPA AQS Toolkit. It allows user to define any parameters that are used to select what data to download, how to format it and where to place the results.

It is a concrete subclass of :class Context:

Constructor

Parameters:

doc – Optional argument, specifying what to print as documentation

classmethod enum(enum_cls, s: str)

A helper method to return Enum value by its name

Parameters:
  • cls – Enum class

  • s – name of a member in Enum class

Returns:

value of the member

years

Year or list of years to download. For example, the following argument: -y 1992:1995 1998 1999 2011 2015:2017 will produce the following list: [1992,1993,1994,1995,1998,1999,2011,2015,2016,2017]

compress

Specifies whether to use gzip compression for the result

parameters

Parameters (variables, e.g. PM25, NO2, etc.) to download

aggregation

Aggregation: daily or annual

destination

Destination directory for the downloaded files

merge_years

Whether to concatenate consecutive years in one file

validate(attr, value)[source]

AQS specific code to handle years and EPA Parameter Codes

Parameters:
Returns:

Classes used Internally

Abstract Context

class Context(subclass, description=None, include_default: bool = True)[source]

Generic class allowing to build context and configuration objects and initialize them using command line arguments

Creates a new object

Parameters:
  • subclass – A concrete class containing configuration information Configuration options must be defined as class memebers with names, starting with one ‘_’ characters and values be instances of :class Argument:

  • description – Optional text to use as description. If not specified, then it is extracted from subclass documentation

years

Year or list of years to download. For example, the following argument: -y 1992:1995 1998 1999 2011 2015:2017 will produce the following list: [1992,1993,1994,1995,1998,1999,2011,2015,2016,2017]

compress

Specifies whether to use gzip compression for the result

validate(attr, value)[source]

Subclasses can override this method to implement custom handling of command line arguments

Parameters:
  • attr – Command line argument name

  • value – Value returned by argparse

Returns:

value to use

classmethod enum(enum_cls, s: str)[source]

A helper method to return Enum value by its name

Parameters:
  • cls – Enum class

  • s – name of a member in Enum class

Returns:

value of the member

Argument

class Argument(name, help: str, type=<class 'str'>, aliases: ~typing.List = None, default=None, cardinality: ~dorieh.utils.context.Cardinality = Cardinality.single, valid_values=None, required=True)[source]

A wrapper class to describe a command-line arguments This is practically, a more rigid format for :func ArgumentParser.add_argument:

All arguments are passed to Argparser

Parameters:
  • name

  • help

  • type

  • aliases

  • default

  • cardinality

  • valid_values

Argument Cardinality Enum

class Cardinality(*values)[source]

Cardinality of a configuration parameter: multiple or singular