예제 #1
0
def imgByOffset():
    ccd, camera, sector = 1,1,1
    col, row = 123, 456
    
    obj = prf.TessPrf(datapath)
    prfObjArray = obj.readPrfFile(ccd, camera, sector)
 
    singlePrfObj = prfObjArray[0]
    img0 = obj.getRegularlySampledPrfByOffset(singlePrfObj, 0, 0)

    for offset in range(9):
#        img1 = obj.getRegularlySampledPrfByOffset(singlePrfObj, offset, 0)
        img1 = obj.getRegularlySampledPrfByOffset(singlePrfObj, offset, 0)
        delta = img1 - img0
        
        kwargs = {'origin':'bottom', 'interpolation':'nearest', 'cmap':plt.cm.YlGnBu_r}
        plt.clf()
        plt.subplot(121)
        plt.imshow(img1, **kwargs)
        plt.colorbar()
        
        plt.subplot(122)
        kwargs['cmap'] = plt.cm.PiYG
        plt.imshow(delta, **kwargs)  
        vm = max( np.fabs( [np.min(delta), np.max(delta)] ))
#        vm = 1e-2
        plt.clim(-vm, vm)
        plt.colorbar()
        plt.suptitle(offset)
        plt.pause(.1)
        raw_input()
예제 #2
0
def example():
    #    ticid = 307210830
    sector = 2
    camera = 4
    ccd = 3

    path = '/home/fergal/data/tess/hlsp_tess-data-alerts_tess_phot_00307210830-s02_tess_v1_tp.fits'
    fits, hdr = pyfits.getdata(path, header=True)

    cube = dtpf.getTargetPixelArrayFromFits(fits, hdr)
    img = cube[100]
    idx = np.isfinite(img)
    img[~idx] = 0

    prfObj = prf.TessPrf("/home/fergal/data/tess/prf/v2")

    bbox = getBoundingBoxForImage(img, hdr)
    res = fitPrfCentroidForImage(img, ccd, camera, sector, bbox, prfObj)

    #The fit fails terribly, so adjusting reported col/row position
    #to make the result look better cosmetically.

    res.x[0] += .5
    res.x[1] += 1.0
    plotCentroidFitDiagnostic(img, hdr, ccd, camera, sector, res, prfObj)
    return res
예제 #3
0
def testIntFloatBug():        
    """getPrfAtColRow() should return same value whether input is int or float"""

    obj = prf.TessPrf(datapath)
    
    img1 = obj.getPrfAtColRow(123, 456, 1,1,1)
    img2 = obj.getPrfAtColRow(123.0, 456.0, 1,1,1)
    
    assert np.all(img1 - img2 == 0)
예제 #4
0
def test_bracketing():
    """The method getRegularlySampledBracketingPrfs() has some fairly complicated
    bookkeeping to find the locations of the 4 prfs that brack the input col,row
    in 2d space. It internally checks this bookkeeping is correct and raises
    an assert on failure. This test exercises all 4 paths in the code.
    """
    obj = prf.TessPrf(datapath)
    
    #This raises an assertion error
    obj.getPrfAtColRow(1587, 1710, 1, 1, 1)
    obj.getPrfAtColRow(1581, 1537, 1, 1, 1)  #A
    obj.getPrfAtColRow(1579, 1537, 1, 1, 1)  #S
    obj.getPrfAtColRow(1579, 1535, 1, 1, 1)  #T
    obj.getPrfAtColRow(1581, 1535, 1, 1, 1)  #Cs
예제 #5
0
def testRowFrac():        
    """Test that changing column fraction moves flux around"""

    obj = prf.TessPrf(datapath)
    
    img1 = obj.getPrfAtColRow(123.0, 456, 1,1,1)
    
    for frac in np.linspace(0, .9, 11):
        img2 = obj.getPrfAtColRow(123.0, 456.0 + frac, 1,1,1)
        delta = img2 - img1
        
#        prfPlot(img1, delta)
        
        #For TESS, PRFs are 13x13. Check the flux near the centre
        #is moving from lower columns to higher ones
        assert delta[6,6] >= 0, delta[6,6]
        assert delta[7,6] >= 0, delta[7,6]
        assert delta[5,6] <= 0, delta[5,6]
예제 #6
0
def test_outOfBounds():

    obj = prf.TessPrf(datapath)
    with pytest.raises(ValueError):
        obj.getPrfAtColRow(0,0, 1, 1, 1)
        
    with pytest.raises(ValueError):
        obj.getPrfAtColRow(44,1, 1, 1, 1)
        
    with pytest.raises(ValueError):
        obj.getPrfAtColRow(2093,1, 1, 1, 1)
    
    with pytest.raises(ValueError):
        obj.getPrfAtColRow(47, 0, 1, 1, 1)

    with pytest.raises(ValueError):
        obj.getPrfAtColRow(47,2048  , 1, 1, 1)
            
    #Check some in bounds
    obj.getPrfAtColRow(45, 1, 1, 1, 1)
    obj.getPrfAtColRow(2091, 2047, 1, 1, 1)