예제 #1
0
def perform_cosmic_removal(im_name, output=None):
    """ Remove cosmics from fits image
    :param im_name: fits image to be cleaned from cosmic rays
    :return: name of the cleaned image
    """
    if output is None:
        output = im_name

    arguments = [im_name, "--output", output, "--maxiter", "2"]

    im = astroim.Astroim(im_name)

    needed_keys = [("--gain", im.primary_header.gaink), ("--readnoise", im.primary_header.ccdronk)]
    for arg, kk in needed_keys:
        if kk is None:
            continue
        arguments += [arg, kk]

    new_name = remove_cosmics.main(arguments=arguments)

    return new_name
예제 #2
0
    for im in list_images["filename"]:
        image = fits.open(im, mode="update")
        image[0].data[mask==2] = 0
        image.flush()
        image.close()
             
print "Estimate sky for images of CIG(s), standard(s) and cluster(s) "
for index, image in enumerate(list_images["filename"]):
    if list_images["type"][index] in ["cig","standards","clusters"]:
        find_sky.main(arguments=[list_images["filename"][index]])  
        
print "Removing cosmic rays from images"
for index, im in enumerate(list_images["filename"]):
    if list_images["type"][index] in ["cig", "standards", "clusters"]:        
            newname = remove_cosmics.main(arguments=["--suffix", " -c", 
                                          "--gain", str(fits.getval(im, gaink)), 
                                          "--readnoise", str(fits.getval(im, read_noisek)),
                                          "--sigclip", "5", "--maxiter", "3", im])
            list_images["filename"][index] = newname

#print "Calculate smoother version of images"
#for index, im in enumerate(list_images["filename"]):
#    if list_images["type"][index] in ["cig", "standards", "clusters"]:    
#        imdata = fits.getdata(im)
#        #im_median = np.median(imdata)
#        #im_MAD = np.median(np.abs(imdata - im_median))
#        #imdata[imdata < im_median + 6. * im_MAD] = im_median
#        imfiltered = filters.gaussian_filter(imdata, 2)
#        filtered_name = utilities.add_suffix_prefix(im, prefix="filtered-")
#        fits.writeto(filtered_name, imfiltered)

print "Include WCS"
예제 #3
0
#                         "--quad-size-min", "0.05", "--ra", str(RA), "--dec", 
#                         str(DEC), "--radius", str(FoV), "--depth", "100,250", 
#                         "--solved", "solved.txt", np.str(image)]) 

                         
### Estimation of the sky level for all the images (except for bias)
print "> Estimate sky for images of CIG(s), standard(s)"
for index, image in enumerate(list_images["filename"]):
    if list_images["type"][index] in ["cig","standards","unknown"]:
        print image
        find_sky.main(arguments=[list_images["filename"][index]])


# Cosmic rays removal. Dependent on the telescope (campaign keyword: TELESCOP)
print "> Removing cosmic rays from images"
telescope = 'INT'
cosmic_dict = cosmic_removal_param(telescope)  # Read the parameters (gain,readout noise)
for index, im in enumerate(list_images["filename"]):
    if list_images["type"][index] not in ["bias", "flats"]:        
            newname = remove_cosmics.main(arguments=["--suffix", " -c", "--gain",\
                   cosmic_dict["gain"], "--readnoise", cosmic_dict["readnoise"], \
                   "--sigclip", cosmic_dict["sigclip"], "--maxiter", "3", im])
            list_images["filename"][index] = newname


<<<<<<< HEAD
sys.exit("* * * * * * Reduction finished * * * * * *")
=======
sys.exit("* * * * * * Reduction finished * * * * * *")
>>>>>>> javi/master