Beispiel #1
0
    def create_obs_station(self, sta_code, start_date, end_date, sta_longitude,
                           sta_latitude, sta_elevation, creation_date,
                           termination_date, site_name):
        obs_station = inventory.Station(sta_code,
                                        latitude=round(sta_latitude, 6),
                                        longitude=round(sta_longitude, 6),
                                        start_date=start_date,
                                        end_date=end_date,
                                        elevation=round(sta_elevation, 1))
        obs_station.site = inventory.Site(
            name=(site_name if site_name else sta_code))
        obs_station.creation_date = creation_date
        obs_station.termination_date = termination_date
        obs_station.total_number_of_channels = 0  # initialized to 0
        obs_station.selected_number_of_channels = 0  # initialized to 0

        return obs_station
Beispiel #2
0
                    start_date = cha[u'start_date']
                    if start_date == '':
                        start_date = UTCDateTime(1970, 1, 1, 0, 0)
                    end_date = cha[u'end_date'] 
                    if end_date =='':
                        end_date = UTCDateTime(2999, 1, 1, 0, 0)

                    #create inventory for station
                    stan_channel = inventory.Channel(code=chn_name, location_code=site_name, depth=depth, azimuth=270, 
                                                    dip=0, sample_rate=sampling, clock_drift_in_seconds_per_sample=0, 
                                                    latitude=latitude, longitude=longitude, elevation=elevation)
                    
                    channel_list.append(stan_channel)
                    site = inventory.Site(name=site_name, description=instrument)
                    station = inventory.Station(code=station_code, creation_date=start_date, 
                                                termination_date=end_date, latitude=latitude,
                                                longitude=longitude, elevation=elevation, vault=station_id,
                                                channels=channel_list, site=site)
                
            station_list.append(station)
                
    network = inventory.Network(code=network_code, alternate_code=network_name, 
                                start_date=start_date, stations=station_list)
    network_list.append(network)
inv = inventory.Inventory(networks=network_list, source='YN.dataless')
    
#print inv
    
inv.write(path_or_file_object='yn_station' + '.xml', format='STATIONXML')

                    
Beispiel #3
0
    #make a new station inventory object with all of the channels and updated start and end dates
    # get the start/end dates from dict
    start_date = UTCDateTime(station_start_end_dict[station][0])
    end_date = UTCDateTime(station_start_end_dict[station][1])

    site = station_inv_dict[station].site

    # make the station_level inventory
    station_inv = inventory.Station(
        code=station,
        creation_date=start_date,
        termination_date=end_date,
        start_date=start_date,
        end_date=end_date,
        site=site,
        latitude=station_inv_dict[station].latitude,
        longitude=station_inv_dict[station].longitude,
        elevation=station_inv_dict[station].elevation,
        vault="Transportable Array",
        channels=station_inventories_default_dict[station],
        total_number_of_channels=len(
            station_inventories_default_dict[station]))

    print(station_inventories_default_dict[station][0])

    print(station_inv)
    station_inventories_list.append(station_inv)

network_start_end = False
# go through station start/end date dict and get the overall start_end date
for key, (start, end) in station_start_end_dict.iteritems():
Beispiel #4
0
def mt_station_to_inventory_station(station_obj, namespace="MT"):
    """
    Translate MT station metadata to inventory station

    Metadata that does not fit under StationXML schema is added as extra.

    :param station_obj: MT station metadata
    :type station_obj: :class:`~mth5.metadata.Station`

    :return: StationXML Station element
    :rtype: :class:`~obspy.core.inventory.Station`

    """
    inv_station = inventory.Station(
        station_obj.archive_id,
        station_obj.location.latitude,
        station_obj.location.longitude,
        station_obj.location.elevation,
    )

    used_list = [
        "channels_recorded",
        "time_period.start",
        "time_period.end",
        "location.latitude",
        "location.longitude",
        "location.elevation",
        "archive_id",
        "channel_layout",
        "hdf5_reference",
        "mth5_type",
    ]
    for inv_key, mth5_key in station_translator.items():
        if mth5_key is None:
            msg = "cannot currently map mth5.station to inventory.station.{0}".format(
                inv_key)
            logger.debug(msg)
            continue
        if inv_key == "operators":
            if station_obj.acquired_by.author is not None:
                operator = inventory.Operator(
                    agency=[station_obj.acquired_by.organization])
                person = inventory.Person(
                    names=[station_obj.acquired_by.author])
                operator.contacts = [person]
                inv_station.operators = [operator]
                used_list.append("acquired_by.author")
                used_list.append("acquired_by.organization")
        elif inv_key == "site":
            inv_station.site.description = station_obj.geographic_name
            inv_station.site.name = station_obj.id
            used_list.append("geographic_name")
            used_list.append("id")
        elif inv_key == "comments":
            if station_obj.comments is not None:
                comment = inventory.Comment(station_obj.comments, id=0)
                inv_station.comments.append(comment)
        else:
            setattr(inv_station, inv_key,
                    station_obj.get_attr_from_name(mth5_key))

    inv_station.extra = AttribDict({})

    # make declination entry
    dec_attrs = {
        "model": station_obj.location.declination.model,
        "comment": str(station_obj.location.declination.comments),
        "units": "degrees",
    }
    inv_station.extra.declination = AttribDict({
        "namespace":
        namespace,
        "value":
        station_obj.location.declination.value,
        "attrib":
        dec_attrs,
    })
    used_list += [
        "location.declination.model",
        "location.declination.value",
        "location.declination.comments",
    ]

    # make data type entry in comments
    inv_station.comments.append(
        inventory.Comment(station_obj.data_type, subject="MT data type"))
    used_list.append("data_type")

    # make submitter entry in comments
    submitter = ", ".join([
        "creation: {0}".format(station_obj.provenance.creation_time),
        "software: {0}".format(station_obj.provenance.software.name),
        "version: {0}".format(station_obj.provenance.software.version),
    ])

    inv_station.comments.append(
        inventory.Comment(
            submitter,
            subject="metadata creation",
            authors=[
                inventory.Person(
                    names=[station_obj.provenance.submitter.author],
                    emails=[station_obj.provenance.submitter.email],
                    agencies=[station_obj.provenance.submitter.organization],
                )
            ],
        ))

    # make a orientation comment
    orientation = ", ".join([
        "method: {0}".format(station_obj.orientation.method),
        "reference_frame: {0}".format(station_obj.orientation.reference_frame),
    ])

    inv_station.comments.append(
        inventory.Comment(orientation, subject="station orientation"))
    used_list += ["orientation.method", "orientation.reference_frame"]

    for mt_key in station_obj.get_attribute_list():
        if "provenance" in mt_key:
            continue
        if not mt_key in used_list:
            add_custom_element(
                inv_station.extra,
                mt_key,
                station_obj.get_attr_from_name(mt_key),
                units=station_obj._attr_dict[mt_key]["units"],
                namespace=namespace,
            )

    return inv_station
Beispiel #5
0
            ASDF_log_file.write("%s.%s_%s" %
                                (FDSNnetwork, station, service_mismatch) +
                                '\t' + "MismatchingChannels\n")

    # get the start/end dates from dict
    start_date = UTCDateTime(station_start_end_dict[station][0])
    end_date = UTCDateTime(station_start_end_dict[station][1])

    site = inventory.Site(name=station)

    # make the station_level inventory
    station = inventory.Station(code=station,
                                creation_date=start_date,
                                termination_date=end_date,
                                site=site,
                                latitude=value[0][0][0].latitude,
                                longitude=value[0][0][0].longitude,
                                elevation=value[0][0][0].elevation,
                                vault="Transportable Array",
                                channels=value[0][0])

    station_inventories_list.append(station)

network_start_end = False
# go through station start/end date dict and get the overall start_end date
for key, (start, end) in station_start_end_dict.iteritems():
    if not network_start_end:
        network_start_end = [start, end]
        continue

    if start < network_start_end[0]:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 19:26:01 2019

@author: jpeacock
"""

from obspy.core import inventory
from obspy.core.util import AttribDict

ns = 'MT'
code = 'MT666'

station_01 = inventory.Station(code, 40.0, -115.0, 1000)
channel_01 = inventory.Channel('SQE',
                               "",
                               39.0,
                               -112.0,
                               150,
                               0,
                               azimuth=90,
                               sample_rate=256,
                               dip=0,
                               types=['ELECTRIC POTENTIAL'])

channel_01.start_date = '2020-01-01T12:20:05.000000Z'
channel_01.end_date = '2020-01-05T62:40:15.000000Z'

channel_01.comments.append(inventory.Comment("DipoleLength = 10 meters"))
channel_01.extra = AttribDict()
channel_01.extra.DipoleLength = AttribDict()
                                  location_code='',
                                  depth=0,
                                  azimuth=270,
                                  dip=0,
                                  sample_rate=50,
                                  clock_drift_in_seconds_per_sample=0,
                                  latitude=fields[2],
                                  longitude=fields[3],
                                  elevation=fields[4])
    channels = [Z_channel, N_channel, E_channel]
    site = inventory.Site(name=fields[1], description=fields[10])
    station = inventory.Station(code=fields[1],
                                creation_date=start_Date,
                                termination_date=end_Date,
                                latitude=fields[2],
                                longitude=fields[3],
                                elevation=fields[4],
                                vault='Transportable Array',
                                channels=channels,
                                site=site)

    station_list.append(station)

    if i == len(data) - 1:
        network = inventory.Network(code=surv_name,
                                    alternate_code=fields[0],
                                    start_date=start_Date,
                                    stations=station_list)

        inv = inventory.Inventory(networks=[network],
                                  source='Geoscience Australia')