pynbody.analysis.luminosity.use_custom_ssp_table

pynbody.analysis.luminosity.use_custom_ssp_table#

pynbody.analysis.luminosity.use_custom_ssp_table(path_or_table: SSPTable)[source]#

Specify a custom SSP table for calculating magnitudes.

This function allows you to specify a custom SSP table for calculating magnitudes. The specified table will be used for all future calls to calc_mags(), and by extension, for all derived arrays that depend on magnitudes. However, be aware that this will not affect any existing arrays that have already been derived.

A context manager is returned, so you can use this function in a with block to temporarily use a custom table, i.e.

>>> with use_custom_ssp_table('mytable.npz'):
>>>     print(pynbody.analysis.luminosity.calc_mags(s, 'V'))
>>> print(pynbody.analysis.luminosity.calc_mags(s, 'V'))

Here, the first call to calc_mags will use ‘mytable.npz’, and the second call will use the default table again.

However, you do not need to enter the context manager if you want to permanently change the table, i.e.

>>> use_custom_ssp_table('mytable.npz')
>>> print(pynbody.analysis.luminosity.calc_mags(s, 'V'))

Here, the call to calc_mags will use ‘mytable.npz’ until the table is changed again.

Parameters:

path_or_table (str or SSPTable) – Path to the SSP table file, or an SSPTable object. Alternatively, you can pass either ‘default’ (for the default table included with pynbody) or ‘v1’ (for the table included with pynbody v1).

Returns:

A context manager that can be used to temporarily use a custom SSP table. This is useful for situations where you want to use a custom table for a specific calculation, but then revert to the default table.

Return type:

SSPTableContext