The following is information about the ReductionContext class. When writing primitives the reduction context is passed into the primitive as the sole argument (generally named rc by Gemini conventions and in addition to the self argument). This object is used by the primitive to both get inputs and store outputs, as well as to communicate with subsystems like the calibration queries system or list keeping for stacking.
Parameters: | thing (str) – A key to check for presence in the Reduction Context |
---|
The __contains__ function implements the Python in operator. The ReductionContext is a subclass of a dict, but it also has a secondary dict of “local parameters” which are available to the current primitive only, which are also tested by the __contains__(..) member. These parameters will generally be those passed in as arguments to a primitive call from a recipe and from the parameter set.
Parameters: | style (string) – Controls the type of return value. Supported values are “AD” and “FN” for AstroData and string filenames respectively. |
---|---|
Returns: | a list of AstroData instances or string filenames |
Return type: | list |
get_inputs(..) gets the current input datasets from the current stream. You cannot choose the stream, use get_stream(..) for that. To report modified datasets back to the stream use report_output(..).
This function is equivalent to:
get_inputs(style=”AD”)
This function is equivalent for:
get_inputs(style=”FN”)
Parameters: |
|
---|---|
Returns: | a list of AstroDataRecord objects, AstroData objects or filenames. |
Return type: | list |
get_stream returns a list of AstroData instances in the specified stream.
This function returns the current reference image. At the moment this is simply the first dataset in the current inputs. However, use of this function allows us to evolve our concept of reference image for more complicated cases where the choice of a “reference” image may need to be different (e.g. require some data analysis to determine).
Parameters: |
|
---|
This function, along with get_inputs(..) allows a primitive to interact with the datastream in which it was invoked (or access other streams).
Parameters: | switch_to (str) – The string name of the stream to switch to. The named stream must already exist. |
---|---|
Note : | This function is used by the infrastructure (in an application such as reduce and in the ReductionContext) to switch the stream being used. Reported output then goes to the specified stream. |
Retrieve calibration.
Parameters: |
|
---|---|
Returns: | The URI of the currently stored calibration or None. |
Return type: | string or None |
Create calibration requests based on raw inputs.
Parameters: |
|
---|
Parameters: | purpose (string) – The purpose is a string prepended to the stackID used to identify the list (see get_list(..)). The default is None and will behave like an empty string. Examples of purpose strings include: ‘forStack’, ‘forSky’. |
---|
The stackID (see IDFactory module) is used to identify the list. The first input in the rc.inputs list is used as the reference image to generate the stackID portion of the list identifier.
The stackID function in IDFactory is meant to produce identical stacking identifiers for different images which can/should be stacked together, e.g. based on program ID and/or other details. Again, see IDFactory for the particular algorithm in use.
Note : | a versioning system is latent within the code, and is added to the id to allow adaptation in the future if identifer construction methods change. |
---|
Parameters: | purpose (str) – The purpose argument is a string prefixed to the generated stackID. This allows two images which would produce identical stackIDs to go in different lists, i.e. such as a fringe frame which might be prepended with “fringe” as the purpose. |
---|
This function creates requests to update a stack list with the files in the current rc.inputs list. Each will go in a stack based on its own stackID (prepended with “purpose”).
Note : | this function places a message on an outbound message queue which will not be sent until the next “yield”, allowing the ReductionObject command clause to execute. |
---|
Parameters: |
|
---|
The caller is expected to supply cachefile, which in principle a value of “None” could mean the “default cachefile” this is not supported by the adcc as of yet. The desired behavior is for reduce instances running in the same directory to cooperate, and those running in separate directories be kept separate, and this is implemented by providing an argument for cachefile which is in a generated subdirectory (hidden) based on the startup directory for the reduce process.
The adcc will negotiate all contention and race conditions regarding multiple applications manipulating a list simultaneously in separate process.
Parameters: | id (str) – Lists are associated with arbitrary identifiers, passed as strings. See IDFactory for IDs built from standard astrodata characteristics. |
---|
The list functionality allows storing dataset names in a list which is shared by all instances of reduce running in a given directory. The list is kept by an adcc instance in charge of that sub-directory. The get_list(..) function retrieves a list that has already been requested via rq_stack_get(..) which initiates the interprocess request.
This function does not block, and if the stack was not requested prior to a yeild, prior to this call, then None or an out of date version of this list will be retrieved.
Note : | “get_stack” calls get_list but takes a “purpose” to which it adds a stackID as a suffix to the list identifier. |
---|
Parameters: |
|
---|---|
Returns: | List of new prepended paths. |
Return type: | list |
Prepends a prefix string to either the inputs or the given list of filenames.
Parameters: | stepname – The primitive or recipe name to run. Note: this is |
---|
The run(..) function allows a primitive to use the reduction context to execute another recipe or primitive.