当前位置: 首页>>代码示例>>Python>>正文


Python InstallCfg.getInstance方法代码示例

本文整理汇总了Python中install_cfg.InstallCfg.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python InstallCfg.getInstance方法的具体用法?Python InstallCfg.getInstance怎么用?Python InstallCfg.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在install_cfg.InstallCfg的用法示例。


在下文中一共展示了InstallCfg.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def run(self):
        """
        Corrects the amplitudes from all stations found in the station
        list according to the correction coefficients provided by the user
        """
        print("Correct PSA".center(80, '-'))

        # Initialize basic variables
        install = InstallCfg.getInstance()
        sim_id = self.sim_id
        sta_base = os.path.basename(os.path.splitext(self.r_stations)[0])

        self.log = os.path.join(install.A_OUT_LOG_DIR,
                                str(sim_id),
                                "%d.obs_seis.log" %
                                (sim_id))

        # Input, tmp, and output directories
        a_indir = os.path.join(install.A_IN_DATA_DIR, str(sim_id))

        # 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, '-'))
开发者ID:SCECcode,项目名称:BBP,代码行数:36,代码来源:correct_psa.py

示例2: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
def run(r_srffile, sim_id=0):
    """
    Creates a SRF plot from an SRF file
    """
    install = InstallCfg.getInstance()

    a_outdir = os.path.join(install.A_OUT_DATA_DIR, str(sim_id))
    a_tmpdir = os.path.join(install.A_TMP_DATA_DIR, str(sim_id))

    # Save current directory
    old_cwd = os.getcwd()
    os.chdir(a_tmpdir)

    # Write slip file
    srfbase = r_srffile[0:r_srffile.find(".srf")]
    slipfile = "%s.slip" % (srfbase)
    cmd = ("%s/srf2xyz calc_xy=0 type=slip nseg=-1 < %s > %s" %
           (install.A_GP_BIN_DIR, r_srffile, slipfile))
    bband_utils.runprog(cmd)

    # Write tinit file
    tinitfile = "%s.tinit" % (srfbase)
    cmd = ("%s/srf2xyz calc_xy=0 type=tinit nseg=-1 < %s > %s" %
           (install.A_GP_BIN_DIR, r_srffile, tinitfile))
    bband_utils.runprog(cmd)

    plottitle = 'Rupture Model for %s' % (r_srffile)
    plot(plottitle, r_srffile, a_outdir)

    os.chdir(old_cwd)
开发者ID:SCECcode,项目名称:BBP,代码行数:32,代码来源:plot_srf.py

示例3: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
 def __init__(self, station_file, sim_id=0, hypo=None):
     self.station_file = station_file
     self.sim_id = sim_id
     self.install = InstallCfg.getInstance()
     self.coast_file = os.path.join(self.install.A_PLOT_DATA_DIR,
                                    "cali_coastline.mapgen")
     if not os.path.isfile(self.coast_file):
         self.coast_file = ""
     self.value = "GOF"
     self.stats = []
     self.dx = 500.0 #100 mts grid resolution
     self.spacing = [self.dx, self.dx]
     self.hypo = hypo
     self.dim = []
     self.rbounds = []
     self.nw = []
     self.sw = []
     self.se = []
     self.ne = []
     self.PLOT_MAP_LOC = [0.10, 0.15, 0.8, 0.8]
     self.origin = []
     self.offset = []
     self.x_invert = False
     self.y_invert = False
     self.init_dims()
开发者ID:SCECcode,项目名称:BBP,代码行数:27,代码来源:plot_value_map.py

示例4: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
 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)
开发者ID:SCECcode,项目名称:BBP,代码行数:10,代码来源:logfile.py

示例5: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
 def __init__(self, sim_id=0, options=None):
     """
     Initialization for BBPStatus class
     """
     self.sim_id = sim_id
     self.__options = options
     self.install = InstallCfg.getInstance()
     self.outdir = os.path.join(self.install.A_OUT_DATA_DIR, str(sim_id))
开发者ID:SCECcode,项目名称:BBP,代码行数:10,代码来源:bbp_status.py

示例6: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def run(self):
        """
        Generates a map showing the fault with stations
        """
        print("Plot MAP".center(80, '-'))

        if (self.input_file is None or self.input_file == "" or
            (not self.input_file.endswith(".srf") and
            not self.input_file.endswith(".src"))):
            # We need a SRC or SRF file to get the fault geometry
            return

        install = InstallCfg.getInstance()

        a_indir = os.path.join(install.A_IN_DATA_DIR, str(self.sim_id))
        a_outdir = os.path.join(install.A_OUT_DATA_DIR, str(self.sim_id))

        a_input_file = os.path.join(a_indir, self.input_file)
        a_station_file = os.path.join(a_indir, self.station_file)

        # Define boundaries to plot using the stations in the station file
        (self.north, self.south,
         self.east, self.west) = set_boundaries_from_stations(a_station_file)

        self.log = os.path.join(install.A_OUT_LOG_DIR, str(self.sim_id),
                                "%d.plot_map.log" % (self.sim_id))
        trace_file = "%s.trace" % (a_input_file)
        simple_station_file = "%s.simple" % (a_station_file)
        if self.input_file.endswith(".srf"):
            self.trace = write_fault_trace(a_input_file, trace_file)
        else:
            self.trace = write_simple_trace(a_input_file, trace_file)
        write_simple_stations(a_station_file, simple_station_file)
        map_prefix = os.path.join(a_outdir, "station_map")
        kml_file = os.path.join(a_outdir, "station_map.kml")
        # Get hypo_lon, hypo_lat from src/srf file
        hypo_lon, hypo_lat = fault_utils.calculate_epicenter(a_input_file)

        # Write the kml file
        self.create_kml_output(a_station_file, kml_file,
                               hypo_lat=hypo_lat, hypo_lon=hypo_lon)

        # Matplotlib
        plottitle = 'Fault Trace with Stations'
        plotregion = [self.west, self.east,
                      self.south, self.north]
        topo = os.path.join(install.A_PLOT_DATA_DIR, 'calTopo18.bf')
        coastal = os.path.join(install.A_PLOT_DATA_DIR, 'gshhs_h.txt')
        border = os.path.join(install.A_PLOT_DATA_DIR, 'wdb_borders_h.txt')
        plotter = PlotMap.PlotMap()
        plotter.plot(plottitle, plotregion, topo,
                     coastal, border, trace_file,
                     simple_station_file, map_prefix,
                     hypo_lat=hypo_lat, hypo_lon=hypo_lon)

        print("Plot MAP Completed".center(80, '-'))
开发者ID:SCECcode,项目名称:BBP,代码行数:58,代码来源:plot_map.py

示例7: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def __init__(self, vmodel_name, a_srcname=None):
        install = InstallCfg.getInstance()
        #
        # Name and Path to executable
        #
        self.R_UC_FFSP_EXE = "ffsp_v2"
        self.A_UC_FFSP_EXE = os.path.join(install.A_UCSB_BIN_DIR,
                                          self.R_UC_FFSP_EXE)
        self.FFSP_OUTPUT_PREFIX = "FFSP_OUTPUT"

        self.FMAX = 50.0 # Nyquist -- use 50 for 100Hz

        vmodel_obj = velocity_models.get_velocity_model_by_name(vmodel_name)
        if vmodel_obj is None:
            raise IndexError("Cannot find velocity model: %s" %
                             (vmodel_name))

        vmodel_params = vmodel_obj.get_codebase_params('ucsb')
        # Configure DT based on information from velocity model
        if 'GF_DT' in vmodel_params:
            self.DT = float(vmodel_params['GF_DT'])
        else:
            raise KeyError("%s parameter missing in velocity model %s" %
                           ("GF_DT", vmodel_name))

        # Other region-specific parameters
        if 'RV_AVG' in vmodel_params:
            self.RV_AVG = float(vmodel_params['RV_AVG'])
        else:
            self.RV_AVG = 2.5

        if 'TP_TR' in vmodel_params:
            self.TP_TR = float(vmodel_params['TP_TR'])
        else:
            self.TP_TR = 0.1

        if 'LF_VELMODEL' in vmodel_params:
            self.A_UC_LF_VELMODEL = os.path.join(vmodel_obj.base_dir,
                                                 vmodel_params['LF_VELMODEL'])
        else:
            raise KeyError("%s parameter missing in velocity model %s" %
                           ("LF_VELMODEL", vmodel_name))

        if a_srcname:
            self.CFGDICT = bband_utils.parse_src_file(a_srcname)

            # RV_AVG is optional!
            # If SRC file has it, it overrides the region and the default values
            if "rv_avg" in self.CFGDICT:
                self.RV_AVG = self.CFGDICT["rv_avg"]
开发者ID:SCECcode,项目名称:BBP,代码行数:52,代码来源:ucrmg_cfg.py

示例8: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def run(self):
        """
        Run the GP WccSiteamp 2014 module
        """
        print("GP Site Response".center(80, '-'))

        self.install = InstallCfg.getInstance()
        install = self.install
        self.config = WccSiteampCfg()
        config = self.config

        sim_id = self.sim_id
        sta_base = os.path.basename(os.path.splitext(self.r_stations)[0])
        self.log = os.path.join(install.A_OUT_LOG_DIR,
                                str(sim_id),
                                "%d.wcc_siteamp_%s.log" % (sim_id, sta_base))

        a_statfile = os.path.join(install.A_IN_DATA_DIR,
                                  str(sim_id),
                                  self.r_stations)

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

        progstring = "mkdir -p %s" % (a_tmpdir)
        bband_utils.runprog(progstring, abort_on_error=True, print_cmd=False)

        #
        # Read and parse the station list with this call
        #
        slo = StationList(a_statfile)
        site_list = slo.getStationList()

        for sites in site_list:
            site = sites.scode
            vs30 = sites.vs30
            if vs30 > config.VREF_MAX:
                vs30 = config.VREF_MAX

            print("*** WccSiteamp Processing station %s..." % (site))

            if self.method == "GP":
                self.process_separate_seismograms(site, sta_base, vs30,
                                                  a_indir, a_tmpdir)
            elif self.method == "SDSU" or self.method == "EXSIM" or self.method == "UCSB":
                self.process_hybrid_seismogram(site, sta_base, vs30,
                                               a_tmpdir, a_outdir)

        print("GP Site Response Completed".center(80, '-'))
开发者ID:SCECcode,项目名称:BBP,代码行数:52,代码来源:wcc_siteamp.py

示例9: plot_dist_gof

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
def plot_dist_gof(resid_file, comp_label, a_outdir_gmpe, sim_id):
    """
    Reads data from resid_file and plots a gof distance plot all
    periods
    """
    # Get directory names
    install = InstallCfg.getInstance()
    a_outdir = os.path.join(install.A_OUT_DATA_DIR, str(sim_id))

    # Collect all the data
    all_data = []
    all_distances = []
    all_gmpe_data = []
    all_gmpe_distances = []
    # Read the residuals data
    for period in DIST_PERIODS:
        summary_output = os.path.join(a_outdir, "%s-%d-resid-%.3f-%s.txt" %
                                      (comp_label, sim_id,
                                       period, COMP_EXT_RD50))
        data, distance = read_resid(resid_file, period, summary_output)
        all_data.append(data)
        all_distances.append(distance)
    # Now do the same for the GMPE data
#    for period in DIST_PERIODS:
#        if os.path.isdir(a_outdir_gmpe):
#            summary_output = os.path.join(a_outdir,
#                                          "%s-%d-resid-gmpe-%.3f-%s.txt" %
#                                          (comp_label, sim_id,
#                                           period, COMP_EXT_RD50))
#            data, distance = read_gmpe_resid(a_outdir_gmpe, sim_id,
#                                             period, summary_output)
#            all_gmpe_data.append(data)
#            all_gmpe_distances.append(distance)
#        else:
#            all_gmpe_data.append([])
#            all_gmpe_distances.append([])

    # Now create the 2 plots, 1 linear and 1 log
    outfile = os.path.join(a_outdir, "gof-dist-linear-%s-%d-rotd50.png" %
                           (comp_label, sim_id))
    create_dist_gof(all_data, all_distances,
                    all_gmpe_data, all_gmpe_distances,
                    comp_label, sim_id, outfile)

    outfile = os.path.join(a_outdir, "gof-dist-log-%s-%d-rotd50.png" %
                           (comp_label, sim_id))
    create_dist_gof(all_data, all_distances,
                    all_gmpe_data, all_gmpe_distances,
                    comp_label, sim_id, outfile, log_scale=True)
开发者ID:SCECcode,项目名称:BBP,代码行数:51,代码来源:plot_dist_gof.py

示例10: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def run(self):
        """
        Calculate GMPEs, create bias plot comparisons
        """
        print("Calculate GMPE".center(80, '-'))

        # Initialize basic variables
        install = InstallCfg.getInstance()
        sim_id = self.sim_id
        sta_base = os.path.basename(os.path.splitext(self.r_stations)[0])

        # Input, tmp, and output directories
        a_outdir = os.path.join(install.A_OUT_DATA_DIR, str(sim_id))
        a_outdir_gmpe = os.path.join(a_outdir,
                                     "gmpe_data_%s" % (sta_base))
        a_logdir = os.path.join(install.A_OUT_LOG_DIR, str(sim_id))

        self.log = os.path.join(a_logdir, "%d.gmpe_compare.log" % (sim_id))

        #
        # Make sure the output and tmp directories exist
        #
        dirs = [a_outdir_gmpe, a_outdir, a_logdir]
        bband_utils.mkdirs(dirs, print_cmd=False)

        # Source file, parse it!
        a_srcfile = os.path.join(install.A_IN_DATA_DIR,
                                  str(sim_id),
                                  self.r_src_file)
        self.src_keys = bband_utils.parse_src_file(a_srcfile)

        # Station file
        a_statfile = os.path.join(install.A_IN_DATA_DIR,
                                  str(sim_id),
                                  self.r_stations)

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

        # Go through each station, and print comparison headers for
        # the first station we process
        for site in site_list:
            stat = site.scode
            print("==> Calculating GMPE for station: %s" % (stat))
            output_file = os.path.join(a_outdir_gmpe, "%s-gmpe.ri50" % (stat))
            self.calculate_gmpe(site, output_file)

        # All done
        print("Calculate GMPE Completed".center(80, '-'))
开发者ID:SCECcode,项目名称:BBP,代码行数:51,代码来源:calculate_gmpe.py

示例11: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
 def __init__(self):
     """
     Initialize class structures
     """
     self.install = InstallCfg.getInstance()
     self.output_sim_id = None
     self.a_indir = None
     self.a_outdir = None
     self.a_logdir = None
     self.a_tmpdir = None
     self.station_list = None
     self.input_sims = []
     self.src_files = []
     self.srf_files = []
     self.val_event = None
开发者ID:SCECcode,项目名称:BBP,代码行数:17,代码来源:merge_multisegment_validation.py

示例12: run

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def run(self):
        """
        Goes through the station list and copy each low-frequency
        seismogram from the seis_dir to the simulation's tmpdir
        """
        install = InstallCfg.getInstance()
        sim_id = self.sim_id

        a_tmpdir = os.path.join(install.A_TMP_DATA_DIR, str(sim_id))
        a_indir = os.path.join(install.A_IN_DATA_DIR, str(sim_id))
        a_stations = os.path.join(a_indir, self.r_stations)

        print(self.seis_dir)

        slo = StationList(a_stations)
        stat_list = slo.getStationList()
        for stat in stat_list:
            # Look for bbp seismogram, copy in
            print("%s/%s-lf.bbp" % (self.seis_dir, stat.scode))
            if os.path.exists("%s/%s-lf.bbp" % (self.seis_dir, stat.scode)):
                print("Copying for site %s" % (stat.scode))
                # Need to eliminate negative times
                fp_in = open("%s/%s-lf.bbp" % (self.seis_dir, stat.scode), 'r')
                fp_out = open("%s/%d.%s-lf.bbp" %
                              (a_tmpdir, sim_id, stat.scode), 'w')
                for line in fp_in:
                    pieces = line.split()
                    try:
                        if pieces[0] == '#' or pieces[0] == '%':
                            fp_out.write(line)
                        elif float(pieces[0]) < -0.0001:
                            continue
                        elif float(pieces[0]) < 0.0001:
                            fp_out.write("0.0\t%s\t%s\t%s\n" % (pieces[1],
                                                                pieces[2],
                                                                pieces[3]))
                        else:
                            fp_out.write(line)
                    except ValueError:
                        fp_out.write(line)
                fp_in.close()
                fp_out.flush()
                fp_out.close()
            else:
                print("Could not find LF seismogram for station %s!" %
                      (stat.scode))
开发者ID:SCECcode,项目名称:BBP,代码行数:48,代码来源:lf_seismograms.py

示例13: setUp

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def setUp(self):
        """
        Configures the environment for the tests
        """
        self.install = 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)
开发者ID:SCECcode,项目名称:BBP,代码行数:20,代码来源:test_bbp_format.py

示例14: __init__

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    def __init__(self, i_r_stations, i_r_srcfile,
                 plot_vel, plot_acc, sim_id=0):
        """
        Initialize basic class parameters
        """
        self.r_stations = i_r_stations
        self.plot_vel = plot_vel
        self.plot_acc = plot_acc
        self.sim_id = sim_id

        install = InstallCfg.getInstance()
        a_indir = os.path.join(install.A_IN_DATA_DIR, str(self.sim_id))

        if i_r_srcfile is not None and i_r_srcfile != "":
            i_a_srcfile = os.path.join(a_indir, i_r_srcfile)
            self.src_keys = bband_utils.parse_src_file(i_a_srcfile)
        else:
            self.src_keys = None
开发者ID:SCECcode,项目名称:BBP,代码行数:20,代码来源:plot_seis.py

示例15: generate_xml

# 需要导入模块: from install_cfg import InstallCfg [as 别名]
# 或者: from install_cfg.InstallCfg import getInstance [as 别名]
    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
开发者ID:SCECcode,项目名称:BBP,代码行数:45,代码来源:gen_accept_tests.py


注:本文中的install_cfg.InstallCfg.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。