Esempio n. 1
0
    def calculate_receiver_weights(self):
        """
        calculate receiver weights for each asdf file
        detertmine source weightings based on source infor and window
        count and info
        """
        logger_block("Receiver Weighting")
        input_info = self.path["input"]
        receiver_weighting = self.param["receiver_weighting"]
        plot = self.param["plot"]
        search_ratio = self.param["receiver_search_ratio"]

        self.rec_weights = defaultdict(dict)
        self.rec_wcounts = defaultdict(dict)
        self.rec_ref_dists = defaultdict(dict)
        self.rec_cond_nums = defaultdict(dict)
        self.src_wcounts = defaultdict(dict)

        nperiods = len(input_info)
        period_idx = 0
        # determine receiver weightings for each asdf file
        for period, period_info in input_info.iteritems():
            period_idx += 1
            logger.info("-" * 15 + "[%d/%d]Period band: %s"
                        % (period_idx, nperiods, period) + "-" * 15)
            nevents = len(period_info)
            event_idx = 0
            for event, event_info in period_info.iteritems():
                event_idx += 1
                logger.info("*" * 6 + " [%d/%d]Event: %s "
                            % (event_idx, nevents, event) + "*" * 6)
                # each file still contains 3-component
                logger.info("station file: %s" % event_info["station_file"])
                logger.info("window file: %s" % event_info["window_file"])
                logger.info("output file: %s" % event_info["output_file"])
                src = self.src_info[period][event]
                station_info = load_json(event_info["station_file"])
                window_info = load_json(event_info["window_file"])
                outputdir = os.path.dirname(event_info["output_file"])
                safe_mkdir(outputdir)
                figname_prefix = os.path.join(
                    outputdir, "%s.%s" % (event, period))
                _results = determine_receiver_weighting(
                    src, station_info, window_info,
                    max_ratio=search_ratio,
                    flag=receiver_weighting,
                    plot=plot, figname_prefix=figname_prefix)

                self.rec_weights[period][event] = _results["rec_weights"]
                self.rec_wcounts[period][event] = _results["rec_wcounts"]
                self.rec_ref_dists[period][event] = _results["rec_ref_dists"]
                self.rec_cond_nums[period][event] = _results["rec_cond_nums"]
                self.src_wcounts[period][event] = _results["src_wcounts"]
def get_event_category_window_counts(path_info):
    cat_wcounts = {}
    print("Reading window files to get events cateogry window counts")
    t1 = time.time()

    for ev, evinfo in path_info.iteritems():
        cat_wcounts[ev] = {}
        for pb, pbinfo in evinfo["period_info"].iteritems():
            winfile = pbinfo["window_file"]
            windows = load_json(winfile)
            _, _wcounts = calculate_receiver_window_counts(windows)
            cat_wcounts[ev][pb] = _wcounts
    t2 = time.time()
    print("Category weighting I/O time: %.2f sec" % (t2 - t1))
    return cat_wcounts
Esempio n. 3
0
def get_event_category_window_counts(path_info):
    cat_wcounts = {}
    print("Reading window files to get events cateogry window counts")
    t1 = time.time()

    for ev, evinfo in path_info.iteritems():
        cat_wcounts[ev] = {}
        for pb, pbinfo in evinfo["period_info"].iteritems():
            winfile = pbinfo["window_file"]
            windows = load_json(winfile)
            _, _wcounts = calculate_receiver_window_counts(windows)
            cat_wcounts[ev][pb] = _wcounts
    t2 = time.time()
    print("Category weighting I/O time: %.2f sec" % (t2 - t1))
    return cat_wcounts
Esempio n. 4
0
    def __init__(self, path, param):
        self.path = load_json(path)
        self.param = load_yaml(param)

        # source information is only used in plotting
        self.src_info = None

        self.weights = None

        self.rec_weights = {}
        self.rec_wcounts = {}
        self.rec_ref_dists = {}
        self.rec_cond_nums = {}

        self.cat_wcounts = {}
        self.cat_weights = None
Esempio n. 5
0
    def __init__(self, path, param):
        self.path = load_json(path)
        self.param = load_yaml(param)

        self.src_info = None
        self.weights = None

        self.rec_weights = None
        self.rec_wcounts = None
        self.rec_ref_dists = None
        self.rec_cond_nums = None

        self.src_wcounts = None
        self.src_ref_dists = None
        self.src_cond_nums = None
        self.src_weights = None

        self.cat_wcounts = None
        self.cat_weights = None
Esempio n. 6
0
def extract_receiver_locations(station_file, windows):
    """
    Extract receiver location information from asdf file
    """
    station_info = load_json(station_file)
    return station_info
Esempio n. 7
0
def extract_receiver_locations(station_file, windows):
    """
    Extract receiver location information from station json file
    """
    station_info = load_json(station_file)
    return station_info