Weather Query Builder
WeatherQueryBuilder
A builder for developing RTDIP forecast queries using any delta table
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
connect(connection)
Specifies the connection to be used for the query
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection |
ConnectionInterface
|
Connection chosen by the user (Databricks SQL Connect, PYODBC SQL Connect, TURBODBC SQL Connect) |
required |
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
39 40 41 42 43 44 45 46 47 |
|
source(source, tagname_column='TagName', timestamp_column='EventTime', forecast_run_timestamp_column='EnqueuedTime', status_column='Status', value_column='Value')
Specifies the source of the query
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str
|
Source of the query can be a Unity Catalog table, Hive metastore table or path |
required |
tagname_column |
optional str
|
The column name in the source that contains the tagnames or series |
'TagName'
|
timestamp_column |
optional str
|
The timestamp column name in the source |
'EventTime'
|
forecast_run_timestamp_column |
optional str
|
The forecast run timestamp column name in the source |
'EnqueuedTime'
|
status_column |
optional str
|
The status column name in the source indicating |
'Status'
|
value_column |
optional str
|
The value column name in the source which is normally a float or string value for the time series event |
'Value'
|
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
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 |
|
raw_point(start_date, end_date, forecast_run_start_date, forecast_run_end_date, lat, lon, limit=None, measurement=None)
A function to return back raw data for a point.
Example:
from rtdip_sdk.queries.weather.weather_query_builder import (
WeatherQueryBuilder,
)
from rtdip_sdk.authentication.azure import DefaultAuth
from rtdip_sdk.connectors import DatabricksSQLConnection
auth = DefaultAuth().authenticate()
token = auth.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
connection = DatabricksSQLConnection("{server_hostname}", "{http_path}", token)
data = (
WeatherQueryBuilder()
.connect(connection)
.source("example.forecast.table")
.raw_point(
start_date="2021-01-01",
end_date="2021-01-02",
forecast_run_start_date="2021-01-01",
forecast_run_end_date="2021-01-02",
lat=0.1,
lon=0.1,
)
)
print(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date |
str
|
Start date (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
end_date |
str
|
End date (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
forecast_run_start_date |
str
|
Start date of the forecast run (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
forecast_run_end_date |
str
|
End date of the forecast run (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
lat |
float
|
latitude |
required |
lon |
float
|
longitude |
required |
limit |
optional int
|
The number of rows to be returned |
None
|
measurement |
optional str
|
Measurement type |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A dataframe of raw timeseries data. |
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
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 |
|
latest_point(lat, lon, limit=None, measurement=None)
A function to return back the latest data for a point.
Example:
from rtdip_sdk.queries.weather.weather_query_builder import (
WeatherQueryBuilder,
)
from rtdip_sdk.authentication.azure import DefaultAuth
from rtdip_sdk.connectors import DatabricksSQLConnection
auth = DefaultAuth().authenticate()
token = auth.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
connection = DatabricksSQLConnection("{server_hostname}", "{http_path}", token)
data = (
WeatherQueryBuilder()
.connect(connection)
.source("example.forecast.table")
.latest_point(
lat=0.1,
lon=0.1,
)
)
print(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lat |
float
|
latitude |
required |
lon |
float
|
longitude |
required |
limit |
optional int
|
The number of rows to be returned |
None
|
measurement |
optional str
|
Measurement type |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A dataframe of raw timeseries data. |
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
raw_grid(start_date, end_date, forecast_run_start_date, forecast_run_end_date, min_lat, min_lon, max_lat, max_lon, limit=None, measurement=None)
A function to return back raw data for a grid.
Example:
from rtdip_sdk.queries.weather.weather_query_builder import (
WeatherQueryBuilder,
)
from rtdip_sdk.authentication.azure import DefaultAuth
from rtdip_sdk.connectors import DatabricksSQLConnection
auth = DefaultAuth().authenticate()
token = auth.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
connection = DatabricksSQLConnection("{server_hostname}", "{http_path}", token)
data = (
WeatherQueryBuilder()
.connect(connection)
.source("example.forecast.table")
.raw_grid(
start_date="2021-01-01",
end_date="2021-01-02",
forecast_run_start_date="2021-01-01",
forecast_run_end_date="2021-01-02",
min_lat=0.1,
max_lat=0.1,
min_lon=0.1,
max_lon=0.1,
)
)
print(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date |
str
|
Start date (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
end_date |
str
|
End date (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
forecast_run_start_date |
str
|
Start date of the forecast run (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
forecast_run_end_date |
str
|
End date of the forecast run (Either a date in the format YY-MM-DD or a datetime in the format YYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz) |
required |
min_lat |
float
|
Min latitude |
required |
min_lon |
float
|
Min longitude |
required |
max_lat |
float
|
Max latitude |
required |
max_lon |
float
|
Max longitude |
required |
limit |
optional int
|
The number of rows to be returned |
None
|
measurement |
optional str
|
Measurement type |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A dataframe of raw timeseries data. |
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
latest_grid(min_lat, min_lon, max_lat, max_lon, limit=None, measurement=None)
A function to return back the latest data for a grid.
Example:
from rtdip_sdk.queries.weather.weather_query_builder import (
WeatherQueryBuilder,
)
from rtdip_sdk.authentication.azure import DefaultAuth
from rtdip_sdk.connectors import DatabricksSQLConnection
auth = DefaultAuth().authenticate()
token = auth.get_token("2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default").token
connection = DatabricksSQLConnection("{server_hostname}", "{http_path}", token)
data = (
WeatherQueryBuilder()
.connect(connection)
.source("example.forecast.table")
.latest_grid(
min_lat=0.1,
max_lat=0.1,
min_lon=0.1,
max_lon=0.1,
)
)
print(data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_lat |
float
|
Min latitude |
required |
min_lon |
float
|
Min longitude |
required |
max_lat |
float
|
Max latitude |
required |
max_lon |
float
|
Max longitude |
required |
limit |
optional int
|
The number of rows to be returned |
None
|
measurement |
optional str
|
Measurement type |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A dataframe of raw timeseries data. |
Source code in src/sdk/python/rtdip_sdk/queries/weather/weather_query_builder.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
Note
These examples are using DefaultAuth()
and DatabricksSQLConnection()
to authenticate and connect. You can find other ways to authenticate here. The alternative built in connection methods are either by PYODBCSQLConnection()
, TURBODBCSQLConnection()
or SparkConnection()
.
Note
server_hostname
and http_path
can be found on the SQL Warehouses Page.