def makepng( atomsfile, operation, dpi): shot = atomsfile.split('atoms')[0] atoms = numpy.loadtxt( shot + 'atoms.manta') noatoms = numpy.loadtxt( shot + 'noatoms.manta') atomsref = numpy.loadtxt( shot + 'atomsref.manta') noatomsref= numpy.loadtxt( shot + 'noatomsref.manta') if operation == 'ABS': out = (atoms - atomsref) / (noatoms - noatomsref) elif operation == 'PHC': out = (atoms - atomsref) - (noatoms - noatomsref) else: print " --> Operation is not ABS or PHC. Program will exit" exit(1) return falsecolor.savepng( out, out.min(), out.max(), falsecolor.my_rainbow, shot, dpi)
def makepng( fitsfile, operation, dpi, bg = None, prefix = None, square=None): shot = fitsfile.split('atoms')[0] print "Inside makepng:" print fitsfile if 'andor2' in fitsfile: atoms = pyfits.open( shot + 'atoms_andor2.fits')[0].data[0] noatoms = pyfits.open( shot + 'noatoms_andor2.fits')[0].data[0] atomsref = pyfits.open( shot + 'atomsref_andor2.fits')[0].data[0] noatomsref= pyfits.open( shot + 'noatomsref_andor2.fits')[0].data[0] else: atoms = pyfits.open( shot + 'atoms.fits')[0].data[0] noatoms = pyfits.open( shot + 'noatoms.fits')[0].data[0] atomsref = pyfits.open( shot + 'atomsref.fits')[0].data[0] noatomsref= pyfits.open( shot + 'noatomsref.fits')[0].data[0] if operation == 'ABS': if bg == None: out = (atoms - atomsref) / (noatoms - noatomsref) else: out = (atoms - atomsref) / bg elif operation == 'PHC': if bg == None: out = (atoms - atomsref) - (noatoms - noatomsref) else: out = (atoms - atomsref) - bg else: print " --> Operation is not ABS or PHC. Program will exit" exit(1) if prefix == None: label = shot else: label = shot + prefix if square is not None: s = [ int(i) for i in square.split(',')] out = out[ s[1]-s[2]:s[1]+s[2], s[0]-s[2]:s[0]+s[2] ] #colormap = falsecolor.my_rainbow colormap = matplotlib.cm.spectral return falsecolor.savepng( out, out.min(), out.max(), colormap, label, dpi)
def makepng( fitsfile, operation, dpi, bg = None, prefix = None): shot = fitsfile.split('atoms')[0] print "Inside makepng:" print fitsfile if 'andor2' in fitsfile: atoms = pyfits.open( shot + 'atoms_andor2.fits')[0].data[0] noatoms = pyfits.open( shot + 'noatoms_andor2.fits')[0].data[0] atomsref = pyfits.open( shot + 'atomsref_andor2.fits')[0].data[0] noatomsref= pyfits.open( shot + 'noatomsref_andor2.fits')[0].data[0] else: atoms = pyfits.open( shot + 'atoms.fits')[0].data[0] noatoms = pyfits.open( shot + 'noatoms.fits')[0].data[0] atomsref = pyfits.open( shot + 'atomsref.fits')[0].data[0] noatomsref= pyfits.open( shot + 'noatomsref.fits')[0].data[0] if operation == 'ABS': if bg == None: out = (atoms - atomsref) / (noatoms - noatomsref) else: out = (atoms - atomsref) / bg elif operation == 'PHC': if bg == None: out = (atoms - atomsref) - (noatoms - noatomsref) else: out = (atoms - atomsref) - bg else: print " --> Operation is not ABS or PHC. Program will exit" exit(1) if prefix == None: label = shot else: label = shot + prefix return falsecolor.savepng( out, out.min(), out.max(), falsecolor.my_rainbow, label, dpi)