# 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

# 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')

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_el-sized intervals)

Type

numpy.ndarray (1D)

self.mag_range

Magnitude range spanned by the grid (with res_el-sized intervals)

Type

numpy.ndarray (1D)

self.grid

Colour-Magnitude 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_filter-filter2

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’s 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 bpass-v2.2-newmodels 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.

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.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 E-3 < n1 < 0.4.

• low_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance n1 < E-3.

• 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 E-3 < n1 < 0.4. Time weighted.

Type

np.ndarray (51x100x100)

self.low_H

HR diagrams for 51 time bins with a hydrogen abundance n1 < E-3. 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 E-3 < n1 < 0.4.

Type

np.ndarray (51x100x100)

self.low_H_not_weighted

HR diagrams for 51 time bins with a hydrogen abundance n1 < E-3.

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 E-3 < 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 E-3 > 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 (E-3 < n1 < 0.4)

• [3] : Low hydrogen abundance (n1 < E-3)

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, E-3 < n1 < 0.4, E-3>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

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)

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 bpass-v2.2-newmodels 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