コード例 #1
0
        # If the file exists, then read it into a dictionary
        if os.path.isfile(fileName):
            polAngs.append(polAng)
            polAngImgs.append(AstroImage(fileName))
        else:
            fileCheck = False

    # Check that all the necessarry files are present
    if not fileCheck:
        print("\tSome required Polaroid Angle files are missing.")
        continue

    # Use the "align_stack" method to align the newly created image list
    print('\nAligning images\n')
    polAngImgs = image_tools.align_images(polAngImgs,
        mode='cross_correlate', subPixel=True, padding=np.nan)

    # Convert the list into a dictionary
    polAngImgs = dict(zip(polAngs, polAngImgs)) #aligned

    #**********************************************************************
    # Stokes I
    #**********************************************************************
    # Average the images to get stokes I
    stokesI = image_tools.combine_images([polAngImgs[0],
                                          polAngImgs[200],
                                          polAngImgs[400],
                                          polAngImgs[600]])
    stokesI = 2 * stokesI

    # Perform astrometry to apply to the headers of all the other images...
コード例 #2
0
            # Catch saturated negative values
            badInds = np.where(Aimg.arr < -3*read_noise/effective_gain)
            Aimg.arr[badInds] = np.NaN

            # Perform the actual background subtraction
            Aimg.arr  = Aimg.arr - B1bkg.background

            # Append the background subtracted image to the list
            sciImgList.append(Aimg.copy())


        # Now that all the backgrounds have been subtracted,
        # let's align the images and compute an average image
        # TODO Should I use "cross-correlation" alignment?
        sciImgList  = image_tools.align_images(sciImgList, padding=np.NaN)
        avgImg      = image_tools.combine_images(sciImgList, output = 'MEAN',
            effective_gain = effective_gain,
            read_noise = read_noise)

    else:
        # Handle HEX-DITHERS images
        # (mostly for calibration images as of now)
        continue
        ##### The Indexing Program should parse hex pointing positions, too.
        # Test if numImgs matches the ABBA pattern
        if (numImgs % 6) != 0:
            print('The HEX dither pattern is not there...')
            pdb.set_trace()

        # Now align and combine these images into a single average image
コード例 #3
0
        # # Loop through each image in the image list and compute its uncertainty
        # imgList1 = imgList.copy()
        # for imgNum, img in enumerate(imgList):
        #     imgList1[imgNum].sigma = np.sqrt((backgroundLevels[imgNum] + img.arr)/effective_gain)
        #
        # imgList = imgList1.copy()
        # del imgList1

        # Now apply the scale factors to the images in imgList
        imgList = [CF*img for CF, img in zip(scaleFactors, imgList)]

        # Now that the background free images are stored, combine them
        # Align the images
        print('\tAligning the background removed images for IPPA {0}'.format(ippa))
        imgList = image_tools.align_images(imgList, mode='wcs', padding=np.nan)

        # Perform identical alignments for the xPos and yPos images
        xPosList = image_tools.align_images(xPosList, mode='wcs', padding=-1e6)
        yPosList = image_tools.align_images(yPosList, mode='wcs', padding=-1e6)

        # Loop through the position lists and cull any stupid numbers
        for imgNum in range(len(xPosList)):
            # Create the temporary position arrays with masks
            tmpXarr      = np.ma.array(xPosList[imgNum].arr)
            tmpYarr      = np.ma.array(yPosList[imgNum].arr)
            tmpXarr.mask = np.zeros_like(tmpXarr, dtype=bool)
            tmpYarr.mask = tmpXarr.mask.copy()

            # Find the positions of the bad values
            badInds     = np.where(np.logical_or(tmpXarr < 0, tmpYarr < 0))
コード例 #4
0
        # If the file exists, then read it into a dictionary
        if os.path.isfile(fileName):
            polAngs.append(polAng)
            polAngImgs.append(AstroImage(fileName))
        else:
            fileCheck = False

    # Check that all the necessarry files are present
    if not fileCheck:
        print("\tSome required Polaroid Angle files are missing.")
        continue

    # Use the "align_stack" method to align the newly created image list
    print('\nAligning images\n')
    polAngImgs = image_tools.align_images(polAngImgs,
                                          mode='cross_correlate',
                                          subPixel=True,
                                          padding=np.nan)

    # Convert the list into a dictionary
    polAngImgs = dict(zip(polAngs, polAngImgs))  #aligned

    #**********************************************************************
    # Stokes I
    #**********************************************************************
    # Average the images to get stokes I
    stokesI = image_tools.combine_images(
        [polAngImgs[0], polAngImgs[200], polAngImgs[400], polAngImgs[600]])
    stokesI = 2 * stokesI

    # Perform astrometry to apply to the headers of all the other images...
    stokesI, success = image_tools.astrometry(stokesI)
コード例 #5
0
            # Catch saturated negative values
            badInds = np.where(Atmp.arr < -3 * read_noise / effective_gain)
            Atmp.arr[badInds] = np.NaN

            # Perform the actual background subtraction by scaling the average
            # *NORMALIZED* background image to the interpolated background level
            Atmp.arr = Atmp.arr - bkgModel(Atime) * bkgImg

            # Append the background subtracted image to the list
            sciImgList.append(Atmp.copy())

        # Now that all the backgrounds have been subtracted,
        # let's align the images and compute an average image
        # TODO Should I use "cross-correlation" alignment?
        sciImgList = image_tools.align_images(sciImgList, padding=np.NaN, mode="cross_correlate", subPixel=True)
        avgImg = image_tools.combine_images(
            sciImgList, output="MEAN", mean_bkg=mean_bkg, effective_gain=effective_gain, read_noise=read_noise
        )

    else:
        # Handle HEX-DITHERS images
        # (mostly for calibration images as of now)
        continue
        ##### The Indexing Program should parse hex pointing positions, too.
        # Test if numImgs matches the ABBA pattern
        if (numImgs % 6) != 0:
            print("The HEX dither pattern is not there...")
            pdb.set_trace()

        # Now align and combine these images into a single average image