Load Data¶
pyshbundle
contains scripts to seemlessly extract and load spherical harmonics coefficients from various data centres.
See Tutorials
¶
extract_SH_data(file_path, source)
¶
Extracts the spherical harmonic coefficients from all the given files.
Currently supports JPL, CSR, and ITSG data sources ONLY. Extracts the spherical harmonic coefficients from the given file and returns them in a dictionary. Uses the degree and order of a coefficient as the key and the coefficient values as the value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Absolute path to the file. |
required |
source
|
str
|
Source of the data (JPL, CSR, or ITSG). |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the coefficients and time coverage start and end dates. |
Source code in pyshbundle/io.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 |
|
extract_deg1_coeff_tn13(file_path)
¶
Extracts the degree 1 coefficients from the given TN-13 file.
Ensure the TN-13 file used is the one recommended by respective data centres (JPL, CSR, or ITSG). Similar to extract_SH_data, but specifically for TN-13 files. Returns degree 1 replacement coefficients as a dictionary. Uses the degree and order of a coefficient as the key and the coefficient values as the value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Absolute path to the file. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the degree 1 (order 1) coefficients and time coverage start and end dates. |
Source code in pyshbundle/io.py
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 |
|
extract_deg2_3_coeff_tn14(file_path)
¶
Extracts the degree 2 and 3 coefficients from the given file.
Ensure the TN-14 file used is the one recommended by respective data centres (JPL, CSR, or ITSG). Similar to extract_SH_data, but specifically for TN-14 files. Returns degree 2, 3 replacement coefficients as a dictionary. Uses the degree and order of a coefficient as the key and the coefficient values as the value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Absolute path to the file. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the degree 2, 3 (order 0) coefficients and time coverage start and end dates. |
Source code in pyshbundle/io.py
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 |
|
load_longterm_mean(source='', use_sample_mean=0)
¶
Loads the long term mean values for the GRACE SH data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
Source of data. Defaults to "". |
''
|
use_sample_mean
|
int
|
Whether to use default long-mean values provided with the data. Defaults to 0. |
0
|
Raises:
Type | Description |
---|---|
ValueError
|
If the source selection is incorrect. |
Returns:
Name | Type | Description |
---|---|---|
str |
Path of the appropriate long term mean file. |
Todo
- Not sure if using "source = ''" is all right.
- Instead of base exception, it can be ValueError.
Source code in pyshbundle/io.py
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 |
|
parse_jpl_file(file_path)
¶
Reads the spherical harmonic data provided by JPL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Absolute path to the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing: - jpl_header (dict): Parsed header information. - jpl_data (dict): Extracted spherical harmonic coefficients data. |
Source code in pyshbundle/io.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 |
|
read_GRACE_SH_paths(use_sample_files=0)
¶
Returns path of data files, path of tn13 and path of tn14 replacement files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
use_sample_files
|
int
|
Defaults to 0. |
0
|
Raises:
Type | Description |
---|---|
Exception
|
If the source selection is incorrect. |
Returns:
Name | Type | Description |
---|---|---|
tuple |
|
Remarks
The purpose of this script is to: - Read what the data source is (JPL, CSR, or ITSG). - Read file path for GRACE L2 spherical harmonics inputs. - Read replacement files for tn13 and tn14. - Identify the source of the SH files (JPL, ITSG, or CSR).
Source code in pyshbundle/io.py
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 |
|
replace_zonal_coeff(data_mat, source, lmax, data_tn13, data_tn14, epoch_begin, epoch_end)
¶
Replaces the zonal coefficients in the given data matrix with the replacement coefficients from the provided TN-13 and TN-14 data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_mat
|
ndarray
|
The original data matrix containing spherical harmonic coefficients. |
required |
source
|
str
|
The source of the data ('jpl', 'csr', or 'itsg'). |
required |
lmax
|
int
|
The maximum degree of the spherical harmonic expansion. |
required |
data_tn13
|
ndarray
|
The TN-13 replacement coefficients data. |
required |
data_tn14
|
ndarray
|
The TN-14 replacement coefficients data. |
required |
epoch_begin
|
float
|
The start date of the epoch in YYYYMMDD format. |
required |
epoch_end
|
float
|
The end date of the epoch in YYYYMMDD format. Defaults to None. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The data matrix with the zonal coefficients replaced. |
Source code in pyshbundle/io.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 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 |
|
sub2ind(array_shape, rows, cols)
¶
Convert row and column subscripts to linear indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array_shape
|
tuple
|
Shape of the array as a tuple (num_rows, num_cols). |
required |
rows
|
int or array - like
|
Row indices. |
required |
cols
|
int or array - like
|
Column indices. |
required |
Returns:
Type | Description |
---|---|
int or array-like: Linear indices corresponding to the row and column subscripts. |
Source code in pyshbundle/io.py
960 961 962 963 964 965 966 967 968 969 970 971 972 973 |
|
Computing Long Term Mean¶
Loads the long term mean values for the GRACE SH data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
Source of data. Defaults to "". |
''
|
use_sample_mean
|
int
|
Whether to use default long-mean values provided with the data. Defaults to 0. |
0
|
Raises:
Type | Description |
---|---|
ValueError
|
If the source selection is incorrect. |
Returns:
Name | Type | Description |
---|---|---|
str |
Path of the appropriate long term mean file. |
Todo
- Not sure if using "source = ''" is all right.
- Instead of base exception, it can be ValueError.
Source code in pyshbundle/io.py
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 |
|
Physical and Geodetic Constants¶
This script contains some of the major relavant Physical and Geodetic(GRS80) constants:
clight
speed of light - \(2.99792458e+8\) \(m/s\)G
Gravitational constant- \(6.67259e-11\) $rac{m^3} {kg \cdot s^2}$-
au
astronomical unit - \(149.597870691e+9\) \(m\) -
ae
semi-major axis of ellipsoidGRS 80
- \(6378137\) m GM
geocentric grav. constantGRS 80
- \(3.986005e+14\) $rac{m^3}{s^2}$J2
earth's dynamic form factorGRS 80
- \(1.08263e-3\) [unitless C20 unnormalized coefficient]-
Omega
mean ang. velocityGRS 80
- $7.292115e-5 $rac{rad}{s}$ -
flat
flattening - $rac{1}{298.257222101}$