Hermes DRS  6.0
reduction software
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
hermes.pipeline.components.merge.merge Class Reference

merge the different orders, managing overlaps and gaps. More...

Inheritance diagram for hermes.pipeline.components.merge.merge:
hermes.pipeline.core.pipelinecomponent.PipelineComponent

Public Member Functions

def __init__
 Make a Hermes component and initialize variables.
 
def optionsAreValid
 use User's options or set defaults
 
def __call__
 run of the component More...
 
- 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

 lastOrderToMerge
 set lastOrderToMerge at user's given value, or use default 0
 
 firstOrderToMerge
 set firstOrderToMerge at user's given value, or use default 0
 
 results
 
- Public Attributes inherited from hermes.pipeline.core.pipelinecomponent.PipelineComponent
 options
 
 logger
 
 ConsoleLogSeverity
 default value
 
 canShowGraphics
 when machine does not run matplotlib. More...
 

Detailed Description

merge the different orders, managing overlaps and gaps.

PURPOSE :



-----------------------------------------------------
[NOTE: I assumed further on, that [order] and [bin] start with 0]

1. check:
HIERARCH REBIN step[order] should have the same value
for firstOrderToMerge until lastOrderToMerge

if false, then STOP with error message specifying the
whole vector HIERARCH REBIN step[order]


2. initialize vectors 'merged' and 'varianceMerged' with
(HIERARCH REBIN step[firstOrderToMerge]) *
(lastOrderToMerge-firstOrderToMerge+1)
bins to the value 0.


3. insert data values of firstOrderToMerge in 'merged'
starting with
HIERARCH REBIN firstUsefulBin[firstOrderToMerge]
and ending with
HIERARCH REBIN lastUsefulBin[firstOrderToMerge]
(in fact a bit too much, because the overlap with the next order
starts before the 'ending' and needs special treatment, but it
does not matter at present; later we'll overwrite part of the data)

insert the corresponding values of 'varianceInput' in 'varianceMerged'

compute the number
start = 'HIERARCH REBIN start[firstOrderToMerge]'
+ 'HIERARCH REBIN step[firstOrderToMerge]' * firstUsefulBin[firstOrderToMerge]
which is the start value of wavelength or ln(wavelength) for
the vectors 'merged' and 'varianceMerged'
and introduce the variable
step = HIERARCH REBIN step[firstOrderToMerge]


4. CYCLE OVER ALL ORDERS k starting with firstOrderToMerge + 1
    results["firstUsefulPixel"] = firstUsefulPixel
    results["lastUsefulPixel"] = lastUsefulPixel

take from orders m=k-1 and k the useful part which overlaps in
both orders, by identifying the relevant bins in the corresponding
orders
startOverlapm = ('HIERARCH REBIN start[k]' - 'HIERARCH REBIN start[m]') / step
        + (firstUsefulBin[k] - 1)
endOverlapm = lastUsefulBin[m]
startOverlapk = firstUsefulBin[k]
endOverlapk = ('HIERARCH REBIN start[m]' - 'HIERARCH REBIN start[k]') / step
        + (lastUsefulBin[m] - 1)

and taking the nearest integer of these expression (in an analytic
computation, they would be exactly integers)

4a.  IF there is indeed a common overlap (endOverlapk >= startOverlapk),

name the two vectors representing the overlapping parts
overlapm[bin] and overlapk[bin]
the vectors have length
size = firstUsefulBin[order k] - lastUsefulBin[order m] + 1

and name the corresponding parts of varianceInput
varianceOverlapm and varianceOverlapk

compute relativePosition[bin] = [bin]/size

compute overlap[bin] = (1.-relativePosition[bin]) * overlapm[bin]
                + relativePosition[bin] * overlapk[bin]

varianceOverlap[bin] = (1.-relativePosition[bin])**2 * varianceOverlapm[bin]
                + relativePosition[bin]**2 * varianceOverlapk[bin]

insert overlap[bin] in 'merged' starting at bin
('HIERARCH REBIN start[k]' - start) / step + (firstUsefulBin[k] - 1)

insert varianceOverlap[bin] in the corresponding bins of varianceMerged

insert the number of the
"starting bin of the overlap in the 'merged' vector"
in the header : HIERARCH MERGE startOverlap000001
insert the number of the
"end bin of the overlap in the 'merged' vector"
in the header : HIERARCH MERGE endOverlap000001


Now, insert the part of order k starting from the first bin after
endOverlapk until 'HIERARCH REBIN lastUsefulBin[k]' in the 'merged'
vector (in fact a bit too much, because the overlap with the next order
starts before the 'ending' and needs special treatment, but it
does not matter at present; later we'll overwrite part of the data)

Do exactly the same in the corresponding variance image.

4b.  IF there is no overlap

take the data of order k
from firstUsefulBin[k] until lastUsefulBin[k]

insert these data in 'merged' starting at bin
('HIERARCH REBIN start[k]' - start) / step + (firstUsefulBin[k] - 1)

take the corresponding data from varianceInput
and insert them in the corresponding bins of varianceMerged

END OF CYCLE

5. Write the results to a FITS file
The FITS image should have a "start" at the value of the variable start
and its "step" is equal to 'HIERARCH REBIN STEP[firstOrderToMerge]'

and provide, in addition to the headers already
available in the input, the following information
HIERARCH MERGE startOverlap000001
HIERARCH MERGE endOverlap000001
HIERARCH MERGE startOverlap001002
HIERARCH MERGE endOverlap001002
...
where "O01002" etc should be more generally two subsequent orders,
from "firstOrderToMerge and the next one" up to the "one-but-last
and last order for which the overlap is not empty.

Each of these 'HIERARCH MERGE' entries contains the chosen coordinate
(wavelength or ln wavelength) of the bin in 'merged' where the
corresponding overlap starts or ends.
[If all orders are merged, we start with "000001" and take the
bin numbers of start and end from startBinOverlap[0] and
endBinOverlap[0], ]

sums the overlapping bins in the rebinnedUnblazedExtractedFlatFlieldBlazedShift

extract from rebinnedUnblazedExtractedFlatFieldBlazedShift
the part of the order k from the first useful bin
to the bin corresponding to the last useful bin
in the order k-1, to construct rebinned[Order]



COMMENTS :


SYNTAX :


INPUT CONSTANTS FROM INSTRUMENT MODEL :





INPUT DATA FROM RESULTDICT :

MANDATORY :
    rebinned orders
    the corresponding input variance array 'varianceInput'

    INPUT DATA FROM THE HEADER:
        HIERARCH REBIN start[order]           # coordinate of first bin in order
        HIERARCH REBIN step[order]            # coordinate step
        HIERARCH REBIN firstUsefulBin[order]  # number of first useful bin in order
        HIERARCH REBIN lastUsefulBin[order]   # number oflast useful bin in order





OPTIONS READ FROM OPTIONDICT :

merge from firstOrderToMerge until lastOrderToMerge
    default = all orders in input


OUTPUT written in the RESULTDICT :

merged spectrum

Member Function Documentation

def hermes.pipeline.components.merge.merge.__call__ (   self,
  instrumentModel 
)

run of the component

for kOrder in range ( self.firstOrderToMerge + 1, rebinned.shape[0] ): for kOrder in range ( self.firstOrderToMerge + 1, self.lastOrderToMerge ):


The documentation for this class was generated from the following file: