Coverage for python/lsst/sims/survey/fields/fields_database.py : 25%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Internal file containing the standard 3.5 degree FOV survey field information."""
"""Initialize the class. """ self.db_name = self.FIELDS_DB self.connect = sqlite3.connect(os.path.join(os.path.dirname(__file__), self.db_name))
"""Delete the class. """ self.connect.close()
"""Get a set of Field instances.
Parameters ---------- query : str The query for field retrieval.
Returns ------- set The collection of Field instances. """ field_set = set() rows = self.get_rows(query) for row in rows: field_set.add(tuple(row))
return field_set
"""Get a formatted string of OpSim3 user regions.
This function gets a formatted string of OpSim3 user regions suitable for an OpSim3 configuration file. The format looks like (RA,Dec,Width):
userRegion = XXX.XX,YYY.YY,0.03 ...
The last column is unused in OpSim3. The precision argument can be used to control the formatting, but OpSim3 configuration files use 2 digits as standard.
Parameters ---------- query : str The query for field retrieval. precision : int, optional The precision used for the RA and Dec columns. Default is 2.
Returns ------- str The OpSim3 user regions formatted string. """ format_str = "userRegion = "\ "{{:.{0}f}},{{:.{0}f}},0.03".format(precision) rows = self.get_rows(query) result = [] for row in rows: result.append(format_str.format(row[2], row[3])) return str(os.linesep.join(result))
"""Retrieve lists of RA and Dec.
Parameters ---------- query : str The query for field retrieval.
Returns ------- numpy.array, numpy.array The arrays of RA and Dec. """ rows = self.get_rows(query) ra = [] dec = [] for row in rows: ra.append(row[2]) dec.append(row[3])
return numpy.array(ra), numpy.array(dec)
"""Retrieve lists of fieldId, RA and Dec.
Parameters ---------- query : str The query for field retrieval.
Returns ------- numpy.array, numpy.array, numpy.array The arrays of fieldId, RA and Dec. """ rows = self.get_rows(query) fieldId = [] ra = [] dec = [] for row in rows: fieldId.append(int(row[0])) ra.append(row[2]) dec.append(row[3])
return numpy.array(fieldId, dtype=int), numpy.array(ra), numpy.array(dec)
"""Get the rows from a query.
This function hands back all rows from a query. This allows one to perform other operations on the information than those provided by this class.
Parameters ---------- query : str The query for field retrieval.
Returns ------- list The set of field information queried. """ cursor = self.connect.cursor() cursor.execute(query) return cursor.fetchall() |