Synthesis Views
This is the main package, containing the BASIN-3D Django Framework’s synthesis view classes used for building custom a brokering service.
django_basin3d.synthesis.viewsets
- synopsis:
BASIN-3D Synthesis Model Viewsets (View Controllers) that support the REST API
- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class django_basin3d.synthesis.viewsets.DataSourcePluginViewSet[source]
Base ViewsSet for all DataSource plugins. This class extends the Django Rest Framework class
rest_framework.viewsets.ViewSet. These are based on Django generic views.- property catalog
- list(**kwargs)[source]
Return the synthesized plugin results
- Parameters:
request (
rest_framework.request.Request) – The incoming request objectformat – The format to present the data (default is json)
- Returns:
The HTTP Response
- Return type:
rest_framework.request.Response
- property plugins
- retrieve(**kwargs)[source]
Retrieve a single object
- Parameters:
pk – The primary key
- Returns:
The HTTP Response
- Return type:
rest_framework.request.Response
- versioning_class
alias of
NamespaceVersioning
- class django_basin3d.synthesis.viewsets.MeasurementTimeseriesTVPObservationViewSet[source]
MeasurementTimeseriesTVPObservation: Series of measurement (numerical) observations in TVP (time value pair) format grouped by time (i.e., a timeseries).
Synthesis Response This endpoint returns the following synthesis response object.
`json { "query": {}, "data": [] } `Data Attributes Attribute for each data element from the synthesis response is as follows:
id: string, Observation identifier (optional)
type: enum, MEASUREMENT_TVP_TIMESERIES
observed_property: str, BASIN-3D vocabulary for the observation’s observed property
datasource: URL, url of the datasource
sampling_medium: enum, sampling medium of the observed property (SOLID_PHASE, WATER, GAS, OTHER)
phenomenon_time: datetime, datetime of the observation, for a timeseries the start and end times can be provided
utc_offset: float, Coordinate Universal Time offset in hours (offset in hours), e.g., +9
feature_of_interest: MonitoringFeature obj, feature on which the observation is being made
feature_of_interest_type: enum (FeatureTypes), feature type of the feature of interest
result: dict of corresponding lists of TimeValuePairs, the observed values of the observed property being assessed, and (opt) their result_quality,
time_reference_position: enum, position of timestamp in aggregated_duration (START, MIDDLE, END)
aggregation_duration: enum, time period represented by observation (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND)
unit_of_measurement: string, units in which the observation is reported
statistic: enum, statistical property of the observation result (MEAN, MIN, MAX, TOTAL)
result_quality: list of enum, quality assessment of the result enum (VALIDATED, UNVALIDATED, SUSPECTED, REJECTED, ESTIMATED)
Filter by the following attributes (?attribute=parameter,parameter&attribute=parameter&…):
monitoring_feature (required): comma separated list of monitoring_features ids
observed_property (required): comma separated list of observed property basin3d vocabularies
start_date (required): date YYYY-MM-DD
end_date (optional): date YYYY-MM-DD
aggregation_duration (default: DAY): enum (YEAR|MONTH|DAY|HOUR|MINUTE|SECOND|NONE)
statistic (optional): comma separated list of statistic enum(s) (MEAN|MIN|MAX|INSTANTANEOUS)
result_quality (optional): comma separated list of result quality enum(s) enum (VALIDATED|UNVALIDATED|SUSPECTED|REJECTED|ESTIMATED)
sampling_medium (optional): comma separated list of sampling medium enum(s) (SOLID_PHASE|WATER|GAS|OTHER)
datasource (optional): a single data source id prefix (e.g ?datasource=`datasource.id_prefix`)
Restrict fields with query parameter fields. (e.g. ?fields=id,name)
- serializer_class
- synthesis_model
alias of
MeasurementTimeseriesTVPObservation
- class django_basin3d.synthesis.viewsets.MonitoringFeatureViewSet[source]
MonitoringFeature: A feature upon which monitoring is made. OGC Timeseries Profile OM_MonitoringFeature.
Synthesis Response This endpoint returns the following synthesis response object.
`json { "query": {}, "data": [] } `Data Attributes Attribute for each data element from the synthesis response is as follows:
id: string, Unique feature identifier
name: string, Feature name
description: string, Description of the feature
feature_type: sting, FeatureType: REGION, SUBREGION, BASIN, SUBBASIN, WATERSHED, SUBWATERSHED, SITE, PLOT, HORIZONTAL PATH, VERTICAL PATH, POINT
observed_properties: list of observed variables made at the feature. Observed property variables are configured via the plugins.
related_sampling_feature_complex: list of related_sampling features. PARENT features are currently supported.
shape: string, Shape of the feature: POINT, CURVE, SURFACE, SOLID
coordinates: location of feature in absolute and/or representative datum
description_reference: string, additional information about the Feature
related_party: (optional) list of people or organizations responsible for the Feature
utc_offset: float, Coordinate Universal Time offset in hours (offset in hours), e.g., +9
url: url, URL with details for the feature
Filter by the following attributes (/?attribute=parameter&attribute=parameter&…)
datasource (optional): a single data source id prefix (e.g ?datasource=`datasource.id_prefix`)
parent_feature (optional): a monitoring feature name
Restrict fields with query parameter fields. (e.g. ?fields=id,name)
- list(request, format=None)[source]
Return the synthesized plugin results
- Parameters:
request (
rest_framework.request.Request) – The incoming request objectformat – The format to present the data (default is json)
- Returns:
The HTTP Response
- Return type:
rest_framework.request.Response
- retrieve(request, pk)[source]
Retrieve a single object
- Parameters:
pk – The primary key
- Returns:
The HTTP Response
- Return type:
rest_framework.request.Response
- serializer_class
alias of
MonitoringFeatureSerializer
- synthesis_model
alias of
MonitoringFeature
- platform:
Unix, Mac
- synopsis:
BASIN-3D
DataSourcesynthesis classes- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class basin3d.core.synthesis.DataSourceModelAccess(plugins, catalog)[source]
Base class for DataSource model access.
- list(query)[source]
Return the synthesized plugin results
- Parameters:
query (
QueryBase) – The query for this function- Return type:
- property plugins
- retrieve(query, **kwargs)[source]
Retrieve a single synthesized value
- Parameters:
query (
QueryBase) – The query for this requestkwargs – messages, list of messages to be returned in the SynthesisResponse
- Return type:
- property synthesis_model
- synthesize_query(plugin_access, query)[source]
Synthesizes query parameters, if necessary
- Parameters:
query (
QueryBase) – The query information to be synthesizedplugin_access (
DataSourcePluginAccess) – The plugin view to synthesize query params for
- Return type:
- Returns:
The synthesized query information
- class basin3d.core.synthesis.DataSourceModelIterator(query, model_access)[source]
BASIN-3D Data Source Model generator
- log(message, level=None, where=None)[source]
Add a synthesis message to the synthesis response :type message:
str:param message: The message :type level:Optional[MessageLevelEnum] :param level: The message level :return: None
- property synthesis_response: SynthesisResponse
Response object for the Synthesis
- class basin3d.core.synthesis.MeasurementTimeseriesTVPObservationAccess(plugins, catalog)[source]
MeasurementTimeseriesTVPObservation: Series of measurement (numerical) observations in TVP (time value pair) format grouped by time (i.e., a timeseries).
Properties
id: string, Observation identifier (optional)
type: enum, MEASUREMENT_TVP_TIMESERIES
observed_property: url, URL for the observation’s observed property
phenomenon_time: datetime, datetime of the observation, for a timeseries the start and end times can be provided
utc_offset: float, Coordinate Universal Time offset in hours (offset in hours), e.g., +9
feature_of_interest: MonitoringFeature obj, feature on which the observation is being made
feature_of_interest_type: enum (FeatureTypes), feature type of the feature of interest
result: dictionary of 2 lists: “value” contains TimeValuePair obj and “quality” the corresponding quality assessment per value, observed values and their quality for the observed property being assessed
time_reference_position: enum, position of timestamp in aggregated_duration (START, MIDDLE, END)
aggregation_duration: enum, time period represented by observation (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, NONE)
unit_of_measurement: string, units in which the observation is reported
statistic: list, statistical properties of the observation result (MEAN, MIN, MAX, TOTAL)
result_quality: list, quality assessment values contained in the result (VALIDATED, UNVALIDATED, SUSPECTED, REJECTED, ESTIMATED)
Filter by the following attributes:
monitoring_feature (required): List of monitoring_features ids, and / or bounding box coordinates (WGS84: western longitude, eastern longitude, southern latitude, northern latitude)
observed_property (required): List of observed property variable ids
start_date (required): date YYYY-MM-DD
end_date (optional): date YYYY-MM-DD
aggregation_duration (default: DAY): enum (YEAR|MONTH|DAY|HOUR|MINUTE|SECOND|NONE)
statistic (optional): List of statistic options, enum (INSTANT|MEAN|MIN|MAX|TOTAL)
datasource (optional): a single data source id prefix (e.g ?datasource=`datasource.id_prefix`)
result_quality (optional): enum (VALIDATED|UNVALIDATED|SUSPECTED|REJECTED|ESTIMATED)
sampling_medium (optional): enum (SOLID_PHASE|WATER|GAS|OTHER)
- synthesis_model
alias of
MeasurementTimeseriesTVPObservation
- synthesize_query(plugin_access, query)[source]
Synthesizes query parameters, if necessary
- Parameters Synthesized:
monitoring_feature
observed_property
aggregation_duration (default: DAY)
statistic
quality_checked
- Parameters:
query (
QueryMeasurementTimeseriesTVP) –plugin_access (
DataSourcePluginAccess) – The plugin view to synthesize query params for
- Return type:
- Returns:
The query parameters
- class basin3d.core.synthesis.MonitorMixin[source]
Adds monitor log functionality to a class for logging synthesis messages
- critical(message, where=None)[source]
Add a critical level message :type where:
Optional[List] :param where: :type message:str:param message: :rtype:Optional[SynthesisMessage] :return:
- error(message, where=None)[source]
Add a error level message :type where:
Optional[List] :param where: :type message:str:param message: :rtype:Optional[SynthesisMessage] :return: SynthesisMessage
- info(message, where=None)[source]
Add a info level message :type where:
Optional[List] :param where: :type message:str:param message: :return: None
- log(message, level=None, where=None)[source]
Add a synthesis message to the synthesis response :type message:
str:param message: The message :type level:Optional[MessageLevelEnum] :param level: The message level :type where:Optional[List] :param where: Where the message is from :rtype:Optional[SynthesisMessage] :return: SynthesisMessage
- class basin3d.core.synthesis.MonitoringFeatureAccess(plugins, catalog)[source]
MonitoringFeature: A feature upon which monitoring is made. OGC Timeseries Profile OM_MonitoringFeature.
Properties
id: string, Unique feature identifier
name: string, Feature name
description: string, Description of the feature
feature_type: sting, FeatureType: REGION, SUBREGION, BASIN, SUBBASIN, WATERSHED, SUBWATERSHED, SITE, PLOT, HORIZONTAL PATH, VERTICAL PATH, POINT
observed_properties: list of observed properties (variables) made at the feature. Observed properties are configured via the plugins.
related_sampling_feature_complex: list of related_sampling features. PARENT features are currently supported.
shape: string, Shape of the feature: POINT, CURVE, SURFACE, SOLID
coordinates: location of feature in absolute and/or representative datum
description_reference: string, additional information about the Feature
related_party: (optional) list of people or organizations responsible for the Feature
utc_offset: float, Coordinate Universal Time offset in hours (offset in hours), e.g., +9
url: url, URL with details for the feature
Filter by the following attributes
datasource (optional): str, a single data source id prefix
id (optional): str, a single monitoring feature id. Cannot be combined with monitoring_feature
parent_feature (optional): list, a list of parent feature ids. Plugin must have this functionality enabled.
monitoring_feature (optional): list, a list of monitoring feature ids and / or bounding box coordinates (WGS84: western longitude, eastern longitude, southern latitude, northern latitude). Cannot be combined with id, which will take precedence.
- retrieve(query)[source]
Retrieve the specified Monitoring Feature
- Parameters:
query (
QueryMonitoringFeature) –basin3d.core.schema.query.QueryMonitoringFeature, id must be specified; monitoring_feature if specified will be removed.- Return type:
- Returns:
The synthesized response containing the specified MonitoringFeature if it exists
- synthesis_model
alias of
MonitoringFeature
- synthesize_query(plugin_access, query)[source]
Synthesizes query parameters, if necessary
Parameters Synthesized:
- Parameters:
query (
QueryMonitoringFeature) – The query information to be synthesizedplugin_access (
DataSourcePluginAccess) – The plugin view to synthesize query params for
- Return type:
- Returns:
The synthesized query information
- platform:
Unix, Mac
- synopsis:
BASIN-3D
DataSourceplugin classes- module author:
Val Hendrix <vhendrix@lbl.gov>
- module author:
Danielle Svehla Christianson <dschristianson@lbl.gov>
- class basin3d.core.plugin.DataSourcePluginAccess(datasource, catalog)[source]
Metaclass for DataSource plugin views. The should be registered in a subclass of
basin3d.plugins.DataSourcePluginPointin attribute plugin_access_classes.- property datasource
- get_attribute_mappings(attr_type=None, attr_vocab=None, from_basin3d=False)[source]
General purpose search for attribute mappings from datasource or BASIN-3D vocabularies. Returns an iterator that yields basin3d.models.MappedAttribute objects that match the criteria :type attr_type: :param attr_type: :type attr_vocab: :param attr_vocab: :type from_basin3d: :param from_basin3d: :return:
- class basin3d.core.plugin.DataSourcePluginPoint(catalog)[source]
Base class for DataSourcePlugins.
- get_datasource()[source]
Get the basin3d.models.DataSource record for the subclass of this Plugin. # :return:
- class basin3d.core.plugin.PluginMount[source]
The idea for the Simple Plugin Framework comes from a post by Marty Alchin on January 10, 2008 about Django
it is under CC-BY-SA 3.0 US License (https://creativecommons.org/licenses/by-sa/3.0/us/)
Plugin classes that extend this will register themselves as soon as they are loaded
-
plugins:
Dict[DataSourcePluginPoint,str] = {'USGS': <class 'basin3d.plugins.usgs.USGSDataSourcePlugin'>}
-
plugins:
- basin3d.core.plugin.get_feature_type(feature_type, return_format='enum')[source]
Return the feature type if exists in the request :type feature_type: :param feature_type: :type return_format: :param return_format: “enum” (default) = the FeatureTypeEnum enum, otherwise return the text version :return: the feature_type in the format specified, None if none exists