Exemplo n.º 1
0
    def Lacosmic_WHTData(self, InputFile, OutputFile, Fits_Folder, CodeName, gain, readnoise, sigclip, verbose):

        #Load the data
        (array, header) = cosmics.fromfits(Fits_Folder + InputFile, verbose = verbose)
        upsample = 1

        #Create the task object
        c = cosmics.cosmicsimage(array, pssl = 0.0, gain=1.16, readnoise=5, sigclip = 16, verbose = verbose)

        #Run the task
        c.run(maxiter = 4, verbose = verbose)
        
        #Proceed to generate the images
        
        #-- 1) The raw input array
        im = f2n.f2nimage(c.getrawarray(), verbose=False)
        im.setzscale()
        im.makepilimage("log")
        im.upsample(upsample)
        im.writetitle("Input image", colour = (0,255,0))
        im.tonet(Fits_Folder + CodeName + "_1_raw.png")        
        
        #-- 2) The raw input array
        #-- We output a list of the positions of detected cosmic ray hits.
        #-- This is made on purpose to be fed into f2n's drawstarslist :
        labeldict = c.labelmask()
        im = f2n.f2nimage(c.getrawarray(), verbose=False)
        im.setzscale()
        im.makepilimage("log")
        im.drawmask(c.getsatstars(), colour=(255, 0, 255))
        im.upsample(upsample)
        im.drawstarslist(labeldict, colour=(255,0,0))
        im.writetitle("Cosmic ray hits", colour = (0,255,0))
        im.tonet(Fits_Folder + CodeName + "_2_labels.png")       

        #-- 3) Tne png with the precise mask in green and a wider version in blue :
        im = f2n.f2nimage(c.getrawarray(), verbose=False)
        im.setzscale()
        im.makepilimage("log")
        im.drawmask(c.getdilatedmask(size=5), colour=(0, 0, 255))
        im.drawmask(c.getmask(), colour=(0, 255, 0))
        im.upsample(upsample)
        im.writetitle("Mask", colour = (0,255,0))
        im.tonet(Fits_Folder + CodeName + "_3_mask.png")

        #-- 4) And of course one png with the clean array :
        im = f2n.f2nimage(c.getcleanarray(), verbose=False)
        im.setzscale()
        im.makepilimage("log")
        im.upsample(upsample)
        im.writetitle("Cleaned image", colour = (0,255,0))
        im.tonet(Fits_Folder + CodeName + "_4_clean.png")
        
        #Save the FitsFile (CHECK THE HEADER):
        cosmics.tofits(Fits_Folder + OutputFile, c.cleanarray, header)
        
        return
Exemplo n.º 2
0
# z1=170
# z2=5000
upsample = 1

# Build the object :

c = cosmics.cosmicsimage(array, pssl = 0.0, gain=1.16, readnoise=5,
    sigclip = 16, verbose = True)

# Run :
c.run(maxiter = 4, verbose = False)

# And now we use f2n.py to make several PNG images :

# The raw input array :
im = f2n.f2nimage(c.getrawarray(), verbose=False)
im.setzscale()
im.makepilimage("log")
im.upsample(upsample)
im.writetitle("Input image", colour = (0,255,0))
im.tonet(Demo_Folder + "0_raw.png")


# The mask of saturated stars, upon the raw image :
im = f2n.f2nimage(c.getrawarray(), verbose=False)
im.setzscale()
im.makepilimage("log")
im.drawmask(c.getsatstars(), colour=(255, 0, 255))
im.upsample(upsample)
im.writetitle("Saturated stars", colour = (0,255,0))
im.tonet(Demo_Folder + "1_satstars.png")