class lasif.components.iterations.IterationsComponent(iterations_folder, communicator, component_name)[source]

Component dealing with the iteration xml files.

  • iterations_folder – The folder with the iteration XML files.
  • communicator – The communicator instance.
  • component_name – The name of this component for the communicator.

Get the number of iterations managed by this component.

>>> comm = getfixture('iterations_comm')
>>> comm.iterations.count()
create_new_iteration(iteration_name, solver_name, events_dict, min_period, max_period, quiet=False, create_folders=True)[source]

Creates a new iteration XML file.

  • iteration_name – The name of the iteration.
  • solver_name – The name of the solver to be used for the new iteration.
  • events_dict – A dictionary specifying the used events.
  • min_period – The minimum period in seconds for the new iteration.
  • max_period – The maximum period in seconds for the new iteration.
  • quiet – Do not print anything if set to True.
  • create_folders – Create the folders for this iteration’s synthetic waveforms
>>> comm = getfixture('iterations_comm')
>>> comm.iterations.has_iteration("3")
>>> 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")
>>> os.remove(comm.iterations.get_iteration_dict()["3"])
create_successive_iteration(existing_iteration_name, new_iteration_name, create_folders=True)[source]

Create an iteration based on an existing one.

It will take all settings in one iteration and transfers them to another iteration. Any comments will be deleted.

  • existing_iteration_name – Name of the iteration to be used as a template.
  • new_iteration_name – Name of the new iteration.
  • create_folders – Create the folders for the next iteration’s synthetic waveforms

Note that the create_folders=False argument is only used here for testing purposes. In most cases you will want this to be True.

>>> comm = getfixture('iterations_comm')
>>> comm.iterations.has_iteration("3")
>>> comm.iterations.create_successive_iteration("1", "3",
...                                             create_folders=False)
>>> comm.iterations.has_iteration("3")

Comments of an iteration will be stripped.

>>> comm.iterations.get("1").comments
['Some', 'random comments']
>>> comm.iterations.get("3").comments
>>> os.remove(comm.iterations.get_iteration_dict()["3"])

If the iteration template does not exist, a LASIFNotFoundError will be raised.

>>> comm.iterations.create_successive_iteration("99", "100")
Traceback (most recent call last):
LASIFNotFoundError: ...

A ValueError will be raised if the new iteration already exists.

>>> comm.iterations.create_successive_iteration("1", "2")
Traceback (most recent call last):
ValueError: ...

Create the synthetics folder if it does not yet exists.

Parameters:iteration_name – The iteration for which to create the folders.

Returns an iteration object.

Parameters:iteration_name – The name of the iteration to retrieve.
>>> comm = getfixture('iterations_comm')
>>> comm.iterations.get("1")  
<lasif.iteration_xml.Iteration object at ...>
>>> print comm.iterations.get("1")          
LASIF Iteration
    Name: 1

A LASIFNotFoundError will be raised, if the iteration is not known.

>>> comm.iterations.get("99")
Traceback (most recent call last):
LASIFNotFoundError: ...

It also works with the long iteration name and event an existing iteration object. This makes it simple to use, one path for all possibilities. >>> it = comm.iterations.get(“ITERATION_1”) >>> it # doctest: +ELLIPSIS <lasif.iteration_xml.Iteration object at …> >>> comm.iterations.get(it) <lasif.iteration_xml.Iteration object at …>


Helper function returning the filename of an iteration.


Returns a dictionary with the keys being the iteration names and the values the iteration filenames.

>>> import pprint
>>> comm = getfixture('iterations_comm')
>>> pprint.pprint(comm.iterations.get_iteration_dict())         
{'1': '/.../ITERATION_1.xml',
 '2': '/.../ITERATION_2.xml'}

Returns the long form of an iteration from its short name.

>>> comm = getfixture('iterations_comm')
>>> comm.iterations.get_long_iteration_name("1")

Test for existence of an iteration.

Parameters:iteration_name (str) – The name of the iteration.
>>> comm = getfixture('iterations_comm')
>>> comm.iterations.has_iteration("1")
>>> comm.iterations.has_iteration("99")

Get a list of all iterations managed by this component.

>>> comm = getfixture('iterations_comm')
>>> comm.iterations.list()
['1', '2']

Plots the Q model for a given iteration. Will only work if the iteration uses SES3D as its solver.


Save an iteration object to disc. :param iteration: