Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/source/notebooks/GRACE-Geostrophic-Maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"# if updating the local data\n",
"if widgets.update.value:\n",
" # run podaac sync program to get latest data\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint.value\n",
" # run GRACE date program to verify months\n",
" !run_grace_date.py --directory=$widgets.base_directory --verbose\n",
" # get geocenter data from Sutterley and Velicogna (2019)\n",
Expand Down Expand Up @@ -233,7 +233,9 @@
"# number of time steps\n",
"nt = len(months)\n",
"# flag for spherical harmonic order\n",
"order_str = f'M{MMAX:d}' if (MMAX != LMAX) else ''"
"order_str = f'M{MMAX:d}' if (MMAX != LMAX) else ''\n",
"# inspect GRACE harmonics\n",
"GRACE_Ylms"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions doc/source/notebooks/GRACE-Harmonic-Plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"# if updating the local data\n",
"if widgets.update.value:\n",
" # run podaac sync program to get latest data\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint.value\n",
" # run GRACE date program to verify months\n",
" !run_grace_date.py --directory=$widgets.base_directory --verbose\n",
" # get geocenter data from Sutterley and Velicogna (2019)\n",
Expand Down Expand Up @@ -228,7 +228,9 @@
"GRACE_Ylms = gravtk.harmonics().from_dict(Ylms)\n",
"GRACE_Ylms.mean(apply=True)\n",
"# number of time steps\n",
"nt = len(months)"
"nt = len(months)\n",
"# inspect GRACE harmonics\n",
"GRACE_Ylms"
]
},
{
Expand Down Expand Up @@ -552,11 +554,9 @@
}
],
"metadata": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
},
"kernelspec": {
"display_name": "Python 3.8.10 64-bit",
"display_name": "py13",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -569,7 +569,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.13.0"
}
},
"nbformat": 4,
Expand Down
6 changes: 4 additions & 2 deletions doc/source/notebooks/GRACE-Spatial-Error.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"# if updating the local data\n",
"if widgets.update.value:\n",
" # run podaac sync program to get latest data\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint.value\n",
" # run GRACE date program to verify months\n",
" !run_grace_date.py --directory=$widgets.base_directory --verbose\n",
" # get geocenter data from Sutterley and Velicogna (2019)\n",
Expand Down Expand Up @@ -225,7 +225,9 @@
"GRACE_Ylms = gravtk.harmonics().from_dict(Ylms)\n",
"GRACE_Ylms.mean(apply=True)\n",
"# number of time steps\n",
"nt = len(months)"
"nt = len(months)\n",
"# inspect GRACE harmonics\n",
"GRACE_Ylms"
]
},
{
Expand Down
15 changes: 6 additions & 9 deletions doc/source/notebooks/GRACE-Spatial-Maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"# if updating the local data\n",
"if widgets.update.value:\n",
" # run podaac sync program to get latest data\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint\n",
" !podaac_cumulus.py --directory=$widgets.base_directory --endpoint=$widgets.endpoint.value\n",
" # run GRACE date program to verify months\n",
" !run_grace_date.py --directory=$widgets.base_directory --verbose\n",
" # get geocenter data from Sutterley and Velicogna (2019)\n",
Expand Down Expand Up @@ -270,7 +270,9 @@
"# number of time steps\n",
"nt = len(months)\n",
"# flag for spherical harmonic order\n",
"order_str = f'M{MMAX:d}' if (MMAX != LMAX) else ''"
"order_str = f'M{MMAX:d}' if (MMAX != LMAX) else ''\n",
"# inspect GRACE harmonics\n",
"GRACE_Ylms"
]
},
{
Expand Down Expand Up @@ -990,7 +992,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 64-bit",
"display_name": "py13",
"language": "python",
"name": "python3"
},
Expand All @@ -1004,12 +1006,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
"version": "3.13.0"
}
},
"nbformat": 4,
Expand Down
25 changes: 20 additions & 5 deletions gravity_toolkit/geocenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

UPDATE HISTORY:
Updated 07/2026: add dunder (magic) methods for mathematical operations
add HTML representation of geocenter class
Updated 06/2024: use wrapper to importlib for optional dependencies
Updated 05/2024: make subscriptable and allow item assignment
Updated 09/2023: add group option to netCDF read function
Expand Down Expand Up @@ -54,7 +55,7 @@
import pathlib
import numpy as np
import gravity_toolkit.time
from gravity_toolkit.utilities import import_dependency
from gravity_toolkit.utilities import import_dependency, html_repr

# attempt imports
netCDF4 = import_dependency('netCDF4')
Expand Down Expand Up @@ -1289,11 +1290,25 @@ def fields(self):
def __str__(self):
"""String representation of the ``geocenter`` object"""
properties = ['gravity_toolkit.geocenter']
if self.month:
properties.append(f' start_month: {min(self.month)}')
properties.append(f' end_month: {max(self.month)}')
if np.any(self.month):
properties.append(f' start_month: {np.min(self.month)}')
properties.append(f' end_month: {np.max(self.month)}')
return '\n'.join(properties)

def __repr__(self):
"""Representation of the ``geocenter`` object"""
return self.__str__()

def _repr_html_(self):
"""HTML representation of the ``geocenter`` object"""
header = 'gravity_toolkit.geocenter'
properties = {}
if np.any(self.month):
properties['start_month'] = np.min(self.month)
properties['end_month'] = np.max(self.month)
properties['slices'] = self.__len__()
return html_repr(header, properties)

def __add__(self, other):
"""Add values to a ``geocenter`` object"""
temp = self.copy()
Expand Down Expand Up @@ -1361,7 +1376,7 @@ def __truediv__(self, other):

def __len__(self):
"""Number of months"""
return len(self.month) if np.any(self.month) else 0
return len(np.atleast_1d(self.month)) if np.any(self.month) else 0

def __iter__(self):
"""Iterate over GRACE/GRACE-FO months"""
Expand Down
28 changes: 23 additions & 5 deletions gravity_toolkit/harmonics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

UPDATE HISTORY:
Updated 07/2026: add dunder (magic) methods for mathematical operations
add HTML representation of harmonics class
Updated 06/2024: use wrapper to importlib for optional dependencies
Updated 05/2024: make subscriptable and allow item assignment
Updated 10/2023: place time and month variables in try/except block
Expand Down Expand Up @@ -110,7 +111,7 @@
from gravity_toolkit.destripe_harmonics import destripe_harmonics
from gravity_toolkit.read_gfc_harmonics import read_gfc_harmonics
from gravity_toolkit.read_GRACE_harmonics import read_GRACE_harmonics
from gravity_toolkit.utilities import import_dependency, reify
from gravity_toolkit.utilities import import_dependency, reify, html_repr

# attempt imports
geoidtk = import_dependency('geoid_toolkit')
Expand Down Expand Up @@ -1976,11 +1977,28 @@ def __str__(self):
properties.append(f' max_degree: {self.lmax}')
if self.mmax and (self.mmax != self.lmax):
properties.append(f' max_order: {self.mmax}')
if self.month:
properties.append(f' start_month: {min(self.month)}')
properties.append(f' end_month: {max(self.month)}')
if np.any(self.month):
properties.append(f' start_month: {np.min(self.month)}')
properties.append(f' end_month: {np.max(self.month)}')
return '\n'.join(properties)

def __repr__(self):
"""Representation of the ``harmonics`` object"""
return self.__str__()

def _repr_html_(self):
"""HTML representation of the ``harmonics`` object"""
header = 'gravity_toolkit.harmonics'
properties = {}
properties['max_degree'] = self.lmax
if self.mmax and (self.mmax != self.lmax):
properties['max_order'] = self.mmax
if np.any(self.month):
properties['start_month'] = np.min(self.month)
properties['end_month'] = np.max(self.month)
properties['slices'] = self.__len__()
return html_repr(header, properties)

def __add__(self, other):
"""Add values to a ``harmonics`` object"""
temp = self.copy()
Expand Down Expand Up @@ -2048,7 +2066,7 @@ def __truediv__(self, other):

def __len__(self):
"""Number of months"""
return len(self.month) if np.any(self.month) else 0
return len(np.atleast_1d(self.month)) if np.any(self.month) else 0

def __iter__(self):
"""Iterate over GRACE/GRACE-FO months"""
Expand Down
33 changes: 32 additions & 1 deletion gravity_toolkit/read_GIA_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
read_GIA_model.py
Written by Tyler Sutterley (05/2023)
Written by Tyler Sutterley (07/2026)

Reads GIA data files that can come in various formats depending on the group
Outputs spherical harmonics for the GIA rates and the GIA model parameters
Expand Down Expand Up @@ -96,6 +96,7 @@
https://doi.org/10.1002/2016JB013844

UPDATE HISTORY:
Updated 07/2026: add string and HTML representations of gia class
Updated 05/2023: use pathlib to define and operate on paths
Updated 03/2023: case insensitive searching for HDF5 and netCDF4 attributes
convert shape and ndim to harmonic class properties
Expand Down Expand Up @@ -148,6 +149,7 @@
import pathlib
import numpy as np
from gravity_toolkit.harmonics import harmonics
from gravity_toolkit.utilities import html_repr

_known_gia_types = [
'IJ05-R2',
Expand Down Expand Up @@ -785,3 +787,32 @@ def from_GIA(self, filename, **kwargs):
# assign degree and order fields
self.update_dimensions()
return self

def __str__(self):
"""String representation of the ``gia`` object"""
properties = ['gravity_toolkit.gia']
properties.append(f' title: {self.title}')
properties.append(f' citation: {self.citation}')
properties.append(f' max_degree: {self.lmax}')
if self.mmax and (self.mmax != self.lmax):
properties.append(f' max_order: {self.mmax}')
properties.append(f' reference: {self.reference}')
properties.append(f' url: {self.url}')
return '\n'.join(properties)

def __repr__(self):
"""Representation of the ``gia`` object"""
return self.__str__()

def _repr_html_(self):
"""HTML representation of the ``gia`` object"""
header = 'gravity_toolkit.gia'
properties = {}
properties['title'] = self.title
properties['citation'] = self.citation
properties['max_degree'] = self.lmax
if self.mmax and (self.mmax != self.lmax):
properties['max_order'] = self.mmax
properties['reference'] = self.reference
properties['url'] = self.url
return html_repr(header, properties)
19 changes: 17 additions & 2 deletions gravity_toolkit/read_love_numbers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
read_love_numbers.py
Written by Tyler Sutterley (11/2024)
Written by Tyler Sutterley (07/2026)

Reads sets of load Love numbers from PREM and applies isomorphic parameters
Linearly interpolates load Love/Shida numbers for missing degrees
Expand Down Expand Up @@ -56,6 +56,7 @@
103(B12), 30205-30229, (1998)

UPDATE HISTORY:
Updated 07/2026: add HTML representation of love_numbers class
Updated 11/2024: allow reading where degree is infinite
Updated 05/2024: make subscriptable and allow item assignment
Updated 08/2023: add string representation of the love_numbers class
Expand Down Expand Up @@ -94,7 +95,7 @@
import logging
import pathlib
import numpy as np
from gravity_toolkit.utilities import get_data_path
from gravity_toolkit.utilities import get_data_path, html_repr

# default maximum degree and order in case of infinite
_default_max_degree = 100000
Expand Down Expand Up @@ -582,6 +583,20 @@ def __str__(self):
properties.append(f' reference: {self.reference}')
return '\n'.join(properties)

def __repr__(self):
"""Representation of the ``love_numbers`` object"""
return self.__str__()

def _repr_html_(self):
"""HTML representation of the ``love_numbers`` object"""
header = 'gravity_toolkit.love_numbers'
properties = {}
properties['citation'] = self.citation
properties['earth_model'] = self.model
properties['max_degree'] = self.lmax
properties['reference'] = self.reference
return html_repr(header, properties)

def __len__(self):
"""Number of degrees"""
return len(self.l)
Expand Down
Loading
Loading