def getData(self, constraint): """Query the data from the database. The currently bundleDict should generally be set before calling getData (using setCurrent). Parameters ---------- constraint : str The constraint for the currently active set of MetricBundles. """ if self.verbose: if constraint == '': print("Querying database %s with no constraint for columns %s." % (self.dbTable, self.dbCols)) else: print("Querying database %s with constraint %s for columns %s" % (self.dbTable, constraint, self.dbCols)) # Note that we do NOT run the stackers at this point (this must be done in each 'compatible' group). self.simData = utils.getSimData(self.dbObj, constraint, self.dbCols, groupBy='default', tableName=self.dbTable) if self.verbose: print("Found %i visits" % (self.simData.size)) # Query for the fieldData if we need it for the opsimFieldSlicer. needFields = [b.slicer.needsFields for b in self.currentBundleDict.values()] if True in needFields: self.fieldData = utils.getFieldData(self.dbObj, constraint) else: self.fieldData = None
def getData(self, sqlconstraint): """Query the data from the database. The currently bundleDict should generally be set before calling getData (using setCurrent). Parameters ---------- sqlconstraint : str The sqlconstraint for the currently active set of MetricBundles. """ if self.verbose: if sqlconstraint == '': print "Querying database with no constraint." else: print "Querying database with constraint %s" % (sqlconstraint) # Note that we do NOT run the stackers at this point (this must be done in each 'compatible' group). if self.dbTable != 'Summary': distinctExpMJD = False groupBy = None else: distinctExpMJD = True groupBy = 'expMJD' self.simData = utils.getSimData(self.dbObj, sqlconstraint, self.dbCols, tableName=self.dbTable, distinctExpMJD=distinctExpMJD, groupBy=groupBy) if self.verbose: print "Found %i visits" % (self.simData.size) # Query for the fieldData if we need it for the opsimFieldSlicer. needFields = [b.slicer.needsFields for b in self.currentBundleDict.itervalues()] if True in needFields: self.fieldData = utils.getFieldData(self.dbObj, sqlconstraint) else: self.fieldData = None