Auxillary Codes¶
The helper functions of the core functions are under the shutils
script.
See Core Functionality.
Gaussian(L, cap)
¶
Generates values for a Gaussian smoothing filter.
The program delivers the spherical harmonic coefficients of a Gaussian smoothing filter. The coefficients are calculated according to Wahr et al. (1998) equation (34) and Swenson and Wahr equation (34).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L
|
int
|
Maximum degree of the spherical harmonics. |
required |
cap
|
int
|
Half width of Gaussian smoothing function [km]. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Smoothing coefficients of the Gausiann filter. |
Raises:
Type | Description |
---|---|
TypeError
|
If |
ValueError
|
If |
TypeError
|
If |
References
Wahr et al. (1998) equation (34) and Swenson and Wahr equation (34).
Source code in pyshbundle/shutils.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
|
derivALF(inn, miin, plin, m, lmax)
¶
Function to calculate the derivative of the associated Legendre functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inn
|
ndarray
|
Input array representing the initial condition. |
required |
miin
|
ndarray
|
Array for the preceding elements in the recursion. |
required |
plin
|
ndarray
|
Array for the subsequent elements in the recursion. |
required |
m
|
int
|
Order of the associated Legendre functions. |
required |
lmax
|
int
|
Maximum degree. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Derivatives of the associated Legendre functions. |
Source code in pyshbundle/shutils.py
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 |
|
eigengrav(lmax, fstr, h)
¶
Returns the isotropic spectral transfer (or: eigenvalues) of several gravity related quantities. Upward continuation may be included.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lmax
|
int
|
Maximum degree of Spherical Coefficients. |
required |
fstr
|
str
|
Denoting the functional under consideration: 'none', 'geoid', 'dg', 'gravity' ... gravity anomaly, 'potential', 'tr' .............. gravity disturbance, 'trr' ............. (d^2/dr^2) 'slope' ........... size of surface gradient, 'water' ........... equivalent water thickness, 'smd' ............. surface mass density. 'height' .......... vertical displacements. |
required |
h
|
float
|
Height above Earth mean radius [m]. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Transfer matrix. Size and shape equal to lmax. Units are respectively [none], [m], [mGal], [mGal], [E], [m^2/s^2], [rad], [m], [kg/m^2][n x 1] |
Uses
upwcon, lovenr, uberall/constants, uberall/isint
Raises:
Type | Description |
---|---|
TypeError
|
Enter a valid lmax value. |
Source code in pyshbundle/shutils.py
443 444 445 446 447 448 449 450 451 452 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 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 531 |
|
grule(n)
¶
Computes Gauss base points and weight factors using the algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Number of base points required. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing: - bp (numpy.ndarray): Cosine of the base points. - wf (numpy.ndarray): Weight factors for computing integrals and such. |
References
- 'Methods of Numerical Integration' by Davis and Rabinowitz, page 365, Academic Press, 1975.
Source code in pyshbundle/shutils.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 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 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
|
iplm(l, m, theRAD, dt=-9999)
¶
Integrals of the fully normalized associated Legendre functions over blocks for a selected order M.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l
|
array
|
Degree (vector). Integer, but not necessarily monotonic. For l < m a vector of zeros will be returned. |
required |
m
|
int
|
Order of the Legendre function. If absent, m = 0 is assumed. |
required |
theRAD
|
array
|
Co-latitude in radians. |
required |
dt
|
int
|
Integration block-size [rad] (scalar). Defaults to -9999. |
-9999
|
Returns:
Type | Description |
---|---|
ndarray
|
Matrix with integrated Legendre functions. Functions are integrated from theRAD(i)-dt/2 till theRAD(i)+dt/2. The matrix has length(TH) rows and length(L) columns, unless L or TH is scalar. Then the output vector follows the shape of respectively L or TH. |
Notes
The blocks at the pole might become too large under circumstances. This is not treated separately, i.e. unwanted output may appear. In case TH is scalar, dt will be 1 (arbitrarily).
Uses
plm
Source code in pyshbundle/shutils.py
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 |
|
ispec(a, b=-9999)
¶
Returns the function F from the spectra A and B.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
ndarray
|
Cosine coefficients. |
required |
b
|
ndarray
|
Sine coefficients. Defaults to -9999. |
-9999
|
Returns:
Type | Description |
---|---|
ndarray
|
The function F computed from the spectra A and B. |
See Also
spec
Source code in pyshbundle/shutils.py
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 |
|
lrecur(inn, x, m, lmax)
¶
Helper function for recursion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inn
|
int
|
Input value representing the initial condition. |
required |
x
|
int
|
The current value for the recursion. |
required |
m
|
int
|
Order of the recursion. |
required |
lmax
|
int
|
Maximum value for recursion. |
required |
Returns:
Type | Description |
---|---|
int
|
Updated value after performing the recursion based on parameters. |
Source code in pyshbundle/shutils.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
naninterp(X)
¶
This function uses cubic interpolation to replace NaNs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array
|
Array with NaN values. |
required |
Returns:
Type | Description |
---|---|
numpy.array: Cubic interpolated array. |
Source code in pyshbundle/shutils.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
|
neumann(inn)
¶
Returns the weights and nodes for Neumann's numerical integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inn
|
int or array
|
Base points (nodes) in the interval [-1;1]. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing: - w (numpy.array): Quadrature weights. - x (numpy.array): Base points (nodes) in the interval [-1;1]. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input argument is not an integer. |
ValueError
|
If there is an error in input dimensions. |
Remarks
- 1st N.-method: see Sneeuw (1994) GJI 118, pp 707-716, eq. 19.5.
- 2nd N.-method: see uberall/GRULE.
Todo
- TypeError is more relevant and shape error from numpy.
Uses
grule
, plm
.
Source code in pyshbundle/shutils.py
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 |
|
normalklm(lmax, typ='wgs84')
¶
Returns an ellipsoidal normal field consisting of normalized -Jn, n=0,2,4,6,8.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lmax
|
int
|
Maximum degree of the spherical harmonics. |
required |
typ
|
str
|
Ellipsoids can be either 'wgs84' (World Geodetic System 84), 'grs80', or 'he' (hydrostatic equilibrium ellipsoid). |
'wgs84'
|
Returns:
Type | Description |
---|---|
array
|
Normal field in CS-format (sparse array - [1, -J2, -J4, -J6, -J8]). |
Raises:
Type | Description |
---|---|
TypeError
|
If |
ValueError
|
If |
ValueError
|
If |
References
- J2, J4 values for hydrostatic equilibrium ellipsoid from Lambeck (1988) "Geophysical Geodesy", p.18.
Source code in pyshbundle/shutils.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
|
plm(l, m, thetaRAD, nargin, nargout)
¶
Fully normalized associated Legendre functions for a selected order M.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l
|
array
|
Degree, but not necessarily monotonic. For l < m a vector of zeros will be returned. |
required |
m
|
int
|
Order. If absent, m = 0 is assumed. |
required |
thetaRAD
|
array
|
Co-latitude in radians. |
required |
nargin
|
int
|
Number of input arguments. |
required |
nargout
|
int
|
Number of output arguments. |
required |
Returns:
Type | Description |
---|---|
array
|
Fully normalized Legendre functions. |
array
|
First derivative of the Legendre functions. |
array
|
Second derivative of the Legendre functions. |
Source code in pyshbundle/shutils.py
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 |
|
secrecur(m, y)
¶
Helper Function for sectorial recursion. This function computes the sectorial recursion for given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The order of the recursion. |
required |
y
|
ndarray
|
The input array for which the recursion is computed. |
required |
Returns:
Type | Description |
---|---|
numpy.ndarray: The result of the sectorial recursion. |
Source code in pyshbundle/shutils.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|