lib.survey_selection.projection.ModelProjectionCollection¶
- class lib.survey_selection.projection.ModelProjectionCollection(*args, **kwargs)¶
Bases:
cosmopipe.lib.utils.BaseOrderedCollectionClass managing a collection of model projections. This is useful to directly get the the theory prediction of heteregenous data, hence using different
ModelProjectionpipelines, e.g. correlation function and power spectrum.- _mapping¶
If not
None, this list contains, in the desired order, the index of each projection in the concatenated projection collection from all model projections. This is useful if one wants__call__()orto_data_vectorto return e.g. a projection of the second model projection before one of the first model projection. This mapping can be set usingreorder_by_projs().- Type
list, None
Initialize
ModelProjectionCollection.Methods
Empty collection.
Concatenate input collections.
Return shallow copy of
self.deepcopyExtend collection with
other.Instantiate and initalize class with state dictionary.
Return index of
ProjectionNameprojin collection.is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredLoad class in numpy binary format from disk.
If different formats are possible, this method should between them based on file name extension.
log_criticallog_debuglog_errorlog_infolog_warningGroup input projection names
projsinto sets that could be handled by a singleModelProjection.Reorder collection following index list
indices.Internally reoder desired projections following projection names
projs.Save class to disk.
If different formats are possible, this method should between them based on file name extension.
Return new collection, after selection of items whose attribute match input values.
Set new
ModelProjectionin collection.Set up all model projections.
Same as
__call__(), but returningDataVectorinstance.Return list of unique attribute
keyof collection items.Attributes
Return data vector, as a concatenation of all
ModelProjection.data_vector.loggerMPI attributes
mpicommmpirootmpistateReturn projection names, as a concatenation of all
ModelProjection.projs, optionally reordered.- __add__(other)¶
Addition of two collections is defined as concatenation.
- __call__(models, concatenate=True, **kwargs)¶
Project input model(s) onto data vector, returning y-coordinates.
- Parameters
models (BaseModel, ModelCollection) – Model callable(s). A single model is expected if a single model basis was provided in
__init__().concatenate (bool, default=True) – If
True, concatenates output y-coordinates over all projections. Else, returns a list of arrays corresponding to eachprojs.kwargs (dict) – Arguments for
ModelEvaluation.__call__()
- Returns
toret – y-coordinates. If input
concatenateisTrue, single array concatenated over all projections. Else, a list of arrays corresponding to eachprojs.- Return type
list, array
- clear()¶
Empty collection.
- classmethod concatenate(*others)¶
Concatenate input collections. Unique items only are kept.
- copy()¶
Return shallow copy of
self.
- property data_vector¶
Return data vector, as a concatenation of all
ModelProjection.data_vector.
- extend(other)¶
Extend collection with
other. Unique items only are kept.
- classmethod from_state(state, mpiroot=0, mpicomm=None)¶
Instantiate and initalize class with state dictionary.
- index(proj)¶
Return index of
ProjectionNameprojin collection.
- classmethod load(filename, mpiroot=0, mpicomm=None)¶
Load class in numpy binary format from disk. If the loaded state contains
__class__and that exists incls._registry, return instance ofcls._registry[__class__](instead ofcls).
- load_auto(*args, **kwargs)¶
If different formats are possible, this method should between them based on file name extension.
- property mpiattrs¶
MPI attributes
- property projs¶
Return projection names, as a concatenation of all
ModelProjection.projs, optionally reordered.
- classmethod propose_groups(projs)¶
Group input projection names
projsinto sets that could be handled by a singleModelProjection.
- reorder(indices)¶
Reorder collection following index list
indices.
- reorder_by_projs(projs)¶
Internally reoder desired projections following projection names
projs.
- save(filename)¶
Save class to disk.
- save_auto(*args, **kwargs)¶
If different formats are possible, this method should between them based on file name extension.
- select(*args, **kwargs)¶
Return new collection, after selection of items whose attribute match input values:
collection.select(name1=value1,name2=value2)
returns collection of items whose attributes
name1and name2` arevalue1,value2, respectively. Also:collection.select(dict(name1=value1,name2=value2),dict(name2=value3))
returns collection of items whose attributes
name1and name2` arevalue1,value2, respectively or attributename2isvalue3.
- set(model_projection)¶
Set new
ModelProjectionin collection. RaiseTypeErrorif not of typeModelProjection.
- setup(data_vector=None, projs=None)¶
Set up all model projections.
- Parameters
data_vector (DataVector, default=None) – Data vector to project onto. If not
None, replace currentdata_vector.projs (list, ProjectionNameCollection) – Projection names. If not
None, replace currentprojs.
- to_data_vector(models, **kwargs)¶
Same as
__call__(), but returningDataVectorinstance.
- unique(key)¶
Return list of unique attribute
keyof collection items.