Skip to content

Commit

Permalink
Added ALSEP PSE Tape reader
Browse files Browse the repository at this point in the history
Rebased:
- Fixed to work with both Python 2 and Python 3
- Added Work Tape Normal reader
- Added Work Tape High reader
- Changed the maximum line length to 78 characters
- Added URL list for unittest
- Removed unnecessary backslash
- Separated definition and added PSE tape structure
- Checked PEP8 using flake8 and updated
- Renamed class names and function names considering accessibility
- Added docs module skeleton
- Fixed bug of PSE new format processing
- Fixed bug of time skipping
- Fixed frame rate bug
  - Frame rate is always the same because slow rate sent a half ALSEP words.
- Added test code for file with many time skipping
- Fixed a bug of dictionary key check in WTN process
- Removed unnecessary test codes
- Added year overwrite option in _pse_read
- Added date validation code
- Fixed unexpected changes
- Fixed unexpected changes
- Added sync pattern barker code validation
- Used collections.deque instead of list for speeding up
  • Loading branch information
isas-yamamoto committed May 24, 2019
1 parent 3ffa320 commit 4db5c69
Show file tree
Hide file tree
Showing 23 changed files with 1,657 additions and 2 deletions.
17 changes: 17 additions & 0 deletions misc/docs/source/packages/obspy.io.alsep.rst
@@ -0,0 +1,17 @@
.. currentmodule:: obspy.io.alsep
.. automodule:: obspy.io.alsep

.. comment to end block
Modules
-------
.. autosummary::
:toctree: autogen
:nosignatures:

assign
core
define
utils

.. comment to end block
4 changes: 2 additions & 2 deletions obspy/core/util/base.py
Expand Up @@ -35,7 +35,7 @@

# defining ObsPy modules currently used by runtests and the path function
DEFAULT_MODULES = ['clients.filesystem', 'core', 'db', 'geodetics', 'imaging',
'io.ah', 'io.arclink', 'io.ascii', 'io.cmtsolution',
'io.ah', 'io.alsep', 'io.arclink', 'io.ascii', 'io.cmtsolution',
'io.cnv', 'io.css', 'io.iaspei', 'io.win', 'io.gcf',
'io.gse2', 'io.json', 'io.kinemetrics', 'io.kml',
'io.mseed', 'io.ndk', 'io.nied', 'io.nlloc', 'io.nordic',
Expand All @@ -54,7 +54,7 @@
'Q', 'SH_ASC', 'SLIST', 'TSPAIR', 'Y', 'PICKLE',
'SEGY', 'SU', 'SEG2', 'WAV', 'WIN', 'CSS',
'NNSA_KB_CORE', 'AH', 'PDAS', 'KINEMETRICS_EVT',
'GCF']
'GCF', 'ALSEP_PSE', 'ALSEP_WTN', 'ALSEP_WTH']
EVENT_PREFERRED_ORDER = ['QUAKEML', 'NLLOC_HYP']
INVENTORY_PREFERRED_ORDER = ['STATIONXML', 'SEED', 'RESP']
# waveform plugins accepting a byteorder keyword
Expand Down
50 changes: 50 additions & 0 deletions obspy/io/alsep/__init__.py
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""
obspy.io.alsep - Apollo seismic data support for ObsPy
======================================================
This module provides read support for the seismic data obtained by
Apollo Lunar Surface Experiments Package (ALSEP).
.. seealso::
The format detail is shown in the `UTIG Technical Report No. 118
<http://www-udc.ig.utexas.edu/external/yosio/PSE/catsrepts/TechRept118.pdf>`_.
The ALSEP seismic data is downloadable from `DARTS website
<http://darts.isas.jaxa.jp/planet/seismology/apollo/>`_.
:author:
Yukio Yamamoto (yukio@planeta.sci.isas.jaxa.jp) Nov. 15, 2018
:copyright:
The ObsPy Development Team (devs@obspy.org) & Yukio Yamamoto
:license:
GNU Lesser General Public License, Version 3
(https://www.gnu.org/copyleft/lesser.html)
Reading
-------
There are three types of ALSEP tape: PSE, WTN, and WTH. They are handled by
using ObsPy's standard:func:`~obspy.core.stream.read` function. The format is
detected automatically.
>>> from obspy import read
>>> st = read("http://darts.isas.jaxa.jp/pub/apollo/pse/p15s/pse.a15.1.2")
>>> st #doctest: +ELLIPSIS
<obspy.core.stream.Stream object at 0x...>
>>> st_spz = st.select(id='XA.S15..SPZ')
>>> print(st_spz) #doctest: +ELLIPSIS
7 Trace(s) in Stream:
XA.S15..SPZ | 1971-08-01T18:52:00.515000Z - ... | 53.0 Hz, 903296 samples
...
XA.S15..SPZ | 1971-08-02T13:35:53.520000Z - ... | 53.0 Hz, 1009920 samples
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import * # NOQA


if __name__ == '__main__':
import doctest
doctest.testmod(exclude_empty=True)
81 changes: 81 additions & 0 deletions obspy/io/alsep/assign.py
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
Assign ALSEP words to each channel
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import * # NOQA

from .util import interp
from .define import FORMAT_ALSEP_PSE_OLD, FORMAT_ALSEP_WTN


def assign_alsep_words(alsep_word, apollo_station, format_type, frame_count,
prev_values):
data = {}
# spz (Apollo 11,12,14,15,16) or lsg(Apollo 17)
if format_type == FORMAT_ALSEP_PSE_OLD and apollo_station != 17:
spz = [None] * 32
for i in range(32):
spz[i] = alsep_word[(i + 1) * 2]
if prev_values is None:
spz[0] = spz[1]
else:
spz[0] = interp(prev_values[0], prev_values[1], spz[1], spz[2])
if apollo_station == 15:
spz[11] = interp(spz[9], spz[10], spz[12], spz[13])
if apollo_station != 14:
spz[22] = interp(spz[20], spz[21], spz[23], spz[24])
spz[27] = interp(spz[25], spz[26], spz[28], spz[29])
data['spz'] = spz
elif apollo_station == 17:
lsg = [None] * 32
for i in range(32):
lsg[i] = 511 - alsep_word[(i + 1) * 2]
if prev_values is None:
lsg[0] = lsg[1]
else:
lsg[0] = interp(prev_values[0], prev_values[1], lsg[1], lsg[2])
data['lsg'] = lsg
data['lsg_tide'] = [511 - alsep_word[25]]
data['lsg_free'] = [511 - alsep_word[27]]
data['lsg_temp'] = [511 - alsep_word[29]]
# lpx/lpy/lpz
lpx = [None] * 4
lpy = [None] * 4
lpz = [None] * 4
for i in range(4):
lpx[i] = alsep_word[16 * i + 9]
lpy[i] = alsep_word[16 * i + 11]
lpz[i] = alsep_word[16 * i + 13]
data['lpx'] = lpx
data['lpy'] = lpy
data['lpz'] = lpz
# TidalX/TidalY/TidalZ/Inst_temp
if frame_count % 2 == 0:
data['tdx'] = [alsep_word[35]]
data['tdy'] = [alsep_word[37]]
else:
data['tdz'] = [alsep_word[35]]
data['inst_temp'] = [alsep_word[37]]
# LSM
if format_type == FORMAT_ALSEP_WTN:
if apollo_station in [12, 15, 16]:
lsm = [None] * 6
lsm[0] = alsep_word[17]
lsm[1] = alsep_word[19]
lsm[2] = alsep_word[21]
lsm[3] = alsep_word[49]
lsm[4] = alsep_word[51]
lsm[5] = alsep_word[53]
data['lsm'] = lsm
data['lsm_status'] = [alsep_word[5]]
# House Keeping (HK)
data['hk'] = [alsep_word[33]]
# Command Verification (CV)
if apollo_station == 14:
data['cv'] = [(alsep_word[5] >> 1)]
else:
data['cv'] = [(alsep_word[46] >> 1)]

return data

0 comments on commit 4db5c69

Please sign in to comment.