TwiceAsNice  2019-02-18
Classes | Functions
SR_Utils Namespace Reference

Classes

class  MyQGS
 

Functions

def FTScale (inA, scF)
 
def SRMetric (inAry)
 
def genPixMap (ary, wid, z1, z2, auto)
 
def parseLast (lstFile)
 

Function Documentation

◆ FTScale()

def SR_Utils.FTScale (   inA,
  scF 
)
Returns a numpy array scaled by the factor scF (integer). The routine uses Fourier
interpolation to return a larger array with appropriate spatial frequency behaviour.
It therefore helps solve the problem of peak-finding in Nyquist sampled data.

◆ genPixMap()

def SR_Utils.genPixMap (   ary,
  wid,
  z1,
  z2,
  auto 
)
   Generates and returns a PixMap suitable for onscreen display, that is, of size wid
   and scaled from 0-255.

   Parameters:  ary   - numpy array of input data (any size, but must be SQUARE!)
                wid   - width of PixMap to return
                z1,z2 - grayscale cuts
                auto  - whether to autoscale

   Returns:     pMp   - pixmap suitable for onscreen display
                z1,z2 - grayscale cuts (changes if auto=True)
                ok    - flag indicating success

◆ parseLast()

def SR_Utils.parseLast (   lstFile)
    Hides a lot of ugly. This routine accepts the (known to exist) file
    lstFile and reads in the last state of the program. 

    WARNING: If you find that values in SR_Conf.py don't seem to have an
             effect, check that they are not being overwritten here!

◆ SRMetric()

def SR_Utils.SRMetric (   inAry)
    This is the heart of the program. SRMetric returns the ratio of the peak signal
    to the total signal of the supplied star. The peak comes from an oversampled version
    via the FTScale routine, and the total signal is that within a radius SR_Conf.phRad.

    Details
    The routine calculates ary8, an eight-times oversampled version of the input image inAry. 
    It then searches a region of size SR_Conf.pfRad for the maximum value, max8. The total
    flux fTot is calculated from the original inAry within radius SR_Conf.phRad. The returned
    SR metric is just max8 / fTot.

    Actually, there is a complication...we have to extract a sub-array centered on the star,
    (that is, on the peak flux, rather than the center of the array, since the user could have
    clicked anywhere) and then only add up those pixels within phRad of this point.

    Actually, there is another complication. A proper SR Metric depends on proper background
    subtraction. This includes determining the actual peak signal. For this reason, the
    routine does the photometry on the input image and then subtracts the original-
    image background value from 64 times the maximum pixel derived from the re-sampled
    image (FTScale conserves flux, and thus 8x oversampling reduces the peak by 64). The
    SR Metric is then actually (64 * max8 - bAvg) / fTot

    One more thing...LINC-NIRVANA has very fine sampling (5.11 mas per pixel). This means
    that a "postage stamp" extract of an image with, say, 1.5 arcsec radius will be almost
    600 pixels across. It does not make sense to 8-times oversample such an image in order
    to find the peak pixel: this would require resampling a 1024 square image to 8192 square.
    While entirely possible, such a procedure is costly in computing and moreover, entirely
    unnecessary. Instead, we extract a smaller sub-region (typically 128 x 128 pixels) for
    the peak finding and do the photometry on the original.

    Parameters
        inAry       - Supplied numpy array containing star image
        srm         - Returned SR Metric

        ary8        - Eight-times oversampled version of inAry
        mBH         - max Box Half...half the size of the peak finding search box, given by
                      the number of input pixels (SR_Conf.phRad/SR_Conf.pxScl*1000) times 8
                      (for oversampling) and then divided by 2 (for half the box). i.e. * 4000.0
        max8        - Maximum pixel value in this box
        inMax       - 64 times max8...the effective peak signal in the input
        phR         - and ibR,obR are the relevant photetry radii in pixels
        phAry       - Extracted photometry sub-array
        fTot,bTot   - Total flux in star, background annulus
        bAvg, bMed  - Average and median background in original image
        nfTot,nbTot - and pixel counts
        starFlux    - Background-subtracted star flux