metloom.pointdata package

Submodules

metloom.pointdata.base module

class metloom.pointdata.base.PointData(station_id, name, metadata=None)[source]

Bases: object

ALLOWED_VARIABLES

alias of VariableBase

DATASOURCE = None
EXPECTED_COLUMNS = ['geometry', 'datasource']
EXPECTED_INDICES = ['datetime', 'site']
ITERATOR_CLASS

alias of PointDataCollection

NON_VARIABLE_COLUMNS = ['datetime', 'site', 'geometry', 'datasource']
POINTS_FROM_GEOM_DEFAULTS = {'buffer': 0.0, 'filter_to_active': False, 'snow_courses': False, 'within_geometry': True}
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get daily measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get snow course data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

property metadata

metadata property Returns:

shapely.point.Point object in Longitude, Latitude with z in ft

points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], snow_courses=False, within_geometry=True, buffer=0.0)[source]

Find a collection of points with measurements for certain variables contained within a shapefile. Any point in the shapefile with measurements for any of the variables should be included Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: boolean for including only snowcourse data or no

snowcourse data

within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize

classmethod validate_sensor_df(gdf: GeoDataFrame)[source]

Validate that the GeoDataFrame returned is formatted correctly. The goal of this method is to ensure base classes are returning a consistent format of dataframe

class metloom.pointdata.base.PointDataCollection(points: Optional[List[object]] = None)[source]

Bases: object

Iterator class for a collection of PointData objects. This allows conversion to a GeoDataFrame

add_point(point)[source]

Append point to collection of PointData objects

Args:

point: PointData object

to_dataframe()[source]
Returns:

GeoDataFrame of points. Columns are [‘name’, ‘id’, ‘geometry’]

metloom.pointdata.cdec module

class metloom.pointdata.cdec.CDECPointData(station_id, name, metadata=None)[source]

Bases: PointData

Implement PointData methods for CDEC data source API documentation here https://cdec.water.ca.gov/dynamicapp/

ALLOWED_VARIABLES

alias of CdecStationVariables

CDEC_URL = 'http://cdec.water.ca.gov/dynamicapp/req/JSONDataServlet'
DATASOURCE = 'CDEC'
META_URL = 'https://cdec.water.ca.gov/dynamicapp/staMeta'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://cdec.water.ca.gov/dynamicapp/req/JSONDataServlet? Stations=TNY&SensorNums=3&dur_code=D&Start=2021-05-16&End=2021-05-16

get_event_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]
get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_snow_course_data

is_only_monthly()[source]

determine if all sensors for a station are on a monthly interval

is_only_snow_course(variables: List[SensorDescription])[source]

Determine if a station only has snow course measurements

is_partly_snow_course()[source]

Determine if any of the snow sensors at a station are on a monthly interval Assumption: Monthly snow sensor measurements are snow courses

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: Boolean for including only snowcourse data or no snowcourse data within_geometry: filter the points to within the shapefile instead of just the extents. Default True buffer: buffer added to search box

Returns:

PointDataCollection

metloom.pointdata.geosphere_austria module

class metloom.pointdata.geosphere_austria.GeoSphereCurrentPointData(station_id, name, metadata=None)[source]

Bases: GeoSpherePointDataBase

Implement PointData methods for GeoSphere Austria data source API documentation here https://dataset.api.hub.geosphere.at/v1/docs/index.html https://dataset.api.hub.geosphere.at/v1/docs/user-guide/resource.html

Datasets available here https://data.hub.geosphere.at/dataset/

We use tawes-v1 data which consists of data from the last 3 months in 10 minute increment

ALLOWED_VARIABLES

alias of GeoSphereCurrentVariables

DATASOURCE = 'GEOSPHERE'
META_EXTENSION = '/v1/station/current/tawes-v1-10min/metadata'
URL = 'https://dataset.api.hub.geosphere.at'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://dataset.api.hub.geosphere.at/v1/station/current/ tawes-v1-10min?parameters=TL&station_ids=11035

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

class metloom.pointdata.geosphere_austria.GeoSphereHistPointData(station_id, name, metadata=None)[source]

Bases: GeoSpherePointDataBase

Implement PointData methods for GeoSphere Austria data source API documentation here https://dataset.api.hub.geosphere.at/v1/docs/index.html https://dataset.api.hub.geosphere.at/v1/docs/user-guide/resource.html

Datasets available here https://data.hub.geosphere.at/dataset/

We use klima-v1-1d data which consists of historical daily data. There is historical hourly data, but the parameter names are different and as such this has not bee implemented

ALLOWED_VARIABLES

alias of GeoSphereHistVariables

DATASOURCE = 'GEOSPHERE'
META_EXTENSION = '/v1/station/historical/klima-v1-1d/metadata'
URL = 'https://dataset.api.hub.geosphere.at'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://dataset.api.hub.geosphere.at/v1/station/historical/klima-v1-1d ?station_ids=11401&start=2023-04-12&end=2023-04-14&parameters=schnee

class metloom.pointdata.geosphere_austria.GeoSpherePointDataBase(station_id, name, metadata=None)[source]

Bases: PointData

Implement PointData methods for GeoSphere Austria data source API documentation here https://dataset.api.hub.geosphere.at/v1/docs/index.html https://dataset.api.hub.geosphere.at/v1/docs/user-guide/resource.html

Datasets available here https://data.hub.geosphere.at/dataset/

We could either use the verified klima-v1 data or the raw tawes-v1 data. Kilma has hourly and daily, taws is 10minute and most current

ALLOWED_VARIABLES = None
DATASOURCE = 'GEOSPHERE'
META_EXTENSION = None
URL = 'https://dataset.api.hub.geosphere.at'
classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

The Austria Geosphere API does not allow filtering by variable. As a result, we do not filter according to which points have specific variables. The function arguments allow variables to be passed in to keep consistency with the same function from other classes.

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription. NOT USED FOR THIS CLASS within_geometry: filter the points to within the shapefile instead of just the extents. Default True buffer: buffer added to search box, filter_to_active: filter to active stations

Returns:

PointDataCollection

metloom.pointdata.mesowest module

class metloom.pointdata.mesowest.MesowestPointData(station_id, name, token_json='~/.synoptic_token.json', metadata=None)[source]

Bases: PointData

ALLOWED_VARIABLES

alias of MesowestVariables

DATASOURCE = 'Mesowest'
MESO_URL = 'https://api.synopticdata.com/v2/stations/timeseries'
META_URL = 'https://api.synopticdata.com/v2/stations/metadata'
NO_DATA_MESSAGE = 'No stations found for this request.'
POINTS_FROM_GEOM_DEFAULTS = {'buffer': 0.0, 'token_json': '~/.synoptic_token.json', 'within_geometry': True}
classmethod create_token_json()[source]

Creates the neccessary synoptic token json for mesowest requests. To get public token visit: https://synopticdata.com/mesonet-api Args:

token: Syntoptic Lab’s public token.

Returns:

None

get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get daily measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

classmethod get_token(token_json)[source]

Return the token stored in the json

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box token_json: Path to the public token for the mesowest api

default = “~/.synoptic_token.json”

Returns:

PointDataCollection

property token

metloom.pointdata.snotel module

class metloom.pointdata.snotel.SnotelPointData(station_id, name, metadata=None)[source]

Bases: PointData

Implement PointData methods for SNOTEL data source API documentation here: https://www.nrcs.usda.gov/wps/portal/wcc/home/dataAccessHelp/webService/webServiceReference/ Website has variable and network codes Possible testing resource: https://wcc.sc.egov.usda.gov/awdbWebService/webservice/testwebservice.jsf?webserviceName=/awdbWebService

ALLOWED_VARIABLES

alias of SnotelVariables

DATASOURCE = 'NRCS'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_snow_course_data

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: boolean for including only snowcourse data or no

snowcourse data

within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize

metloom.pointdata.snotel_client module

class metloom.pointdata.snotel_client.BaseSnotelClient(**kwargs)[source]

Bases: object

Base snotel client class. Used for interacting with SNOTEL SOAP client. This is just a base class and not meant for direct use.

Example use with extended class:

MetaDataSnotelClient('TNY:CA:SNOW').get_data()
DEFAULT_PARAMS = {}
PARAMS_MAP = {'begin_date': 'beginDate', 'duration': 'duration', 'element_cd': 'elementCd', 'element_cds': 'elementCds', 'end_date': 'endDate', 'height_depth': 'heightDepth', 'max_latitude': 'maxLatitude', 'max_longitude': 'maxLongitude', 'min_latitude': 'minLatitude', 'min_longitude': 'minLongitude', 'network_cds': 'networkCds', 'ordinal': 'ordinal', 'parameter': 'parameter', 'station_triplet': 'stationTriplet', 'station_triplets': 'stationTriplets'}
SERVICE_NAME = None
URL = 'https://wcc.sc.egov.usda.gov/awdbWebService/services?WSDL'
get_data()[source]

Make the actual request and return data.

class metloom.pointdata.snotel_client.DailySnotelDataClient(begin_date: datetime, end_date: datetime, station_triplet: str, **kwargs)[source]

Bases: SeriesSnotelClient

Class for getting daily data

class metloom.pointdata.snotel_client.ElementSnotelClient(station_triplet: str, **kwargs)[source]

Bases: BaseSnotelClient

Get all station elements for a station triplet. Station triplets are descriptions of each sensor on the station

get_data returns a list of zeep objects. Zeep objects are indexible or attributes can be accessed with getattr or .

SERVICE_NAME = 'getStationElements'
class metloom.pointdata.snotel_client.HourlySnotelDataClient(begin_date: datetime, end_date: datetime, station_triplet: str, **kwargs)[source]

Bases: SeriesSnotelClient

Class for getting hourly data

DEFAULT_PARAMS = {'ordinal': 1}
DURATION = None
SERVICE_NAME = 'getHourlyData'
class metloom.pointdata.snotel_client.MetaDataSnotelClient(station_triplet: str, **kwargs)[source]

Bases: BaseSnotelClient

Read metadata from the metadata service for a particular station triplet

SERVICE_NAME = 'getStationMetadata'
get_data()[source]

Returns a dictionary of metadata values

class metloom.pointdata.snotel_client.PointSearchSnotelClient(max_latitude: float, min_latitude: float, max_longitude: float, min_longitude: float, network_cds: str, element_cds: str, **kwargs)[source]

Bases: BaseSnotelClient

Search for stations based on criteria. This search is default logical AND meaning all criteria need to be true. get_data returns a list of string station triplets

DEFAULT_PARAMS = {'logicalAnd': 'true'}
SERVICE_NAME = 'getStations'
class metloom.pointdata.snotel_client.SemiMonthlySnotelClient(begin_date: datetime, end_date: datetime, station_triplet: str, **kwargs)[source]

Bases: SeriesSnotelClient

Class for getting semi monthly (snow course) data

DURATION = 'SEMIMONTHLY'
class metloom.pointdata.snotel_client.SeriesSnotelClient(begin_date: datetime, end_date: datetime, station_triplet: str, **kwargs)[source]

Bases: BaseSnotelClient

Base extension for services that return timseries data.

DEFAULT_PARAMS = {'alwaysReturnDailyFeb29': 'false', 'getFlags': 'true', 'ordinal': 1}
DURATION = 'DAILY'
SERVICE_NAME = 'getData'
get_data(element_cd: str, **extra_params)[source]

get the timeseires data

Args:
element_cd: the variable code from the allowed variable codes

in the API

extra_params: kwargs for any extra parameters. These override

the default parameters

metloom.pointdata.usgs module

class metloom.pointdata.usgs.USGSPointData(station_id, name, metadata=None, duration=None)[source]

Bases: PointData

Implement PointData methods for USGS data source.

APIs and help

https://waterservices.usgs.gov/rest/DV-Service.html#Service https://waterservices.usgs.gov/rest/IV-Service.html#Service https://waterservices.usgs.gov/rest/Site-Test-Tool.html

ALLOWED_VARIABLES

alias of USGSVariables

DATASOURCE = 'USGS'
META_URL = 'https://waterservices.usgs.gov/nwis/site/'
USGS_URL = 'https://waterservices.usgs.gov/nwis/'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_instantaneous_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

USGS ‘instantaneous’ data, which is generally 15 minutes.

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize

Module contents

class metloom.pointdata.CDECPointData(station_id, name, metadata=None)[source]

Bases: PointData

Implement PointData methods for CDEC data source API documentation here https://cdec.water.ca.gov/dynamicapp/

ALLOWED_VARIABLES

alias of CdecStationVariables

CDEC_URL = 'http://cdec.water.ca.gov/dynamicapp/req/JSONDataServlet'
DATASOURCE = 'CDEC'
META_URL = 'https://cdec.water.ca.gov/dynamicapp/staMeta'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://cdec.water.ca.gov/dynamicapp/req/JSONDataServlet? Stations=TNY&SensorNums=3&dur_code=D&Start=2021-05-16&End=2021-05-16

get_event_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]
get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_snow_course_data

is_only_monthly()[source]

determine if all sensors for a station are on a monthly interval

is_only_snow_course(variables: List[SensorDescription])[source]

Determine if a station only has snow course measurements

is_partly_snow_course()[source]

Determine if any of the snow sensors at a station are on a monthly interval Assumption: Monthly snow sensor measurements are snow courses

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: Boolean for including only snowcourse data or no snowcourse data within_geometry: filter the points to within the shapefile instead of just the extents. Default True buffer: buffer added to search box

Returns:

PointDataCollection

class metloom.pointdata.GeoSphereCurrentPointData(station_id, name, metadata=None)[source]

Bases: GeoSpherePointDataBase

Implement PointData methods for GeoSphere Austria data source API documentation here https://dataset.api.hub.geosphere.at/v1/docs/index.html https://dataset.api.hub.geosphere.at/v1/docs/user-guide/resource.html

Datasets available here https://data.hub.geosphere.at/dataset/

We use tawes-v1 data which consists of data from the last 3 months in 10 minute increment

ALLOWED_VARIABLES

alias of GeoSphereCurrentVariables

DATASOURCE = 'GEOSPHERE'
META_EXTENSION = '/v1/station/current/tawes-v1-10min/metadata'
URL = 'https://dataset.api.hub.geosphere.at'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://dataset.api.hub.geosphere.at/v1/station/current/ tawes-v1-10min?parameters=TL&station_ids=11035

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

class metloom.pointdata.GeoSphereHistPointData(station_id, name, metadata=None)[source]

Bases: GeoSpherePointDataBase

Implement PointData methods for GeoSphere Austria data source API documentation here https://dataset.api.hub.geosphere.at/v1/docs/index.html https://dataset.api.hub.geosphere.at/v1/docs/user-guide/resource.html

Datasets available here https://data.hub.geosphere.at/dataset/

We use klima-v1-1d data which consists of historical daily data. There is historical hourly data, but the parameter names are different and as such this has not bee implemented

ALLOWED_VARIABLES

alias of GeoSphereHistVariables

DATASOURCE = 'GEOSPHERE'
META_EXTENSION = '/v1/station/historical/klima-v1-1d/metadata'
URL = 'https://dataset.api.hub.geosphere.at'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data Example query: https://dataset.api.hub.geosphere.at/v1/station/historical/klima-v1-1d ?station_ids=11401&start=2023-04-12&end=2023-04-14&parameters=schnee

class metloom.pointdata.MesowestPointData(station_id, name, token_json='~/.synoptic_token.json', metadata=None)[source]

Bases: PointData

ALLOWED_VARIABLES

alias of MesowestVariables

DATASOURCE = 'Mesowest'
MESO_URL = 'https://api.synopticdata.com/v2/stations/timeseries'
META_URL = 'https://api.synopticdata.com/v2/stations/metadata'
NO_DATA_MESSAGE = 'No stations found for this request.'
POINTS_FROM_GEOM_DEFAULTS = {'buffer': 0.0, 'token_json': '~/.synoptic_token.json', 'within_geometry': True}
classmethod create_token_json()[source]

Creates the neccessary synoptic token json for mesowest requests. To get public token visit: https://synopticdata.com/mesonet-api Args:

token: Syntoptic Lab’s public token.

Returns:

None

get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get daily measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

classmethod get_token(token_json)[source]

Return the token stored in the json

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box token_json: Path to the public token for the mesowest api

default = “~/.synoptic_token.json”

Returns:

PointDataCollection

property token
class metloom.pointdata.PointData(station_id, name, metadata=None)[source]

Bases: object

ALLOWED_VARIABLES

alias of VariableBase

DATASOURCE = None
EXPECTED_COLUMNS = ['geometry', 'datasource']
EXPECTED_INDICES = ['datetime', 'site']
ITERATOR_CLASS

alias of PointDataCollection

NON_VARIABLE_COLUMNS = ['datetime', 'site', 'geometry', 'datasource']
POINTS_FROM_GEOM_DEFAULTS = {'buffer': 0.0, 'filter_to_active': False, 'snow_courses': False, 'within_geometry': True}
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get daily measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get snow course data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

property metadata

metadata property Returns:

shapely.point.Point object in Longitude, Latitude with z in ft

points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], snow_courses=False, within_geometry=True, buffer=0.0)[source]

Find a collection of points with measurements for certain variables contained within a shapefile. Any point in the shapefile with measurements for any of the variables should be included Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: boolean for including only snowcourse data or no

snowcourse data

within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize

classmethod validate_sensor_df(gdf: GeoDataFrame)[source]

Validate that the GeoDataFrame returned is formatted correctly. The goal of this method is to ensure base classes are returning a consistent format of dataframe

class metloom.pointdata.PointDataCollection(points: Optional[List[object]] = None)[source]

Bases: object

Iterator class for a collection of PointData objects. This allows conversion to a GeoDataFrame

add_point(point)[source]

Append point to collection of PointData objects

Args:

point: PointData object

to_dataframe()[source]
Returns:

GeoDataFrame of points. Columns are [‘name’, ‘id’, ‘geometry’]

class metloom.pointdata.SnotelPointData(station_id, name, metadata=None)[source]

Bases: PointData

Implement PointData methods for SNOTEL data source API documentation here: https://www.nrcs.usda.gov/wps/portal/wcc/home/dataAccessHelp/webService/webServiceReference/ Website has variable and network codes Possible testing resource: https://wcc.sc.egov.usda.gov/awdbWebService/webservice/testwebservice.jsf?webserviceName=/awdbWebService

ALLOWED_VARIABLES

alias of SnotelVariables

DATASOURCE = 'NRCS'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_hourly_data

get_snow_course_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_snow_course_data

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription snow_courses: boolean for including only snowcourse data or no

snowcourse data

within_geometry: filter the points to within the shapefile

instead of just the extents. Default True

buffer: buffer added to search box

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize

class metloom.pointdata.USGSPointData(station_id, name, metadata=None, duration=None)[source]

Bases: PointData

Implement PointData methods for USGS data source.

APIs and help

https://waterservices.usgs.gov/rest/DV-Service.html#Service https://waterservices.usgs.gov/rest/IV-Service.html#Service https://waterservices.usgs.gov/rest/Site-Test-Tool.html

ALLOWED_VARIABLES

alias of USGSVariables

DATASOURCE = 'USGS'
META_URL = 'https://waterservices.usgs.gov/nwis/site/'
USGS_URL = 'https://waterservices.usgs.gov/nwis/'
get_daily_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

See docstring for PointData.get_daily_data

get_hourly_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

Get hourly measurement data Args:

start_date: datetime object for start of data collection period end_date: datetime object for end of data collection period variables: List of metloom.variables.SensorDescription object

from self.ALLOWED_VARIABLES

Returns:

GeoDataFrame of data. The dataframe should be indexed on [‘datetime’, ‘site’] and have columns [‘geometry’, ‘site’, ‘measurementDate’]. Additionally, for each variables, it should have column f’{variable.name}’ and f’{variable.name}_UNITS’ See CDECPointData._get_data for example implementation and TestCDECStation.tny_daily_expected for example dataframe. Datetimes should be in UTC

get_instantaneous_data(start_date: datetime, end_date: datetime, variables: List[SensorDescription])[source]

USGS ‘instantaneous’ data, which is generally 15 minutes.

classmethod points_from_geometry(geometry: GeoDataFrame, variables: List[SensorDescription], **kwargs)[source]

See docstring for PointData.points_from_geometry

Args:

geometry: GeoDataFrame for shapefile from gpd.read_file variables: List of SensorDescription

Returns:

PointDataCollection

property tzinfo

tzinfo that pandas can use for tz_localize