Skip to content
Merged
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
14 changes: 9 additions & 5 deletions gravity_toolkit/read_GRACE_harmonics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
read_GRACE_harmonics.py
Written by Tyler Sutterley (05/2023)
Written by Tyler Sutterley (11/2024)
Contributions by Hugo Lecomte

Reads GRACE files and extracts spherical harmonic data and drift rates (RL04)
Expand Down Expand Up @@ -42,6 +42,7 @@
time.py: utilities for calculating time operations

UPDATE HISTORY:
Updated 11/2024: check if the GRACE/GRACE-FO files are gfc format
Updated 05/2023: use pathlib to define and operate on paths
Updated 03/2023: added regex formatting for CNES GRGS harmonics
improve typing for variables in docstrings
Expand Down Expand Up @@ -145,13 +146,15 @@ def read_GRACE_harmonics(input_file, LMAX, **kwargs):
FLAG = r'gfc'
# COST-G unfiltered combination solutions
# https://doi.org/10.5880/ICGEM.COST-G.001
elif PRC in ('COSTG',):
DSET, = re.findall(r'GSM|GAC',PFX)
# GFC solutions from the GFZ ICGEM
# https://icgem.gfz-potsdam.de/sl/temporal
elif PRC in ('COSTG',) or SFX in ('.gfc',):
DSET, = re.findall(r'(GSM|GAA|GAB|GAC|GAD)', PFX)
DREL = np.int64(DRL)
FLAG = r'gfc'
# Standard GRACE/GRACE-FO Level-2 solutions
else:
DSET = PFX
DSET, = re.findall(r'(GSM|GAA|GAB|GAC|GAD)', PFX)
DREL = np.int64(DRL)
FLAG = r'GRCOF2'

Expand Down Expand Up @@ -207,7 +210,8 @@ def read_GRACE_harmonics(input_file, LMAX, **kwargs):
header_parameters = ['modelname','earth_gravity_constant','radius',
'max_degree','errors','norm','tide_system']
header_regex = re.compile(r'(' + r'|'.join(header_parameters) + r')')
grace_L2_input['header'] = [l for l in head if header_regex.match(l)]
header = [l.split(maxsplit=1) for l in head if header_regex.match(l)]
grace_L2_input['header'] = {i[0]:i[1] for i in header}
elif ((N == 'GRAC') and (DREL >= 6)) or (N == 'GRFO'):
# parse the YAML header for RL06 or GRACE-FO (specifying yaml loader)
grace_L2_input.update(yaml.load('\n'.join(head),Loader=yaml.BaseLoader))
Expand Down