Ejemplo n.º 1
0
    def setStationDictionary(self, imcs=None, imts=None):
        """
        Calculate the station summaries and set the dictionary.

        Args:
            imcs (list): List of intensity measurement components (str). Default
                    is None. If none imclist from config is used.
            imts (list): List of intensity measurement types (str). Default
                    is None. If None imtlist from config is used.

        Notes:
            Requires that corrected_streams is set.

        Raises:
            Exception: If corrected_streams is not set.
        """
        # use defaults if imcs or imts are not specified
        config = get_config()
        if imcs is None:
            imcs = config['imclist']
        if imts is None:
            imts = config['imtlist']

        if self.corrected_streams is None:
            raise Exception('Processed streams are required to create a '
                            'StationSummary object and create the dictionary.')
        station_dict = OrderedDict()
        for station in self.corrected_streams:
            stream = self.corrected_streams[station]
            station_dict[station] = StationSummary.from_stream(
                stream, imcs, imts)
        self._station_dict = station_dict
Ejemplo n.º 2
0
def test_put_params():
    config = get_config()
    if config is None or config == DEFAULT_CONFIG:
        return True
    if 'pdl' not in config:
        print('This system is not configured with a PDL client. Stopping.')
        return True
    put_params_test(config['pdl'])
Ejemplo n.º 3
0
def test_get_params():
    config = get_config()
    if config is None or config == DEFAULT_CONFIG:
        return True
    if 'comcat' not in config:
        fmt = 'No configuration to retrieve data from comcat. Stopping.'
        print(fmt)
        return True
    get_params_test(config['comcat']['host'])
Ejemplo n.º 4
0
    def process(self,
                config=None,
                station=None,
                event_time=None,
                epi_dist=None):
        """Process all stations in the EventSummary.

        Args:
            config (dictionary): Config dictionary containing processing
                    parameters. Default is None. None results in using
                    get_config to find the user defined config or the default.
            station (str): Station to process. Default is None. None results in
                    all stations being processed.

        Raises:
            Exception: If there are not unprocessed streams.
        """
        if self.uncorrected_streams is None:
            raise Exception('There are no unprocessed streams to process.')

        # get config if none is supplied
        if config is None:
            config = get_config()

        if station is None:
            corrected_streams = {}
            for station_code in self.uncorrected_streams:
                stream = self.uncorrected_streams[station_code]
                processed_stream = process_config(stream,
                                                  config=config,
                                                  event_time=event_time,
                                                  epi_dist=epi_dist)
                corrected_streams[station_code] = processed_stream
            self.corrected_streams = corrected_streams
        else:
            if self.corrected_streams is None:
                warnings.warn(
                    '%r cannot be reprocessed, since the '
                    'processed_streams dictionary has not been populated. Process '
                    'all stream, then this station can be reprocessed.' %
                    station)
                return
            if station not in self.uncorrected_streams:
                warnings.warn(
                    '%r is not an available station. Processing will '
                    'not continue.' % station)
                return
            stream = self.uncorrected_streams[station]
            corrected_streams = self.corrected_streams
            processed_stream = process_config(stream,
                                              config=config,
                                              event_time=event_time,
                                              epi_dist=epi_dist)
            corrected_streams[station] = processed_stream
            self.corrected_streams = corrected_streams
Ejemplo n.º 5
0
def get_remote_cfg():
    config = get_config()
    if config is None or config == DEFAULT_CONFIG:
        return (None, None)
    if 'scp' not in config:
        return (None, None)

    remote_host = config['scp']['remote_host']
    keyfile = config['scp']['keyfile']

    return (remote_host, keyfile)