Example #1
0
    def test_readAndWriteSEED(self):
        """
        Reads all SEED records from the Bavarian network and writes them
        again.

        This should not change them.

        There are some differences which will be edited before comparison:
        - The written SEED file will always have the version 2.4. BW uses
          version 2.3.

        The different formating of numbers in the stations blockettes will not
        be changed but 'evened'. Both are valid ways to do it - see SEED-Manual
        chapter 3 for more informations.
        """
        # Loop over all files.
        for file in (self.BW_SEED_files[-1],):
            f = open(file, 'rb')
            # Original SEED file.
            original_seed = f.read()
            f.seek(0)
            # Parse and write the data.
            parser = Parser(f)
            f.close()
            new_seed = parser.getSEED()
            # compare both SEED strings
            compareSEED(original_seed, new_seed)
            del parser
            parser1 = Parser(original_seed)
            parser2 = Parser(new_seed)
            self.assertEqual(parser1.getSEED(), parser2.getSEED())
            del parser1, parser2
Example #2
0
    def test_xseed2dataless(self):
        with NamedTemporaryFile() as tf:
            with CatchOutput() as out:
                obspy_xseed2dataless(['--output', tf.name, self.xseed_file])

            expected = '''Found 1 files.
Parsing file %s
''' % (self.xseed_file,)
            self.assertEqual(expected.encode('utf-8'), out.stdout)

            with open(self.dataless_file, 'rb') as fh:
                expected = fh.read()
            with open(tf.name, 'rb') as fh:
                actual = fh.read()

            try:
                compareSEED(expected, actual)
            except Exception:
                self.fail('compareSEED raised Exception unexpectedly!')
            parser1 = Parser(expected)
            parser2 = Parser(actual)
            self.assertEqual(parser1.getSEED(), parser2.getSEED())
Example #3
0
try:
    print "rS",
    sys.stdout.flush()
    # parse SEED
    sp = Parser(org_seed)
    print "wS",
    sys.stdout.flush()
    # write SEED to compare to original SEED.
    f1 = open(seedfile, 'w')
    seed = sp.getSEED(compact=compact)
    f1.write(seed)
    f1.close()
    print "cS",
    sys.stdout.flush()
    # Compare to original SEED.
    utils.compareSEED(org_seed, seed)
    print "wX",
    sys.stdout.flush()
    # generate XSEED versions 1.0 and 1.1
    f1 = open(xseedfile_10, 'w')
    f2 = open(xseedfile_11, 'w')
    xml_10 = sp.getXSEED(version='1.0')
    xml_11 = sp.getXSEED()
    f1.write(xml_10)
    f1.close()
    f2.write(xml_11)
    f2.close()
    print "vX",
    sys.stdout.flush()
    # test against schemas
    if not skip: