Exemplo n.º 1
0
    def parse_arguments(self):
        """
        This function takes care of parsing the command-line arguments and
        asking the user for any missing parameters that we need
        """
        parser = argparse.ArgumentParser(description="Processes a numer of "
                                         "single segment BBP runs and combines "
                                         "them into a merged run.")
        parser.add_argument("--sim-id", dest="sim_id", type=int,
                            help="sim_id for merged simulation")
        parser.add_argument("--scenario", dest="scenario",
                            help="scenario name")
        parser.add_argument('input_sims', nargs='*')
        args = parser.parse_args()

        # Input simulations
        if len(args.input_sims) < 2:
            print("[ERROR]: Please provide at least two simulations to merge!")
            sys.exit(-1)

        self.input_sims = args.input_sims

        # Output simulation id
        if args.sim_id is None:
            self.output_sim_id = int(seqnum.get_seq_num())
        else:
            self.output_sim_id = args.sim_id

        # Scenario name
        if args.scenario is None:
            print("[ERROR]: Please provide a scenario name!")
            sys.exit(-1)

        self.scenario = args.scenario
Exemplo n.º 2
0
    def setUp(self):
        """
        Set up and stage in all input files
        """
        self.install = InstallCfg()
        self.hfsim_cfg = HfsimsCfg()
        self.velmodel = "genslip_nr_generic1d-gp01.vmod"
        self.srcfile = "test_wh.src"
        self.srffile = "m5.89-0.20x0.20_s2379646.srf"
        self.stations = "test_stat.txt"
        self.metadata = "metadata.txt"
        self.sim_id = int(seqnum.get_seq_num())

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_outdir, a_logdir],
                           print_cmd=False)

        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "gp", self.velmodel), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "gp", self.stations), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "gp", self.srffile), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "gp", self.srcfile), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 3
0
    def setUp(self):
        self.install = InstallCfg()
        self.cfg = BBToolboxCfg()
        self.sim_id = int(seqnum.get_seq_num())
        self.velmodel = "sdsu-aug2018-labasin-vmod.txt"
        self.srffile = "m589-s2379646.srf"
        self.stations = "test_stat.txt"
        self.srcfile = "wh_test.src"
        self.vmodel_name = "LABasin500"

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        a_refdir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_outdir, a_logdir],
                           print_cmd=False)

        cmd = "cp %s %s" % (os.path.join(a_refdir, self.velmodel), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.stations), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.srffile), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.srcfile), a_indir)
        bband_utils.runprog(cmd)
        for i in range(1, 6):
            cmd = "cp %s %s" % (
                os.path.join(self.install.A_TEST_REF_DIR, "gp", "s0%d-lf.bbp" %
                             (i)),
                os.path.join(a_tmpdir, "%d.s0%d-lf.bbp" % (self.sim_id, i)))
            bband_utils.runprog(cmd)
Exemplo n.º 4
0
    def setUp(self):
        self.install = InstallCfg()
        self.cfg = GenslipCfg()
        os.chdir(self.install.A_COMP_DIR)
        self.sim_id = int(seqnum.get_seq_num())
        self.velmodel = "nr02-vs500.fk1d"
        self.srcfile = "test_wh.src"
        self.outsrf = "%d_test_eq.srf" % self.sim_id

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir],
                           print_cmd=False)

        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.velmodel,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.srcfile,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 5
0
 def setUp(self):
     self.install = InstallCfg()
     self.r_velmodel = "labasin.vel"
     self.vmodel_name = "LABasin"
     self.r_srcfile = "test_wh_ucsb.src"
     self.r_srffile = "FFSP_OUTPUT.001"
     self.sim_id = int(seqnum.get_seq_num())
     self.cfg = UCrmgCfg(self.vmodel_name)
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                      self.r_srcfile,
                                      self.install.A_IN_DATA_DIR,
                                      self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                      self.r_velmodel,
                                      self.install.A_IN_DATA_DIR,
                                      self.sim_id)
     bband_utils.runprog(cmd)
     os.chdir(os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id)))
Exemplo n.º 6
0
 def setUp(self):
     self.install = InstallCfg()
     self.wcc_siteamp_cfg = WccSiteampCfg()
     os.chdir(self.install.A_INSTALL_ROOT)
     self.stations = "test_stat.txt"
     self.sim_id = int(seqnum.get_seq_num())
     self.freqs = ['lf', 'hf']
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = ("cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                     self.stations,
                                     self.install.A_IN_DATA_DIR,
                                     self.sim_id))
     bband_utils.runprog(cmd)
     for i in range(1, 6):
         for freq in self.freqs:
             cmd = ("cp %s/gp/s%02d-%s.bbp %s/%d/%d.s%02d-%s.bbp" %
                    (self.install.A_TEST_REF_DIR, i, freq,
                     self.install.A_TMP_DATA_DIR, self.sim_id,
                     self.sim_id, i, freq))
             bband_utils.runprog(cmd)
Exemplo n.º 7
0
    def setUp(self):
        """
        Copy needed files to run the test
        """
        self.velmodel = "genslip_nr_generic1d-gp01.vmod"
        self.srffile = "m5.89-0.20x0.20_s2379646.srf"
        self.stations = "one_stat.txt"
        self.vmodel_name = "LABasin"
        self.sim_id = int(seqnum.get_seq_num())

        self.install = InstallCfg()
        self.jbsim_cfg = JbsimCfg(self.vmodel_name)

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.velmodel,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.stations,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.srffile,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 8
0
    def setUp(self):
        """
        Set up and stage in all input files
        """
        self.install = InstallCfg()
        self.velmodel = "nr02-vs500.fk1d"
        self.srcfile = "whittier_v12_11_0_fs.src"
        self.srffile = "whittier_v12_11_0_fs.srf"
        self.stations = "whittier_v19_02_1_short.stl"
        self.sim_id = int(seqnum.get_seq_num())

        # Set up paths
        refdir = os.path.join(self.install.A_TEST_REF_DIR, "irikura")
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_outdir, a_logdir],
                           print_cmd=False)

        cmd = "cp %s %s" % (os.path.join(refdir, self.velmodel), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(refdir, self.stations), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(refdir, self.srffile), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(refdir, self.srcfile), a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 9
0
 def setUp(self):
     self.install = InstallCfg()
     self.match_cfg = MatchCfg()
     os.chdir(self.install.A_INSTALL_ROOT)
     self.stations = "test_stat.txt"
     self.vmodel_name = "LABasin"
     self.sim_id = int(seqnum.get_seq_num())
     self.freqs = ['lf', 'hf']
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                    self.stations,
                                    self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     for i in range(1, 6):
         for freq in self.freqs:
             cmd = ("cp %s/gp/s%02d-%s-site.bbp %s/%d/%d.s%02d-%s.acc.bbp" %
                    (self.install.A_TEST_REF_DIR, i, freq,
                     self.install.A_TMP_DATA_DIR, self.sim_id, self.sim_id,
                     i, freq))
             bband_utils.runprog(cmd)
Exemplo n.º 10
0
    def setUp(self):
        self.install = InstallCfg()
        self.cfg = GenslipCfg()
        os.chdir(self.install.A_COMP_DIR)
        self.sim_id = int(seqnum.get_seq_num())
        self.velmodel = "genslip_nr_generic1d-gp01.vmod"
        self.srcfile = "test_wh.src"
        self.outsrf = "%d_test_eq.srf" % self.sim_id

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir],
                           print_cmd=False)

        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.velmodel,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.srcfile,
                                       self.install.A_IN_DATA_DIR,
                                       self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 11
0
    def setUp(self):
        """
        Copy needed files to run the test
        """
        self.velmodel = "nr02-vs500.fk1d"
        self.srffile = "m5.89-0.20x0.20_s2379646.srf"
        self.stations = "one_stat.txt"
        self.vmodel_name = "LABasin500"
        self.sim_id = int(seqnum.get_seq_num())

        self.install = InstallCfg()

        refdir = os.path.join(self.install.A_TEST_REF_DIR, "gp")
        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        cmd = "cp %s %s" % (os.path.join(refdir, self.velmodel), indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(refdir, self.stations), indir)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s %s" % (os.path.join(refdir, self.srffile), indir)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 12
0
    def setUp(self):
        self.install = InstallCfg()
        self.stations = "nr_v13_3_1.stl"
        self.source = "nr_v14_02_1.src"
        self.eventname = "NR"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.basename(os.path.splitext(self.stations)[0])
        sim_id = self.sim_id

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(sim_id))
        a_tmpdir_seis = os.path.join(self.install.A_TMP_DATA_DIR, str(sim_id),
                                     "obs_seis_%s" % (sta_base))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(sim_id))
        a_validation_outdir = os.path.join(a_outdir, "validations",
                                           "stewart_duration_gmpe")

        # Create directories
        bband_utils.mkdirs([
            a_indir, a_tmpdir, a_tmpdir_seis, a_outdir, a_logdir,
            a_validation_outdir
        ])

        # Copy station list
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR, "as16",
                                         self.stations), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR, "as16",
                                         self.source), a_indir)
        bband_utils.runprog(cmd)
Exemplo n.º 13
0
    def setUp(self):
        """
        Copy needed files to run the test
        """
        self.velmodel = "genslip_nr_generic1d-gp01.vmod"
        self.srffile = "m5.89-0.20x0.20_s2379646.srf"
        self.stations = "one_stat.txt"
        self.vmodel_name = "LABasin"
        self.sim_id = int(seqnum.get_seq_num())

        self.install = InstallCfg()
        self.jbsim_cfg = JbsimCfg(self.vmodel_name)

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.velmodel,
                                       self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.stations,
                                       self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
        cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                       self.srffile,
                                       self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 14
0
    def setUp(self):
        self.install = InstallCfg()
        self.stations = "nr_v13_3_1.stl"
        self.source = "nr_v14_02_1.src"        
        self.eventname = "NR"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.basename(os.path.splitext(self.stations)[0])
        sim_id = self.sim_id

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(sim_id))
        a_tmpdir_seis = os.path.join(self.install.A_TMP_DATA_DIR,
                                     str(sim_id),
                                     "obs_seis_%s" % (sta_base))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(sim_id))
        a_validation_outdir = os.path.join(a_outdir,
                                           "validations",
                                           "stewart_duration_gmpe")

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_tmpdir_seis,
                            a_outdir, a_logdir, a_validation_outdir])

        # Copy station list
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "as16", self.stations),
                            a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "as16", self.source),
                            a_indir)
        bband_utils.runprog(cmd)
Exemplo n.º 15
0
    def setUp(self):
        self.install = InstallCfg()
        self.r_srcfile = "test_wh_ucsb.src"
        self.r_faultfile = "ffsp.inp"
        self.r_velmodel = "nr02-vs500_lf.vel"
        self.vmodel_name = "LABasin500"
        self.sim_id = int(seqnum.get_seq_num())

        # Create directories
        a_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        cmd = "mkdir -p %s" % (a_indir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_tmpdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_outdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_logdir)
        bband_utils.runprog(cmd)

        # Copy SRC file
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.r_srcfile), a_indir)
        bband_utils.runprog(cmd)
Exemplo n.º 16
0
    def setUp(self):
        self.install = InstallCfg()
        self.match_cfg = MatchCfg()
        os.chdir(self.install.A_INSTALL_ROOT)
        self.stations = "test_stat.txt"
        self.vmodel_name = "LABasin500"
        self.sim_id = int(seqnum.get_seq_num())
        self.freqs = ['lf', 'hf']

        refdir = os.path.join(self.install.A_TEST_REF_DIR, "gp")
        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        # Copy station list
        cmd = "cp %s %s" % (os.path.join(refdir, self.stations), indir)
        bband_utils.runprog(cmd)

        for i in range(1, 6):
            for freq in self.freqs:
                cmd = "cp %s %s" % (os.path.join(
                    refdir, "s%02d-%s-site.bbp" % (i, freq)),
                                    os.path.join(
                                        tmpdir, "%d.s%02d-%s.acc.bbp" %
                                        (self.sim_id, i, freq)))
                bband_utils.runprog(cmd)
Exemplo n.º 17
0
    def setUp(self):
        """
        Set up unit test
        """
        self.install = InstallCfg()
        self.r_velocity = "labasin.vel"
        self.r_stations = "one_stat.txt"
        self.r_src = "test_wh_ucsb.src"
        self.r_srf = "test_ucsb.srf"
        self.sim_id = int(seqnum.get_seq_num())
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))

        #
        # Make sure output directories exist
        #
        bband_utils.mkdirs([a_indir, a_tmpdir, a_outdir, a_logdir],
                           print_cmd=False)

        # Copy files
        a_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")

        # Copy seismogram
        shutil.copy2(os.path.join(a_refdir, "s01.3comp"), a_tmpdir)

        # Copy other input files
        shutil.copy2(os.path.join(a_refdir, self.r_stations), a_indir)
        shutil.copy2(os.path.join(a_refdir, self.r_velocity), a_indir)
        shutil.copy2(os.path.join(a_refdir, self.r_src), a_indir)
        shutil.copy2(os.path.join(a_refdir, self.r_srf), a_indir)

        # Change directory to tmpdir
        os.chdir(a_tmpdir)
Exemplo n.º 18
0
    def setUp(self):
        self.install = InstallCfg()
        self.r_velmodel = "nr02-vs500_lf.vel"
        self.vmodel_name = "LABasin500"
        self.r_srcfile = "test_wh_ucsb.src"
        self.r_srffile = "FFSP_OUTPUT.001"
        self.sim_id = int(seqnum.get_seq_num())
        self.cfg = UCrmgCfg(self.vmodel_name)

        a_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))

        cmd = "mkdir -p %s" % (a_indir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_tmpdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_outdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_logdir)
        bband_utils.runprog(cmd)

        cmd = "cp %s %s" % (os.path.join(a_refdir, self.r_srcfile), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.r_velmodel), a_indir)
        bband_utils.runprog(cmd)

        os.chdir(a_tmpdir)
Exemplo n.º 19
0
 def __init__(self, snum=None):
     if snum == None:
         self.sim_id = seqnum.get_seq_num()
     else:
         self.sim_id = int(snum)
     install = InstallCfg.getInstance()
     logdir = install.A_OUT_LOG_DIR
     self.outlogfile = logdir + "/%d/%d.txt" % (self.sim_id, self.sim_id)
Exemplo n.º 20
0
    def setUp(self):
        self.install = InstallCfg()
        self.sim_id = int(seqnum.get_seq_num())
        self.a_outdir = os.path.join(self.install.A_OUT_DATA_DIR,
                                     str(self.sim_id))

        # Create directories
        bband_utils.mkdirs([self.a_outdir])
Exemplo n.º 21
0
 def __init__(self, snum=None):
     if snum == None:
         self.sim_id = seqnum.get_seq_num()
     else:
         self.sim_id = int(snum)
     install = InstallCfg.getInstance()
     logdir = install.A_OUT_LOG_DIR
     self.outlogfile = logdir + "/%d/%d.txt" % (self.sim_id, self.sim_id)
Exemplo n.º 22
0
    def setUp(self):
        """
        Set up and stage in input files
        """

        self.install = InstallCfg()
        self.cfg = SDSUMOGofCfg()
        os.chdir(self.install.A_INSTALL_ROOT)
        self.r_velocity = ""
        self.gof_weights = dict()
        #  Weighting on PGA
        self.gof_weights["pga"] = 1.0
        #  Weighting on PGV
        self.gof_weights["pgv"] = 1.0
        #  Weighting on PGD
        self.gof_weights["pgd"] = 1.0
        #  Weighting on PSA
        self.gof_weights["psa"] = 1.0
        #  Weighting on Spectral Fit
        self.gof_weights["spectral_Fit"] = 1.0
        #  Weighting on Cumulative Energy Fit
        self.gof_weights["cumulative_energy_fit"] = 1.0
        #  Weighting on Inelastic/Elastic Fit (16)
        self.gof_weights["inelastic_elastic_fit"] = 1.0
        #  Weighting on Spec Acc (16)
        self.gof_weights["sepctral_acc"] = 1.0
        #  Weighting on Spec Dur (16)
        self.gof_weights["spec_duration"] = 1.0
        #  Weighting on Data Energy Release Duration (5%-75%)
        self.gof_weights["data_energy_release_duration"] = 1.0
        #  Weighting on Cross-Correlation
        self.gof_weights["cross_correlation"] = 1.0
        #  Weighting on Fourier Spectrum
        self.gof_weights["fourier_spectrum"] = 1.0

        self.plot_map = False
        self.r_datadir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.r_format = "A"
        self.r_mag = 0.0
        self.r_comparison_label = "Northridge"
        self.sim_id = int(seqnum.get_seq_num())
        self.a_ref_dir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.a_res_dir = os.path.join(self.install.A_OUT_DATA_DIR,
                                      str(self.sim_id))
        self.in_data_dir = os.path.join(self.install.A_IN_DATA_DIR,
                                        str(self.sim_id))
        self.tmp_data_dir = os.path.join(self.install.A_TMP_DATA_DIR,
                                         str(self.sim_id))
        self.out_data_dir = os.path.join(self.install.A_OUT_DATA_DIR,
                                         str(self.sim_id))
        self.out_log_dir = os.path.join(self.install.A_OUT_LOG_DIR,
                                        str(self.sim_id))
        os.mkdir(self.in_data_dir)
        os.mkdir(self.tmp_data_dir)
        os.mkdir(self.out_data_dir)
        os.mkdir(self.out_log_dir)

        os.chdir(os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id)))
Exemplo n.º 23
0
    def setUp(self):
        self.install = InstallCfg()
        self.gp_gof_cfg = GPGofCfg()
        os.chdir(self.install.A_INSTALL_ROOT)
        self.srcfile = "test_wh.src"
        self.stations = "test_stat.txt"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.basename(os.path.splitext(self.stations)[0])

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir_seis = os.path.join(self.install.A_OUT_DATA_DIR,
                                     str(self.sim_id),
                                     "obs_seis_%s" % (sta_base))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_outdir_seis,
                            a_outdir, a_logdir],
                           print_cmd=False)
        # Copy stations
        cmd = "cp %s/gp/%s %s/." % (self.install.A_TEST_REF_DIR,
                                    self.stations,
                                    a_indir)
        bband_utils.runprog(cmd, print_cmd=False)
        # Copy src file
        cmd = "cp %s/gp/%s %s/." % (self.install.A_TEST_REF_DIR,
                                    self.srcfile,
                                    a_indir)
        bband_utils.runprog(cmd, print_cmd=False)

        for i in range(1, 6):
            # Copy sample calculated seismograms and response files
            cmd = ("cp %s/gp/s%02d.merged.bbp %s/%d/%d.s%02d.vel.bbp" %
                   (self.install.A_TEST_REF_DIR, i,
                    self.install.A_OUT_DATA_DIR, self.sim_id,
                    self.sim_id, i))
            bband_utils.runprog(cmd, print_cmd=False)
            cmd = ("cp %s/gp/s%02d.rd50 %s/%d/%d.s%02d.rd50" %
                   (self.install.A_TEST_REF_DIR, i,
                    self.install.A_OUT_DATA_DIR, self.sim_id,
                    self.sim_id, i))
            bband_utils.runprog(cmd, print_cmd=False)
            # Cope sample observed seismograms and response files
            cmd = ("cp %s/gp/s%02d.merged.bbp %s/s%02d.bbp" %
                   (self.install.A_TEST_REF_DIR, i,
                    a_outdir_seis, i))
            bband_utils.runprog(cmd, print_cmd=False)
            cmd = ("cp %s/gp/s%02d.rd50 %s/s%02d.rd50" %
                   (self.install.A_TEST_REF_DIR, i,
                    a_outdir_seis, i))
            bband_utils.runprog(cmd, print_cmd=False)
Exemplo n.º 24
0
    def setUp(self):
        self.install = InstallCfg()
        self.stations = "nr_v13_3_1.stl"
        self.eventname = "NR"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.basename(os.path.splitext(self.stations)[0])
        sim_id = self.sim_id

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(sim_id))
        a_tmpdir_seis = os.path.join(self.install.A_TMP_DATA_DIR,
                                     str(sim_id),
                                     "obs_seis_%s" % (sta_base))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(sim_id))
        a_validation_outdir = os.path.join(a_outdir, "validations",
                                           "rzz2015")

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_tmpdir_seis,
                            a_outdir, a_logdir, a_validation_outdir])

        # Copy station list
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "rzz2015", self.stations),
                            a_indir)
        bband_utils.runprog(cmd)

        # Read station list
        slo = StationList(os.path.join(a_indir, self.stations))
        site_list = slo.getStationList()

        # Loop over stations
        for site in site_list:
            station = site.scode
            src_sims_acc = os.path.join(self.install.A_TEST_REF_DIR,
                                        "rzz2015", "syn_seis",
                                        "%s.acc.bbp" % (station))
            dst_sims_acc = os.path.join(a_outdir, "%d.%s.acc.bbp" %
                                        (sim_id, station))
            src_obs_acc = os.path.join(self.install.A_TEST_REF_DIR,
                                       "rzz2015", "obs_seis",
                                       "%s.bbp" % (station))
            dst_obs_acc = os.path.join(a_tmpdir_seis, "%s.bbp" %
                                       (station))

            cmd = "cp %s %s" % (src_sims_acc, dst_sims_acc)
            bband_utils.runprog(cmd)

            cmd = "cp %s %s" % (src_obs_acc, dst_obs_acc)
            bband_utils.runprog(cmd)
Exemplo n.º 25
0
    def setUp(self):
        self.install = InstallCfg()
        self.stations = "nr_v13_3_1.stl"
        self.eventname = "NR"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.basename(os.path.splitext(self.stations)[0])
        sim_id = self.sim_id

        # Set up paths
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(sim_id))
        a_tmpdir_seis = os.path.join(self.install.A_TMP_DATA_DIR,
                                     str(sim_id),
                                     "obs_seis_%s" % (sta_base))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(sim_id))
        a_validation_outdir = os.path.join(a_outdir, "validations",
                                           "rzz2015")

        # Create directories
        bband_utils.mkdirs([a_indir, a_tmpdir, a_tmpdir_seis,
                            a_outdir, a_logdir, a_validation_outdir])

        # Copy station list
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "rzz2015", self.stations),
                            a_indir)
        bband_utils.runprog(cmd)

        # Read station list
        slo = StationList(os.path.join(a_indir, self.stations))
        site_list = slo.getStationList()

        # Loop over stations
        for site in site_list:
            station = site.scode
            src_sims_acc = os.path.join(self.install.A_TEST_REF_DIR,
                                        "rzz2015", "syn_seis",
                                        "%s.acc.bbp" % (station))
            dst_sims_acc = os.path.join(a_outdir, "%d.%s.acc.bbp" %
                                        (sim_id, station))
            src_obs_acc = os.path.join(self.install.A_TEST_REF_DIR,
                                       "rzz2015", "obs_seis",
                                       "%s.bbp" % (station))
            dst_obs_acc = os.path.join(a_tmpdir_seis, "%s.bbp" %
                                       (station))

            cmd = "cp %s %s" % (src_sims_acc, dst_sims_acc)
            bband_utils.runprog(cmd)

            cmd = "cp %s %s" % (src_obs_acc, dst_obs_acc)
            bband_utils.runprog(cmd)
Exemplo n.º 26
0
    def setUp(self):
        self.r_velmodel = "labasin.vel"
        self.r_srcfile = "test_wh_ucsb.src"
        self.r_metadata = "metadata.txt"
        self.r_stations = "one_stat.txt"
        self.r_srffile = "FFSP_OUTPUT.001"
        self.vmodel_name = "LABasin"
        self.sim_id = int(seqnum.get_seq_num())

        self.install = InstallCfg()
        self.cfg = Syn1DCfg(self.vmodel_name)

        cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                         self.r_srffile,
                                         self.install.A_IN_DATA_DIR,
                                         self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                         self.r_srcfile,
                                         self.install.A_IN_DATA_DIR,
                                         self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                         self.r_velmodel,
                                         self.install.A_IN_DATA_DIR,
                                         self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                         self.r_stations,
                                         self.install.A_IN_DATA_DIR,
                                         self.sim_id)
        bband_utils.runprog(cmd)
        cmd = ("cp %s/ucsb/faultGlobal.in %s/%d/." %
               (self.install.A_TEST_REF_DIR, self.install.A_TMP_DATA_DIR,
                self.sim_id))
        bband_utils.runprog(cmd)
        cmd = ("cp %s/ucsb/source_model.list %s/%d/." %
               (self.install.A_TEST_REF_DIR, self.install.A_TMP_DATA_DIR,
                self.sim_id))
        bband_utils.runprog(cmd)

        os.chdir(os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id)))
Exemplo n.º 27
0
    def setUp(self):
        """
        Copy needed files to run the test
        """
        self.install = InstallCfg()
        self.sim_id = int(seqnum.get_seq_num())
        self.a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        self.a_ucsb_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")
        self.a_sdsu_refdir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.a_gp_refdir = os.path.join(self.install.A_TEST_REF_DIR, "gp")

        #
        # Make sure output directories exist
        #
        bband_utils.mkdirs([self.a_tmpdir])
Exemplo n.º 28
0
    def setUp(self):
        """
        Copy needed files to run the test
        """
        self.install = InstallCfg()
        self.sim_id = int(seqnum.get_seq_num())
        self.a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR,
                                     str(self.sim_id))
        self.a_ucsb_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")
        self.a_sdsu_refdir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.a_gp_refdir = os.path.join(self.install.A_TEST_REF_DIR, "gp")

        #
        # Make sure output directories exist
        #
        bband_utils.mkdirs([self.a_tmpdir])
Exemplo n.º 29
0
    def setUp(self):
        self.r_velmodel = "labasin.vel"
        self.r_srcfile = "test_wh_ucsb.src"
        self.r_metadata = "metadata.txt"
        self.r_stations = "one_stat.txt"
        self.r_srffile = "FFSP_OUTPUT.001"
        self.vmodel_name = "LABasin"
        self.sim_id = int(seqnum.get_seq_num())

        self.install = InstallCfg()
        self.cfg = Syn1DCfg(self.vmodel_name)

        cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (
            self.install.A_TEST_REF_DIR, self.r_srffile,
            self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (
            self.install.A_TEST_REF_DIR, self.r_srcfile,
            self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (
            self.install.A_TEST_REF_DIR, self.r_velmodel,
            self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = "cp %s/ucsb/%s %s/%d/." % (
            self.install.A_TEST_REF_DIR, self.r_stations,
            self.install.A_IN_DATA_DIR, self.sim_id)
        bband_utils.runprog(cmd)
        cmd = ("cp %s/ucsb/faultGlobal.in %s/%d/." %
               (self.install.A_TEST_REF_DIR, self.install.A_TMP_DATA_DIR,
                self.sim_id))
        bband_utils.runprog(cmd)
        cmd = ("cp %s/ucsb/source_model.list %s/%d/." %
               (self.install.A_TEST_REF_DIR, self.install.A_TMP_DATA_DIR,
                self.sim_id))
        bband_utils.runprog(cmd)

        os.chdir(os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id)))
Exemplo n.º 30
0
    def setUp(self):
        """
        Cope needed files to run the test
        """
        self.vmodel_name = "LABasin"
        self.sim_id = int(seqnum.get_seq_num())
        self.install = InstallCfg()
        self.vmodel_obj = vmodels.get_velocity_model_by_name(self.vmodel_name)

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        # Copy needed files

        # src file
        r_src_file = "nr_v12_11_0_fs.src"
        src_file = os.path.join(self.install.A_TEST_REF_DIR, "uwo", r_src_file)
        self.src_file = os.path.join(indir, r_src_file)
        cmd = "cp %s %s" % (src_file, self.src_file)
        bband_utils.runprog(cmd)

        # exsim param template file
        vmodel_params = self.vmodel_obj.get_codebase_params('exsim')
        self.failIf('GENERIC_PARAM' not in vmodel_params)
        r_param_template = vmodel_params['GENERIC_PARAM']

        self.failIf(r_param_template == "" or r_param_template is None)
        param_template = os.path.join(self.vmodel_obj.base_dir,
                                      r_param_template)
        # r_param_template is relative to the velocity model basedir,
        # get only basename
        r_param_template = os.path.basename(r_param_template)
        self.param_template = os.path.join(indir, r_param_template)
        cmd = "cp %s %s" % (param_template, self.param_template)
        bband_utils.runprog(cmd)

        # station file
        r_stations = "nr_v12_11_2.stl"
        stations = os.path.join(self.install.A_TEST_REF_DIR, "uwo", r_stations)
        self.stations = os.path.join(indir, r_stations)
        cmd = "cp %s %s" % (stations, self.stations)
        bband_utils.runprog(cmd)
Exemplo n.º 31
0
    def setUp(self):
        """
        Sets up the environment for the test
        """
        self.install = install_cfg.InstallCfg.getInstance()
        self.sim_id = int(seqnum.get_seq_num())

        # Make sure all directories exist
        self.indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        self.tmpdir = os.path.join(self.install.A_TMP_DATA_DIR,
                                   str(self.sim_id))
        self.outdir = os.path.join(self.install.A_OUT_DATA_DIR,
                                   str(self.sim_id))
        self.logdir = os.path.join(self.install.A_OUT_LOG_DIR,
                                   str(self.sim_id))
        bband_utils.mkdirs([self.indir, self.tmpdir, self.outdir, self.logdir],
                           print_cmd=False)
Exemplo n.º 32
0
 def setUp(self):
     self.install = InstallCfg()
     os.chdir(self.install.A_INSTALL_ROOT)
     self.velocity = "labasin.vel"
     self.srffile = "test_ucsb.srf"
     self.stations = "test_stat.txt"
     self.sim_id = int(seqnum.get_seq_num())
     sta_base = os.path.splitext(self.stations)[0]
     self.a_tmpdir_mod = os.path.join(self.install.A_TMP_DATA_DIR,
                                      str(self.sim_id),
                                      "uc_stitch_%s" % (sta_base))
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                      self.velocity,
                                      self.install.A_IN_DATA_DIR,
                                      self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                      self.srffile,
                                      self.install.A_IN_DATA_DIR,
                                      self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                    self.stations,
                                    self.install.A_IN_DATA_DIR,
                                    self.sim_id)
     bband_utils.runprog(cmd)
     for i in range(1, 6):
         cmd = ("cp %s/gp/s%02d-lf.bbp %s/%d/%d.s%02d-lf.bbp" %
                (self.install.A_TEST_REF_DIR, i,
                 self.install.A_TMP_DATA_DIR, self.sim_id,
                 self.sim_id, i))
         bband_utils.runprog(cmd)
         cmd = ("cp %s/ucsb/s%02d.3comp %s/%d/%d.s%02d.bbp" %
                (self.install.A_TEST_REF_DIR, i,
                 self.install.A_TMP_DATA_DIR, self.sim_id,
                 self.sim_id, i))
         bband_utils.runprog(cmd)
Exemplo n.º 33
0
    def setUp(self):
        self.install = InstallCfg()
        os.chdir(self.install.A_INSTALL_ROOT)
        self.velocity = "nr02-vs500_lf.vel"
        self.srffile = "test_ucsb.srf"
        self.stations = "test_stat.txt"
        self.sim_id = int(seqnum.get_seq_num())
        sta_base = os.path.splitext(self.stations)[0]
        self.a_tmpdir_mod = os.path.join(self.install.A_TMP_DATA_DIR,
                                         str(self.sim_id),
                                         "uc_stitch_%s" % (sta_base))

        # Create directories
        a_refdir = os.path.join(self.install.A_TEST_REF_DIR, "ucsb")
        a_indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        a_tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        a_logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        cmd = "mkdir -p %s" % (a_indir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_tmpdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_outdir)
        bband_utils.runprog(cmd)
        cmd = "mkdir -p %s" % (a_logdir)
        bband_utils.runprog(cmd)

        cmd = "cp %s %s" % (os.path.join(a_refdir, self.velocity), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(a_refdir, self.srffile), a_indir)
        bband_utils.runprog(cmd)
        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR, "gp",
                                         self.stations), a_indir)
        bband_utils.runprog(cmd)
        for i in range(1, 6):
            cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR, "gp",
                                             "s%02d-lf.bbp" % (i)),
                                os.path.join(
                                    a_tmpdir, "%d.s%02d-lf.bbp" %
                                    (self.sim_id, i)))
            bband_utils.runprog(cmd)
            cmd = "cp %s %s" % (os.path.join(a_refdir, "s%02d.3comp" % (i)),
                                os.path.join(a_tmpdir, "%d.s%02d.bbp" %
                                             (self.sim_id, i)))
            bband_utils.runprog(cmd)
Exemplo n.º 34
0
    def setUp(self):
        """
        Sets up the environment for the test
        """
        self.install = install_cfg.InstallCfg.getInstance()
        self.sim_id = int(seqnum.get_seq_num())

        # Make sure all directories exist
        self.indir = os.path.join(self.install.A_IN_DATA_DIR,
                                  str(self.sim_id))
        self.tmpdir = os.path.join(self.install.A_TMP_DATA_DIR,
                                   str(self.sim_id))
        self.outdir = os.path.join(self.install.A_OUT_DATA_DIR,
                                   str(self.sim_id))
        self.logdir = os.path.join(self.install.A_OUT_LOG_DIR,
                                   str(self.sim_id))
        bband_utils.mkdirs([self.indir, self.tmpdir, self.outdir, self.logdir],
                           print_cmd=False)
Exemplo n.º 35
0
    def setUp(self):
        self.install = InstallCfg()
        os.chdir(self.install.A_COMP_DIR)
        self.sim_id = int(seqnum.get_seq_num())
        self.srcfile = "test_whittier_song.src"
        self.outsrf = "%d_test_eq.srf" % self.sim_id

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir], print_cmd=False)

        cmd = "cp %s %s" % (
            os.path.join(self.install.A_TEST_REF_DIR, "song", self.srcfile),
            os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id)))
        bband_utils.runprog(cmd)
Exemplo n.º 36
0
    def parse_arguments(self):
        """
        This function takes care of parsing the command-line arguments and
        asking the user for any missing parameters that we need
        """
        parser = argparse.ArgumentParser(
            description="Processes a numer of "
            "single segment BBP runs and combines "
            "them into a merged run.")
        parser.add_argument("--sim-id",
                            dest="sim_id",
                            type=int,
                            help="sim_id for merged simulation")
        parser.add_argument("--event", dest="event", help="validation event")
        parser.add_argument('input_sims', nargs='*')
        args = parser.parse_args()

        # Input simulations
        if len(args.input_sims) < 2:
            print("[ERROR]: Please provide at least two simulations to merge!")
            sys.exit(-1)

        self.input_sims = args.input_sims

        # Output simulation id
        if args.sim_id is None:
            self.output_sim_id = int(seqnum.get_seq_num())
        else:
            self.output_sim_id = args.sim_id

        # Validation event
        if args.event is None:
            print("[ERROR]: Please provide a validation event!")
            sys.exit(-1)

        # Make sure event exists
        event_names = validation_cfg.VE_EVENTS.get_all_names()
        event_names_lc = [event.lower() for event in event_names]
        if not args.event.lower() in event_names_lc:
            print("[ERROR]: Unknown event %s!" % (args.event))
            print("[ERROR]: Available events: ", event_names)
        self.val_event = args.event
        self.val_obj = validation_cfg.VE_EVENTS.get_event_by_print_name(
            args.event)
Exemplo n.º 37
0
    def generate_xml(self, optfiles):
        install = InstallCfg.getInstance()

        # Generate xml workflows
        tests = []
        for key in optfiles.keys():
            sim_id = int(seqnum.get_seq_num())
            test = key.split('.')[0]
            xmlfile = os.path.join(self.input_dir, "%s.xml" % (test))
            if os.path.basename(xmlfile) in self.resume_list:
                # Skip this test
                print("Skipping %s" % (key))
                continue

            print("Generating %s" % (key))
            optfile = os.path.join(self.input_dir, key)

            # Save the option file
            op = open(optfile, 'w')
            for line in optfiles[key]:
                op.write("%s\n" % (line))
            op.close()

            # Generate xml
            print("Generating xml for %s" % (key))
            print("\t %s" % (str(optfiles[key])))
            cmd = ("%s --expert -s %d -g -o %s" % (os.path.join(
                install.A_COMP_DIR, "run_bbp.py"), sim_id, optfile))
            print("Running: %s" % (cmd))
            rc = bband_utils.runprog(cmd, False)
            if rc != 0:
                print("Failed to run bbp, aborting.")
                return []
            oldxmlfile = os.path.join(install.A_XML_DIR, "%d.xml" % (sim_id))
            shutil.copy2(oldxmlfile, xmlfile)
            if not os.path.exists(xmlfile):
                print("Workflow %s not found, aborting." % (xmlfile))
                return []

            tests.append([sim_id, xmlfile])
            time.sleep(1)

        return tests
Exemplo n.º 38
0
    def generate_xml(self, optfiles):
        install = InstallCfg.getInstance()

        # Generate xml workflows
        tests = []
        for key in optfiles.keys():
            sim_id = int(seqnum.get_seq_num())
            test = key.split('.')[0]
            xmlfile = os.path.join(self.input_dir, "%s.xml" % (test))
            if os.path.basename(xmlfile) in self.resume_list:
                # Skip this test
                print("Skipping %s" % (key))
                continue

            print("Generating %s" % (key))
            optfile = os.path.join(self.input_dir, key)

            # Save the option file
            op = open(optfile, 'w')
            for line in optfiles[key]:
                op.write("%s\n" % (line))
            op.close()

            # Generate xml
            print("Generating xml for %s" % (key))
            print("\t %s" % (str(optfiles[key])))
            cmd = ("%s/run_bbp.py --expert -s %d -g -o %s" %
                   (install.A_COMP_DIR, sim_id, optfile))
            print("Running: %s" % (cmd))
            rc = bband_utils.runprog(cmd, False)
            if rc != 0:
                print("Failed to run bbp, aborting.")
                return []
            oldxmlfile = os.path.join(install.A_XML_DIR, "%d.xml" % (sim_id))
            shutil.copy2(oldxmlfile, xmlfile)
            if not os.path.exists(xmlfile):
                print("Workflow %s not found, aborting." % (xmlfile))
                return []

            tests.append([sim_id, xmlfile])
            time.sleep(1)

        return tests
Exemplo n.º 39
0
 def setUp(self):
     self.install = InstallCfg()
     self.r_srcfile = "test_wh_ucsb.src"
     self.r_faultfile = "ffsp.inp"
     self.r_velmodel = "labasin.vel"
     self.vmodel_name = "LABasin"
     self.sim_id = int(seqnum.get_seq_num())
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (
         self.install.A_TEST_REF_DIR, self.r_srcfile,
         self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
Exemplo n.º 40
0
 def setUp(self):
     self.install = InstallCfg()
     self.r_srcfile = "test_wh_ucsb.src"
     self.r_faultfile = "ffsp.inp"
     self.r_velmodel = "labasin.vel"
     self.vmodel_name = "LABasin"
     self.sim_id = int(seqnum.get_seq_num())
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                      self.r_srcfile,
                                      self.install.A_IN_DATA_DIR,
                                      self.sim_id)
     bband_utils.runprog(cmd)
Exemplo n.º 41
0
    def setUp(self):
        """
        Set up unit test
        """
        self.install = InstallCfg()
        self.cfg = SDSUMOGofCfg()
        os.chdir(self.install.A_INSTALL_ROOT)
        self.r_velocity = ""
        self.gof_weights = dict()
        self.gof_weights["pga"] = 1.0                          #  Weighting on PGA
        self.gof_weights["pgv"] = 1.0                          #  Weighting on PGV
        self.gof_weights["pgd"] = 1.0                          #  Weighting on PGD
        self.gof_weights["psa"] = 1.0                          #  Weighting on PSA
        self.gof_weights["spectral_Fit"] = 0.0                 #  Weighting on Spectral Fit
        self.gof_weights["cumulative_energy_fit"] = 0.0        #  Weighting on Cumulative Energy Fit
        self.gof_weights["inelastic_elastic_fit"] = 0.0        #  Weighting on Inelastic/Elastic Fit (16)
        self.gof_weights["sepctral_acc"] = 0.0                 #  Weighting on Spec Acc (16)
        self.gof_weights["spec_duration"] = 0.0                #  Weighting on Spec Dur (16)
        self.gof_weights["data_energy_release_duration"] = 0.0 #  Weighting on Data Energy Release Duration (5%-75%)
        self.gof_weights["cross_correlation"] = 0.0            #  Weighting on Cross-Correlation
        self.gof_weights["fourier_spectrum"] = 0.0             #  Weighting on Fourier Spectrum

        self.plot_map = True
        self.r_datadir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.r_format = "A"
        self.r_mag = 0.0
        self.r_comparison_label = "Landers"
        self.r_cutoff = 10.0
        self.sim_id = int(seqnum.get_seq_num())
        self.a_ref_dir = os.path.join(self.install.A_TEST_REF_DIR, "sdsu")
        self.a_res_dir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        self.in_data_dir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        self.tmp_data_dir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        self.out_data_dir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        self.out_log_dir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        os.mkdir(self.in_data_dir)
        os.mkdir(self.tmp_data_dir)
        os.mkdir(self.out_data_dir)
        os.mkdir(self.out_log_dir)

        os.chdir(os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id)))
Exemplo n.º 42
0
    def parse_arguments(self):
        """
        This function takes care of parsing the command-line arguments and
        asking the user for any missing parameters that we need
        """
        parser = argparse.ArgumentParser(description="Processes a numer of "
                                         "single segment BBP runs and combines "
                                         "them into a merged run.")
        parser.add_argument("--sim-id", dest="sim_id", type=int,
                            help="sim_id for merged simulation")
        parser.add_argument("--event", dest="event",
                            help="validation event")
        parser.add_argument('input_sims', nargs='*')
        args = parser.parse_args()

        # Input simulations
        if len(args.input_sims) < 2:
            print("[ERROR]: Please provide at least two simulations to merge!")
            sys.exit(-1)

        self.input_sims = args.input_sims

        # Output simulation id
        if args.sim_id is None:
            self.output_sim_id = int(seqnum.get_seq_num())
        else:
            self.output_sim_id = args.sim_id

        # Validation event
        if args.event is None:
            print("[ERROR]: Please provide a validation event!")
            sys.exit(-1)

        # Make sure event exists
        event_names = validation_cfg.VE_EVENTS.get_all_names()
        event_names_lc = [event.lower() for event in event_names]
        if not args.event.lower() in event_names_lc:
            print("[ERROR]: Unknown event %s!" % (args.event))
            print("[ERROR]: Available events: ", event_names)
        self.val_event = args.event
        self.val_obj = validation_cfg.VE_EVENTS.get_event_by_print_name(args.event)
Exemplo n.º 43
0
 def permutation_test(self, file_base=file_base, xml_file=xml_file):
     input_dir = os.path.join(self.install.A_TEST_REF_DIR,
                              accept_test_inputs)
     log_dir = os.path.join(self.install.A_OUT_LOG_DIR,
                            "acceptance_test_logs")
     sim_id = int(seqnum.get_seq_num())
     self.file_base = file_base
     self.log_file = os.path.join(log_dir, "%s.log" % (self.file_base))
     self.input_file = os.path.join(input_dir, xml_file)
     cmd = ("%s/run_bbp.py -x %s -s %d -l %s" %
            (self.install.A_COMP_DIR,
             self.input_file, sim_id, self.log_file))
     rc = bband_utils.runprog(cmd, False)
     self.failIf(rc != 0, "Acceptance test failed to execute")
     ref_file_dir = os.path.join(self.install.A_TEST_REF_DIR,
                                 accept_test_refs,
                                 self.file_base)
     agree = True
     for ref_file in os.listdir(ref_file_dir):
         if os.path.isfile(os.path.join(ref_file_dir, ref_file)):
             test_file = os.path.join(self.install.A_OUT_DATA_DIR,
                                      str(sim_id),
                                      ("%d.%s" % (sim_id, ref_file)))
             a_ref_file = os.path.join(ref_file_dir, ref_file)
             compare_result = cmp_bbp.cmp_bbp(a_ref_file, test_file,
                                              tolerance=tolerance)
             errmsg = ("Output file "
                       "%s does not match reference file: %s" %
                       (test_file, a_ref_file))
             self.failIf(compare_result != 0, errmsg)
             if compare_result != 0:
                 agree = False
     if agree == True:
         # Write success to the resume file
         resume_fp = open(os.path.join(install.A_OUT_LOG_DIR,
                                       "resume.txt"), 'a')
         resume_fp.write("%s\n" % xml_file)
         resume_fp.flush()
         resume_fp.close()
     sys.stdout.flush()
     sys.stderr.flush()
Exemplo n.º 44
0
 def setUp(self):
     self.install = InstallCfg()
     os.chdir(self.install.A_INSTALL_ROOT)
     self.velocity = "labasin.vel"
     self.srffile = "test_ucsb.srf"
     self.stations = "test_stat.txt"
     self.sim_id = int(seqnum.get_seq_num())
     sta_base = os.path.splitext(self.stations)[0]
     self.a_tmpdir_mod = os.path.join(self.install.A_TMP_DATA_DIR,
                                      str(self.sim_id),
                                      "uc_stitch_%s" % (sta_base))
     cmd = "mkdir -p %s/%d" % (self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_TMP_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "mkdir -p %s/%d" % (self.install.A_OUT_LOG_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (
         self.install.A_TEST_REF_DIR, self.velocity,
         self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/ucsb/%s %s/%d/." % (
         self.install.A_TEST_REF_DIR, self.srffile,
         self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     cmd = "cp %s/gp/%s %s/%d/." % (self.install.A_TEST_REF_DIR,
                                    self.stations,
                                    self.install.A_IN_DATA_DIR, self.sim_id)
     bband_utils.runprog(cmd)
     for i in range(1, 6):
         cmd = ("cp %s/gp/s%02d-lf.bbp %s/%d/%d.s%02d-lf.bbp" %
                (self.install.A_TEST_REF_DIR, i,
                 self.install.A_TMP_DATA_DIR, self.sim_id, self.sim_id, i))
         bband_utils.runprog(cmd)
         cmd = ("cp %s/ucsb/s%02d.3comp %s/%d/%d.s%02d.bbp" %
                (self.install.A_TEST_REF_DIR, i,
                 self.install.A_TMP_DATA_DIR, self.sim_id, self.sim_id, i))
         bband_utils.runprog(cmd)
Exemplo n.º 45
0
    def setUp(self):
        self.install = InstallCfg()
        self.cfg = RMGCfg()
        os.chdir(self.install.A_COMP_DIR)
        self.sim_id = int(seqnum.get_seq_num())
        self.srcfile = "test_whittier_song.src"
        self.outsrf = "%d_test_eq.srf" % self.sim_id

        indir = os.path.join(self.install.A_IN_DATA_DIR, str(self.sim_id))
        tmpdir = os.path.join(self.install.A_TMP_DATA_DIR, str(self.sim_id))
        outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(self.sim_id))
        logdir = os.path.join(self.install.A_OUT_LOG_DIR, str(self.sim_id))
        # Create all directories
        bband_utils.mkdirs([indir, tmpdir, outdir, logdir],
                           print_cmd=False)

        cmd = "cp %s %s" % (os.path.join(self.install.A_TEST_REF_DIR,
                                         "song",
                                         self.srcfile),
                            os.path.join(self.install.A_IN_DATA_DIR,
                                         str(self.sim_id)))
        bband_utils.runprog(cmd)
Exemplo n.º 46
0
    def parse_arguments(self):
        """
        This function takes care of parsing the command-line arguments and
        asking the user for any missing parameters that we need
        """
        parser = argparse.ArgumentParser(
            description="Processes a numer of "
            "single segment BBP runs and combines "
            "them into a merged run.")
        parser.add_argument("--sim-id",
                            dest="sim_id",
                            type=int,
                            help="sim_id for merged simulation")
        parser.add_argument("--scenario",
                            dest="scenario",
                            help="scenario name")
        parser.add_argument('input_sims', nargs='*')
        args = parser.parse_args()

        # Input simulations
        if len(args.input_sims) < 2:
            print("[ERROR]: Please provide at least two simulations to merge!")
            sys.exit(-1)

        self.input_sims = args.input_sims

        # Output simulation id
        if args.sim_id is None:
            self.output_sim_id = int(seqnum.get_seq_num())
        else:
            self.output_sim_id = args.sim_id

        # Scenario name
        if args.scenario is None:
            print("[ERROR]: Please provide a scenario name!")
            sys.exit(-1)

        self.scenario = args.scenario
Exemplo n.º 47
0
    def test_gp2uc(self):
        """
        Inputs a GP format file and get out a UCSB format file
        """
        install = InstallCfg()
        sim_id = int(seqnum.get_seq_num())
        a_tmpdir = os.path.join(install.A_TMP_DATA_DIR, str(sim_id))
        a_refdir = os.path.join(install.A_TEST_REF_DIR, "ucsb")

        #
        # Make sure output directories exist
        #
        bband_utils.mkdirs([a_tmpdir], print_cmd=False)

        # File paths
        gpfile = os.path.join(a_refdir, "stats-h0.125.ll")
        ucref = os.path.join(a_refdir, "stations.ll")
        ofile = os.path.join(a_tmpdir, "stations.ll")
        ofile30 = os.path.join(a_tmpdir, "stations.vs30")

        sl = StationList(gpfile)
        _ = stas2files.gp2uc_stalist(sl, ofile, ofile30)
        errmsg = "Conversion of station list from GP to UC format failed"
        self.failIf(filecmp.cmp(ucref, ofile) == False, errmsg)
Exemplo n.º 48
0
        # Station file
        a_statfile = os.path.join(a_indir, self.r_stations)

        slo = StationList(a_statfile)
        site_list = slo.getStationList()

        # Go through each station
        # print "Working dir: %s" % (self.proc_dir)
        for site in site_list:
            stat = site.scode
            print("==> Correcting amplitudes for station: %s" % (stat))
            self.correct_station(stat, self.extension)

        print("Correct PSA Completed".center(80, '-'))

if __name__ == "__main__":
    print("Testing module: %s" % os.path.basename((sys.argv[0])))
    if len(sys.argv) < 5:
        print("usage: %s " % (sys.argv[0]) +
              "station_file corr_file extension"
              " proc_dir [sim_id]")
        sys.exit(1)
    if len(sys.argv) == 5:
        SIM_ID = int(seqnum.get_seq_num())
    else:
        SIM_ID = int(sys.argv[5])
    CORR_PSA = CorrectPSA(sys.argv[1], sys.argv[2], sys.argv[3],
                          sys.argv[4], SIM_ID)
    CORR_PSA.run()
Exemplo n.º 49
0
    def validation_test(self, event, code_base, test_name, run_rupture_gen):
        """
        This function runs the full validation test for the event and
        code_base specified. It creates a Broadband option file with
        the required answers in the input directory and then invokes
        the platform. After execution finishes, it checks if the .bbp
        files were correctly generated, and looks for the gof output
        file.
        """
        # event - Northridge = 1, Loma Prieta = 2, Landers = 3, LOMAP = 4
        #         NR = 5, Whittier = 6, Saguenay = 7
        # code_base GP = 1, UCSB = 2, SDSU = 3
        events = ["Northridge", "Loma Prieta",
                  "Landers", "LOMAP", "NR", "Whittier", "Saguenay"]

        num_stations = 0
        bbp_files_found = 0
        gof_png_file_found = False
        gof_png_file_valid = False
        a_station_list_filename = None
        install = InstallCfg()

        if SIM_ID is None:
            self.sim_id = int(seqnum.get_seq_num())
        else:
            self.sim_id = SIM_ID

        #print
        #print "Using sim_ID: %d..." % self.sim_id
        # Create input and log directories
        cmd = "mkdir -p %s" % os.path.join(install.A_IN_DATA_DIR,
                                           str(self.sim_id))
        self.failIf(bband_utils.runprog(cmd, False) != 0,
                    "Error creating input directory")
        cmd = "mkdir -p %s" % os.path.join(install.A_OUT_LOG_DIR,
                                           str(self.sim_id))
        self.failIf(bband_utils.runprog(cmd, False) != 0,
                    "Error creating log directory")
        # Create path for option file
        a_opt_filename = os.path.join(install.A_IN_DATA_DIR,
                                      str(self.sim_id),
                                      "%d.optfile" % (self.sim_id))
        try:
            opt_file = open(a_opt_filename, 'w')
            # Select validation run
            opt_file.write("y\n")
            # Select event
            opt_file.write("%s\n" % (events[event - 1]))
            # Select the rupture generator
            if run_rupture_gen:
                # Yes to rupture generator
                opt_file.write("y\n")
                if code_base == 2:
                    # Run UCSB rupture generator
                    opt_file.write("2\n")
                else:
                    # Otherwise run GP rupture generator
                    opt_file.write("1\n")
                # No need to provide custom src file, use existing
                opt_file.write("n\n")
            else:
                # Not using the rupture generator
                opt_file.write("n\n")
            # Validate all stations
            opt_file.write("1\n")
            # Select codebase
            if code_base == 1:
                # GP across the board
                opt_file.write("1\n1\n4\n")
            elif code_base == 2:
                # UCSB low-frequency requires UCSB across the board
                opt_file.write("3\n2\n4\n")
            elif code_base == 3:
                # SDSU doesn't have a low-frequency component
                opt_file.write("1\n3\n4\n")
            else:
                self.failIf(True, "Code base not supported!")
            # We don't want velocity seismograms
            opt_file.write("y\n")
            # But we want acceleration seismograms
            opt_file.write("y\n")
            # Select GOF module, for validation we want to use GP
            opt_file.write("1\n")
            opt_file.close()
        except IOError:
            self.failIf(True, "Cannot create option file!")

        # Log output to a_log_filename
        a_log_filename = os.path.join(install.A_OUT_LOG_DIR, str(self.sim_id),
                                      "%s.%s.log" % (str(self.sim_id),
                                                     test_name))

        # Run BBP command
        cmd = "%s/run_bbp.py -s %d -o %s >> %s" % (install.A_COMP_DIR,
                                                   self.sim_id,
                                                   a_opt_filename,
                                                   a_log_filename)
        # print cmd
        # Run the validation scenario
        self.failIf(bband_utils.runprog(cmd, False) != 0,
                    "Fatal error while running the Broadband Platform")
        # First look for the station list
        try:
            files = os.listdir(os.path.join(install.A_IN_DATA_DIR,
                                            str(self.sim_id)))
        except OSError:
            self.failIf(True, "Cannot access input directory!")

        for my_file in files:
            if my_file.endswith(".stl"):
                a_station_list_filename = os.path.join(install.A_IN_DATA_DIR,
                                                       str(self.sim_id),
                                                       my_file)
                break

        # Fail if we don't have a station list
        self.failIf(a_station_list_filename is None,
                    "Cannot find file with station list!")

        # Now, figure out how many stations we have
        try:
            stl_file = open(a_station_list_filename, 'r')
            for _ in stl_file:
                num_stations = num_stations + 1
        except IOError:
            self.failIf(True, "Cannot read station list file!")

       # Now look for the output files
        try:
            files = os.listdir(os.path.join(install.A_OUT_DATA_DIR,
                                            str(self.sim_id)))
        except OSError:
            self.failIf(True, "Cannot access output directory!")
        for my_file in files:
            if my_file.endswith(".acc.bbp"):
                a_bbp_file_path = os.path.join(install.A_OUT_DATA_DIR,
                                               str(self.sim_id),
                                               my_file)
                try:
                    my_size = os.stat(a_bbp_file_path).st_size
                except OSError:
                    self.failIf(True,
                                "Cannot stat file %s!" % a_bbp_file_path)
                # Ok, let's count this file
                if my_size > 0:
                    bbp_files_found = bbp_files_found + 1
            if my_file.startswith("gof-") and my_file.endswith(".png"):
                # Found the gof.png file
                gof_png_file_found = True
                a_gofpng_file_path = os.path.join(install.A_OUT_DATA_DIR,
                                                  str(self.sim_id),
                                                  my_file)
                try:
                    my_size = os.stat(a_gofpng_file_path).st_size
                except OSError:
                    self.failIf(True,
                                "Cannot stat file %s!" % a_gofpng_file_path)
                # Check if size > 0
                if my_size > 0:
                    gof_png_file_valid = True

        # Now check if we got the right results
        self.failIf(not gof_png_file_found, "GOF file not found!")
        self.failIf(not gof_png_file_valid, "GOF file size is 0!")
        self.failIf(bbp_files_found != num_stations,
                    "Found %d valid BBP files, expecting %d!" %
                    (bbp_files_found, num_stations))
Exemplo n.º 50
0
    if options.xmlFile is None or options.inputSimID is None:
        parser.error("Resume option requires both -x and -s options.")

# Check if user specified sim_id
if options.inputSimID:
    try:
        sim_id = int(options.inputSimID)
        if sim_id < 0:
            print("SimID must be a nonnegative integer.")
            sys.exit(2)
    except ValueError:
        print("SimID must be a nonnegative integer.")
        sys.exit(3)
else:
    # Otherwise, get sim_id from timestamp
    sim_id = int(seqnum.get_seq_num())

a_indir = os.path.join(install.A_IN_DATA_DIR, str(sim_id))
a_tmpdir = os.path.join(install.A_TMP_DATA_DIR, str(sim_id))
a_outdir = os.path.join(install.A_OUT_DATA_DIR, str(sim_id))
a_logdir = os.path.join(install.A_OUT_LOG_DIR, str(sim_id))

# Create indir, tmpdir, outdir, and logdir, if they don't exist
if not os.path.exists(a_indir):
    cmd = "mkdir %s" % (a_indir)
    rc = bband_utils.runprog(cmd, False)
    if rc != 0:
        print("Failed to create in directory %s, aborting." % (a_indir))
        sys.exit(1)
if not os.path.exists(a_tmpdir):
    cmd = "mkdir %s" % (a_tmpdir)