Dependencies¶
Here is a list of dependencies for hoki. If you choose to pip install it, these will be taken care of automatically.
astropy
numpy
pandas
matplotlib
pyyaml
wheel
numba
emcee
corner
scipy
hoki.cmd¶
This module implements the CMD infrastructure

class
hoki.cmd.
CMD
(file, col_lim=[ 3, 7], mag_lim=[ 14, 10], res_el=0.1, bpass_version='v221', models_path='../../BPASS_hoki_dev/bpassv2.2newmodels/')¶ Colour Magnitude Diagram Object
 Parameters
file (str) – Location of the file containing the model inputs
col_lim (list of 2 integers (positive or negative), optional) – Limits on the colour range of the CMD grid, Default is [3,7].
mag_lim (list of 2 integers (positive or negative), optional) – Limits on the magnitude range of the CMD grid. Default is [14,10].
res_el (float or int, optional) – Resolution element of the CMD grid. The resolution element is the same for colour and magnitude. Default is 0.1.
bpass_version (str, optional (v221 or v222)) – The BPASS version to consider  this changes the “dummy_dictionary” that is loaded from the settings.yaml file Default = hoki.constants.DEFAULT_BPASS_VERSION

self.
bpass_input
¶ Input file given by the file parameter
 Type
str

self.
col_range
¶ Colour range spanned by the grid (with res_elsized intervals)
 Type
numpy.ndarray (1D)

self.
mag_range
¶ Magnitude range spanned by the grid (with res_elsized intervals)
 Type
numpy.ndarray (1D)

self.
grid
¶ ColourMagnitude grid.
 Type
numpy.ndarray (2D)

self.
path
¶ The absolute path to the stellar models. It is set to hoki.cconstants.MODELS_PATH which you can set to the right path by using hoki.load.set_models.path().
 Type
str

self.
t
¶ Class attribute  The time bins in BPASS  note they are in LOG SPACE
 Type
np.ndarray 1D

self.
dt
¶ Class attribute  Time intervals between bins NOT in log space
 Type
np.ndarray 1D

at_log_age
(log_age)¶ Returns the HR diagrams at a specific age.
 Parameters
log_age (int or float) – The log(age) of choice.
 Returns
The CMD grid
 Return type
np.ndarray 240x100

make
(mag_filter, col_filters)¶ Make the CMD  a.k.a fill the grid
Notes
This may take a few seconds to a minute to run.
The colour will be mag_filter  filter2
If you later call CMD.plot() you will obtain a contour plot of mag_filter against mag_filterfilter2
 Parameters
mag_filter (str) – Magnitude Axis Filter
col_filters (list of 2 str) – The two filters for the colour. The colours will be col_filter[0]col_filter[1].
 Returns
 Return type
None

plot
(log_age=6.8, loc=111, cmap='Greys', **kwargs)¶ Plots the CMD grid at a particular age
 Parameters
log_age (float) – Must be a valid BPASS time bin
loc (3 integers, optional) – Location of the subplot. Default is 111.
cmap (str, optional) – Colour map for the contours. Default is ‘Greys’ **kwargs : matplotlib keyword arguments, optional
 Returns
The plot created is returned, so you can add stuff to it, like text or extra data.
 Return type
matplotlib.axes._subplots.AxesSubplot
hoki.constants¶
This module just contains BPASS constants and defines variables used in hoki.
Just BPASS things

hoki.constants.
set_default_bpass_version
(version)¶ Changes the path to the stellar models in hoki’dc settings
 Parameters
version (str, v221 or v222) – Version of BPASS to consider by default.
Notes
You are going to have to reload hoki for your new default version to be taken into account.

hoki.constants.
set_models_path
(path)¶ Changes the path to the stellar models in hoki’s settings
 Parameters
path (str,) – Absolute path to the top level of the stellar models this could be a directory named something like bpassv2.2newmodels and the next level down should contain ‘NEWBINMODS’ and ‘NEWSINMODS’.
Notes
You are going to have to reload hoki for your new path to take effect.

hoki.constants.
set_outputs_path
(path)¶ Changes the defaullt path to the BPASS outputs in hoki’s settings
 Parameters
path (str,) – Absolute path to the folder containing the BPASS outputs.
Notes
You are going to have to reload hoki for your new path to take effect.
 path_to_settings
path to the settings.yaml file located in the package resources
 MODELS_PATH
Path to the BPASS models as defined in the settings file. If you have not downloaded the models and updated this path with load.set_models_path(), it will not correspond to a valid path on your machine. This is not going to cause issues unless you’re using functionalities that require the full set of BPASS models (like making CMDs)
 BPASS_TIME_BINS
1D array containing the 51 BPASS time bins (from log(age) = 6.0 to 11.0)
 BPASS_TIME_INTERVALS
Time interval between BPASS time bins in years
 BPASS_TIME_WEIGHT_GRID
Grid of weights to apply to HR Diagrams based on BPASS definitions
 dummy_dict
Dictionary linking column number to column name for the large BPASS array traditionally called dummy. See the BPASS manual for a text version of the numner/name correspondance.
hoki.load¶
This module implements the tools to easily load BPASS data.

hoki.load.
model_input
(path)¶ Loads inputs from one file and put them in a dataframe
 Parameters
path (str) – Path to the file containing the input data.

hoki.load.
model_output
(path, hr_type=None)¶ Loads a BPASS output file
 Parameters
path (str) – Path to the file containing the target data.
hr_type (str, optional) – Type of HR diagram to load: ‘TL’, ‘Tg’ or ‘TTG’.
 Returns
Output Data
 Return type
pandas.DataFrame or hoki.hrdiagrams.HRDiagrams object

hoki.load.
set_models_path
(path)¶ Changes the path to the stellar models in hoki’s settings
 Parameters
path (str,) – Absolute path to the top level of the stellar models this could be a directory named something like bpassv2.2newmodels and the next level down should contain ‘NEWBINMODS’ and ‘NEWSINMODS’.
Notes
You are going to have to reload hoki for your new path to take effect.

hoki.load.
unpickle
(path)¶ Extract pickle files
hoki.hrdiagrams¶
This module implements the HR diagram infrastructure.

class
hoki.hrdiagrams.
HRDiagram
(high_H_input, medium_H_input, low_H_input, hr_type)¶ A class containing the HR diagram data produced by BPASS.
This class is called by the functions hrTL(), hrTg() and hrTTG() in hoki.load and users should not need to create an HRDiagram object themselves.
For more details on the BPASS outputs  and therefore why the data structure is as it is  please refer to the manual: https://bpass.auckland.ac.nz/8/files/bpassv2_1_manual_accessible_version.pdf
Note
HRDiagram supports indexing. The indexed array is a 51x100x100 np.array that stacked the time weighted arrays
corresponding to the 3 different abundances.
Initialisation from a text file is done through the hoki.load functions
 Parameters
high_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance n1 > 0.4.
medium_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance E3 < n1 < 0.4.
low_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance n1 < E3.
hr_type (str  Valid options are 'TL' , 'Tg', 'TTG') – This tells the class what type of HR diagrams are being given. For more details on what the 3 options mean, consult the BPASS manual section on HR diagram isocontours.

self.
high_H
¶ HR diagrams for 51 time bins with a hydrogen abundance n1 > 0.4. Time weighted.
 Type
np.ndarray (51x100x100)

self.
medium_H
¶ HR diagrams for 51 time bins with a hydrogen abundance E3 < n1 < 0.4. Time weighted.
 Type
np.ndarray (51x100x100)

self.
low_H
¶ HR diagrams for 51 time bins with a hydrogen abundance n1 < E3. Time weighted.
 Type
np.ndarray (51x100x100)

self.
type
¶ Type of HR diagram: TL, Tg or TTG
 Type
str

self.
high_H_not_weighted
¶ HR diagrams for 51 time bins with a hydrogen abundance n1 > 0.4.
 Type
np.ndarray (51x100x100)

self.
medium_H_not_weighted
¶ HR diagrams for 51 time bins with a hydrogen abundance E3 < n1 < 0.4.
 Type
np.ndarray (51x100x100)

self.
low_H_not_weighted
¶ HR diagrams for 51 time bins with a hydrogen abundance n1 < E3.
 Type
np.ndarray (51x100x100)

self.
_all_H
¶ HR diagrams for 51 time bins  all hydrogen abundances stacked. This attribute is private because it can simply be called using the indexing capabilities of the class.
 Type
np.ndarray (51x100x100)

self.
high_H_stacked
¶ HR diagram stacked for a given age range  hydrogen abundance n1 > 0.4. None before calling self.stack()
 Type
np.ndarray (51x100x100)

self.
medium_H_stacked
¶ HR diagram stacked for a given age range  hydrogen abundance E3 < n1 < 0.4. None before calling self.stack()
 Type
np.ndarray (51x100x100)

self.
low_H_stacked
¶ HR diagram stacked for a given age range  hydrogen abundance E3 > n1. None before calling self.stack()
 Type
np.ndarray (51x100x100)

self.
all_stacked
¶ HR diagram stacked for a given age range  all abundances added up. None before calling self.stack()
 Type
np.ndarray (51x100x100)

self.
t
¶ Class attribute  The time bins in BPASS  note they are in LOG SPACE
 Type
np.ndarray 1D

self.
dt
¶ Class attribute  Time intervals between bins NOT in log space
 Type
np.ndarray 1D

at_log_age
(log_age)¶ Returns the HR diagrams at a specific age.
 Parameters
log_age (int or float) – The log(age) of choice.
 Returns
[0] : Stack of all the abundances
[1] : High hydrogen abundance n1>0.4
[2] : Medium hydrogen abundance (E3 < n1 < 0.4)
[3] : Low hydrogen abundance (n1 < E3)
 Return type
Tuple of 4 np.ndarrays (100x100)

plot
(log_age=None, age_range=None, abundances=(1, 1, 1), **kwargs)¶ Plots the HR Diagram  calls hoki.hrdiagrams.plot_hrdiagram()
 Parameters
log_age (int or float, optional) – Log(age) at which to plot the HRdiagram.
age_range (tuple or list of 2 ints or floats, optional) – Age range within which you want to plot the HR diagram
abundances (tuple or list of 3 ints, zeros or ones, optional) – This turns on or off the inclusion of the abundances. The corresponding abundances are: (n1 > 0.4, E3 < n1 < 0.4, E3>n1). A 1 means a particular abundance should be included, a 0 means it will be ignored. Default is (1,1,1), meaning all abundances are plotted. Note that (0,0,0) is not valid and will return and assertion error.
**kwargs (matplotlib keyword arguments, optional) –
Notes
If you give both an age and an age range, the age range will take precedent and be plotted. You will get a warning if that happens though.
 Returns
The plot created is returned, so you can add stuff to it, like text or extra data.
 Return type
matplotlib.axes._subplots.AxesSubplot

stack
(log_age_min=None, log_age_max=None)¶ Creates a stack of HR diagrams within a range of ages
 Parameters
log_age_min (int or float, optional) – Minimum log(age) to stack
log_age_max (int or float, optional) – Maximum log(age) to stack
 Returns
This method stores the stacked values in the class attributes self.high_H_stacked, self.medium_H_stacked, self.low_H_stacked and self.all_stacked.
 Return type
None

hoki.hrdiagrams.
plot_hrdiagram
(single_hr_grid, kind='TL', loc=111, cmap='Greys', **kwargs)¶ Plots an HR diagram with a contour plot
 Parameters
single_hr_grid (np.ndarray (100x100)) – One HR diagram grid.
kind (str, optional) – Type of HR diagram: ‘TL’, ‘Tg’, or ‘TTG’. Default is ‘TL’.
loc (int  3 digits, optional) – Location to parse plt.subplot(). The Default is 111, to make only one plot.
cmap (str, optional) – The matplotlib colour map to use. Default is ‘RdGy’.
kwargs (matplotlib key word arguments to parse) –
Note
The default levels are defined such that they show the maximum value, then a 10th, then a 100th, etc… down to the minimum level. You can also use the “levels” keyword of the contour function to choose the number of levels you want (but them matplotlib will arbitrarily define where the levels fall).
 Returns
The plot created is returned, so you can add stuff to it, like text or extra data.
 Return type
matplotlib.axes._subplots.AxesSubplot
hoki.age¶

class
hoki.age.wizard.
AgeWizard
(obs_df, model, nsamples=100)¶ AgeWizard object

calculate_p_given_age_range
(age_range)¶ Calculates the probability that each source has age within age_range
 Parameters
age_range (list or tuple of 2 values) – Minimum and Maximum age to consider (inclusive).
 Returns
 Return type
numpy.array containing the probabilities.

property
most_likely_age
¶ Finds the most likely age by finding the max value in self.calculate_sample_pdf

property
most_likely_ages
¶ Finds the most likely ages for all the sources given in the obs_df DataFrame.


hoki.age.utils.
calculate_distributions
(obs_df, model)¶ Given observations and an HR Diagram, calculates the distribution across ages (not normalised) Note to self: KEEP THIS I NEED IT
 Parameters
obs_df (pandas.DataFrame) – Observational data. MUST contain a logT and logL column.
model (hoki.hrdiagrams.HRDiagrams or hoki.cmd.CMD) – BPASS HRDiagram or CMD
 Returns
 Return type
Age Probability Distribution Functions in a pandas.DataFrame.

hoki.age.utils.
calculate_individual_pdfs
(obs_df, model, nsamples=100)¶ Calculates the individual age PDFs for each star
 Parameters
obs_df (pandas.DataFrame) – Observational data. MUST contain a logT and logL column (for HRD comparison) or a col and mag column (for CMD comparison)
model (str or hoki.hrdiagrams.HRDiagrams() hoki.cmd.CMD()) – Location of the modeled HRD or CMD. This can be an already instanciated HRDiagram or CMD() object, or a path to an HR Diagram file or a pickled CMD.
nsamples (int, optional) – Number of times each data point should be sampled from its error distribution. Default is 100. This only matters if you are taking errors into account.

hoki.age.utils.
calculate_p_given_age_range
(pdfs, age_range=None)¶ Calculates the probability that each source has age within age_range
 Parameters
pdfs (pandas.DataFrame) – Age Probability Distributions Functions
age_range (list or tuple of 2 values) – Minimum and Maximum age to consider (inclusive).
 Returns
 Return type
numpy.array containing the probabilities.

hoki.age.utils.
calculate_sample_pdf
(distributions_df, not_you=None)¶ Adds together all the columns in given in DataFrame apart from the “time_bins” column
 Parameters
distributions_df (pandas.DataFrame) – DataFrame containing probability distribution functions
not_you (list, optional) – List of the column names to ignore. Default is None so all the pdfs are multiplied
 Returns
 Return type
Combined Probability Distribution Function in a pandas.DataFrame.

hoki.age.utils.
find_coordinates
(obs_df, model)¶ Finds the coordinates on a BPASS CMD or HRD that correspond to the given observations
 Parameters
obs_df (pandas.DataFrame) – Observational data. MUST contain a logT and logL column (for HRD comparison) or a col and mag column (for CMD comparison)
model (str or hoki.hrdiagrams.HRDiagrams() hoki.cmd.CMD()) – Location of the modeled HRD or CMD. This can be an already instanciated HRDiagram or CMD() object, or a path to an HR Diagram file or a pickled CMD.

hoki.age.utils.
fit_lognorm_params
(c, m, p, percentiles=array([0.16, 0.5, 0.84]), p0=1)¶ Fits the CDF of a log normal distribution to the percentiles and offset values of a parameter
 Parameters
c (numpy.array) – 50th percentile, a.k.a median (c for center)
m (numpy.array) – Lower error  1 sigma (m for minus, because this value would be subtracted to the median to retrieve the Xth percentile). Please provide the absolute value.
p (numpy.array) – Upper error  1 sigma (p for plus, because these values would be added to the median to create the Yth percentile)
percentiles (numpy.array) –
p0 (numpy.array) –

hoki.age.utils.
normalise_1d
(distribution, crop_the_future=False)¶ Simple function that devides by the sum of the 1D array or DataFrame given.
hoki.csp¶
Author: Max Briel
Parent class of a complex stellar population

class
hoki.csp.csp.
CSP
¶ Complex Stellar Population class
Notes
Parent class for CSPEventRate and CSPSpectra

now
¶ The age of the universe.
 Type
float

Author: Max Briel
Object to calculate the event rate at a certain lookback time or over binned lookback time

class
hoki.csp.eventrate.
CSPEventRate
(data_path, imf, binary=True)¶ Object to calculate event rates using complex stellar formation histories.
 Parameters
data_path (str) – Folder containing the BPASS data files (in units #events per bin)
imf (str) – The BPASS identifier for the IMF of the BPASS event rate files. The accepted IMF identifiers are:  “imf_chab100”  “imf_chab300”  “imf100_100”  “imf100_300”  “imf135_100”  “imf135_300”  “imfall_300”  “imf170_100”  “imf170_300”
binary (bool) – If True, loads the binary files. Otherwise, just loads single stars. Default=True

bpass_rates
¶ The BPASS delay time distributions in #events/yr/M_odot per metallicity. Usage: rates.loc[log_age, (type, metallicity)]
Note
This dataframe has the following structure. The index is the log_age as a float. The column is a pandas.MultiIndex with the event types (level=0, str) and the metallicity (level=1, float)
Event Type  Ia  IIP  ...  PISNe  low_mass  Metallicity 0.00001  0.00001  …  0.04  0.04   log_age —————  6.0   …  Event Rate values  11.0 
 Type
pandas.DataFrame (51, (8, 13))

at_time
(SFH, ZEH, event_type_list, t0, sample_rate=1000)¶ Calculates the event rates at lookback time t0 for functions as input.
 Parameters
SFH (python callable,) –
 hoki.csp.sfh.SFH,
list(hoki.csp.sfh.SFH, ), list(callable, )
SFH can be the following things:  A python callable (function) which takes the lookback time and
returns the stellar formation rate in units M_odot per yr at the given time.
A list of python callables with the above requirement.
A hoki.csp.sfh.SFH object.
A list of hoki.csp.sfh.SFH objects.
ZEH (callable, list(callable, )) –
ZEH can be the following things:  A python callable (function) which takes the lookback time and
returns the metallicity at the given time.
A list of python callables with the above requirement.
event_type_list (list(str, )) – A list of BPASS event types. The available types are:  Ia  IIP  II  Ib  Ic  LGRB  PISNe  low_mass
t0 (float) – The moment in lookback time, where to calculate the the event rate
sample_rate (int) – The number of samples to take from the SFH and metallicity evolutions. Default = 1000. If a negative value is given, the BPASS binning to calculate the event rates.
 Returns
Returns a numpy.ndarray containing the event rates for each sfh and metallicity pair (N) and event type (M) at the requested lookback time. Usage: event_rates[1][“Ia”] (Gives the Ia event rates for the second sfh and metallicity history pair)
 Return type
numpy.ndarray (N, M) [nr_sfh, nr_event_types]

grid_at_time
(SFH_list, time_points, event_type_list, t0, sample_rate=1000)¶ Calculates event rates for the given BPASS event types for the given SFH in a 2D grid (over BPASS metallicity and time_points)
 Parameters
SFH_list (numpy.ndarray (N, 13, M) [nr_sfh, metalllicities, time_points]) – A list of N stellar formation histories divided into BPASS metallicity bins, over lookback time points with length M.
time_points (numpy.ndarray (M)) – An array of the lookback time points of length N2 at which the SFH is given in the SFH_list.
event_type_list (list(str, )) –
A list of BPASS event types.
The available types are:  Ia  IIP  II  Ib  Ic  LGRB  PISNe  low_mass
t0 (float) – The moment in lookback time, where to calculate the the event rate
sample_rate (int) – The number of samples to take from the SFH and metallicity evolutions. Default = 1000. If a negative value is given, the BPASS binning to calculate the event rates.
 Returns
event_rate_list – A numpy array containing the event rates per SFH (N), per metallicity (13), per event type (nr_events) at t0.
 Return type
numpy.ndarray (N, 13, nr_events)

grid_over_time
(SFH_list, time_points, event_type_list, nr_time_bins, return_time_edges=False)¶ Calculates event rates for the given BPASS event types for the given Stellar Formation Histories
 Parameters
SFH_list (numpy.ndarray (N, 13, M) [nr_sfh, metalllicities, time_points]) – A list of N stellar formation histories divided into BPASS metallicity bins, over lookback time points with length M.
time_points (numpy.ndarray (M)) – An array of the lookback time points of length N2 at which the SFH is given in the SFH_list.
event_type_list (list(str, )) –
A list of BPASS event types.
The available types are:  Ia  IIP  II  Ib  Ic  LGRB  PISNe  low_mass
nr_time_bins (int) – The number of time bins in which to divide the lookback time
return_time_edges (bool) – If True, also returns the edges of the lookback time bins. Default=False
 Returns
event_rate_list – ((N, 13, nr_events, nr_time_bins), time_edges) A numpy array containing the event rates per galaxy (N), per metallicity (13), per event type (nr_events) and per time bins (nr_time_bins).
If return_time_edges=True, returns a numpy array containing the event rates and the time edges, eg. out[0]=event_rates_list out[1]=time_edges.
 Return type
numpy.ndarray (N, 13, nr_events, nr_time_bins)

over_time
(SFH, ZEH, event_type_list, nr_time_bins, return_time_edges=False)¶ Calculates the event rates over lookback time for functions as input.
 Parameters
SFH (python callable,) –
 hoki.csp.sfh.SFH,
list(hoki.csp.sfh.SFH, ), list(callable, )
SFH can be the following things:  A python callable (function) which takes the lookback time and
returns the stellar formation rate in units M_odot per yr at the given time.
A list of python callables with the above requirement.
A hoki.csp.sfh.SFH object.
A list of hoki.csp.sfh.SFH objects.
ZEH (callable, list(callable, )) –
ZEH can be the following thins:  A python callable (function) which takes the lookback time and
returns the metallicity at the given time.
A list of python callables with the above requirement.
event_type_list (list(str, )) –
A list of BPASS event types.
The available types are:  Ia  IIP  II  Ib  Ic  LGRB  PISNe  low_mass
nr_time_bins (int) – The number of bins to split the lookback time into.
return_time_edges (bool) – If True, also returns the edges of the lookback time bins. Default=False
 Returns
((nr_sfh, nr_event_types, nr_time_bins), nr_time_bins)
The event rates in a 3D matrix with sides, the number of SFHZ pairs, the number of events selected, and the number of time bins choosen.
If return_time_edges=False, returns a numpy.ndarray containing the event rates. Usage: event_rates[1][“Ia”][10]
(Gives the Ia event rates in bin number 11 for the second sfh and metallicity history pair)
If return_time_edges=True, returns a numpy array containing the event rates and the edges, eg. out[0]=event_rates out[1]=time_edges.
 Return type
numpy.ndarray (nr_sfh, nr_event_types, nr_time_bins),
Authors: Max Briel and Heloise Stevance
Object to contain the stellar formation history.

class
hoki.csp.sfh.
SFH
(time_axis, sfh_type, parameters_dict=None, sfh_arr=None)¶ An object to contain a stellar formation history of a population.

time_axis
¶ An array containing the given time points of the stellar formation rate
 Type
numpy.array

mass_per_bin
(time_edges, sample_rate=25)¶ Gives the mass per bin for the given edges in time.
 time_edgesnumpy.ndarray
The edges of the bins in which the mass per bin is wanted in yrs.
 numpy.ndarray
The mass per time bin given the time edges.


hoki.csp.sfh.
burst_sfh
(time_bins, sfr, burst_time)¶ Burst star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
sfr (int or float) – Value of the desired star formation rate at the burst time
burst_time (int or float) – Time of the star burst
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
constant_sfh
(time_bins, sfr)¶ Constant star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
sfr (int or float) – Value of the desired constant star formation rate.
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
dble_pwr_law
(time_bins, tau, alpha, beta, factor=1)¶ Double Power Law star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
tau (float or int) –
alpha (float or int) –
beta (float or int) –
factor (float or int, optional) – Default = 1
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
delayed_exp_sfh
(time_bins, tau, T0, factor=1)¶ Delayed exponential star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
tau (float or int) –
T0 (float or int) –
factor (float or int, optional) – Default = 1
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
exp_sfh
(time_bins, tau, T0, factor=1)¶ Exponential star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
tau (float or int) –
T0 (float or int) –
factor (float or int, optional) – Default = 1
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
lognormal
(time_bins, tau, T0, factor=1)¶ Lognormal star formation history
 Parameters
time_bins (list or numpy.ndarray) – Time bins
tau (float or int) –
T0 (float or int) –
factor (float or int, optional) – Default = 1
 Returns
 Return type
Array containing the star formation history corresponding to the given time_bins

hoki.csp.sfh.
sfherrormessage
(func, *args, **kwargs)¶ A decorator to automate a repeated error message.
Author: Max Briel
Utilities to be used in the complex stellar populations module

hoki.csp.utils.
mass_per_bin
(sfh_function, time_edges, sample_rate=25)¶ Calculates the mass per bin for the given edges in time
Notes
The default sample_rate is set to 25 for a untested balance between speed and accuracy
 sfh_functioncallable
A python callable (function) giving the stellar formation rate at a given lookback time. For faster calculations give a vector optimised function.
 time_edgesnumpy.ndarray
The edges of the bins in which the mass per bin is wanted in yrs.
 sample_rateint
The number of samples to take to use for the trapezodial integration. Default = 25
 numpy.ndarray [len(time_edges)1]
The mass per time bin.

hoki.csp.utils.
metallicity_per_bin
(Z_function, time_edges)¶ Gives the metallicity per bin for the given edges in time.
 Z_functionfunction
A function giving the metallicity history given a lookback time.
 time_edgesnumpy.ndarray
The edges of the bins in which the mass per bin is wanted in yrs.
 numpy.ndarray [len(time_edges)1]
The average metallicity per time bin

hoki.csp.utils.
trapz_loop
(dp, fp, sample_rate)¶ Perform a trapezodial integration over subsections of the given arrays.
Notes
dp and fp are split into a number of bins [(N1)/sample_rate]. Each subsection is integrated using the _optimised_trapezodial_rule. An array containing the integral for each subsection is returned.
 Parameters
dp (numpy.ndarray (N)) – Time points
fp (numpy.ndarray (N)) – Function values at the time points
sample_rate (int) – The sample rate over which to integrate the values. (N1) has to be divisible by sample_rate
 Returns
An array containing the integrals over bins separated by sample_rate
 Return type
numpy.ndarray (N1)/sample_rate