def parse_sgwn_comments(): retval = {} lines = storage.vofile('vos:sgwyn/tkBAD').read().splitlines() for line in lines: ln = line.partition(' ') retval[ln[0]] = ln[2] return retval
def parse_sgwn_comments(): retval = {} lines = storage.vofile('vos:sgwyn/tkBAD', 'r').read().splitlines() for line in lines: ln = line.partition(' ') retval[ln[0]] = ln[2] return retval
def generate_MegaCam_previews(image_id): # modified from script by Chris Willott fitsfile = storage.vofile(storage.DBIMAGES + '/' + image_id) prev1file = "%s_preview_256.jpg" % (image_id) prev2file = "%s_preview_1024.jpg" % (image_id) prev3file = "%s_preview_zoom_1024.jpg" % (image_id) prim_hdr = pyfits.open(fitsfile, "update") numextens = prim_hdr[0].header['NEXTEND'] cmd3 = "ds9 -mosaicimage wcs %s -geometry 258x505 -rotate 180 -scale squared -scale mode zscale " \ "-scale scope global -scale datasec yes -invert -mode no -view colorbar no -zoom to fit " \ "-saveimage jpeg %s -quit" % (fitsfile, prev1file) cmd4 = "ds9 -mosaicimage wcs %s -geometry 1026x1273 -rotate 180 -scale squared -scale mode zscale " \ "-scale scope global -scale datasec yes -invert -view colorbar no -zoom to fit " \ "-saveimage jpeg %s -quit" % (fitsfile, prev2file) # Sometimes MegaCam images have fewer than 23 chips available. if numextens >= 23: cmd5 = "ds9 -fits %s[23] -pan -9 1780 image -geometry 1026x1273 -scale squared -scale mode zscale " \ "-scale scope global -scale datasec yes -invert -mode no -view colorbar no -zoom 1 " \ "-saveimage jpeg %s -quit" % (fitsfile, prev3file) elif numextens >= 14: cmd5 = "ds9 -fits %s[14] -pan -9 1780 image -geometry 1026x1273 -rotate 180 -scale squared " \ "-scale mode zscale -scale scope global -scale datasec yes -invert -mode no -view colorbar no " \ "-zoom 1 -saveimage jpeg %s -quit" % (fitsfile, prev3file) else: cmd5 = "ds9 -fits %s[1] -pan -9 1780 image -geometry 1026x1273 -rotate 180 -scale squared " \ "-scale mode zscale -scale scope global -scale datasec yes -invert -mode no -view colorbar no " \ "-zoom 1 -saveimage jpeg %s -quit" % (fitsfile, prev3file) # Start ds9 processes but kill ds9 if takes longer than 60 seconds for cmdnum in [cmd3, cmd4, cmd5]: args = shlex.split(cmdnum) p = Popen(args) pid = p.pid # need to add a timeout after 60 sec if image isn't opened by ds9 in that time return
def open(self, filename): return storage.vofile(self.get_full_path(filename), os.O_RDONLY)
def _get_file_size_by_downloading(self, filename): filehandle = storage.vofile(self.get_full_path(filename), os.O_RDONLY) contents = filehandle.read() filehandle.close() return len(contents)