예제 #1
0
    def subScatLgt(self, inIm, mask, **kwargs):

        print "\nSUBTRACTING SCATTERED LIGHT FROM", inIm

        pref = kwargs["prefix"]

        # allow user to iterate over orders used to model scattered light
        while True:
            fixScat = bool(
                input(
                    "\nDoes subtraction of scattered light need improvement? (True/False): "
                ))
            if fixScat:
                # request orders from user
                xOrders = raw_input("X orders (csv): ")
                yOrders = raw_input("Y orders (csv): ")

                # model and subtract the light, and view the result
                iraf.imdelete(pref + inIm)
                iraf.gfscatsub(inIm, mask, xorder=xOrders, yorder=yOrders, \
                 **kwargs)

                utils.examIm(pref + inIm + "[SCI]", frame=1)
            else:
                break

        return
예제 #2
0
# Scattered light
blkmsk = np.loadtxt("blkmask_name.txt", dtype=str).item(0)
blkmsk0 = blkmsk

iraf.imdelete('brg@' + ic.lst_std)

std = np.loadtxt(ic.lst_std, dtype=str)
if (std.size > 1):
    raise ValueError(
        "Please check if there is only one image for the standard star.")
std0 = std.item(0)

iraf.gfscatsub('rg' + std0,
               blkmsk0,
               outimage='',
               prefix='b',
               xorder='3,3,3,3,3,3,3,3,3,3,3,3',
               yorder='3,3,3,3,3,3,3,3,3,3,3,3',
               cross='yes',
               fl_inter='no')

# os.system('ds9 &')
# iraf.sleep(5.0)
# for std in iraf.type(ic.lst_std, Stdout=1):
#     std = std.strip()
#     for i in range(12):
#         iraf.imexamine('brg'+std+'[sci,'+str(i+1)+']', 1)

# Printing the running time
print('--- %.4f seconds ---' % (time.time() - start_time))
예제 #3
0
    def reduceFlats(self, flatList, inPref="", arcList="", arcPath="", \
     subscat="no", **kwargs):

        print "\nREDUCING FLATS"

        # retrieve filenames of individual exposures
        flatPaths = utils.getImPaths(flatList)

        # process flats one at a time
        for flat in flatPaths:

            # make additional preparations if QE correction requested
            if "fl_qecorr" in kwargs.keys() and kwargs["fl_qecorr"] == "yes":

                # move extracted arcs to working directory
                refIm = "erg" + utils.matchCentWave(inPref + flat, "./", \
                 arcList, "arc/")
                os.system("mv " + arcPath + refIm + " ./")

                # add reference image to kwargs
                kwargs["qe_refim"] = refIm

            # model and remove the scattered light, if requested;
            # otherwise, reduce the image
            if subscat == "yes":
                # TODO: display all science extensions

                # find file holding extracted flat spectra
                # TODO: determination of extFlat probably needs improvement
                dirList = os.listdir("./")
                descendList = [im for im in dirList if flat in im]
                extFlat = [im for im in descendList if "erg" in im][0]
                print extFlat

                # find gaps between fiber bundles on detector
                gapFile = "blkMask_" + flat[:flat.find(".")] + ".txt"
                iraf.delete(gapFile)
                iraf.gffindblocks(extFlat[1:], extFlat, gapFile)

                # model and remove scattered light, if necessary
                # (and repeat until satisfied)
                utils.examIm(extFlat[1:] + "[SCI]", frame=1)
                while True:
                    fixScat = bool(
                        input(
                            "Does subtraction of scattered light need improvement? (True/False): "
                        ))
                    if fixScat:
                        xOrders = raw_input("X orders (csv): ")
                        yOrders = raw_input("Y orders (csv): ")

                        iraf.imdelete("b" + extFlat[1:])
                        iraf.gfscatsub(extFlat[1:], gapFile, fl_inter="yes", \
                         prefix="b", xorder=xOrders, yorder=yOrders, \
                         cross="yes")

                        utils.examIm("b" + extFlat[1:] + "[SCI]", frame=1)
                    else:
                        break
            else:
                # reduce the image
                outPref = self.reduceIm(inPref + flat, **kwargs)

                # TODO: for this to work, need to know the proper prefix ...
                # (have reduceIm return the prefix?)
                self.viewCube(outPref + inPref + flat)
                pass

            # return extracted arcs to their rightful place
            if "fl_qecorr" in kwargs.keys() and kwargs["fl_qecorr"] == "yes":
                os.system("mv " + refIm + " " + arcPath)

        return