Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Often an analysis wants to treat events differently based upon something in the data.  A common example is the presence of an eventcode, which may indicate the firing of a pump laser or some other condition.   If the  The selection logic is can be put into a PythonEditor box, then the editor box should return python's None object to indicate the event flow is to be terminated here; returning a value (even 0) causes the flow to continue with that value and possibly weighting your statistics in unexpected waysyields unexpected/incorrect results.  An example flowchart and with a PythonEditor box doing eventcode filtering is shown below.   Other boxes can also handle filtering with their "conditional" attributes.Image RemovedImage Removed This particular example "ping pongs" an image output between two displays depending on whether an eventcode is present or not.

This example should be run like this:

Code Block
ami-local -b 1 -f interval=1 -l /sdf/group/lcls/ds/ana/tutorials/ami2/eventcode_filter.fc psana://exp=tmoc00118,run=222,dir=/sdf/data/lcls/ds/prj/public01/xtc/


Image Added

The code inside the Python editor box that performs user-specified logic based on the eventcodes is:

Code Block
languagepy
class EventProcessor():

    def __init__(self):
        pass

    def begin_run(self):
        pass

    def end_run(self):
        pass

    def begin_step(self, step):
        pass

    def end_step(self, step):
        pass

    def on_event(self, image, codes, *args, **kwargs):
        # an eventcode that alternates for this data
        if codes[14]:
            return (image, None)
        else:
            return (None, image)

Configuring Plots

Many features of plots can be controlled from the "wrench" icon in the upper-left of AMI plots.  This menu allows you to do things like:

...