pydap.handlers.pcic¶
This module provides an Pydap handler which reads in-situ observations out of the BC Provincial Climate Data Set. It is implemented as a subclass of pydap.handlers.sql.Handler
(the Pydap SQL handlers). Since the Pydap SQL handler is written to use an on-disk config file for each dataset, this handlers generates the config file dynamically in memory and then uses it to instantiate the base class.
The handler will configure a different dataset for each station based on the file path of the request. In general the file path is assumed to be
.../(raw|climo)/[network_name]/[native_id]/
Each dataset will contain a variety of global attributes such as the station and network names, latitude and longitide of the station and some contact information. Each dataset will contain one sequence named station_observations
and some number of variables (including time) attached to that sequence. Each variable will be attributed with its name, long_name, CF standard_name, CF cell_method and the units.
-
class
pydap.handlers.pcic.
ClimoPcicSqlHandler
(dsn, sesh=None)¶ Subclass of PcicSqlHandler which handles the climatological observations
-
get_full_query
(stn_id, sesh)¶ Sends a special query to the database that actually retrieves generated SQL for constructing an observation table (time by variable) for a single station. Uses the
query_one_station
stored procedure.Parameters: - stn_id (int or str) – the database station_id of the desired station
- sesh – sqlalchemy session
-
get_vars
(stn_id, sesh)¶ Makes a database query to retrieve all of the climatological variables for a particular station
-
-
class
pydap.handlers.pcic.
PcicSqlHandler
(dsn, sesh=None)¶ A Pydap handler which reads in-situ observations from the BC Provincial Climate Data Set.
-
__call__
(environ, start_response)¶ Parameters: environ – WSGI environment such that PATH_INFO is set to something that matches the pattern /[network_name]/[native_id].sql.[response] Return type: iterable WSGI response
-
__init__
(dsn, sesh=None)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__weakref__
¶ list of weak references to the object (if defined)
-
create_ini
(sesh, net_name, native_id)¶ Creates the actual text of a pydap SQL handler config file and returns it as a StringIO. self.filepath should be set before this is called. It will typically be something like
.../[network_name]/[native_id].rsql
. The database station_id is looked up from that.Parameters: environ – WSGI environment which must contain a dsn string under the key pydap.handlers.pcic.dsn Return type: StringIO.StringIO
-
-
class
pydap.handlers.pcic.
RawPcicSqlHandler
(dsn, sesh=None)¶ Subclass of PcicSqlHandler which handles the raw observations
-
get_full_query
(stn_id, sesh)¶ Sends a special query to the database that actually retrieves generated SQL for constructing an observation table (time by variable) for a single station. The query needs to return at least one column (obs_time) with additional columns for each available variable, if any. Uses the
query_one_station
stored procedure.Parameters: - stn_id (int or str) – the database station_id of the desired station
- sesh – an sqlalchemy session
-
get_vars
(stn_id, sesh)¶ Makes a database query to retrieve all of the raw variables for a particular station
-
-
pydap.handlers.pcic.
session_scope
(*args, **kwds)¶ Provide a transactional scope around a series of operations.