Skip to content

refactor: add ocean and land geocenter functions to class - #192

Merged
tsutterley merged 3 commits into
mainfrom
deg1
Aug 18, 2026
Merged

refactor: add ocean and land geocenter functions to class#192
tsutterley merged 3 commits into
mainfrom
deg1

Conversation

@tsutterley

Copy link
Copy Markdown
Member

refactor: change assertions to value errors
test: add geocenter tests

refactor: change assertions to value errors
test: add geocenter tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors geocenter-related functionality by moving seasonal land/ocean geocenter models into the geocenter class (with additional constructor-style helpers), and replaces a few runtime assert checks with explicit ValueErrors. Adds initial test coverage for geocenter seasonal modeling and from_harmonics.

Changes:

  • Add geocenter.land_seasonal() / geocenter.ocean_seasonal() seasonal model classmethods and convert some constructors to classmethods (from_harmonics, from_matrix).
  • Replace selected assert statements with ValueError for more reliable runtime validation.
  • Add new geocenter tests and expand output metadata in degree-1 processing scripts.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test_geocenter.py Adds tests for land seasonal geocenter modeling and geocenter.from_harmonics.
gravity_toolkit/time.py Replaces an assert with ValueError for datetime unit validation.
gravity_toolkit/time_series/lomb_scargle.py Replaces an assert with ValueError for OMEGA range validation.
gravity_toolkit/scripts/monte_carlo_degree_one.py Uses new geocenter.land_seasonal and updates geocenter construction patterns; adds time_coverage_duration.
gravity_toolkit/scripts/calc_degree_one.py Uses new geocenter.land_seasonal and updates geocenter construction patterns; adds time_coverage_duration.
gravity_toolkit/read_SLR_harmonics.py Replaces an assert with a ValueError including a clearer mismatch message.
gravity_toolkit/harmonic_summation.py Replaces longitude coverage asserts with explicit ValueErrors.
gravity_toolkit/geocenter.py Adds seasonal land/ocean geocenter model helpers and converts from_harmonics/from_matrix to classmethods.
doc/source/_assets/gravity-refs.bib Adds bibliography entry for Chen et al. (1999) referenced by new seasonal model docs.
Suppressed comments (1)

gravity_toolkit/geocenter.py:891

  • Same issue as land_seasonal: mean(apply=True) updates only C10/C11/S11, so X/Y/Z keep any non-zero mean and become inconsistent with the mean-removed harmonics. Recompute cartesian components after mean removal (or subtract the mean in X/Y/Z before converting).
        temp = cls(time=time, **XYZ).from_cartesian()
        # remove the mean geocenter motion from the seasonal component
        temp.mean(apply=True)
        # return the seasonal geocenter motion
        return temp

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +854 to +858
temp = cls(time=time, **XYZ).from_cartesian()
# remove the mean geocenter motion from the seasonal component
temp.mean(apply=True)
# return the seasonal geocenter motion
return temp
Comment thread gravity_toolkit/geocenter.py Outdated
Comment on lines 994 to 998
if temp.ndim == 2:
self.C10 = np.copy(temp.clm[1, 0])
self.C11 = np.copy(temp.clm[1, 1])
self.S11 = np.copy(temp.slm[1, 1])
C10 = np.copy(temp.clm[1, 0])
C11 = np.copy(temp.clm[1, 1])
S11 = np.copy(temp.slm[1, 1])
elif temp.ndim == 3:
)
end_time = f'{calendar_year[-1]:4.0f}-{calendar_month[-1]:02.0f}'
fid.write(' {0:22}: {1}\n'.format('time_coverage_end', end_time))
duration = f'{month[-1] - month[0]:02.0f} months'
)
end_time = f'{calendar_year[-1]:4.0f}-{calendar_month[-1]:02.0f}'
fid.write(' {0:22}: {1}\n'.format('time_coverage_end', end_time))
duration = f'{month[-1] - month[0]:02.0f} months'
Comment on lines +861 to +865
def ocean_seasonal(cls, time):
"""
Model the seasonal component of geocenter motion induced by ocean
variations as estimated by :cite:t:`Chen:1999ki`

@tsutterley
tsutterley merged commit f58b0b6 into main Aug 18, 2026
5 checks passed
@tsutterley
tsutterley deleted the deg1 branch August 18, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants