broker
Broker
- class weatherDB.broker.Broker[source]
Bases:
object
A class to manage and update the database.
Can get used to update all the stations and parameters at once.
This class is only working with super user privileges.
Public Methods:
__init__
()update_raw
([only_new, paras])Update the raw data from the DWD-CDC server to the database.
update_meta
([paras])Update the meta file from the CDC Server to the Database.
update_ma
([paras])Update the multi-annual data from raster to table.
update_period_meta
([paras])Update the periods in the meta table.
quality_check
([paras, with_fillup_nd])Do the quality check on the stations raw data.
last_imp_quality_check
([paras, with_fillup_nd])Quality check the last imported data.
fillup
([paras])Fillup the timeseries.
last_imp_fillup
([paras])Fillup the last imported data.
Richter correct all of the precipitation data.
Richter correct the last imported precipitation data.
update_db
([paras])The regular Update of the database.
Initiate the Database.
vacuum
([do_analyze])get_setting
(key)Get a specific settings value.
set_setting
(key, value)Set a specific setting.
Get the package version that the databases state is at.
set_db_version
([version])Set the package version that the databases state is at.
set_is_broker_active
(is_active)Set the state of the broker.
Get the state of the broker.
Check if another broker instance is active and if so raise an error.
- check_is_broker_active()[source]
Check if another broker instance is active and if so raise an error.
- Raises:
RuntimeError – If the broker is not active.
- fillup(paras=['n', 't', 'et'])[source]
Fillup the timeseries.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- get_db_version()[source]
Get the package version that the databases state is at.
- Returns:
The version of the database.
- Return type:
version
- get_is_broker_active()[source]
Get the state of the broker.
- Returns:
Whether the broker is active.
- Return type:
bool
- get_setting(key)[source]
Get a specific settings value.
- Parameters:
key (str) – The key of the setting.
- Returns:
value – The version of the database.
- Return type:
str
- initiate_db()[source]
Initiate the Database.
Downloads all the data from the CDC server for the first time. Updates the multi-annual data and the richter-class for all the stations. Quality checks and fills up the timeseries.
- last_imp_fillup(paras=['n', 't', 'et'])[source]
Fillup the last imported data.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- last_imp_quality_check(paras=['n', 't', 'et'], with_fillup_nd=True)[source]
Quality check the last imported data.
Also fills up the daily precipitation data if the 10 minute precipitation data should get quality checked.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n”, “t”, “et”]. The default is [“n”, “t”, “et”].
with_fillup_nd (bool, optional) – Should the daily precipitation data get filled up if the 10 minute precipitation data gets quality checked. The default is True.
- quality_check(paras=['n', 't', 'et'], with_fillup_nd=True)[source]
Do the quality check on the stations raw data.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n”, “t”, “et”]. The default is [“n”, “t”, “et”].
with_fillup_nd (bool, optional) – Should the daily precipitation data get filled up if the 10 minute precipitation data gets quality checked. The default is True.
- set_db_version(version=<Version('0.0.40')>)[source]
Set the package version that the databases state is at.
- Parameters:
version (pv.Version, optional) – The Version of the python package The default is the version of this package.
- set_is_broker_active(is_active: bool)[source]
Set the state of the broker.
- Parameters:
is_active (bool) – Whether the broker is active.
- set_setting(key: str, value: str)[source]
Set a specific setting.
- Parameters:
key (str) – The key of the setting.
value (str) – The value of the setting.
- update_db(paras=['n_d', 'n', 't', 'et'])[source]
The regular Update of the database.
Downloads new data. Quality checks the newly imported data. Fills up the newly imported data.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- update_ma(paras=['n_d', 'n', 't', 'et'])[source]
Update the multi-annual data from raster to table.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- update_meta(paras=['n_d', 'n', 't', 'et'])[source]
Update the meta file from the CDC Server to the Database.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- update_period_meta(paras=['n_d', 'n', 't', 'et'])[source]
Update the periods in the meta table.
- Parameters:
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].
- update_raw(only_new=True, paras=['n_d', 'n', 't', 'et'])[source]
Update the raw data from the DWD-CDC server to the database.
- Parameters:
only_new (bool, optional) – Get only the files that are not yet in the database? If False all the available files are loaded again. The default is True.
paras (list of str, optional) – The parameters for which to do the actions. Can be one, some or all of [“n_d”, “n”, “t”, “et”]. The default is [“n_d”, “n”, “t”, “et”].