Approximate estimate of shift in the positions of the spectral orders. More...
Public Member Functions | |
def | __init__ |
Make a Hermes component and initialize variables. | |
def | optionsAreValid |
options ? : crossAxis (the direction perpendicular to the orders input: definition of the subregion to cross correlate (xStart, xEnd, yStart, yEnd) | |
def | __call__ |
invoked from here | |
def | getAbsoluteOrderImagePositionsMonoVariate |
Get the absolute order poistions assuming that the polynomial provided only depends on the row and that coefficients are provided for each order. | |
def | getModelAbsoluteOrderPositions |
Knowing the coefficients, it computes the expected order positions. | |
def | getBivariatePolynomialValue |
Computes a bivariate polynomial. | |
def | getAbsoluteOrderImagePositionsBiVariate |
Get the absolute order poistions assuming that the polynomial provided only depends on the row and that coefficients are provided for each order. | |
def | getAbsoluteOrderImagePositionsMonoVariateSlower |
Get the absolute order poistions assuming that the polynomial provided only depends on the row and that coefficients are provided for each order deprecated does not take into account the fact that we need to add edge orders. | |
def | getAbsoluteOrderImagePositionsBiVariateFeros |
Get the absolute order poistions assuming that the polynomial provided is bivariate on the row and order number. | |
def | getAbsoluteOrderImagePositionsBiVariateSlower |
deprecated it is the double loop here that slows down the whole process this version does not account for the fact that we may need edge orders added | |
def | doFastCleanOfImage |
Fast clean of input image : use 3x3 median and mask if value-median larger than tolFastClean WARNING: for the moment when some pixels are masked, the CCF is not correctly normalized. | |
def | checkCenterInsideCheckedInterval |
looks for maximum point in interval | |
def | getShiftEstimateOrderModel |
The centre of the cross-correlation peak is determined following David & Verschueren 1995, A&A, 111, 183 The input are the shift values and the cross correlation coefficients. | |
def | getCorrelationCoefficientsCoordinates |
Prepares the subregions on the image and template frame and launches the cross correlation. More... | |
def | getShiftedFrame |
shift a 2D frame in the crossAxis direction inputs are the frame and the shift in pixels | |
Public Member Functions inherited from hermes.pipeline.core.pipelinecomponent.PipelineComponent | |
def | __init__ |
def | __call__ |
def | optionsAreValid |
def | getOptions |
def | setOptions |
def | checkExistShapeUnits |
def | isOption |
Public Attributes | |
isNotRolledTemplate | |
The template is larger than the input frame to avoid "cyclicity" when shifting. | |
shiftStep | |
orderMid | |
User can give the middle order. | |
rowMid | |
User can give the middle row. | |
numberOfOrders | |
user can give the number of orders | |
areRelativeCoordinates | |
user can force absolute coordinates | |
crossAxis | |
user can force columns axis by setting this to 1 More... | |
shiftSup | |
User may force shifts but has to give both. More... | |
shiftInf | |
inf | |
tolFastClean | |
User can force his own value, but not tested. | |
isPolynomeBivariate | |
User can deactivate this feature. | |
isEstimatedAbsoluteOrderPositionsNeeded | |
if at this stage absolute order positions are needed | |
isFerosData | |
set True for Feros data | |
isCoordinates | |
Definition cross-correlation application domain by ... More... | |
areVirtualEdgeOrdersAdded | |
User can deactivate this feature. | |
isDebug | |
User can obtain intermediary images in debug folder. | |
results | |
xStart | |
Start in x direction. | |
xEnd | |
value for xEnd | |
yStart | |
value for yStart | |
yEnd | |
value for yEnd | |
Public Attributes inherited from hermes.pipeline.core.pipelinecomponent.PipelineComponent | |
options | |
logger | |
ConsoleLogSeverity | |
default value | |
canShowGraphics | |
when machine does not run matplotlib. More... | |
Approximate estimate of shift in the positions of the spectral orders.
PURPOSE : This module estimates the difference between the positions of the spectral orders on the input frame and those on a template as a simple shift in the column coordinate (perpendicular to the wavelength coordinate along the spectral orders). A more complex model can be constructed using the module measureOrderPosition. The shift is computed through cross-correlation on a selected part of the frame, using either a mask or a rectangular subpart defined by four coordinate pairs. The centre of the cross-correlation peak is determined with an algorithm (David & Verschueren 1995, A&A, 111, 183) that minimizes errors due to the discretisation of the data. COMMENTS : This fast order-position estimate is useful: (a) when computing time is an issue (first-look pipeline) (b) when the highest precision is not needed (e.g. to decide where to measure the background) The loss of precision relates to : (a) the assumption that the change in the positions of the spectral orders may be described as a constant offset (usually relevant at the level of several hundredths of a pixel) (b) the use of less data than available (optional) SYNTAX : INPUT CONSTANTS FROM INSTRUMENT MODEL : referenceFrame or orderPositionTemplate Is the modelFlatField image. The path and name of the file could be written in the InstrumentConfig.xml file. In that case we should decide if the modelFlatField is loaded once for all in the beginning of the chain, or if it has to be loaded each time we need it in a component. If orderPositionTemplate does not exist in the resultDic, then it reads it from the instrument model. templateorderpositionscoefficients Are the coefficients of the polynomial used to represent the order shape and positions in the template frame. This should be placed in the model template (depending on the fiber mode). For testing purposes we asked to the module to check first in the result dictionary. They can also be loaded from the dictionary. IF they are not provided, then the coefficients are extracted from the header of the referenceFrame (orderPositionTemplateHeader) INPUT DATA FROM RESULTDICT : MANDATORY ; image : Input image frame inputImageHeader (fits header) fits header of the input image Note that if orderPositionTemplate and orderPositionTemplateHeader are provided, this input is not needed. templateorderpositionscoefficients (matrix of floats) Coefficients of the model used to represent the order positions in the reference frame. If not provided in the dictionary, they are read in the header of the reference frame. orderPositionTemplate orderPositionTemplateHeader From the instrument model. This information can be provided in the resultdic. Or it can be loaded by the module providing the inputImageHeader and the FIBMOD keyword. You can also provide directly a templateOrderCentersFileName instead. OPTIONS READ FROM OPTIONDICT : MANDATORY : maxShiftEstimateOrderModel (int) default : +3 (if there is no value set for maxShiftEstimateOrderModel or/and minShiftEstimateOrderModel) Is the upper boundary of the allowed template shifts. Could be written in the InstrumentConfig. minShiftEstimateOrderModel (int) default : -3 (if there is no value set for maxShiftEstimateOrderModel or/and minShiftEstimateOrderModel) Is the lower boundary of the allowed template shifts. Could be written in the InstrumentConfig. crossAxis (0 or 1) default : 0 Is the cross order axis. Its value is 1 or 0. Could be written in the InstrumentConfig. tolFastClean (double) default : 9.e99 Is the tolerance for the fast cleaning of the frame subregion we want to cross-correlate. All pixels having an intensity higher than tolFastClean are masked. xStart (int) Definition of the frame subregion. It is the X lower edge of the subregion. Definition of X and Y depends for the moment on the crossAxis value. May be this is stupid ? Could be set in the InstrumentConfig file or Model.xml file. xEnd (int) Definition of the frame subregion. It is the X upper edge of the subregion. Definition of X and Y depends for the moment on the crossAxis value. May be this is stupid ? Could be set in the InstrumentConfig file or Model.xml file. yStart (int) Definition of the frame subregion. It is the Y lower edge of the subregion. Definition of X and Y depends for the moment on the crossAxis value. May be this is stupid ? Could be set in the InstrumentConfig file or Model.xml file. yEnd (int) Definition of the frame subregion. It is the Y upper edge of the subregion. Definition of X and Y depends for the moment on the crossAxis value. May be this is stupid ? Could be set in the InstrumentConfig file or Model.xml file. OPTIONAL : isDebug (boolean) default value : False writes results to a fits file named 'T25orders.fits' isCoordinates (boolean) default value : True This options tells whether the region on the CCD that is used is defined by coordinates (True) or by providing a mask (False: This options is not implemented yet). isEstimatedAbsoluteOrderPositionsNeeded default value : True If True the absolute order positions of the input image are stored in the result dictionary using the "estimateAbsoluteOrderPositions" key. TODO: change the key in estimatedAbsoluteOrderPositions (in all modules) isFerosData (boolean) default is False Tells whether we are using FEROS data. isPolynomeBivariate (boolean) default value : True If True, the polynome used to provide the shape and position of the orders in the template is bivariate (in order and row number). The degree of the polynomial is deduced from the dimensions of the coefficient arrays. If False, the polynome only has one variable (the row number). Coefficients are therefore given for each order. Polynome degree is deduced from the coefficients array dimensions. isNotRolledTemplate (boolean) hardcoded value is True Tells the way we have to shift the template frame. Do we allow cyclicity (False) or not (True) ? shiftStep (int) hardcoded value is 1 number of pixels we allow for the template shift areRelativeCoordinates (boolean) default is True De we used relative CCD coordinates to model the order positions areVirtualEdgeOrdersAdded (boolean) hardcoded value is True to measure the background we need one additional order on both sides of the CCD middleOrder (int) if areRelativeCoordinates is true, then the module looks to the dictionary if a reference order has been set. If not, it takes the instrumentmodel value. middleRow (int) if areRelativeCoordinates is true, then the module looks to the dictionary if a reference row has been set. If not, it takes the instrumentmodel value. nbOfOrders (int) if the nb of orders is not in the dictionary, it computes the number from the values saved in the instrumentmodel file. OUTPUT WRITTEN TO THE RESULTDICT: Are always written : estimateOrderPositionShifts : the array containing the considered pixel shifts of the cross-correlation estimateOrderPositionCorrelation : the array containing the corresponding cross-correlation coefficients shiftEstimateOrderModel : the shift of the order positions When success condition is not met : record the fatal error message and stop the chain. SUCCESS CONDITIONS : OPTIONS are tested before execution of the component, and some values are making that execution impossible. crossAxis should be 0 or 1 other values ends the execution with message : "The cross order direction should be 0 (columns) or 1 (rows)" RESULTDICT should provide the input information, usually coming from previously runned components.
def hermes.pipeline.components.estimateorderposition.estimateOrderPosition.getCorrelationCoefficientsCoordinates | ( | self, | |
inputFrameInp, | |||
templateFrameInp, | |||
isNotRolledTemplate, | |||
tolFastClean | |||
) |
Prepares the subregions on the image and template frame and launches the cross correlation.
there are two methods possible (0 and 1). 0 - assumes that the image and template subregions are the same. 1 - assumes that the template subregion is larger than the image accounting for the fact that it will be shifted in the row or column direction. it returns the correlation coefficients and the shift values
hermes.pipeline.components.estimateorderposition.estimateOrderPosition.crossAxis |
user can force columns axis by setting this to 1
this is a test on the input frames ...
definition cross-correlation application domain by ...
In the diagram we do this check after the shift determination
since the template will be saved in the model then, may be, this check is not needed
should we not have also a "inputsAreValid" method like for the options ? do we not have to make a distinction between resultdict and "inputdict" ? or do you consider that an option is also an input ?
hermes.pipeline.components.estimateorderposition.estimateOrderPosition.isCoordinates |
Definition cross-correlation application domain by ...
May have two value: mask or coordinates for the moment we will only consider "coordinates" Since there are only two values possible I use a boolean TODO implement the definition of the region by providing a mask
hermes.pipeline.components.estimateorderposition.estimateOrderPosition.shiftSup |
User may force shifts but has to give both.
sup