Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: option to specify a specific geocenter correction file #61

Merged
merged 1 commit into from
Dec 23, 2021
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
2 changes: 2 additions & 0 deletions doc/source/user_guide/calc_mascon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Command Line Options
* ``'SLF'``: Sutterley and Velicogna coefficients, Remote Sensing (2019)
* ``'Swenson'``: GRACE-derived coefficients from Sean Swenson
* ``'GFZ'``: GRACE/SLR derived coefficients from GFZ GravIS
- ``--geocenter-file X``: Specific geocenter file if not default
- ``--interpolate-geocenter``: Least-squares model missing Degree 1 coefficients
- ``--slr-c20 X``: Replace *C*\ :sub:`20` coefficients with SLR values

* ``None``: use original values
Expand Down
2 changes: 2 additions & 0 deletions doc/source/user_guide/grace_mean_harmonics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Command Line Options
* ``'SLF'``: Sutterley and Velicogna coefficients, Remote Sensing (2019)
* ``'Swenson'``: GRACE-derived coefficients from Sean Swenson
* ``'GFZ'``: GRACE/SLR derived coefficients from GFZ GravIS
- ``--geocenter-file X``: Specific geocenter file if not default
- ``--interpolate-geocenter``: Least-squares model missing Degree 1 coefficients
- ``--slr-c20 X``: Replace *C*\ :sub:`20` coefficients with SLR values

* ``None``: use original values
Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/grace_spatial_error.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Command Line Options
* ``'SLF'``: Sutterley and Velicogna coefficients, Remote Sensing (2019)
* ``'Swenson'``: GRACE-derived coefficients from Sean Swenson
* ``'GFZ'``: GRACE/SLR derived coefficients from GFZ GravIS
- ``--geocenter-file X``: Specific geocenter file if not default
- ``--interpolate-geocenter``: Least-squares model missing Degree 1 coefficients
- ``--slr-c20 X``: Replace *C*\ :sub:`20` coefficients with SLR values

Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/grace_spatial_maps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Command Line Options
* ``'SLF'``: Sutterley and Velicogna coefficients, Remote Sensing (2019)
* ``'Swenson'``: GRACE-derived coefficients from Sean Swenson
* ``'GFZ'``: GRACE/SLR derived coefficients from GFZ GravIS
- ``--geocenter-file X``: Specific geocenter file if not default
- ``--interpolate-geocenter``: Least-squares model missing Degree 1 coefficients
- ``--slr-c20 X``: Replace *C*\ :sub:`20` coefficients with SLR values

Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/scale_grace_maps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Command Line Options
* ``'SLF'``: Sutterley and Velicogna coefficients, Remote Sensing (2019)
* ``'Swenson'``: GRACE-derived coefficients from Sean Swenson
* ``'GFZ'``: GRACE/SLR derived coefficients from GFZ GravIS
- ``--geocenter-file X``: Specific geocenter file if not default
- ``--interpolate-geocenter``: Least-squares model missing Degree 1 coefficients
- ``--slr-c20 X``: Replace *C*\ :sub:`20` coefficients with SLR values

Expand Down
2 changes: 1 addition & 1 deletion gravity_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from gravity_toolkit.read_SLR_CS2 import read_SLR_CS2
from gravity_toolkit.read_SLR_C30 import read_SLR_C30
from gravity_toolkit.read_SLR_C50 import read_SLR_C50
from gravity_toolkit.read_SLR_harmonics import read_SLR_harmonics
from gravity_toolkit.read_SLR_harmonics import read_SLR_harmonics, convert_weekly
from gravity_toolkit.savitzky_golay import savitzky_golay
from gravity_toolkit.spatial import spatial
from gravity_toolkit.tsamplitude import tsamplitude
Expand Down
64 changes: 57 additions & 7 deletions gravity_toolkit/geocenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

UPDATE HISTORY:
Updated 12/2021: added netCDF4 reader for UCI iteration files
add cartesian and surface mass density conversions for errors
logging case_insensitive_filename output for debugging
Updated 11/2021: converted to class with all data readers and converters
Updated 07/2020: added function docstrings
Updated 06/2019: added option RADIUS to manually set the Earth's radius
Expand All @@ -31,6 +33,7 @@
import gzip
import time
import uuid
import logging
import netCDF4
import numpy as np
import gravity_toolkit.time
Expand Down Expand Up @@ -85,6 +88,8 @@ def case_insensitive_filename(self,filename):
errmsg = '{0} not found in file system'.format(filename)
raise FileNotFoundError(errmsg)
self.filename = os.path.join(directory,f.pop())
#-- print filename
logging.debug(self.filename)
return self

#-- PURPOSE: read AOD1b geocenter for month and calculate the mean harmonics
Expand Down Expand Up @@ -734,7 +739,7 @@ def from_dict(self, temp, **kwargs):
#-- set default keyword arguments
kwargs.setdefault('fields',['time','month',
'C10','C11','S11','eC10','eC11','eS11',
'X','Y','Z'])
'X','Y','Z','X_sigma','Y_sigma','Z_sigma'])
#-- assign dictionary variables to self
for key in kwargs['fields']:
try:
Expand Down Expand Up @@ -809,7 +814,7 @@ def to_dict(self, **kwargs):
#-- set default keyword arguments
kwargs.setdefault('fields',['time','month',
'C10','C11','S11','eC10','eC11','eS11',
'X','Y','Z'])
'X','Y','Z','X_sigma','Y_sigma','Z_sigma'])
#-- assign dictionary variables to self
for key in kwargs['fields']:
try:
Expand Down Expand Up @@ -844,10 +849,20 @@ def to_cartesian(self, kl=0.0):
-----------------
kl: gravitational load love number of degree 1
"""
#-- Stokes Coefficients to geocenter
self.Z = self.C10*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.X = self.C11*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.Y = self.S11*self.radius*np.sqrt(3.0)/(1.0 + kl)
#-- Stokes Coefficients to cartesian geocenter
try:
self.Z = self.C10*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.X = self.C11*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.Y = self.S11*self.radius*np.sqrt(3.0)/(1.0 + kl)
except Exception as e:
pass
#-- convert errors to cartesian geocenter
try:
self.Z_sigma = self.eC10*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.X_sigma = self.eC11*self.radius*np.sqrt(3.0)/(1.0 + kl)
self.Y_sigma = self.eS11*self.radius*np.sqrt(3.0)/(1.0 + kl)
except Exception as e:
pass
return self

def to_cmwe(self, kl=0.0):
Expand All @@ -866,6 +881,13 @@ def to_cmwe(self, kl=0.0):
self.C10 *= (rho_e*rad_e)/(1.0 + kl)
self.C11 *= (rho_e*rad_e)/(1.0 + kl)
self.S11 *= (rho_e*rad_e)/(1.0 + kl)
#-- convert errors to centimeters water equivalent
try:
self.eC10 *= (rho_e*rad_e)/(1.0 + kl)
self.eC11 *= (rho_e*rad_e)/(1.0 + kl)
self.eS11 *= (rho_e*rad_e)/(1.0 + kl)
except Exception as e:
pass
return self

def to_mmwe(self, kl=0.0):
Expand All @@ -881,6 +903,13 @@ def to_mmwe(self, kl=0.0):
self.C10 *= 10.0
self.C11 *= 10.0
self.S11 *= 10.0
#-- convert errors to millimeters water equivalent
try:
self.eC10 *= 10.0
self.eC11 *= 10.0
self.eS11 *= 10.0
except Exception as e:
pass
return self

def from_cartesian(self, kl=0.0):
Expand All @@ -891,10 +920,17 @@ def from_cartesian(self, kl=0.0):
-----------------
kl: gravitational load love number of degree 1
"""
#-- geocenter to Stokes Coefficients
#-- cartesian geocenter to Stokes Coefficients
self.C10 = (1.0 + kl)*self.Z/(self.radius*np.sqrt(3.0))
self.C11 = (1.0 + kl)*self.X/(self.radius*np.sqrt(3.0))
self.S11 = (1.0 + kl)*self.Y/(self.radius*np.sqrt(3.0))
#-- convert cartesian geocenter to stokes coefficients
try:
self.eC10 = (1.0 + kl)*self.Z_sigma/(self.radius*np.sqrt(3.0))
self.eC11 = (1.0 + kl)*self.X_sigma/(self.radius*np.sqrt(3.0))
self.eS11 = (1.0 + kl)*self.Y_sigma/(self.radius*np.sqrt(3.0))
except Exception as e:
pass
return self

def from_cmwe(self, kl=0.0):
Expand All @@ -913,6 +949,13 @@ def from_cmwe(self, kl=0.0):
self.C10 *= (1.0 + kl)/(rho_e*rad_e)
self.C11 *= (1.0 + kl)/(rho_e*rad_e)
self.S11 *= (1.0 + kl)/(rho_e*rad_e)
#-- convert errors from centimeters water equivalent
try:
self.eC10 *= (1.0 + kl)/(rho_e*rad_e)
self.eC11 *= (1.0 + kl)/(rho_e*rad_e)
self.eS11 *= (1.0 + kl)/(rho_e*rad_e)
except Exception as e:
pass
return self

def from_mmwe(self, kl=0.0):
Expand All @@ -928,6 +971,13 @@ def from_mmwe(self, kl=0.0):
self.C10 /= 10.0
self.C11 /= 10.0
self.S11 /= 10.0
#-- convert errors from centimeters water equivalent
try:
self.eC10 /= 10.0
self.eC11 /= 10.0
self.eS11 /= 10.0
except Exception as e:
pass
return self

def mean(self, apply=False, indices=Ellipsis):
Expand Down
Loading