Example #1
0
    def test_schema_validation(self):
        with NamedTemporaryFile() as tf:
            obspy.Trace(data=np.arange(10, dtype=np.int32),
                        header={"starttime": obspy.UTCDateTime(0)}).write(
                tf.name, format="mseed")

            md = MSEEDMetadata(files=[tf.name])

            # One can either directly validate the metrics.
            md.validate_qc_metrics(md.meta)
            # Or do it during the serialization.
            md.get_json_meta(validate=True)

            # Also try with extracting the flags.
            md = MSEEDMetadata(files=[tf.name], add_flags=True)
            md.validate_qc_metrics(md.meta)
            md.get_json_meta(validate=True)
Example #2
0
    def test_schema_validation(self):
        with NamedTemporaryFile() as tf:
            obspy.Trace(data=np.arange(10, dtype=np.int32),
                        header={"starttime": obspy.UTCDateTime(0)}).write(
                tf.name, format="mseed")

            md = MSEEDMetadata(files=[tf.name])

            # One can either directly validate the metrics.
            md.validate_qc_metrics(md.meta)
            # Or do it during the serialization.
            md.get_json_meta(validate=True)

            # Also try with extracting the flags.
            md = MSEEDMetadata(files=[tf.name], add_flags=True)
            md.validate_qc_metrics(md.meta)
            md.get_json_meta(validate=True)
Example #3
0
    def test_json_serialization(self):
        """
        Just tests that it actually works and raises no error. We tested the
        dictionaries enough - now we just test the JSON encoder.
        """
        with NamedTemporaryFile() as tf:
            obspy.Trace(data=np.arange(10, dtype=np.int32),
                        header={"starttime": obspy.UTCDateTime(0)}).write(
                tf.name, format="mseed")

            md = MSEEDMetadata(files=[tf.name])

        self.assertTrue(md.get_json_meta())
Example #4
0
    def test_json_serialization(self):
        """
        Just tests that it actually works and raises no error. We tested the
        dictionaries enough - now we just test the JSON encoder.
        """
        with NamedTemporaryFile() as tf:
            obspy.Trace(data=np.arange(10, dtype=np.int32),
                        header={"starttime": obspy.UTCDateTime(0)}).write(
                tf.name, format="mseed")

            md = MSEEDMetadata(files=[tf.name])

        self.assertTrue(md.get_json_meta())
Example #5
0
from obspy.signal.quality_control import MSEEDMetadata

# IO Directories
INPUT = "/var/input"
OUTPUT = "/var/output/metadata.json"
ERROR = "/var/output/error.log"

# Get the filename from the input directory
files = [
  os.path.join(INPUT, file) for file in os.listdir(INPUT)
]

# Calculate the metadata
try:

  MD = MSEEDMetadata(
    files,
    add_c_segments=True,
    add_flags=True
  )

  # Write result to file
  with open(OUTPUT, "w") as outfile:
    outfile.write(MD.get_json_meta());

except Exception as e:
  
  # Write error to file
  with open(ERROR, "w") as outfile:
    outfile.write("Could not complete metric calculation: %s" % e);
Example #6
0
import os

from obspy.signal.quality_control import MSEEDMetadata

# IO Directories
INPUT = "/var/input"
OUTPUT = "/var/output/metadata.json"
ERROR = "/var/output/error.log"

# Get the filename from the input directory
files = [os.path.join(INPUT, file) for file in os.listdir(INPUT)]

# Calculate the metadata
try:

    MD = MSEEDMetadata(files, add_c_segments=True, add_flags=True)

    # Write result to file
    with open(OUTPUT, "w") as outfile:
        outfile.write(MD.get_json_meta())

except Exception as e:

    # Write error to file
    with open(ERROR, "w") as outfile:
        outfile.write("Could not complete metric calculation: %s" % e)