Skip to content

Commit

Permalink
Additional CPS warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rmodrak committed Apr 25, 2024
1 parent 57f180c commit b1500f4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions mtuq/io/clients/CPS_SAC.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
'TSS', 'TDS',
]


# disply prominent warning
print('CPS client still under testing')


class Client(ClientBase):
""" CPS database client
Expand Down Expand Up @@ -185,7 +190,7 @@ def _get_greens_tensor(self, station=None, origin=None):
# utility functions
#

def _closest_depth(path, depth_km, thresh=1.):
def _closest_depth(path, depth_km, thresh_km=1.):
""" Searches CPS directory tree to find closest depth for which
Green's functions are available
"""
Expand All @@ -205,20 +210,24 @@ def _closest_depth(path, depth_km, thresh=1.):

closest_depth = min(depths, key=lambda z: abs(z - depth_km))

if (closest_depth - depth_km) > thresh:
if (closest_depth - depth_km) > thresh_km:
print('Warning: Closest available Greens functions differ from given source '
'by %.f km vertically' % (closest_depth - depth_km))
print('Warning: Depth displayed in figure header may be inaccurate')

return closest_depth


def _closest_offset(path, depth_km, offset_km, thresh=1.):
def _closest_offset(path, depth_km, offset_km, thresh_km=1.):
""" Searches CPS directory tree to find closest horizontal offset for which
Green's functions are available
"""

# the file naming convention used by CPS is ZZZz/RRRRrZZZz.EXT
wildcard = '%s/%04d/?????%04d.ZEX' % (path, 10*depth_km, 10*depth_km)
# the directory naming convention used by CPS is ZZZz
wildcard = '%s/%04d' % (path, 10*depth_km)

# the file naming convention used by CPS is RRRRrZZZz.EXT
wildcard = '%s/?????%04d.ZEX' % (wildcard, 10*depth_km)

if not glob(wildcard):
raise Exception('No Greens functions found: %s' % wildcard)
Expand All @@ -236,7 +245,7 @@ def _closest_offset(path, depth_km, offset_km, thresh=1.):

closest_offset = min(offsets, key=lambda r: abs(r - offset_km))

if (closest_offset - offset_km) > thresh:
if (closest_offset - offset_km) > thresh_km:
print('Warning: Closest available Greens functions differ from given source '
'by %.f km horizontally' % (closest_offset - offset_km))

Expand Down

0 comments on commit b1500f4

Please sign in to comment.