Skip to content

Actions

AndrewReynen edited this page Feb 5, 2018 · 45 revisions

Contents

Action basic description

Almost all operations done within Lazylyst use actions. An action links a specific trigger, either a key-bind or another action; to a specific function. The action is set to pass a combination of hot variables and or preferences to the function, and then accept the return values from the functions. All returned values must be one of the currently defined hot variables*. When a hot variable is returned, it must conform to the expected data type, as well as pass its built in sanity check.

Please see the Main Window page for a description and visual on Lazylyst's main windows widgets (which are referenced here).

*One hot variable exists which allows storing any number of values, named customDict (custom dictionary)

Types of actions

Actions can be either active, or passive.

Active actions require a key bind to be activated, any key press, ex. A, ctrl+A, shift+B, etc. are accepted. These actions have the capability to be set on a timer, such actions when triggered will be added to the strolling widget list and will execute using their specified interval (unless the function takes longer than the interval itself to compute). To stop a strolling active action, press the actions key bind again. Strolling actions will also stop if any of the returned hot variables fail to pass their built in check. No two active actions are allowed to have the same trigger (if you want this capability, set one as passive and have it trigger off of other). Active actions may also be set to run outside of the main processing loop ("in the background"), some notes on this here.

Passive actions are triggered by one or many active actions, they can be set to go either before or after the triggering action. As many passive actions could potentially link to the same active action, the order in which they are executed can be set by dragging the action tag up/down in the "Passive Actions Ordering" list of the configuration dialog. Passive actions can be linked to active actions which have timers.

Default actions

For a complete description of all of the default actions, refer to the function defaultActions, or if you prefer, open up each of the actions by double clicking on its tag in the configuration dialog to see its properties. Please note that these are here to mainly give users an impression on how to implement their own actions (and some basic functionality for those who are scared of coding).

Default actions include (and not limited to):

  • OpenOptions: Open up the configuration dialog
  • ChangeSource: Open up the source dialog
  • ReloadPlugins: Plugins which have had their functions edited after starting Lazylyst are forced to reload (defaults to keybind F5)
  • ReloadArchive: Checks for any changes in the MSEED archive. By default this is run in the background (threaded) and has the keybind F6. Do not set both optionals resetSearch and showBar to be True, as this will ask for a progress bar to be shown in a thread (will break things).
  • CloseLazylyst: Closing Lazylyst
  • OpenLazylyst: Opening Lazylyst, is called after all GUI elements have been set up
  • PageNext/PagePrev/GoToStaPage: Changing the page
  • PickModeP/PickModeS: Changing the picking mode between P and S (any arbitrary phase name could be added by user)
  • PickAdd: Adding (double click) and removing picks on the current page with current picking mode
    • Single-pick addition can also be done using key presses by adding a new action which points to the function "addClickPick" in $main
  • PickDelete: Remove the currently hovered over trace data widgets pick(s) of the current picking type (hot variable pickMode)
  • PickSetDelete: Remove all picks within the current pick file
  • PickFileNext/PickFilePrev/PickFileSetToClick: Changing the current event
  • !NotAUserVisibleAction!: Adding a new event via the archive event or archive span widgets (double click)
  • PickFileCurDelete: Deleting the current pick file (hot variable curPickFile) for the pick file list (hot variable pickFiles)
  • SimpleLocate: Automatic (passive) updates of the event location, map station coloring and trace background coloring - this occurs whenever the hot variable pickSet is updated. Note that the passive action requires some (extremely simplistic) velocity model information which relates to the current source (see getVelDelay)
  • Sorting by...
    • StaSortAlph: Network.Station.Location code
    • StaSortPickTime: current pick modes time
    • StaSortDist: distance to the current event
    • StaSortResidual: time residual (largest values first)
    • StaSortReverse: reverse the current sorting
  • FiltHPX: Filtering with 1,5,10 Hz high-pass filters using obspy's filter function (note that these optionals sent to the obspy function can be edited through use of the GUI)
  • ImageSpectVert: Create a spectrogram of the currently hovered over trace widget (hot variable curTraceSta), the vertical channel is used in this case. See the Image Plugin for an example

As clicking has different operations depending on which widget is present, all actions with clicking triggers cannot be edited, aside from their tag.

Removing actions

To remove an action go to the configuration dialog click once on the desired action and press the delete button or click on the "-" button for the associated list. Some default actions cannot be removed, as they are seen as a vital component in time series review.

Adding actions

To add an action go to the configuration dialog and press the "+" button over the associated list. Optionally you can hover over either the passive or active list and then hit the insert button. Actions can also be duplicated from existing actions by right clicking on the action in the configuration dialog, then click on the "Copy" option in the pop-up.

All functions pointed to by actions must be contained in pythons path (by default the computers PATH variable). By default "yourInstallDirectory/Lazylyst/lazylst/" is added to the python path variable. For example, if the path "/home/user/test/" is on the PATH variable any scripts within that folder can be imported. Additional scripts from sub-directories (ex. "/home/user/test/subDir1/") can be imported given that there is an "init.py" file in that sub-directory (ie. "/home/user/test/subDir1/init.py"). init.py can be left as an empty file. In this example a function "doSomething" located in "/home/user/test/subDir1/importMe.py" would be linked to an action like this:
capture

To add a directory to the python path, add it to the preference pythonPathAdditions

Editing actions

To edit an action go to the configuration dialog and double click on one of the present actions, its properties will appear. An example using the default passive action ToggleTracePen.
setup action_008
Action properties include:

  • Tag, the user visible name of the action
  • Name, the name of the function which the action calls
  • Path, the path of the script containing the function
  • Optionals, the key-word-arguments to be sent to the function. Currently only integers, floats, and strings are accepted. An example of the optionals would look like: intVariable=30,floatVariable=30.0,stringVariable=dog
  • Active or Passive, use the radio buttons. Active actions enable the timer, interval, and key-bind trigger options. Passive actions enable the Before Trigger check box, as well as the Passive Triggers lists.
  • Inputs, the preferences and hot variables to be sent to the function (in the correct order, top to bottom).
  • Returns, the expected hot variables to be returned from the function (in the correct order, top to bottom).

Double click on the available items to add to the selected list, similarly double click on the selected item to remove from the selected list. Click and drag to move the item within the selected list to change the ordering.

Sleeping actions

In some scenarios an action will want to be disabled temporarily. To do so, put it to sleep and wake it up again when required. Actions can be set to sleep or awoken by right clicking on the action in the configuration dialog, then click on the "Sleep" or "Awake" option in the pop-up. Any action which is sleeping will not respond to any of its triggers. Actions which are currently sleeping will display grey text in the configuration dialog.

Threading actions

In the case where a function will take a long period of time, active actions can be set to run on separate threads. This frees the user to continue using Lazylyst while waiting on the slow function. Passive actions triggered by threaded active actions will also be run on the separate thread, the ordering of the actions in these cases are maintained. When a threaded action finishes it still has to pause the GUI to update the necessary hot variables. When a thread is working it will be listed in the scheming list widget, threaded actions cannot be called again if they are already in the scheming list.

Although it may be tempting to thread all active actions, it is strongly suggested to only apply this (sparingly) to actions which take a long time. Each computer has its limitations for how many threads it can maintain. Threading will not assist with the processing speed if the CPU is already maxed out.

Note If the threaded action contains a qt dialog the application will exit. Any tips on how to fix this are welcome.

New action requests

You would like a new action? Cool! Make one.

But be sure to upload it to Lazylysts "Plugins/YourNameOrTag/...". Look through the current actions, and the plugin directory for examples.

Clone this wiki locally