class Field(object): def __init__(self, request): self.request = request self.imagesQuery = ImagesQuery() # BIT HACKED - FIX! Transfer to urllib parsing. More Reliable. fi = request.current_route_url().rpartition("/")[2] if fi.__contains__("%2B"): fi2 = fi.split("%2B") fi3 = "+".join(fi2) self.fieldId = fi3 else: self.fieldId = fi print self.fieldId @Lazy def discovery_triplet(self): retval = self.imagesQuery.discovery_triplet(self.fieldId) return retval @Lazy def observations(self): rv = self.imagesQuery.field_images(self.fieldId) proc_rv = self.imagesQuery.processing_status(rv, update=True) # use this to trigger renewal # format the errors in html with links to their joblogs retproc = [] for row in proc_rv: statuses = [mk_status(s, row[2]) for s in row[len(row) - 1]] # statuses are always at the end retrow = row[:-1] # without the unformatted errors retrow.append(statuses) retproc.append(retrow) retval = {"obs": retproc} return retval @Lazy def ra(self): ret = self.imagesQuery.field_ra(self.fieldId) # parse just the first bit for niceness retval = (ret.split(":")[0], ret.split(":")[1]) return retval @Lazy def dec(self): ret = self.imagesQuery.field_dec(self.fieldId) # FIXME: need these to catch the ones that are being stored as ints and parse them properly dec = ret.split(":")[0] dec2 = ret.split(":")[1] + "'" retval = (dec, dec2) return retval @Lazy def ecliptic_loc(self): rr = ephem.Equatorial( ephem.hours(self.imagesQuery.field_ra(self.fieldId)), ephem.degrees(self.imagesQuery.field_dec(self.fieldId)), ) ec = ephem.Ecliptic(rr) retval = (degrees(ec.lat), str(ec.lon)) # eclat is float (deg), eclon is str in deg return retval @Lazy def numObs(self): retval = len(self.observations["obs"]) return retval @Lazy def num_precoveries(self): retval = self.imagesQuery.num_precoveries(self.fieldId) return retval @Lazy def num_nailings(self): retval = self.imagesQuery.num_nailings(self.fieldId) return retval @Lazy def num_doubles(self): retval = self.imagesQuery.num_doubles(self.fieldId) return retval # Only uncomment and set this active when a triplet file in vos:OSSOS/triplets needs to be generated. # @property # def export_triplet(self): # CHECK TMPFILE HAS BEEN SET TO CORRECT BLOCK # retval = self.imagesQuery.export_discovery_triplet(self.fieldId) @view_config(route_name="field_obs", renderer="field_obs.pt", permission="ossos") def inspect_observations(self): # uid = self.request.matchdict['uid'] # return dict(title='Triplet', uid=uid) retval = { "fieldId": self.fieldId, "observations": self.observations, "ra": self.ra, "dec": self.dec, "ec_loc": self.ecliptic_loc, "discovery_triplet": self.discovery_triplet, "totalObs": self.numObs, "precoveries": self.num_precoveries, "nailings": self.num_nailings, "doubles": self.num_doubles, # 'update_vospace': self.export_triplet } return retval
class Field(object): def __init__(self, request): self.request = request self.imagesQuery = ImagesQuery() # BIT HACKED - FIX! Transfer to urllib parsing. More Reliable. fi = request.current_route_url().rpartition('/')[2] if fi.__contains__('%2B'): fi2 = fi.split('%2B') fi3 = '+'.join(fi2) self.fieldId = fi3 else: self.fieldId = fi @Lazy def discovery_triplet(self): retval = self.imagesQuery.discovery_triplet(self.fieldId) return retval @Lazy def observations(self): rv = self.imagesQuery.field_images(self.fieldId) proc_rv = self.imagesQuery.processing_status( rv, update=True) # use this to trigger renewal # format the errors in html with links to their joblogs retproc = [] for row in proc_rv: statuses = [mk_status(s, row[2]) for s in row[len(row) - 1] ] # statuses are always at the end retrow = row[:-1] # without the unformatted errors retrow.append(statuses) retproc.append(retrow) retval = {'obs': retproc} return retval @Lazy def ra(self): ret = self.imagesQuery.field_ra(self.fieldId) # parse just the first bit for niceness retval = (ret.split(':')[0], ret.split(':')[1]) return retval @Lazy def dec(self): ret = self.imagesQuery.field_dec(self.fieldId) # FIXME: need these to catch the ones that are being stored as ints and parse them properly dec = ret.split(':')[0] dec2 = ret.split(':')[1] + "'" retval = (dec, dec2) return retval @Lazy def ecliptic_loc(self): rr = ephem.Equatorial( ephem.hours(self.imagesQuery.field_ra(self.fieldId)), ephem.degrees(self.imagesQuery.field_dec(self.fieldId))) ec = ephem.Ecliptic(rr) retval = (degrees(ec.lat), str(ec.lon) ) # eclat is float (deg), eclon is str in deg return retval @Lazy def numObs(self): retval = len(self.observations['obs']) return retval @Lazy def num_precoveries(self): retval = self.imagesQuery.num_precoveries(self.fieldId) return retval @Lazy def num_nailings(self): retval = self.imagesQuery.num_nailings(self.fieldId) return retval @Lazy def num_doubles(self): retval = self.imagesQuery.num_doubles(self.fieldId) return retval # @property # def export_triplet(self): # CHECK TMPFILE HAS BEEN SET TO CORRECT BLOCK # retval = self.imagesQuery.export_discovery_triplet(self.fieldId) @view_config(route_name='field_obs', renderer='field_obs.pt', permission='ossos') def inspect_observations(self): # uid = self.request.matchdict['uid'] # return dict(title='Triplet', uid=uid) retval = { 'fieldId': self.fieldId, 'observations': self.observations, 'ra': self.ra, 'dec': self.dec, 'ec_loc': self.ecliptic_loc, 'discovery_triplet': self.discovery_triplet, 'totalObs': self.numObs, 'precoveries': self.num_precoveries, 'nailings': self.num_nailings, 'doubles': self.num_doubles #'update_vospace': self.export_triplet } return retval
class Field(object): def __init__(self, request): self.request = request self.imagesQuery = ImagesQuery() # BIT HACKED - FIX! Transfer to urllib parsing. More Reliable. fi = request.current_route_url().rpartition('/')[2] if fi.__contains__('%2B'): fi2 = fi.split('%2B') fi3 = '+'.join(fi2) self.fieldId = fi3 else: self.fieldId = fi @Lazy def observations(self): rv = self.imagesQuery.field_images(self.fieldId) proc_rv = self.imagesQuery.processing_status(rv, update=True) # use this to trigger renewal # format the errors in html with links to their joblogs retproc = [] for row in proc_rv: statuses = [mk_status(s, row[2]) for s in row[3]] retrow = row[0:3] # without the unformatted errors retrow.append(statuses) retproc.append(retrow) retval = {'obs': retproc} return retval @Lazy def ra(self): ret = self.imagesQuery.field_ra(self.fieldId) # parse just the first bit for niceness retval = (ret.split(':')[0], ret.split(':')[1]) return retval @Lazy def dec(self): ret = self.imagesQuery.field_dec(self.fieldId) dec = ret.split(':')[0] dec2 = ret.split(':')[1] + "'" retval = (dec, dec2) return retval @Lazy def ecliptic_loc(self): rr = ephem.Equatorial(ephem.hours(self.imagesQuery.field_ra(self.fieldId)), ephem.degrees(self.imagesQuery.field_dec(self.fieldId))) ec = ephem.Ecliptic(rr) retval = (degrees(ec.lat), str(ec.lon)) # eclat is float (deg), eclon is str in deg return retval @Lazy def discovery_triplet(self): retval = self.imagesQuery.discovery_triplet(self.fieldId) return retval @Lazy def numObs(self): retval = len(self.observations['obs']) return retval @Lazy def num_precoveries(self): retval = self.imagesQuery.num_precoveries(self.fieldId) return retval @Lazy def num_nailings(self): retval = self.imagesQuery.num_nailings(self.fieldId) return retval @Lazy def num_doubles(self): retval = self.imagesQuery.num_doubles(self.fieldId) return retval # @property # def export_triplet(self): # CHECK TMPFILE HAS BEEN SET TO CORRECT BLOCK # retval = self.imagesQuery.export_discovery_triplet(self.fieldId) @view_config(route_name='field_obs', renderer='field_obs.pt', permission='ossos') def inspect_observations(self): # uid = self.request.matchdict['uid'] # return dict(title='Triplet', uid=uid) retval = {'fieldId': self.fieldId, 'observations': self.observations, 'ra': self.ra, 'dec': self.dec, 'ec_loc': self.ecliptic_loc, 'discovery_triplet': self.discovery_triplet, 'totalObs': self.numObs, 'precoveries': self.num_precoveries, 'nailings': self.num_nailings, 'doubles': self.num_doubles #'update_vospace': self.export_triplet } return retval
class Field(object): def __init__(self, request): self.request = request self.imagesQuery = ImagesQuery() # BIT HACKED - FIX! Transfer to urllib parsing. More Reliable. fi = request.current_route_url().rpartition('/')[2] if fi.__contains__('%2B'): fi2 = fi.split('%2B') fi3 = '+'.join(fi2) self.fieldId = fi3 else: self.fieldId = fi @property def observations(self): retval = self.imagesQuery.field_images(self.fieldId) return retval @property def ra(self): ret = self.imagesQuery.field_ra(self.fieldId) # parse just the first bit for niceness retval = (ret.split(':')[0], ret.split(':')[1]) return retval @property def dec(self): ret = self.imagesQuery.field_dec(self.fieldId) dec = ret.split(':')[0] dec2 = ret.split(':')[1] + "'" retval = (dec, dec2) return retval @property def ecliptic_loc(self): rr = ephem.Equatorial( ephem.hours(self.imagesQuery.field_ra(self.fieldId)), ephem.degrees(self.imagesQuery.field_dec(self.fieldId))) ec = ephem.Ecliptic(rr) retval = (degrees(ec.lat), str(ec.lon) ) # eclat is float (deg), eclon is str in deg return retval @property def discovery_triplet(self): retval = self.imagesQuery.discovery_triplet(self.fieldId) return retval @property def numObs(self): retval = len(self.observations['obs']) return retval @property def num_precoveries(self): retval = self.imagesQuery.num_precoveries(self.fieldId) return retval @property def num_nailings(self): retval = self.imagesQuery.num_nailings(self.fieldId) return retval @property def num_doubles(self): retval = self.imagesQuery.num_doubles(self.fieldId) return retval # @property # def export_triplet(self): # retval = self.imagesQuery.export_discovery_triplet(self.fieldId) @view_config(route_name='field_obs', renderer='field_obs.pt', permission='ossos') def inspect_observations(self): # uid = self.request.matchdict['uid'] # return dict(title='Triplet', uid=uid) retval = { 'fieldId': self.fieldId, 'observations': self.observations, 'ra': self.ra, 'dec': self.dec, 'ec_loc': self.ecliptic_loc, 'discovery_triplet': self.discovery_triplet, 'totalObs': self.numObs, 'precoveries': self.num_precoveries, 'nailings': self.num_nailings, 'doubles': self.num_doubles #'update_vospace': self.export_triplet } return retval