示例#1
0
    def create_new_iteration(self,
                             iteration_name,
                             solver_name,
                             events_dict,
                             min_period,
                             max_period,
                             seconds_prior_arrival=5.,
                             window_length_in_sec=50.,
                             quiet=False,
                             create_folders=True):
        """
        Creates a new iteration XML file.

        :param iteration_name: The name of the iteration.
        :param solver_name: The name of the solver to be used for the new
            iteration.
        :param events_dict: A dictionary specifying the used events.
        :param min_period: The minimum period in seconds for the new iteration.
        :param max_period: The maximum period in seconds for the new iteration.
        :param seconds_prior_arrival: nb of seconds prior the theoretical phase arrival time used to window seismograms for quality control, default 5.
        :param window_length_in_sec: nb of seconds of the time window used to window seismograms for quality control, default 50.
        :param quiet: Do not print anything if set to `True`.
        :param create_folders: Create the folders for this iteration's
            synthetic waveforms

        >>> comm = getfixture('iterations_comm')
        >>> comm.iterations.has_iteration("3")
        False
        >>> comm.iterations.create_new_iteration("3", "ses3d_4_1",
        ...     {"EVENT_1": ["AA.BB", "CC.DD"], "EVENT_2": ["EE.FF"]},
        ...     10.0, 20.0, quiet=True, create_folders=False)
        >>> comm.iterations.has_iteration("3")
        True
        >>> os.remove(comm.iterations.get_iteration_dict()["3"])
        """
        iteration_name = str(iteration_name)
        if iteration_name in self.get_iteration_dict():
            msg = "Iteration %s already exists." % iteration_name
            raise LASIFError(msg)

        from lasif.iteration_xml import create_iteration_xml_string
        xml_string = create_iteration_xml_string(iteration_name,
                                                 solver_name,
                                                 events_dict,
                                                 min_period,
                                                 max_period,
                                                 seconds_prior_arrival,
                                                 window_length_in_sec,
                                                 quiet=quiet)
        with open(self.get_filename_for_iteration(iteration_name), "wt")\
                as fh:
            fh.write(xml_string)

        if create_folders:
            self.create_synthetics_folder_for_iteration(iteration_name)
            self.create_stf_folder_for_iteration(iteration_name)
示例#2
0
文件: iterations.py 项目: Phlos/LASIF
    def create_new_iteration(self, iteration_name, solver_name, events_dict,
                             min_period, max_period, quiet=False,
                             create_folders=True):
        """
        Creates a new iteration XML file.

        :param iteration_name: The name of the iteration.
        :param solver_name: The name of the solver to be used for the new
            iteration.
        :param events_dict: A dictionary specifying the used events.
        :param min_period: The minimum period in seconds for the new iteration.
        :param max_period: The maximum period in seconds for the new iteration.
        :param quiet: Do not print anything if set to `True`.
        :param create_folders: Create the folders for this iteration's
            synthetic waveforms

        >>> comm = getfixture('iterations_comm')
        >>> comm.iterations.has_iteration("3")
        False
        >>> comm.iterations.create_new_iteration("3", "ses3d_4_1",
        ...     {"EVENT_1": ["AA.BB", "CC.DD"], "EVENT_2": ["EE.FF"]},
        ...     10.0, 20.0, quiet=True, create_folders=False)
        >>> comm.iterations.has_iteration("3")
        True
        >>> os.remove(comm.iterations.get_iteration_dict()["3"])
        """
        iteration_name = str(iteration_name)
        if iteration_name in self.get_iteration_dict():
            msg = "Iteration %s already exists." % iteration_name
            raise LASIFError(msg)

        from lasif.iteration_xml import create_iteration_xml_string
        xml_string = create_iteration_xml_string(iteration_name,
                                                 solver_name, events_dict,
                                                 min_period, max_period,
                                                 quiet=quiet)
        with open(self.get_filename_for_iteration(iteration_name), "wt")\
                as fh:
            fh.write(xml_string)

        if create_folders:
            self.create_synthetics_folder_for_iteration(iteration_name)