Ejemplo n.º 1
0
def ispr():

    ## File lists
    originals = sort(file_seek("../Data/", "CFHTLS_*_sci_rescaled.png"))
    stretched = sort(file_seek("../Data/", "CFHTLS_*_rescaled.png"))
    stars = sort(file_seek("../Data/", "samp_CFHTLS*_rescaled.png"))
    psf = sort(file_seek("../Data/", "snap_n1_d0_CFHTLS*_rescaled_z8.png"))
    residuals = sort(file_seek("../Data/", "resi_CFHTLS*_rescaled.png"))

    ## Check
    numfiles = len(originals)
    if len(stars) != numfiles or len(psf) != numfiles or len(
            residuals) != numfiles or len(stretched) != numfiles:
        print "GalleryScript.py: ispr: There are gaps. Abort."
        print numfiles, len(stars), len(psf), len(residuals), len(stretched)
        return

    ## Make ordered string of files
    full_list = ""
    for i in range(numfiles):
        #full_list+=" "+originals[i]
        full_list += " " + stretched[i]
        full_list += " " + stars[i]
        full_list += " " + psf[i]
        full_list += " " + residuals[i]

    print "GalleryScript.py: ispr: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/ispr.pdf"): os.remove("../Data/ispr.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/ispr.pdf")

    return
Ejemplo n.º 2
0
def ispr():

    ## File lists
    originals = sort(file_seek("../Data/", "CFHTLS_*_sci_rescaled.png"))
    stretched = sort(file_seek("../Data/", "CFHTLS_*_rescaled.png"))
    stars = sort(file_seek("../Data/", "samp_CFHTLS*_rescaled.png"))
    psf = sort(file_seek("../Data/", "snap_n1_d0_CFHTLS*_rescaled_z8.png"))
    residuals = sort(file_seek("../Data/", "resi_CFHTLS*_rescaled.png"))

    ## Check
    numfiles = len(originals)
    if len(stars) != numfiles or len(psf) != numfiles or len(residuals) != numfiles or len(stretched) != numfiles:
        print "GalleryScript.py: ispr: There are gaps. Abort."
        print numfiles, len(stars), len(psf), len(residuals), len(stretched)
        return

        ## Make ordered string of files
    full_list = ""
    for i in range(numfiles):
        # full_list+=" "+originals[i]
        full_list += " " + stretched[i]
        full_list += " " + stars[i]
        full_list += " " + psf[i]
        full_list += " " + residuals[i]

    print "GalleryScript.py: ispr: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/ispr.pdf"):
        os.remove("../Data/ispr.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/ispr.pdf")

    return
Ejemplo n.º 3
0
def manual(module, sel, directory, liststring1, liststring2, outname):

    ## File lists
    files_1 = sort(file_seek(directory, liststring1 + ".png"))
    files_2 = sort(file_seek(directory, liststring2 + ".png"))

    ## Check
    if len(files_1) != len(files_2):
        print "GalleryScript.py: manual: there are gaps. Abort."
        return

        ## Make ordered string of files
    full_list = ""
    for i in range(len(files_1)):
        full_list += " " + files_1[i]
        full_list += " " + files_2[i]

    print "GalleryScript.py: manual: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/" + outname + ".pdf"):
        os.remove("../Data/" + outname + ".pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/" + outname + ".pdf")

    return
Ejemplo n.º 4
0
def manual(module, sel, directory, liststring1, liststring2, outname):

    ## File lists
    files_1 = sort(file_seek(directory, liststring1 + ".png"))
    files_2 = sort(file_seek(directory, liststring2 + ".png"))

    ## Check
    if len(files_1) != len(files_2):
        print "GalleryScript.py: manual: there are gaps. Abort."
        return

    ## Make ordered string of files
    full_list = ""
    for i in range(len(files_1)):
        full_list += " " + files_1[i]
        full_list += " " + files_2[i]

    print "GalleryScript.py: manual: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/" + outname + ".pdf"):
        os.remove("../Data/" + outname + ".pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/" +
              outname + ".pdf")

    return
Ejemplo n.º 5
0
def stretch_all(sel=0):

	for string in ["CFHTLS_*_sci.fits"]:#
		for fits in file_seek("../Data/",string):
			if sel==0: stretch(fits)
			else: stretch_plus(fits)
			
	return
Ejemplo n.º 6
0
def stretch_plus(fits_original):
	
	## Stretching parameters	
	vmin,vmax=stretch(fits_original)
	
	## Apply to diagnostic files
	homedir=os.path.dirname(fits_original)
	for string in ["snap_*_sci.fits","samp_*_sci.fits","resi_*_sci.fits"]:#"CFHTLS_*_sci.fits"
		for fits in file_seek(homedir,string):
			stretch(fits, vmin,vmax)
			
	return
Ejemplo n.º 7
0
def cmap():

    ## File lists
    originals = sort(file_seek("../Data/", "CFHTLS_*_sci.png"))
    stretched = sort(file_seek("../Data/", "CFHTLS_*_rescaled.png"))
    brights = sort(file_seek("../Data/", "CFHTLS_*_br*.png"))
    BB = sort(file_seek("../Data/", "CFHTLS_*_cBB.png"))
    HE = sort(file_seek("../Data/", "CFHTLS_*_cHE.png"))

    ## Check
    numfiles = len(originals)
    if len(brights) != numfiles or len(BB) != numfiles or len(HE) != numfiles or len(stretched) != numfiles:
        print "GalleryScript.py: cmap: There are gaps. Abort."
        print numfiles, len(brights), len(BB), len(HE), len(stretched)
        return

        ## Make ordered list of files
    full_list = ""
    for i in range(numfiles):
        full_list += " " + originals[i]
        full_list += " " + stretched[i]
        full_list += " " + brights[i]
        # full_list+=" "+BB[i]
        full_list += " " + HE[i]

    print "GalleryScript.py: cmap: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/cmap.pdf"):
        os.remove("../Data/cmap.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/cmap.pdf")

    ## Rename gallery.pl output
    # os.rename("gallery.pdf","cmaps.pdf")
    ## Move to appropriate location
    # move("cmaps.pdf","../Data/")

    return
Ejemplo n.º 8
0
def cmap():

    ## File lists
    originals = sort(file_seek("../Data/", "CFHTLS_*_sci.png"))
    stretched = sort(file_seek("../Data/", "CFHTLS_*_rescaled.png"))
    brights = sort(file_seek("../Data/", "CFHTLS_*_br*.png"))
    BB = sort(file_seek("../Data/", "CFHTLS_*_cBB.png"))
    HE = sort(file_seek("../Data/", "CFHTLS_*_cHE.png"))

    ## Check
    numfiles = len(originals)
    if len(brights) != numfiles or len(BB) != numfiles or len(
            HE) != numfiles or len(stretched) != numfiles:
        print "GalleryScript.py: cmap: There are gaps. Abort."
        print numfiles, len(brights), len(BB), len(HE), len(stretched)
        return

    ## Make ordered list of files
    full_list = ""
    for i in range(numfiles):
        full_list += " " + originals[i]
        full_list += " " + stretched[i]
        full_list += " " + brights[i]
        #full_list+=" "+BB[i]
        full_list += " " + HE[i]

    print "GalleryScript.py: cmap: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/cmap.pdf"): os.remove("../Data/cmap.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/cmap.pdf")

    ## Rename gallery.pl output
    #os.rename("gallery.pdf","cmaps.pdf")
    ## Move to appropriate location
    #move("cmaps.pdf","../Data/")

    return
Ejemplo n.º 9
0
def FITStoPNG(args):
	
	## THIS NEEDS TO BE TIDIED UP
	## get rid of old stuff	
	
  params=""
  namext=""
  ## Change colourmap option
  if len(args)>4:
		if args[4]=="BB":
			params=" -cmap BB "
			namext="_cBB"
		elif args[4]=="HE":
			params=" -cmap HE "
			namext="_cHE"
		elif args[4]=="zoom":
			params=" -zoom 8 "
			namext="_z8"
  if len(args)>5:
		if args[5]=="nocolourbar":
			params += " -colorbar no "
  else:
    params=""
    namext=""
  
  i=0 
  for f_img in file_seek(args[2], args[3]+"*.fits"):
  
		## Prepare destination directory
		outdir=os.path.dirname(f_img)#+"/Enhanced_Original/" ## Needs to be commented when brightening
		if os.path.isdir(outdir)==False: os.mkdir(outdir)
		
		## Outfile name
		p_img = outdir+"/"+os.path.basename(f_img)[:-5]+namext+".png"
		
		## File conversion
		os.system("ds9 "+f_img+" "+params+" -minmax -colorbar no -saveimage png "+p_img+" -exit")
		i+=1
	
	## Shave whitespace?
	##
	##
		
  print "ImageScript.py: FITStoPNG: Converted",i,"files to png format."
  return
Ejemplo n.º 10
0
def all_kernels(kdim, writefile=True,makeimage=False, vb=False):
		
	## Get files
	allpngs = numpy.sort(file_seek("../Data/GPSF/","snap*d0_CFHTLS_03_g*.png"))
	
	## Collect pairs of files
	for i in range (0,len(allpngs),2):
	
		## Extract image info
		image1 = png_pix(allpngs[i])
		image2 = png_pix(allpngs[i+1])
		
		## Cut out extraneous white pixels
		image1 = pngcropwhite(image1)
		image2 = pngcropwhite(image2)
		
		## Deconvolve
		A=get_kernel(image1,image2, kdim)
		B=get_kernel(image2,image1, kdim)	

##------------------------------------------------------------
			
		## Write kernels to file and make images
		
		## Gaussian to PSF
		outfile=os.path.splitext(allpngs[i])[0][:-4]+"_GausstoPSF_"+str(A.shape[0])+".krn"
		f=open(outfile,"w")
		f.write("## Convolution kernel taking 2D Gaussian to PSFEx image\n\n\n")
		writearray(f,A,True)
		if vb: print "DeconvolveToTargetPSF.py: kernel written to",outfile
		
		## PSF to Gaussian		
		outfile=os.path.splitext(allpngs[i])[0][:-4]+"_PSFtoGauss_"+str(B.shape[0])+".krn"
		f=open(outfile,"w")
		f.write("## Convolution kernel taking PSFEx image to 2D Gaussian\n\n\n")
		writearray(f,B,True)
		if vb: print "DeconvolveToTargetPSF.py: kernel written to",outfile
		
		print "\n"

##------------------------------------------------------------	
	
	return
Ejemplo n.º 11
0
def psfs():

    ## File lists
    psf_files = sort(file_seek("../Data/", "*fit?.png"))

    ## Check

    ## Make ordered string of files
    full_list = ""
    for i in range(len(psf_files)):
        full_list += " " + psf_files[i]

    print "GalleryScript.py: psfs: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/psfs.pdf"): os.remove("../Data/psfs.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/psfs.pdf")

    return
Ejemplo n.º 12
0
def psfs():

    ## File lists
    psf_files = sort(file_seek("../Data/", "*fit?.png"))

    ## Check

    ## Make ordered string of files
    full_list = ""
    for i in range(len(psf_files)):
        full_list += " " + psf_files[i]

    print "GalleryScript.py: psfs: files found. Proceed with latex."

    ## Destroy current version
    if os.path.isfile("../Data/psfs.pdf"):
        os.remove("../Data/psfs.pdf")

    ## Call gallery script
    os.system("perl gallery.pl " + full_list + " -pdf -t -o ../Data/psfs.pdf")

    return
Ejemplo n.º 13
0
def all_psfs(topdir="~/Dropbox/Hogg_2012/Data/PSFs/", filestring="snap_*.fits"):	
	for fitsfile in file_seek(topdir, filestring):
		GPSF(fitsfile)
	return
Ejemplo n.º 14
0
			krn_size = int(a)
		elif o in ("-s", "--fstr"):
			file_string = a
		elif o in ("--sim "):
			simul=True
		else:
			assert False, "Unhandled option."
			
	##--------------------------------------------------------------------
	
	## Input a collection of files or directory?
	## filelist is a list of raw image files.
	filelist=[]
	for arg in args:
		if os.path.isfile(arg):  filelist+=[arg]
		elif os.path.isdir(arg): filelist+=file_seek(arg,file_string)
	
	if simul is False:
		single_deconvolve(filelist, krn_size, vb)
	else:
		simultaneous_deconvolve(filelist, krn_size, vb)
	
	##--------------------------------------------------------------------
	
	if vb: print "deconvolve.py: deconvolution of",len(filelist),\
								"file(s) took",round(time.time()-t_init,3),"seconds."
	
	return

##============================================================
	
Ejemplo n.º 15
0
def PSFtoPNG_all(args):
	for psffile in file_seek(args[2], "*.psf"):
		PSFtoPNG(psffile)		
	return
Ejemplo n.º 16
0
            krn_size = int(a)
        elif o in ("-s", "--fstr"):
            file_string = a
        elif o in ("--sim "):
            simul = True
        else:
            assert False, "Unhandled option."

    ##--------------------------------------------------------------------

    ## Input a collection of files or directory?
    ## filelist is a list of raw image files.
    filelist = []
    for arg in args:
        if os.path.isfile(arg): filelist += [arg]
        elif os.path.isdir(arg): filelist += file_seek(arg, file_string)

    if simul is False:
        single_deconvolve(filelist, krn_size, vb)
    else:
        simultaneous_deconvolve(filelist, krn_size, vb)

    ##--------------------------------------------------------------------

    if vb:        print "deconvolve.py: deconvolution of",len(filelist),\
        "file(s) took",round(time.time()-t_init,3),"seconds."

    return


##============================================================
Ejemplo n.º 17
0
def bright_all(factor=8):
	for original in file_seek("../Data/","CFHTLS_*sci.png"):
		brig(original,factor,1)
	return