Time Setting
Overview¤
A module for handling time settings passed in the RetrievalSettings
class.
Set time settings used by DisruptionPy to set the timebase for data retrieval from MDSPlus and any SQL tables.
This module defines the abstract class TimeSetting
that can have subclasses passed as the
time_setting
parameter to the RetrievalSettings
class.
It also provides built-in classes and mappings to easily set the timebase for data retrievel for common use cases.
Usage¤
Currently, these are the options that can be passed to the time_setting
parameter in RetrievalSettings
:
- An instance of a subclass of
TimeSetting
- A string identifier in the
_time_setting_mappings
dictionary:
_time_setting_mappings: Dict[str, TimeSetting] = {
"efit": EfitTimeSetting(),
"disruption": DisruptionTimeSetting(),
"disruption_warning": {
Tokamak.CMOD: EfitTimeSetting(),
Tokamak.D3D: DisruptionTimeSetting(),
},
"ip": IpTimeSetting(),
}
ListTimeSetting
for more details.
- A dictionary mapping tokamak type strings to the desired TimeSetting
for that tokamak. E.g. {'cmod': 'efit'}
.
Built-in Implemenations¤
This module defines classes for time settings, used to manage the timebase for retrieving data in disruption_py for various tokamaks and shot configurations.
disruption_py.settings.time_setting.CacheTimeSetting ¤
Bases: TimeSetting
Time setting for using the timebase from cached data.
If no cached data is available, the fallback time setting is used.
Source code in disruption_py/settings/time_setting.py
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 |
|
__init__ ¤
__init__(fallback_time_setting: TimeSettingType) -> None
PARAMETER | DESCRIPTION |
---|---|
fallback_time_setting |
Fallback time setting to use if cached data is unavailable.
TYPE:
|
Source code in disruption_py/settings/time_setting.py
211 212 213 214 215 216 217 218 219 220 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Retrieve the timebase from cached data, or use the fallback if unavailable.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
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 |
|
disruption_py.settings.time_setting.DisruptionTimeSetting ¤
Bases: TimeSetting
Time setting for using the disruption timebase.
The disruption timebase is the timebase of the shot that was disrupted.
Source code in disruption_py/settings/time_setting.py
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 |
|
__init__ ¤
__init__(minimum_ip=400000.0, minimum_duration=0.1)
PARAMETER | DESCRIPTION |
---|---|
minimum_ip |
Minimum current in amps (default is 400,000 A).
TYPE:
|
minimum_duration |
Minimum duration in seconds (default is 0.1 seconds).
TYPE:
|
Source code in disruption_py/settings/time_setting.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
_get_end_of_shot
classmethod
¤
_get_end_of_shot(signal, signal_time, threshold=100000.0)
Calculate the end of shot based on signal and threshold.
PARAMETER | DESCRIPTION |
---|---|
signal |
Signal array representing the current.
TYPE:
|
signal_time |
Time array corresponding to the signal.
TYPE:
|
threshold |
Threshold value for determining shot end.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
duration
|
Duration of the shot.
TYPE:
|
signal_max
|
Maximum signal value.
TYPE:
|
Source code in disruption_py/settings/time_setting.py
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 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Abstract method for retrieving disruption timebase.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
d3d_times ¤
d3d_times(params: TimeSettingParams)
Retrieve disruption timebase for the D3D tokamak.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.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 399 400 401 402 |
|
disruption_py.settings.time_setting.EfitTimeSetting ¤
Bases: TimeSetting
Time setting for using the EFIT timebase.
Source code in disruption_py/settings/time_setting.py
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 |
|
__init__ ¤
__init__()
Source code in disruption_py/settings/time_setting.py
260 261 262 263 264 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Abstract method for retrieving EFIT timebase.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
cmod_times ¤
cmod_times(params: TimeSettingParams)
Retrieve the EFIT timebase for the CMOD tokamak.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
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 |
|
disruption_py.settings.time_setting.IpTimeSetting ¤
Bases: TimeSetting
Time setting for using the timebase of the plasma current.
Source code in disruption_py/settings/time_setting.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
__init__ ¤
__init__()
Source code in disruption_py/settings/time_setting.py
458 459 460 461 462 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Abstract method for retrieving the Ip timebase.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
d3d_times ¤
d3d_times(params: TimeSettingParams)
Retrieve the Ip timebase for the D3D tokamak.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
disruption_py.settings.time_setting.ListTimeSetting ¤
Bases: TimeSetting
Time setting for using a pre-defined list of times.
Used when a list, numpy array, or pandas series is passed as the time_setting
parameter in RetrievalSettings
.
Source code in disruption_py/settings/time_setting.py
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 |
|
__init__ ¤
__init__(times)
PARAMETER | DESCRIPTION |
---|---|
times |
List or array of times to use as the timebase.
TYPE:
|
Source code in disruption_py/settings/time_setting.py
176 177 178 179 180 181 182 183 184 185 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Return the pre-defined list of times.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
disruption_py.settings.time_setting.SignalTimeSetting ¤
Bases: TimeSetting
Time setting for using the timebase of a specific signal.
Source code in disruption_py/settings/time_setting.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
__init__ ¤
__init__(tree_name: str, signal_path: str)
PARAMETER | DESCRIPTION |
---|---|
tree_name |
Name of the tree containing the signal.
TYPE:
|
signal_path |
Path to the signal within the tree.
TYPE:
|
Source code in disruption_py/settings/time_setting.py
505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
_get_times ¤
_get_times(params: TimeSettingParams) -> np.ndarray
Retrieve the timebase for the specified signal.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters needed to retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
disruption_py.settings.time_setting.resolve_time_setting ¤
resolve_time_setting(
time_setting: TimeSettingType,
) -> TimeSetting
Resolve a time setting to a TimeSetting object.
PARAMETER | DESCRIPTION |
---|---|
time_setting |
The time setting, which can be a string, list, or TimeSetting instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
TimeSetting
|
The resolved TimeSetting object. |
Source code in disruption_py/settings/time_setting.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
|
Custom Implementations¤
Custom implementations of time settings must inherit from the TimeSetting
abstract class, implementing the abstract methods.
disruption_py.settings.time_setting ¤
This module defines classes for time settings, used to manage the timebase for retrieving data in disruption_py for various tokamaks and shot configurations.
TimeSetting ¤
Bases: ABC
Abstract base class for managing time settings to retrieve the timebase for shots.
METHOD | DESCRIPTION |
---|---|
get_times |
Retrieve the timebase as a numpy array. |
Source code in disruption_py/settings/time_setting.py
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 |
|
_get_times
abstractmethod
¤
_get_times(params: TimeSettingParams) -> np.ndarray
Abstract method for subclasses to implement timebase retrieval.
PARAMETER | DESCRIPTION |
---|---|
params |
Parameters used to determine the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
get_times ¤
get_times(params: TimeSettingParams) -> np.ndarray
Retrieve the timebase using the provided parameters.
PARAMETER | DESCRIPTION |
---|---|
params |
The parameters used to determine and retrieve the timebase.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
Array of times in the timebase. |
Source code in disruption_py/settings/time_setting.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
TimeSettingParams
dataclass
¤
Parameters passed by disruption_py to the _get_times() method.
ATTRIBUTE | DESCRIPTION |
---|---|
shot_id |
Shot ID for the timebase being created.
TYPE:
|
mds_conn |
Connection to MDSPlus for retrieving MDSPlus data.
TYPE:
|
cache_data |
Pre-filled data provided to disruption_py.
TYPE:
|
database |
Database object with connection to the SQL database.
TYPE:
|
disruption_time |
Time when the shot disrupted in seconds (or None if no disruption occurred).
TYPE:
|
tokamak |
Tokamak for which the time setting is applied.
TYPE:
|
logger |
Logger object used by disruption_py for logging messages.
TYPE:
|
Source code in disruption_py/settings/time_setting.py
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 |
|
disrupted
property
¤
disrupted: bool
Check if the shot disrupted.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the shot was disrupted, False otherwise. |