def _validate_variability_indices(self, variability_indices): """ Validate any variability indices given to this object """ # Validate input for var_idx in self.indices: try: variability_indices[var_idx] except ValueError: # e.g. field not found print redText("Variability statistic '{}' not found in the data you provided.".format(var_idx)) raise return True
def _validate_variability_indices(self, variability_indices): """ Validate any variability indices given to this object """ # Validate input for var_idx in self.indices: try: variability_indices[var_idx] except ValueError: # e.g. field not found print redText( "Variability statistic '{}' not found in the data you provided." .format(var_idx)) raise return True
def ptf_images_from_name(name, size, intersect="overlaps", filter="R", epoch=None, number=None): """ Creates PTF FITS Images given a name of an astronomical object that can be resolved by SIMBAD. Parameters ---------- name : str The name of an astronomical object. size : apwlib.geometry.Angle, tuple An angular extent on the sky, or a tuple of 2 angular extents representing a size in RA and a size in Dec. intersect : str See IPAC image query documentation: http://kanaloa.ipac.caltech.edu/ibe/queries.html filter : (optional) str Select only observations of this filter. epoch : (optional) float The MJD of the observation of the image. If not specified, the image with the best seeing is returned. number : (optional) int Constrain the number of images to return. """ url = "http://simbad.u-strasbg.fr/simbad/sim-id?Ident={}&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id&output.format=ASCII_TAB".format( urllib.quote(name)) request = urllib2.Request(url) response = urllib2.urlopen(request) pattr = re.compile( "Coordinates\(ICRS\,ep\=J2000\,eq\=2000\)\: ([0-9\s\+\-\.]+)\(") try: radec_str = pattr.search(response.read()).groups()[0] except AttributeError: raise ValueError(redText("Unable to resolve name '{}'".format(name))) ra, dec = radec_str.strip().split(" ") ra = g.RA(ra) dec = g.Dec(dec) return ptf_images_from_position(ra, dec, size=size, intersect=intersect, filter=filter, epoch=epoch, number=number)
def ptf_images_from_name(name, size, intersect="overlaps", filter="R", epoch=None, number=None): """ Creates PTF FITS Images given a name of an astronomical object that can be resolved by SIMBAD. Parameters ---------- name : str The name of an astronomical object. size : apwlib.geometry.Angle, tuple An angular extent on the sky, or a tuple of 2 angular extents representing a size in RA and a size in Dec. intersect : str See IPAC image query documentation: http://kanaloa.ipac.caltech.edu/ibe/queries.html filter : (optional) str Select only observations of this filter. epoch : (optional) float The MJD of the observation of the image. If not specified, the image with the best seeing is returned. number : (optional) int Constrain the number of images to return. """ url = "http://simbad.u-strasbg.fr/simbad/sim-id?Ident={}&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id&output.format=ASCII_TAB".format(urllib.quote(name)) request = urllib2.Request(url) response = urllib2.urlopen(request) pattr = re.compile("Coordinates\(ICRS\,ep\=J2000\,eq\=2000\)\: ([0-9\s\+\-\.]+)\(") try: radec_str = pattr.search(response.read()).groups()[0] except AttributeError: raise ValueError(redText("Unable to resolve name '{}'".format(name))) ra,dec = radec_str.strip().split(" ") ra = g.RA(ra) dec = g.Dec(dec) return ptf_images_from_position(ra, dec, size=size, intersect=intersect, filter=filter, epoch=epoch, number=number)
break var_indices_with_event.append(lc_var_indices) dtype = zip(indices, [float]*len(indices)) var_indices = np.array(var_indices, dtype=dtype) var_indices_with_event = np.array(var_indices_with_event, dtype=dtype) return var_indices, var_indices_with_event if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) try: field_id = int(sys.argv[1]) except: print redText("You must specify a field as a command line arg") raise field = pdb.Field(field_id, filter="R") u0s = [0.01, 0.1, 0.5, 1.0]#, 1.34] filename_base = "data/sigma_experiment_{:06d}_{:.3f}.pickle" generate_data = False for u0 in u0s: filename = filename_base.format(field.id, u0) print filename, os.path.exists(filename) if not os.path.exists(filename): generate_data = True if generate_data: light_curves = select_light_curves(field, N=1000)
var_indices_with_event.append(lc_var_indices) dtype = zip(indices, [float] * len(indices)) var_indices = np.array(var_indices, dtype=dtype) var_indices_with_event = np.array(var_indices_with_event, dtype=dtype) return var_indices, var_indices_with_event if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) try: field_id = int(sys.argv[1]) except: print redText("You must specify a field as a command line arg") raise field = pdb.Field(field_id, filter="R") u0s = [0.01, 0.1, 0.5, 1.0] #, 1.34] filename_base = "data/sigma_experiment_{:06d}_{:.3f}.pickle" generate_data = False for u0 in u0s: filename = filename_base.format(field.id, u0) print filename, os.path.exists(filename) if not os.path.exists(filename): generate_data = True if generate_data: light_curves = select_light_curves(field, N=1000)