API reference¶
The public Python surface is small: package metadata in weather_tools, the Cyclopts app in weather_tools.cli_commands, and Database / GraphGrouping in weather_tools.db_helpers.
Package wide variables.
cli_commands
¶
Main methods to interact with rain data.
Common
dataclass
¶
Class for common db-path parameter.
Source code in src/weather_tools/cli_commands.py
db_dir = Path('.')
class-attribute
instance-attribute
¶
Path to database file
add(reading, date=None, back_fill=False, common=None)
¶
Add rain data to database.
Paramters¶
date: datetime Date to record rain for reading: float Rain reading common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
calculate_interval(max_value)
¶
Calculate order of magnitude.
Source code in src/weather_tools/cli_commands.py
change(reading, date=None, common=None)
¶
Update rain data in the database.
Paramters¶
date: datetime Date to record rain for reading: float Rain reading common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
default_datetime()
¶
graph(size=30, group=GraphGrouping.daily, common=None)
¶
Retrieve historic rain data from DB and show it as a graph.
Parameters¶
size: int Number of graph elements to show group: GraphGrouping Grouping for graph common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
rainy_days(size=30, group=GraphGrouping.daily, common=None)
¶
Retrieve historic rain data from DB and show it as a graph.
Parameters¶
size: int Number of graph elements to show group: GraphGrouping Grouping for graph common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
weewx_import(weewx_db=Path('./weewx.sdb'), common=None)
¶
Export daily rain from weewx database into the DB for this project.
Parameters¶
weewx_db: Path Full path to the weewx sqlite database file. common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
db_helpers
¶
Classes and methods around working with the history database.
Database
¶
Implements helper methods to add and retrieve data from database.
Source code in src/weather_tools/db_helpers.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
__init__(db_dir)
¶
Create database connection. Also creates database and table(s) if they don't exist yet.
Source code in src/weather_tools/db_helpers.py
add_rain_record(date, amount)
¶
Add a record / measurement of rain to the DB.
Source code in src/weather_tools/db_helpers.py
get_rain(history_size, group)
¶
Get 'history_size' number of rain records.
Source code in src/weather_tools/db_helpers.py
get_rainy_days(history_size, group)
¶
Get 'history_size' number of rain records.
Source code in src/weather_tools/db_helpers.py
get_single_day_rain(date)
¶
Return amount of rain for that day as a float or False if no rain record was found for that particular date.
Source code in src/weather_tools/db_helpers.py
import_weewx(weewx_db_file)
¶
Import data from a weewx database file.
Source code in src/weather_tools/db_helpers.py
update_rain_record(date, amount)
¶
Update a record / measurement of rain in the DB.
Source code in src/weather_tools/db_helpers.py
GraphGrouping
¶
Bases: str, Enum
Provides possible values for grouping of graphs.
Source code in src/weather_tools/db_helpers.py
Main methods to interact with rain data.
Common
dataclass
¶
Class for common db-path parameter.
Source code in src/weather_tools/cli_commands.py
db_dir = Path('.')
class-attribute
instance-attribute
¶
Path to database file
add(reading, date=None, back_fill=False, common=None)
¶
Add rain data to database.
Paramters¶
date: datetime Date to record rain for reading: float Rain reading common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
calculate_interval(max_value)
¶
Calculate order of magnitude.
Source code in src/weather_tools/cli_commands.py
change(reading, date=None, common=None)
¶
Update rain data in the database.
Paramters¶
date: datetime Date to record rain for reading: float Rain reading common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
default_datetime()
¶
graph(size=30, group=GraphGrouping.daily, common=None)
¶
Retrieve historic rain data from DB and show it as a graph.
Parameters¶
size: int Number of graph elements to show group: GraphGrouping Grouping for graph common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
rainy_days(size=30, group=GraphGrouping.daily, common=None)
¶
Retrieve historic rain data from DB and show it as a graph.
Parameters¶
size: int Number of graph elements to show group: GraphGrouping Grouping for graph common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
weewx_import(weewx_db=Path('./weewx.sdb'), common=None)
¶
Export daily rain from weewx database into the DB for this project.
Parameters¶
weewx_db: Path Full path to the weewx sqlite database file. common : Common, optional Shared options such as --db-path.
Source code in src/weather_tools/cli_commands.py
Classes and methods around working with the history database.
Database
¶
Implements helper methods to add and retrieve data from database.
Source code in src/weather_tools/db_helpers.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
__init__(db_dir)
¶
Create database connection. Also creates database and table(s) if they don't exist yet.
Source code in src/weather_tools/db_helpers.py
add_rain_record(date, amount)
¶
Add a record / measurement of rain to the DB.
Source code in src/weather_tools/db_helpers.py
get_rain(history_size, group)
¶
Get 'history_size' number of rain records.
Source code in src/weather_tools/db_helpers.py
get_rainy_days(history_size, group)
¶
Get 'history_size' number of rain records.
Source code in src/weather_tools/db_helpers.py
get_single_day_rain(date)
¶
Return amount of rain for that day as a float or False if no rain record was found for that particular date.
Source code in src/weather_tools/db_helpers.py
import_weewx(weewx_db_file)
¶
Import data from a weewx database file.
Source code in src/weather_tools/db_helpers.py
update_rain_record(date, amount)
¶
Update a record / measurement of rain in the DB.
Source code in src/weather_tools/db_helpers.py
GraphGrouping
¶
Bases: str, Enum
Provides possible values for grouping of graphs.