Exemplo n.º 1
0
    def test_format_iris_webservice(self):
        """
        Tests the format IRIS webservice function.

        See issue #1096.
        """
        # These are parse slightly differently (1 microsecond difference but
        # the IRIS webservice string should be identical as its only
        # accurate to three digits.
        d1 = UTCDateTime(2011, 1, 25, 15, 32, 12.26)
        d2 = UTCDateTime("2011-01-25T15:32:12.26")

        self.assertEqual(d1.format_iris_web_service(), d2.format_iris_web_service())
Exemplo n.º 2
0
    def test_format_iris_webservice(self):
        """
        Tests the format IRIS webservice function.

        See issue #1096.
        """
        # These are parse slightly differently (1 microsecond difference but
        # the IRIS webservice string should be identical as its only
        # accurate to three digits.
        d1 = UTCDateTime(2011, 1, 25, 15, 32, 12.26)
        d2 = UTCDateTime("2011-01-25T15:32:12.26")

        self.assertEqual(d1.format_iris_web_service(),
                         d2.format_iris_web_service())
Exemplo n.º 3
0
def wav_in_asdf(
    network: str, station: str, location: str, channel: str,
        starttime: UTCDateTime, endtime: UTCDateTime) -> bool:
    """Is the waveform already in the asdf database?"""
    asdf_file = os.path.join(tmp.folder, os.pardir, '%s.%s.h5' % (
        network, station))

    if not os.path.isfile(asdf_file):
        logging.debug(f'{asdf_file} not found')
        return False

    # Change precision of start and endtime
    # Pyasdf rounds with a precision of 1 for the starttime and 0 for endtime
    starttime = UTCDateTime(
        starttime, precision=1).format_iris_web_service()[:-6]
    endtime = endtime.format_iris_web_service()[:-6]
    # make them patterns for the cases where it downloads a slightly different
    # time window
    starttime += '??'
    endtime += '??'

    # Waveforms are saved in pyasdf with filenames akin to:
    nametag = "%s.%s.%s.%s__%s__%s__raw_recording"\
        % (network, station, location, channel, starttime, endtime)

    with ASDFDataSet(asdf_file, mode='r') as ds:
        # Note .list only checks the names not the actual traces and is
        # therefore way faster!
        try:
            exists = len(fnmatch.filter(ds.waveforms[
                '%s.%s' % (network, station)].list(), nametag)) > 0
            # exists = nametag in ds.waveforms[
            #     '%s.%s' % (network, station)].list()
            if exists:
                logging.debug(f'{nametag} already exists!')
            return exists
        except KeyError:
            return False