lib.survey_selection.projection.ModelProjectionCollection

class lib.survey_selection.projection.ModelProjectionCollection(*args, **kwargs)

Bases: cosmopipe.lib.utils.BaseOrderedCollection

Class managing a collection of model projections. This is useful to directly get the the theory prediction of heteregenous data, hence using different ModelProjection pipelines, 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__() or to_data_vector to return e.g. a projection of the second model projection before one of the first model projection. This mapping can be set using reorder_by_projs().

Type

list, None

Initialize ModelProjectionCollection.

Methods

clear

Empty collection.

concatenate

Concatenate input collections.

copy

Return shallow copy of self.

deepcopy

extend

Extend collection with other.

from_state

Instantiate and initalize class with state dictionary.

index

Return index of ProjectionName proj in collection.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

load

Load class in numpy binary format from disk.

load_auto

If different formats are possible, this method should between them based on file name extension.

log_critical

log_debug

log_error

log_info

log_warning

propose_groups

Group input projection names projs into sets that could be handled by a single ModelProjection.

reorder

Reorder collection following index list indices.

reorder_by_projs

Internally reoder desired projections following projection names projs.

save

Save class to disk.

save_auto

If different formats are possible, this method should between them based on file name extension.

select

Return new collection, after selection of items whose attribute match input values.

set

Set new ModelProjection in collection.

setup

Set up all model projections.

to_data_vector

Same as __call__(), but returning DataVector instance.

unique

Return list of unique attribute key of collection items.

Attributes

data_vector

Return data vector, as a concatenation of all ModelProjection.data_vector.

logger

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

projs

Return 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 each projs.

  • kwargs (dict) – Arguments for ModelEvaluation.__call__()

Returns

toret – y-coordinates. If input concatenate is True, single array concatenated over all projections. Else, a list of arrays corresponding to each projs.

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 ProjectionName proj in 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 in cls._registry, return instance of cls._registry[__class__] (instead of cls).

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 projs into sets that could be handled by a single ModelProjection.

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 name1 and name2` are value1, value2, respectively. Also:

collection.select(dict(name1=value1,name2=value2),dict(name2=value3))

returns collection of items whose attributes name1 and name2` are value1, value2, respectively or attribute name2 is value3.

set(model_projection)

Set new ModelProjection in collection. Raise TypeError if not of type ModelProjection.

setup(data_vector=None, projs=None)

Set up all model projections.

Parameters
to_data_vector(models, **kwargs)

Same as __call__(), but returning DataVector instance.

unique(key)

Return list of unique attribute key of collection items.