def make_frame_jpg(**keys): from PIL import Image from numpy import array, flipud import sdsspy import esutil as eu import images #import biggles g,gh=sdsspy.read('frame', filter='g', header=True, **keys) r,rh=sdsspy.read('frame', filter='r', header=True, **keys) i,ih=sdsspy.read('frame', filter='i', header=True, **keys) gwcs=eu.wcsutil.WCS(gh) rwcs=eu.wcsutil.WCS(rh) iwcs=eu.wcsutil.WCS(ih) # convert r-band center to ra,dec rowcen_r=r.shape[0]/2. colcen_r=r.shape[1]/2. racen_r,deccen_r = rwcs.image2sky(colcen_r, rowcen_r) # now see where that falls in the g and i images gcol,grow=gwcs.sky2image(racen_r, deccen_r) icol,irow=iwcs.sky2image(racen_r, deccen_r) gshift=[rowcen_r-grow, colcen_r-gcol] ishift=[rowcen_r-irow, colcen_r-icol] g = shift_image(g, gshift) i = shift_image(i, ishift) rescale=0.4 scales= rescale*array([5., 6.5, 9.]) nonlinear=0.15 colorim=images.get_color_image(i, r, g, scales=scales, nonlinear=nonlinear, satval=30.) fname=get_jpg_path(**keys) print 'writing:',fname dname=os.path.dirname(fname) if not os.path.exists(dname): print 'making dirs:',dname os.makedirs(dname) #colorim = (colorim*255).astype('u1') colorim = images.bytescale(colorim) colorim=flipud(colorim) pim=Image.fromarray(colorim) pim.save(fname, quality=90)
def write_jpg(fname, im, **keys): """ image is flipped up-down and transposed so that, in a jpg, north is up and east is left. The image is bytescaled, so should be between [0,1]. extra keywords for images.write_image() are passed on. """ from numpy import flipud import images # for DES images this results in north up east to the left # because jpg coordinates start in the upper left imout = flipud(im) imout=imout.transpose() imout = images.bytescale(imout) images.write_image(fname, imout, **keys) return imout.shape
def write_jpg(fname, im, **keys): """ image is flipped up-down and transposed so that, in a jpg, north is up and east is left. The image is bytescaled, so should be between [0,1]. extra keywords for images.write_image() are passed on. """ from numpy import flipud import images # for DES images this results in north up east to the left # because jpg coordinates start in the upper left imout = flipud(im) imout = imout.transpose() imout = images.bytescale(imout) images.write_image(fname, imout, **keys) return imout.shape
def make_image(self): import images self._make_imlist() scales=self._get_scales() print("using satval:",self.satval) print('getting color image') imlist=self.imlist colorim=images.get_color_image(imlist[2].image, imlist[1].image, imlist[0].image, scales=scales, nonlinear=NONLINEAR, satval=self.satval) print('bytescaling') colorim = images.bytescale(colorim) self.colorim=colorim
def make_image(self): """ create the rgb image """ import images self._make_imlist() scales = self._get_scales() print("using satval:", self.satval) print('getting color image') imlist = self.imlist colorim = images.get_color_image(imlist[2].image, imlist[1].image, imlist[0].image, scales=scales, nonlinear=NONLINEAR, satval=self.satval) print('bytescaling') colorim = images.bytescale(colorim) self.colorim = colorim