Coverage for python/lsst/sims/catalogs/definitions/CompoundInstanceCatalog.py : 91%

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
""" This is essentially an InstanceCatalog class meant to wrap together several disparate InstanceCatalog instantiations that will ultimately be written to the same output catalog.
You pass the constructor a list of InstanceCatalog classes, a list of CatalogDBObject classes, and ObservationMetaData, and an optional SQL constraint.
The write_catalog method then writes all of the InstanceCatalogs to one ASCII file using the same API as InstanceCatalog.write_catalog.
Note: any member variables of the CompoundInstanceCatalog whose names do not begin with '_' will be assigned to the InstanceCatalogs iterated over by the CompoundInstanceCatalog. This allows you to, for example, format the outputs of every InstanceCatalog in the CompoundInstanceCatalog by setting override_formats in just the CompoundInstanceCatalog, e.g.
class myCompoundInstanceCatalog(CompoundInstanceCatalog): transformations = {'raJ2000': np.degrees, 'decJ2000': np.degrees}
comCat = myCompoundInstanceCatalog([catClass1, catClass2], [dbClass1, dbClass2])
will write raJ2000 and decJ2000 in degrees without having to define transformations in catClass1 and catClass2. """
obs_metadata=None, constraint=None, compoundDBclass = None): """ @param [in] instanceCatalogClassList is a list of the InstanceCatalog classes to be combined into one output catalog.
@param [in] catalogDBObjectClassList is a list of the CatalogDBObject classes to be associated with the InstanceCatalog classes in instanceCatalogClassList. There should be one CatalogDBObject class for each InstanceCatalogClass.
@param [in] obs_metadata is the ObservationMetaData describing the telescope pointing
@param [in] constraint is an optional SQL constraint to be applied to the database query
@param [in] compoundDBclass is an optional argument specifying what CompoundCatalogDBobject class(es) to use to combine InstanceCatalogs that query the same table. This can be either a single ComboundCatalogDBObject class, or a list of classes. The CompoundInstanceCatalog will figure out which InstanceCatalog(s) go with which CompoundCatalogDBObject class. If no CompoundCatalogDBObject class corresponds to a given group of InstanceCatalogs, then the base CompoundCatalogDBObject class will be used.
Note: compoundDBclass should be a CompoundCatalogDBObject class. Not an instantiation of a CompoundCatalogDBObject class. """
new_row.append(iy)
""" @param [in] db1 is a CatalogDBObject instantiation
@param [in] db2 is a CatalogDBObject instantiation
@param [out] a boolean stating whether or not db1 and db2 query the same table of the same database """
else:
else:
else:
else:
else: driver1 = None
else: driver2 = None
return False return False return False return False
""" Write the stored list of InstanceCatalogs to a single ASCII output catalog.
@param [in] filename is the name of the file to be written
@param [in] chunk_size is an optional parameter telling the CompoundInstanceCatalog to query the database in manageable chunks (in case returning the whole catalog takes too much memory)
@param [in] write_header a boolean specifying whether or not to add a header to the output catalog (Note: only one header will be written; there will not be a header for each InstanceCatalog in the CompoundInstanceCatalog; default True)
@param [in] write_mode is 'w' if you want to overwrite the output file or 'a' if you want to append to an existing output file (default: 'w') """
# first, loop over all of the InstanceCatalog and CatalogDBObject classes, pre-processing # them (i.e. verifying that they have access to all of the columns they need)
# assign all non-private member variables of the CompoundInstanceCatalog # to the instantiated InstanceCatalogs setattr(ic, kk, self.__dict__[kk])
write_header=write_header, write_mode=write_mode, obs_metadata=self._obs_metadata, constraint=self._constraint)
else:
default_compound_dbo is CompoundCatalogDBObject
# if self._compoundDBclass is not a list except: compound_dbo = default_compound_dbo(dbObjClassList) else: dbo.tableid in candidate._table_restriction for dbo in dbObjClassList]:
chunk_size=chunk_size, write_header=write_header, write_mode=write_mode)
chunk_size=None, write_header=False, write_mode='a'): """ Write out a set of InstanceCatalog instantiations that have been determined to query the same database table.
@param [in] catList is the list of InstanceCatalog instantiations
@param [in] compound_db is the CompoundCatalogDBObject instantiation associated with catList
@param [in] filename is the name of the file to be written
@param [in] chunk_size is an optional parameter telling the CompoundInstanceCatalog to query the database in manageable chunks (in case returning the whole catalog takes too much memory)
@param [in] write_header a boolean specifying whether or not to add a header to the output catalog (Note: only one header will be written; there will not be a header for each InstanceCatalog in the CompoundInstanceCatalog; default True)
@param [in] write_mode is 'w' if you want to overwrite the output file or 'a' if you want to append to an existing output file (default: 'w') """
obs_metadata=self._obs_metadata, constraint=self._constraint, chunk_size=chunk_size)
# because it thinks we may accidentally # write to this array [local_recarray.dtype[dd]]) for dd in master_colnames[ix]])
|