Magnetic Field Utilities
el_paso.processing.magnetic_field_utils
Classes
el_paso.processing.magnetic_field_utils.Coords
A class to handle coordinate transformations using the IRBEM library.
This class provides a Pythonic interface for converting coordinates between different systems (e.g., GEO, GSE, GSM) by calling the underlying Fortran routines of the IRBEM-LIB.
Source code in el_paso/processing/magnetic_field_utils/irbem.py
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | |
Methods:
__init__
__init__
Initializes the Coords object and loads the IRBEM shared library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lib_path
|
Optional[str | Path]
|
The path to the IRBEM shared library file. Defaults to DEFAULT_LIBIRBEM_PATH. |
DEFAULT_LIBIRBEM_PATH
|
Source code in el_paso/processing/magnetic_field_utils/irbem.py
939 940 941 942 943 944 945 946 947 948 949 950 951 | |
transform
transform
Transforms coordinates from one system to another.
This method is a vectorized wrapper around the coord_trans_vec1_ Fortran subroutine,
which handles multiple input positions and times efficiently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
list[datetime] | list[str] | datetime | str
|
A single datetime object or a list of datetime objects or ISO-formatted strings. |
required |
pos
|
NDArray[floating]
|
An array of input positions. The shape should be (N, 3), where N is the number of time steps. |
required |
sysaxes_in
|
int | str
|
The integer code or string name of the input coordinate system (e.g., 0 or 'GDZ' for GEI/GEO). |
required |
sysaxes_out
|
int | str
|
The integer code or string name of the output coordinate system. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
NDArray[np.float64]: A NumPy array of the transformed positions with shape (N, 3). |
Source code in el_paso/processing/magnetic_field_utils/irbem.py
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | |
el_paso.processing.magnetic_field_utils.IrbemInput
dataclass
A data class to hold all necessary input parameters for IRBEM calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
magnetic_field |
MagneticField
|
The magnetic field model to be used. |
maginput |
dict[MagInputKeys, NDArray[float64]]
|
A dictionary of magnetic field input parameters required by IRBEM (e.g., Kp, Dst). |
irbem_options |
list[int]
|
A list of integer options to configure the IRBEM library's behavior. |
num_cores |
int
|
The number of CPU cores to use for parallel processing. Defaults to 4. |
irbem_lib_path |
str | Path
|
The file path to the compiled IRBEM library. Defaults to the 'libirbem.so' located in the same directory as the el_paso package. |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
el_paso.processing.magnetic_field_utils.IrbemOutput
Bases: NamedTuple
A named tuple to represent the output of a single IRBEM calculation.
This is used for intermediate results in parallel processing.
Attributes:
| Name | Type | Description |
|---|---|---|
arr |
NDArray[float64]
|
The calculated data as a NumPy array. |
unit |
UnitBase
|
The unit of the calculated data. |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
71 72 73 74 75 76 77 78 79 80 81 82 | |
el_paso.processing.magnetic_field_utils.MagneticField
Bases: Enum
Enum for magnetic field models.
Source code in el_paso/processing/magnetic_field_utils/mag_field_enum.py
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 | |
Methods:
kext
kext
Returns the kext value for the magnetic field model.
Source code in el_paso/processing/magnetic_field_utils/mag_field_enum.py
48 49 50 | |
Functions:
el_paso.processing.magnetic_field_utils.create_var_name
create_var_name
Creates a standardized variable name combining the variable type and magnetic field model.
This function is used internally to generate consistent variable names for all output quantities based on the magnetic field model used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_type
|
MagFieldVarTypes
|
The type of the magnetic field-related variable (e.g., "B_eq", "MLT"). |
required |
mag_field
|
MagneticField
|
The specific magnetic field model used for the calculation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The concatenated and standardized variable name. |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
el_paso.processing.magnetic_field_utils.get_Lstar
get_Lstar
Calculates Lm, Lstar, and the third adiabatic invariant (J).
This function computes Lm and Lstar for each satellite position and local pitch angle. These are crucial parameters for characterizing particle drift shells in the magnetosphere. The calculation is parallelized for performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps. |
required |
pa_local_var
|
Variable
|
The variable containing the local pitch angle data. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | |
el_paso.processing.magnetic_field_utils.get_MLT
get_MLT
Calculates the magnetic local time (MLT).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
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 | |
el_paso.processing.magnetic_field_utils.get_footpoint_atmosphere
get_footpoint_atmosphere
Calculates the magnetic field strength at the atmospheric foot point.
This function uses parallel processing to calculate the magnetic field strength
at the atmospheric foot point (100 km altitude) for each satellite position.
It returns the result as a dictionary of el_paso.Variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
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 | |
el_paso.processing.magnetic_field_utils.get_local_B_field
get_local_B_field
Calculates the local magnetic field magnitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
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 | |
el_paso.processing.magnetic_field_utils.get_magequator
get_magequator
Calculates the magnetic field strength and radial distance at the magnetic equator.
This function uses parallel processing to efficiently compute magnetic field
and position properties at the magnetic equator for a given set of satellite
positions over time. It returns the results as a dictionary of el_paso.Variable objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps for the data. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
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 | |
el_paso.processing.magnetic_field_utils.get_mirror_point
get_mirror_point
Calculates the magnetic field strength at the mirror point.
This function computes the magnetic field strength at the mirror point for a given set of local pitch angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xgeo_var
|
Variable
|
The variable containing satellite position data in GEO coordinates. |
required |
time_var
|
Variable
|
The variable containing the timestamps. |
required |
pa_local_var
|
Variable
|
The variable containing the local pitch angle data. |
required |
irbem_input
|
IrbemInput
|
A data class with all required IRBEM input parameters. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, ep.Variable]: A dictionary containing the calculated |
Source code in el_paso/processing/magnetic_field_utils/magnetic_field_functions.py
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 498 499 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 | |