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 X > 0.4.
medium_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance E-3 < X < 0.4.
low_H_input (np.ndarray with shape (51x100x100)) – This inputs the HR diagrams corresponding to a hydrogen abundance X < 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 X > 0.4. Time weighted.
- Type
np.ndarray (51x100x100)
-
self.
medium_H
¶ HR diagrams for 51 time bins with a hydrogen abundance E-3 < X < 0.4. Time weighted.
- Type
np.ndarray (51x100x100)
-
self.
low_H
¶ HR diagrams for 51 time bins with a hydrogen abundance X < 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 X > 0.4.
- Type
np.ndarray (51x100x100)
-
self.
medium_H_not_weighted
¶ HR diagrams for 51 time bins with a hydrogen abundance E-3 < X < 0.4.
- Type
np.ndarray (51x100x100)
-
self.
low_H_not_weighted
¶ HR diagrams for 51 time bins with a hydrogen abundance X < 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 X > 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 < X < 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 > X. 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 X>0.4
[2] : Medium hydrogen abundance (E-3 < X < 0.4)
[3] : Low hydrogen abundance (X < 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: (X > 0.4, E-3 < X < 0.4, E-3>X). 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