Ejemplo n.º 1
0
    def set_stations(self, stations: fetcher_station_type):
        """
        Set the station state in fetcher.

        Parameters
        ----------
        stations
            Data representing stations, from which a client or dataframe
            can be inferred.
        """
        try:
            self.station_client = get_station_client(stations)
        except TypeError:
            self.station_client = getattr(self, "station_client", None)
        try:
            # since its common for inventories to have far out enddates this
            # can raise a warning. These are safe to ignore.
            with suppress_warnings(category=TimeOverflowWarning):
                self.station_df = stations_to_df(stations)
        except TypeError:
            # if unable to get station info from stations use waveform client
            try:
                self.station_df = stations_to_df(self.waveform_client)
            except TypeError:
                #  if no waveforms try events
                try:
                    self.station_df = stations_to_df(self.event_client)
                except TypeError:
                    self.station_df = None
        # make sure seed_id is set
        if self.station_df is not None:
            self.station_df["seed_id"] = get_seed_id_series(self.station_df)
Ejemplo n.º 2
0
 def test_not_a_client(self):
     """ensure a non station-client-able object raises."""
     with pytest.raises(TypeError):
         get_station_client(1)
Ejemplo n.º 3
0
 def test_inventory_on_disk(self, bingham_dataset):
     """Ensure a path to an obspy-readable inventory works."""
     path = bingham_dataset.station_path / "UU.NOQ.xml"
     client = get_station_client(path)
     assert isinstance(client, StationClient)
     assert isinstance(client, obspy.Inventory)
Ejemplo n.º 4
0
 def test_inventory(self, bingham_dataset):
     """Ensure an inventory returns an inventory."""
     client = get_station_client(bingham_dataset.station_client)
     assert isinstance(client, StationClient)
     assert isinstance(client, obspy.Inventory)
Ejemplo n.º 5
0
 def test_read_inventory_from_file(self, tmpdir):
     """Should be able to read file into inventory."""
     path = Path(tmpdir) / "inv"
     inv = obspy.read_inventory()
     inv.write(str(path), "stationxml")
     assert inv == get_station_client(str(path))