CompositeStarFormationHistory#

class cogsworth.sfh.CompositeStarFormationHistory(components, component_ratios, **kwargs)[source]#

Bases: object

A star formation history that is a combination of multiple other star formation histories.

This class allows you to combine multiple star formation histories together, for example to create a composite star formation history for the Milky Way with a disc and a bulge. You can also use this to combine multiple instances of the same star formation history, for example to create a composite star formation history for the Milky Way with a thin and thick disc.

Parameters:
componentslist of StarFormationHistory

The star formation histories to combine. These will be sampled in proportion to their size.

Attributes Summary

positions

The galactocentric positions of the sampled points

velocities

The galactocentric velocities of the sampled points

Methods Summary

from_file(file_name[, key])

Load a composite star formation history from file

get_citations([filename])

Print the citations for the packages/papers used in the star formation history

plot(**kwargs)

Plot the star formation history using the default plotting function

sample(size)

Sample from the distributions for each component, combine and save in class attributes

save(file_name[, key])

Save the entire class to storage.

Attributes Documentation

positions[source]#

The galactocentric positions of the sampled points

Returns:
positionsQuantity [length], shape=(3, size)

The galactocentric positions of the sampled points

velocities[source]#

The galactocentric velocities of the sampled points

Returns:
velocitiesQuantity [velocity], shape=(3, size)

The galactocentric velocities of the sampled points

Methods Documentation

classmethod from_file(file_name, key='sfh')[source]#

Load a composite star formation history from file

Parameters:
file_namestr

The name of the hdf5 file from which to load the star formation history. If this doesn’t end in “.h5” then “.h5” will be appended.

keystr, optional

The key under which the data is stored in the hdf5 file, by default “sfh”

Returns:
sfhCompositeStarFormationHistory

The loaded composite star formation history

get_citations(filename=None)[source]#

Print the citations for the packages/papers used in the star formation history

plot(**kwargs)[source]#

Plot the star formation history using the default plotting function

See plot_sfh() for more details and options.

sample(size)[source]#

Sample from the distributions for each component, combine and save in class attributes

save(file_name, key='sfh')[source]#

Save the entire class to storage.

Data will be stored in an hdf5 file using file_name.

Parameters:
file_namestr
keystr, optional

The key under which to store the data in the hdf5 file, by default “sfh”