Skip to content

Commit

Permalink
remove "Seismic" name prefixes from classes Inventory, Network, Station,
Browse files Browse the repository at this point in the history
Channel
  • Loading branch information
megies committed Sep 18, 2013
1 parent d8bb3bb commit f98d342
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions obspy/station/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from obspy.station.util import BaseNode, Equipment, Operator, Person, \
PhoneNumber, ExternalReference, Comment, Site
from obspy.station.channel import SeismicChannel
from obspy.station.station import SeismicStation
from obspy.station.network import SeismicNetwork
from obspy.station.inventory import SeismicInventory, read_inventory
from obspy.station.channel import Channel
from obspy.station.station import Station
from obspy.station.network import Network
from obspy.station.inventory import Inventory, read_inventory
from obspy.station.response import ResponseStage, PolesZerosResponseStage, \
CoefficientsTypeResponseStage, ResponseListResponseStage, \
FIRResponseStage, PolynomialResponseStage, Response, \
Expand Down
8 changes: 4 additions & 4 deletions obspy/station/channel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Provides the SeismicChannel class.
Provides the Channel class.
:copyright:
Lion Krischer (krischer@geophysik.uni-muenchen.de), 2013
Expand All @@ -12,7 +12,7 @@
from obspy.station import BaseNode


class SeismicChannel(BaseNode):
class Channel(BaseNode):
"""
From the StationXML definition:
Equivalent to SEED blockette 52 and parent element for the related the
Expand Down Expand Up @@ -142,14 +142,14 @@ def __init__(self, code, location_code, latitude, longitude,
self.response = response
if comments is None:
comments = []
super(SeismicChannel, self).__init__(code=code,
super(Channel, self).__init__(code=code,
description=description, comments=comments, start_date=start_date,
end_date=end_date, restricted_status=restricted_status,
alternate_code=alternate_code, historical_code=historical_code)

def __str__(self):
ret = (
"Seismic Channel '{id}', Location '{location}' {description}\n"
"Channel '{id}', Location '{location}' {description}\n"
"\tLatitude: {latitude:.2f}, Longitude: {longitude:.2f}, "
"Elevation: {elevation:.1f} m, Local Depth: {depth:.1f} m\n"
"{azimuth}"
Expand Down
14 changes: 7 additions & 7 deletions obspy/station/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
import obspy
from obspy.station import stationxml
from obspy.station.network import SeismicNetwork
from obspy.station.network import Network
import textwrap


Expand Down Expand Up @@ -50,7 +50,7 @@ def read_inventory(path_or_file_object, format=None):
return FORMAT_FCTS[fileformat]["read_fct"](path_or_file_object)


class SeismicInventory(object):
class Inventory(object):
"""
The root object of the Inventory->Network->Station->Channel hierarchy.
Expand All @@ -59,7 +59,7 @@ class SeismicInventory(object):
def __init__(self, networks, source, sender=None, created=None,
module=None, module_uri=None):
"""
:type networks: List of :class:`~obspy.station.network.SeismicNetwork`
:type networks: List of :class:`~obspy.station.network.Network`
:param networks: A list of networks part of this inventory.
:type source: String
:param source: Network ID of the institution sending the message.
Expand Down Expand Up @@ -112,7 +112,7 @@ def get_contents(self):
return content_dict

def __str__(self):
ret_str = "Seismic Inventory created at %s\n" % str(self.created)
ret_str = "Inventory created at %s\n" % str(self.created)
if self.module:
module_uri = self.module_uri
if module_uri and len(module_uri) > 70:
Expand All @@ -137,7 +137,7 @@ def __str__(self):

def write(self, path_or_file_object, format, **kwargs):
"""
Writes the seismic inventory object to a file or file-like object in
Writes the inventory object to a file or file-like object in
the specified format.
:param path_or_file_object: Filename or file-like object to be written
Expand All @@ -164,7 +164,7 @@ def networks(self, value):
if not hasattr(value, "__iter__"):
msg = "networks needs to be iterable, e.g. a list."
raise ValueError(msg)
if any([not isinstance(x, SeismicNetwork) for x in value]):
msg = "networks can only contain SeismicNetwork objects."
if any([not isinstance(x, Network) for x in value]):
msg = "networks can only contain Network objects."
raise ValueError(msg)
self.__networks = value
14 changes: 7 additions & 7 deletions obspy/station/network.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Provides the SeismicNetwork class.
Provides the Network class.
:copyright:
Lion Krischer (krischer@geophysik.uni-muenchen.de), 2013
Expand All @@ -10,11 +10,11 @@
(http://www.gnu.org/copyleft/lesser.html)
"""
from obspy.station.util import BaseNode
from obspy.station.station import SeismicStation
from obspy.station.station import Station
import textwrap


class SeismicNetwork(BaseNode):
class Network(BaseNode):
"""
From the StationXML definition:
This type represents the Network layer, all station metadata is
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(self, code, stations=[], total_number_of_stations=None,
self.total_number_of_stations = total_number_of_stations
self.selected_number_of_stations = selected_number_of_stations

super(SeismicNetwork, self).__init__(code=code,
super(Network, self).__init__(code=code,
description=description, comments=comments, start_date=start_date,
end_date=end_date, restricted_status=restricted_status,
alternate_code=alternate_code, historical_code=historical_code)
Expand All @@ -69,7 +69,7 @@ def __getitem__(self, index):
return self.stations[index]

def __str__(self):
ret = ("Seismic Network {id} {description}\n"
ret = ("Network {id} {description}\n"
"\tStation Count: {selected}/{total} (Selected/Total)\n"
"\t{start_date} - {end_date}\n"
"\tAccess: {restricted} {alternate_code}{historical_code}\n")\
Expand Down Expand Up @@ -124,8 +124,8 @@ def stations(self, values):
if not hasattr(values, "__iter__"):
msg = "stations needs to be iterable, e.g. a list."
raise ValueError(msg)
if any([not isinstance(x, SeismicStation) for x in values]):
msg = "stations can only contain SeismicStation objects."
if any([not isinstance(x, Station) for x in values]):
msg = "stations can only contain Station objects."
raise ValueError(msg)
self.__stations = values

Expand Down
10 changes: 5 additions & 5 deletions obspy/station/station.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Provides the SeismicStation class.
Provides the Station class.
:copyright:
Lion Krischer (krischer@geophysik.uni-muenchen.de), 2013
Expand All @@ -14,7 +14,7 @@
import textwrap


class SeismicStation(BaseNode):
class Station(BaseNode):
"""
From the StationXML definition:
This type represents a Station epoch. It is common to only have a
Expand All @@ -28,7 +28,7 @@ def __init__(self, code, latitude, longitude, elevation, channels=[],
description=None, comments=[], start_date=None, end_date=None,
restricted_status=None, alternate_code=None, historical_code=None):
"""
:type channels: A list of 'obspy.station.SeismicChannel`
:type channels: A list of :class:`obspy.station.channel.Channel`
:param channels: All channels belonging to this station.
:param latitude: The latitude of the station
:param longitude: The longitude of the station
Expand Down Expand Up @@ -94,14 +94,14 @@ def __init__(self, code, latitude, longitude, elevation, channels=[],
self.total_number_of_channels = total_number_of_channels
self.selected_number_of_channels = selected_number_of_channels
self.external_references = []
super(SeismicStation, self).__init__(code=code,
super(Station, self).__init__(code=code,
description=description, comments=comments, start_date=start_date,
end_date=end_date, restricted_status=restricted_status,
alternate_code=alternate_code, historical_code=historical_code)

def __str__(self):
contents = self.get_contents()
ret = ("Seismic Station {station_name}\n"
ret = ("Station {station_name}\n"
"\tStation Code: {station_code}\n"
"\tChannel Count: {selected}/{total} (Selected/Total)\n"
"\t{start_date} - {end_date}\n"
Expand Down
12 changes: 6 additions & 6 deletions obspy/station/stationxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def read_StationXML(path_or_file_object):
for network in root.findall(_ns("Network")):
networks.append(_read_network(network, _ns))

inv = obspy.station.SeismicInventory(networks=networks, source=source,
inv = obspy.station.Inventory(networks=networks, source=source,
sender=sender, created=created, module=module, module_uri=module_uri)
return inv

Expand Down Expand Up @@ -123,7 +123,7 @@ def _read_base_node(element, object_to_write_to, _ns):


def _read_network(net_element, _ns):
network = obspy.station.SeismicNetwork(net_element.get("code"))
network = obspy.station.Network(net_element.get("code"))
_read_base_node(net_element, network, _ns)
network.total_number_of_stations = _tag2obj(net_element,
_ns("TotalNumberStations"), int)
Expand All @@ -140,7 +140,7 @@ def _read_station(sta_element, _ns):
latitude = _tag2obj(sta_element, _ns("Latitude"), float)
longitude = _tag2obj(sta_element, _ns("Longitude"), float)
elevation = _tag2obj(sta_element, _ns("Elevation"), float)
station = obspy.station.SeismicStation(code=sta_element.get("code"),
station = obspy.station.Station(code=sta_element.get("code"),
latitude=latitude, longitude=longitude, elevation=elevation)
station.site = _read_site(sta_element.find(_ns("Site")), _ns)
_read_base_node(sta_element, station, _ns)
Expand Down Expand Up @@ -174,7 +174,7 @@ def _read_channel(cha_element, _ns):
depth = _tag2obj(cha_element, _ns("Depth"), float)
code = cha_element.get("code")
location_code = cha_element.get("locationCode")
channel = obspy.station.SeismicChannel(code=code,
channel = obspy.station.Channel(code=code,
location_code=location_code, latitude=latitude,
longitude=longitude, elevation=elevation, depth=depth)
_read_base_node(cha_element, channel, _ns)
Expand Down Expand Up @@ -476,7 +476,7 @@ def write_StationXML(inventory, file_or_file_object, validate=False, **kwargs):
"""
Writes an inventory object to a buffer.
:type inventory: :class:`~obspy.station.inventory.SeismicInventory`
:type inventory: :class:`~obspy.station.inventory.Inventory`
:param inventory: The inventory instance to be written.
:param file_or_file_object: The file or file-like object to be written to.
:type validate: Boolean
Expand Down Expand Up @@ -553,7 +553,7 @@ def _write_base_node(element, object_to_read_from):

def _write_network(parent, network):
"""
Helper function converting a SeismicNetwork instance to an etree.Element.
Helper function converting a Network instance to an etree.Element.
"""
attribs = _get_base_node_attributes(network)
network_elem = etree.SubElement(parent, "Network", attribs)
Expand Down
6 changes: 3 additions & 3 deletions obspy/station/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
import unittest

import obspy
from obspy.station import SeismicInventory
from obspy.station import Inventory


class InventoryTestCase(unittest.TestCase):
"""
Tests the for :class:`~obspy.station.inventory.SeismicInventory` class.
Tests the for :class:`~obspy.station.inventory.Inventory` class.
"""
def test_initialization(self):
"""
Some simple sanity tests.
"""
dt = obspy.UTCDateTime()
inv = SeismicInventory(source="TEST", networks=[])
inv = Inventory(source="TEST", networks=[])
# If no time is given, the creation time should be set to the current
# time. Use a large offset for potentially slow computers and test
# runs.
Expand Down
4 changes: 2 additions & 2 deletions obspy/station/tests/test_stationxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_writing_module_tags(self):
"""
Tests the writing of ObsPy related tags.
"""
net = obspy.station.SeismicNetwork(code="UL")
inv = obspy.station.SeismicInventory(networks=[net], source="BLU")
net = obspy.station.Network(code="UL")
inv = obspy.station.Inventory(networks=[net], source="BLU")

file_buffer = BytesIO()
inv.write(file_buffer, format="StationXML", validate=True)
Expand Down

0 comments on commit f98d342

Please sign in to comment.