Gravimeters
gravtools.models.gravimeter
Modelling gravimeters.
Copyright (C) 2024 Andreas Hellerschmied andreas.hellerschmied@bev.gv.at
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Gravimeter
Describes properties of a single gravity meter.
Attributes:
| Name | Type | Description |
|---|---|---|
gravimeter_type |
str
|
Gravimeter type. The type has to be a key in |
manufacturer |
str
|
Manufacturer of the instrument. |
serial_number |
str
|
Instrument serial number. |
height_offset_m |
float
|
Height offset between the instrument's reference surface (usually instrument top surface) and the sensor level. |
description |
str
|
Arbitrary description. |
data_source |
str
|
Source from which the gravimeter data was loaded. This is either the name of a file, or the name of a survey. |
data_source_type |
str
|
Type of the gravimeter data source. HAs to be listed as key in |
scale_df |
:py:obj:`pandas.core.frame.DataFrame`
|
Pandas Dataframe containing the instrument's calibration parameters valid for time specific time intervals.
|
code |
(str, optional(default=''))
|
Short instrument code. |
Notes
All epochs have to be given w.r.t. UTC. Dates have bo TZ.
Source code in gravtools/models/gravimeter.py
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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
name
property
Return the name of the gravimeter by combing type and S/N
num_scale_factors
property
Return the number of scale factors.
__init__(gravimeter_type, manufacturer, serial_number, height_offset_m, data_source, data_source_type, description='', scale_parameters=None, code='', verbose=True)
Default constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravimeter_type
|
str
|
Gravimeter type. The type has to be a key in |
required |
manufacturer
|
str
|
Manufacturer of the instrument. |
required |
serial_number
|
str
|
Instrument serial number. |
required |
height_offset_m
|
float
|
Height offset between the instrument's reference surface (usually instrument top surface) and the sensor level. |
required |
data_source
|
str
|
Source from which the gravimeter data was loaded. This is either the name of a file, or the name of a survey. |
required |
data_source_type
|
str
|
Type of the gravimeter data source. Has to be listed as key in |
required |
description
|
(str, optional(default=''))
|
Arbitrary description. |
''
|
scale_parameters
|
list of dicts, optional (default = `None`)
|
Each dict contains the start date, the end date and the linear calibration factor. If no data is provided, default values are used. |
None
|
code
|
Short instrument code. |
''
|
|
verbose
|
Print terminal output if |
True
|
Source code in gravtools/models/gravimeter.py
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 348 349 350 351 352 353 | |
apply_linear_scaling(gravity_df)
Applies a linear scaling factor on the input gravity data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravity_df
|
DataFrame
|
Pandas DataFrame with two columns containing the reference epochs (col. "epoch_dt") as datetime objects and the gravity values (col. "g") that are scaled with the linear scaling factor corresponding to the reference epochs. |
required |
Notes
An error is raised if noe scaling factor is available for the given epoch.
Returns:
| Type | Description |
|---|---|
pd.DataFrame : "gravity_df" with two additional columns for the scale factors ("linear_scale") and the scaled
|
|
gravity ("g_scaled").
|
|
Source code in gravtools/models/gravimeter.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
get_linear_scale_factor(epoch, raise_error_availability=False, verbose=True)
Returns the linear scale factor for the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch
|
Pandas.Timestamp (timezone aware with tz=UTC).
|
Epoch for which a scale factor should be returned |
required |
raise_error_availability
|
optional (default = `False`)
|
|
False
|
verbose
|
Print terminal output if |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
Scale factor or `numpy.nan` if not available or in case of multiple matches.
|
|
Notes
Only the dates are compared when matching epochs!
Source code in gravtools/models/gravimeter.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
get_linear_scale_factors(ref_epochs, raise_error_availability=False)
Returns the linear scale factor for the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_epochs
|
List of datetime64 objects (timezone aware with tz=UTC).
|
Epochs for which a scale factor should be returned |
required |
raise_error_availability
|
optional (default = `False`)
|
|
False
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Scale factors.
|
|
Source code in gravtools/models/gravimeter.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
Gravimeters
Manages gravity meters.
Attributes:
| Name | Type | Description |
|---|---|---|
gravimeters |
(dict, optional(default=None))
|
The keys are tuples of the form ( |
Source code in gravtools/models/gravimeter.py
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 | |
number_of_gravimeters
property
Return the number of gravimeters.
__init__()
Default constructor.
Source code in gravtools/models/gravimeter.py
39 40 41 | |
add_from_json(filename_json, verbose=True)
Load data of one or multiple gravimeters a json file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename_json
|
str
|
Name of the json file holding the gravimeter information. |
required |
verbose
|
Print terminal output if |
True
|
Notes
If the gravimeter already exists with data loaded from an observation file (= survey) and default scale factors
(self.data_source_type is survey), this information is overwritten by the data loaded from the json file.
Source code in gravtools/models/gravimeter.py
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 | |
add_from_survey(survey, verbose=True)
Get the gravimeter data from a single survey object and set unknown attributes to default values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
survey
|
`gravtools.models.survey.Survey` object
|
GravTools survey object. |
required |
verbose
|
Print terminal output if |
True
|
Notes
If there is already an entry for a gravimeter loaded from an external source, e.g. from a json file, the
existing content will NOT be overwritten by default values! In this case self.data_source_type is set to
file.
The default linear scale factor is defined in settings.DEFAULT_GRAVIMETER_LINEAR_SCALE_FACTOR
Source code in gravtools/models/gravimeter.py
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 | |
add_gravimeter(gravi, verbose=True)
Add a gravimeter object and carry out checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravi
|
Gravimeter object that contains all relevant data. |
required | |
verbose
|
Print terminal output if |
True
|
Notes
Do not overwrite existing data loaded from a gravimeter file by default values and/or values from an observation file.
Source code in gravtools/models/gravimeter.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
apply_linear_scale(gravimeter_type, serial_number, gravity_df, verbose=False)
Apply linear scale factor on observations of the gravimeter with the given type and S/N.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravimeter_type
|
str
|
Gravimeter type. |
required |
serial_number
|
str
|
Instrument serial number |
required |
gravity_df
|
DataFrame
|
Pandas DataFrame with two columns containing the reference epochs (col. "epoch_dt") as datetime objects and the gravity values (col. "g") that are scaled with the linear scaling factor corresponding to the reference epochs. |
required |
verbose
|
Print terminal output if |
False
|
Returns:
| Type | Description |
|---|---|
pd.DataFrame : "gravity_df" with two additional columns for the scale factors ("linear_scale") and the scaled
|
|
gravity ("g_scaled").
|
|
Source code in gravtools/models/gravimeter.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
delete_gravimeter(gravimeter_type, serial_number, verbose=True)
Delete the gravimeter with the given type and S/N.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravimeter_type
|
str
|
Gravimeter type. |
required |
serial_number
|
str
|
Instrument serial number |
required |
verbose
|
Print terminal output if |
True
|
Source code in gravtools/models/gravimeter.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
get_height_offset(gravimeter_type, serial_number)
Returns the height offset between the sensor and the top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravimeter_type
|
str
|
Gravimeter type. |
required |
serial_number
|
str
|
Instrument serial number |
required |
Source code in gravtools/models/gravimeter.py
174 175 176 177 178 179 180 181 182 183 184 | |