Lines from Grid
objects¶
Grids that have been post-processed through a photoionisation code (e.g. Cloudy
) contain information on emission lines. These can be loaded like regular grids, but there are a number of additional methods for working with lines, as demonstrated in these examples.
[1]:
import matplotlib.pyplot as plt
import numpy as np
import synthesizer.line_ratios as line_ratios
from synthesizer.grid import Grid
from synthesizer.line import (
get_diagram_labels,
)
Let’s first introduce the line_ratios
module. This contains a set of useful definitions.
[2]:
# the ID of H-alpha
print(line_ratios.Ha)
# the available in-built line ratios ...
print(line_ratios.available_ratios)
# ... and diagrams.
print(line_ratios.available_diagrams)
H 1 6562.80A
('BalmerDecrement', 'N2', 'S2', 'O1', 'R2', 'R3', 'R23', 'O32', 'Ne3O2')
('OHNO', 'BPT-NII')
Next let’s initialise a grid:
[3]:
grid_dir = "../../../tests/test_grid"
grid_name = "test_grid"
grid = Grid(grid_name, grid_dir=grid_dir)
We can easily get a list of the available lines:
[4]:
print(grid.available_lines)
['Al 2 1670.79A', 'Ar 3 7135.79A', 'Ar 3 7751.11A', 'Ar 4 2853.66A', 'C 1 1657.91A', 'C 1 1992.01A', 'C 1 2582.90A', 'C 2 1334.53A', 'C 2 1335.66A', 'C 2 1335.71A', 'C 2 2325.40A', 'C 2 2326.93A', 'C 3 1906.68A', 'C 3 1908.73A', 'C 4 1548.19A', 'C 4 1550.77A', 'Ca 2 7291.47A', 'Ca 2 7323.89A', 'Cl 2 8578.70A', 'Fe 2 1.25668m', 'Fe 2 1.27877m', 'Fe 2 1.29427m', 'Fe 2 1.32055m', 'Fe 2 1.32777m', 'Fe 2 1.37181m', 'Fe 2 1.53348m', 'Fe 2 1.59948m', 'Fe 2 1.64355m', 'Fe 2 1.66377m', 'Fe 2 1.67688m', 'Fe 2 1.71113m', 'Fe 2 1.74494m', 'Fe 2 1.79711m', 'Fe 2 1.80002m', 'Fe 2 1.80940m', 'Fe 2 1.89541m', 'Fe 2 1.95361m', 'Fe 2 2395.63A', 'Fe 2 2399.24A', 'Fe 2 2406.66A', 'Fe 2 2410.52A', 'Fe 2 2598.37A', 'Fe 2 2607.09A', 'Fe 2 2611.87A', 'Fe 2 2613.82A', 'Fe 2 2625.67A', 'Fe 2 2628.29A', 'Fe 2 2631.05A', 'Fe 2 2631.32A', 'Fe 2 4243.97A', 'Fe 2 4276.84A', 'Fe 2 4287.39A', 'Fe 2 4319.62A', 'Fe 2 4346.86A', 'Fe 2 4352.79A', 'Fe 2 4358.37A', 'Fe 2 4359.33A', 'Fe 2 4413.78A', 'Fe 2 4416.27A', 'Fe 2 4452.10A', 'Fe 2 4474.90A', 'Fe 2 4814.54A', 'Fe 2 4874.50A', 'Fe 2 4889.62A', 'Fe 2 4905.35A', 'Fe 2 4923.92A', 'Fe 2 4947.39A', 'Fe 2 4973.40A', 'Fe 2 5005.52A', 'Fe 2 5018.44A', 'Fe 2 5020.25A', 'Fe 2 5049.30A', 'Fe 2 5072.41A', 'Fe 2 5111.64A', 'Fe 2 5158.01A', 'Fe 2 5158.79A', 'Fe 2 5169.03A', 'Fe 2 5184.80A', 'Fe 2 5261.63A', 'Fe 2 5273.36A', 'Fe 2 5284.10A', 'Fe 2 5333.66A', 'Fe 2 5376.47A', 'Fe 2 5412.67A', 'Fe 2 5433.15A', 'Fe 2 5527.36A', 'Fe 2 6516.08A', 'Fe 2 7155.17A', 'Fe 2 7172.00A', 'Fe 2 7388.17A', 'Fe 2 7452.56A', 'Fe 2 8616.95A', 'Fe 2 8891.93A', 'Fe 2 9051.95A', 'Fe 2 9226.63A', 'Fe 2 9267.56A', 'Fe 2 9399.04A', 'Fe 2 9470.94A', 'Fe 3 4658.05A', 'Fe 3 4985.87A', 'Fe 3 5270.40A', 'Fe 4 2829.36A', 'Fe 4 2835.74A', 'Fe 4 3094.96A', 'Fe 5 3891.28A', 'Fe 6 3662.50A', 'Fe 6 5176.04A', 'Fe 7 3586.32A', 'Fe 7 3758.92A', 'Fe 7 5720.71A', 'Fe 7 6086.97A', 'H 1 1.00494m', 'H 1 1.09381m', 'H 1 1.28181m', 'H 1 1.87510m', 'H 1 1215.67A', 'H 1 2.16553m', 'H 1 3734.37A', 'H 1 3750.15A', 'H 1 3770.63A', 'H 1 3797.90A', 'H 1 3835.38A', 'H 1 3889.05A', 'H 1 3970.07A', 'H 1 4101.73A', 'H 1 4340.46A', 'H 1 4861.32A', 'H 1 6562.80A', 'H 1 9229.02A', 'H 1 9545.97A', 'He 1 1.08291m', 'He 1 1.08303m', 'He 1 3187.74A', 'He 1 3888.64A', 'He 1 5875.61A', 'He 1 5875.64A', 'He 1 6678.15A', 'He 2 1025.27A', 'He 2 1084.94A', 'He 2 1215.13A', 'He 2 1640.41A', 'He 2 4685.68A', 'Mg 2 2795.53A', 'Mg 2 2802.71A', 'Mg 5 2782.76A', 'Mg 6 1806.00A', 'Mg 7 2628.89A', 'N 2 6548.05A', 'N 2 6583.45A', 'N 3 1749.67A', 'N 4 1486.50A', 'N 5 1238.82A', 'N 5 1242.80A', 'Ne 3 3868.76A', 'Ne 3 3967.47A', 'Ne 4 1601.45A', 'Ne 5 3345.82A', 'Ne 5 3425.88A', 'Ni 2 1.19102m', 'Ni 2 1.93877m', 'Ni 2 6666.80A', 'Ni 2 7377.83A', 'Ni 2 7411.61A', 'O 1 1.12863m', 'O 1 1.12864m', 'O 1 1.12869m', 'O 1 1.12870m', 'O 1 1.12873m', 'O 1 1302.17A', 'O 1 1304.86A', 'O 1 1306.03A', 'O 1 1641.31A', 'O 1 6300.30A', 'O 1 6363.78A', 'O 1 8446.25A', 'O 1 8446.36A', 'O 1 8446.76A', 'O 2 3726.03A', 'O 2 3728.81A', 'O 3 1660.81A', 'O 3 1666.15A', 'O 3 2320.95A', 'O 3 4363.21A', 'O 3 4958.91A', 'O 3 5006.84A', 'O 4 1399.78A', 'O 4 1401.16A', 'O 4 1404.81A', 'O 4 1407.38A', 'O 5 1218.34A', 'O 6 1031.91A', 'O 6 1037.61A', 'S 2 1.02867m', 'S 2 1.03205m', 'S 2 1.03364m', 'S 2 4068.60A', 'S 2 4076.35A', 'S 2 6716.44A', 'S 2 6730.82A', 'S 3 9068.62A', 'S 3 9530.62A', 'Si 2 1179.59A', 'Si 2 1260.42A', 'Si 2 1264.74A', 'Si 2 1265.00A', 'Si 2 1526.71A', 'Si 2 1533.43A', 'Si 3 1206.50A', 'Si 3 1882.71A', 'Si 3 1892.03A', 'Si 4 1393.75A', 'Si 4 1402.77A', 'Si 6 1.96247m', 'Si 7 2.48071m', 'Si 7 2146.64A']
This is also reported if we give use the print
function on a grid directly:
[5]:
print(grid)
+------------------------------------------------------------------------------------------------+
| GRID |
+-----------------------------+------------------------------------------------------------------+
| Attribute | Value |
+-----------------------------+------------------------------------------------------------------+
| grid_dir | '../../../tests/test_grid' |
+-----------------------------+------------------------------------------------------------------+
| grid_name | 'test_grid' |
+-----------------------------+------------------------------------------------------------------+
| grid_ext | 'hdf5' |
+-----------------------------+------------------------------------------------------------------+
| grid_filename | '../../../tests/test_grid/test_grid.hdf5' |
+-----------------------------+------------------------------------------------------------------+
| reprocessed | True |
+-----------------------------+------------------------------------------------------------------+
| lines_available | True |
+-----------------------------+------------------------------------------------------------------+
| naxes | 2 |
+-----------------------------+------------------------------------------------------------------+
| has_lines | True |
+-----------------------------+------------------------------------------------------------------+
| has_spectra | True |
+-----------------------------+------------------------------------------------------------------+
| lines_available | True |
+-----------------------------+------------------------------------------------------------------+
| reprocessed | True |
+-----------------------------+------------------------------------------------------------------+
| shape | (51, 13, 9244) |
+-----------------------------+------------------------------------------------------------------+
| available_lines | [Al 2 1670.79A, Ar 3 7135.79A, Ar 3 7751.11A, Ar 4 2853.66A, |
| | C 1 1657.91A, C 1 1992.01A, C 1 2582.90A, C 2 1334.53A, |
| | C 2 1335.66A, C 2 1335.71A, C 2 2325.40A, C 2 2326.93A, |
| | C 3 1906.68A, C 3 1908.73A, C 4 1548.19A, C 4 1550.77A, |
| | Ca 2 7291.47A, Ca 2 7323.89A, Cl 2 8578.70A, Fe 2 1.25668m, |
| | Fe 2 1.27877m, Fe 2 1.29427m, Fe 2 1.32055m, Fe 2 1.32777m, |
| | Fe 2 1.37181m, Fe 2 1.53348m, Fe 2 1.59948m, Fe 2 1.64355m, |
| | Fe 2 1.66377m, Fe 2 1.67688m, Fe 2 1.71113m, Fe 2 1.74494m, |
| | Fe 2 1.79711m, Fe 2 1.80002m, Fe 2 1.80940m, Fe 2 1.89541m, |
| | Fe 2 1.95361m, Fe 2 2395.63A, Fe 2 2399.24A, Fe 2 2406.66A, |
| | Fe 2 2410.52A, Fe 2 2598.37A, Fe 2 2607.09A, Fe 2 2611.87A, |
| | Fe 2 2613.82A, Fe 2 2625.67A, Fe 2 2628.29A, Fe 2 2631.05A, |
| | Fe 2 2631.32A, Fe 2 4243.97A, Fe 2 4276.84A, Fe 2 4287.39A, |
| | Fe 2 4319.62A, Fe 2 4346.86A, Fe 2 4352.79A, Fe 2 4358.37A, |
| | Fe 2 4359.33A, Fe 2 4413.78A, Fe 2 4416.27A, Fe 2 4452.10A, |
| | Fe 2 4474.90A, Fe 2 4814.54A, Fe 2 4874.50A, Fe 2 4889.62A, |
| | Fe 2 4905.35A, Fe 2 4923.92A, Fe 2 4947.39A, Fe 2 4973.40A, |
| | Fe 2 5005.52A, Fe 2 5018.44A, Fe 2 5020.25A, Fe 2 5049.30A, |
| | Fe 2 5072.41A, Fe 2 5111.64A, Fe 2 5158.01A, Fe 2 5158.79A, |
| | Fe 2 5169.03A, Fe 2 5184.80A, Fe 2 5261.63A, Fe 2 5273.36A, |
| | Fe 2 5284.10A, Fe 2 5333.66A, Fe 2 5376.47A, Fe 2 5412.67A, |
| | Fe 2 5433.15A, Fe 2 5527.36A, Fe 2 6516.08A, Fe 2 7155.17A, |
| | Fe 2 7172.00A, Fe 2 7388.17A, Fe 2 7452.56A, Fe 2 8616.95A, |
| | Fe 2 8891.93A, Fe 2 9051.95A, Fe 2 9226.63A, Fe 2 9267.56A, |
| | Fe 2 9399.04A, Fe 2 9470.94A, Fe 3 4658.05A, Fe 3 4985.87A, |
| | Fe 3 5270.40A, Fe 4 2829.36A, Fe 4 2835.74A, Fe 4 3094.96A, |
| | Fe 5 3891.28A, Fe 6 3662.50A, Fe 6 5176.04A, Fe 7 3586.32A, |
| | Fe 7 3758.92A, Fe 7 5720.71A, Fe 7 6086.97A, H 1 1.00494m, |
| | H 1 1.09381m, H 1 1.28181m, H 1 1.87510m, H 1 1215.67A, |
| | H 1 2.16553m, H 1 3734.37A, H 1 3750.15A, H 1 3770.63A, |
| | H 1 3797.90A, H 1 3835.38A, H 1 3889.05A, H 1 3970.07A, |
| | H 1 4101.73A, H 1 4340.46A, H 1 4861.32A, H 1 6562.80A, |
| | H 1 9229.02A, H 1 9545.97A, He 1 1.08291m, He 1 1.08303m, |
| | He 1 3187.74A, He 1 3888.64A, He 1 5875.61A, He 1 5875.64A, |
| | He 1 6678.15A, He 2 1025.27A, He 2 1084.94A, He 2 1215.13A, |
| | He 2 1640.41A, He 2 4685.68A, Mg 2 2795.53A, Mg 2 2802.71A, |
| | Mg 5 2782.76A, Mg 6 1806.00A, Mg 7 2628.89A, N 2 6548.05A, |
| | N 2 6583.45A, N 3 1749.67A, N 4 1486.50A, N 5 1238.82A, |
| | N 5 1242.80A, Ne 3 3868.76A, Ne 3 3967.47A, Ne 4 1601.45A, |
| | Ne 5 3345.82A, Ne 5 3425.88A, Ni 2 1.19102m, Ni 2 1.93877m, |
| | Ni 2 6666.80A, Ni 2 7377.83A, Ni 2 7411.61A, O 1 1.12863m, |
| | O 1 1.12864m, O 1 1.12869m, O 1 1.12870m, O 1 1.12873m, |
| | O 1 1302.17A, O 1 1304.86A, O 1 1306.03A, O 1 1641.31A, |
| | O 1 6300.30A, O 1 6363.78A, O 1 8446.25A, O 1 8446.36A, |
| | O 1 8446.76A, O 2 3726.03A, O 2 3728.81A, O 3 1660.81A, |
| | O 3 1666.15A, O 3 2320.95A, O 3 4363.21A, O 3 4958.91A, |
| | O 3 5006.84A, O 4 1399.78A, O 4 1401.16A, O 4 1404.81A, |
| | O 4 1407.38A, O 5 1218.34A, O 6 1031.91A, O 6 1037.61A, |
| | S 2 1.02867m, S 2 1.03205m, S 2 1.03364m, S 2 4068.60A, |
| | S 2 4076.35A, S 2 6716.44A, S 2 6730.82A, S 3 9068.62A, |
| | S 3 9530.62A, Si 2 1179.59A, Si 2 1260.42A, Si 2 1264.74A, |
| | Si 2 1265.00A, Si 2 1526.71A, Si 2 1533.43A, Si 3 1206.50A, |
| | Si 3 1882.71A, Si 3 1892.03A, Si 4 1393.75A, Si 4 1402.77A, |
| | Si 6 1.96247m, Si 7 2.48071m, Si 7 2146.64A, ] |
+-----------------------------+------------------------------------------------------------------+
| available_spectra | [incident, linecont, nebular, transmitted, |
| | total, nebular_continuum, ] |
+-----------------------------+------------------------------------------------------------------+
| axes | [log10age, metallicity, ] |
+-----------------------------+------------------------------------------------------------------+
| log10age (51,) | 6.00e+00 -> 1.10e+01 (Mean: 8.50e+00) |
+-----------------------------+------------------------------------------------------------------+
| metallicity (13,) | 1.00e-05 -> 4.00e-02 (Mean: 1.06e-02) |
+-----------------------------+------------------------------------------------------------------+
| lam (9244,) | 1.30e-04 Å -> 2.99e+11 Å (Mean: 9.73e+09 Å) |
+-----------------------------+------------------------------------------------------------------+
| log10ages (51,) | 6.00e+00 -> 1.10e+01 (Mean: 8.50e+00) |
+-----------------------------+------------------------------------------------------------------+
| log10metallicities (13,) | -5.00e+00 -> -1.40e+00 (Mean: -2.49e+00) |
+-----------------------------+------------------------------------------------------------------+
| spectra | incident: ndarray |
| | linecont: ndarray |
| | nebular: ndarray |
| | transmitted: ndarray |
| | total: ndarray |
| | nebular_continuum: ndarray |
+-----------------------------+------------------------------------------------------------------+
| line_lams | Al 2 1670.79A: float64 |
| | Ar 3 7135.79A: float64 |
| | Ar 3 7751.11A: float64 |
| | Ar 4 2853.66A: float64 |
| | C 1 1657.91A: float64 |
| | C 1 1992.01A: float64 |
| | C 1 2582.90A: float64 |
| | C 2 1334.53A: float64 |
| | C 2 1335.66A: float64 |
| | C 2 1335.71A: float64 |
| | C 2 2325.40A: float64 |
| | C 2 2326.93A: float64 |
| | C 3 1906.68A: float64 |
| | C 3 1908.73A: float64 |
| | C 4 1548.19A: float64 |
| | C 4 1550.77A: float64 |
| | Ca 2 7291.47A: float64 |
| | Ca 2 7323.89A: float64 |
| | Cl 2 8578.70A: float64 |
| | Fe 2 1.25668m: float64 |
| | Fe 2 1.27877m: float64 |
| | Fe 2 1.29427m: float64 |
| | Fe 2 1.32055m: float64 |
| | Fe 2 1.32777m: float64 |
| | Fe 2 1.37181m: float64 |
| | Fe 2 1.53348m: float64 |
| | Fe 2 1.59948m: float64 |
| | Fe 2 1.64355m: float64 |
| | Fe 2 1.66377m: float64 |
| | Fe 2 1.67688m: float64 |
| | Fe 2 1.71113m: float64 |
| | Fe 2 1.74494m: float64 |
| | Fe 2 1.79711m: float64 |
| | Fe 2 1.80002m: float64 |
| | Fe 2 1.80940m: float64 |
| | Fe 2 1.89541m: float64 |
| | Fe 2 1.95361m: float64 |
| | Fe 2 2395.63A: float64 |
| | Fe 2 2399.24A: float64 |
| | Fe 2 2406.66A: float64 |
| | Fe 2 2410.52A: float64 |
| | Fe 2 2598.37A: float64 |
| | Fe 2 2607.09A: float64 |
| | Fe 2 2611.87A: float64 |
| | Fe 2 2613.82A: float64 |
| | Fe 2 2625.67A: float64 |
| | Fe 2 2628.29A: float64 |
| | Fe 2 2631.05A: float64 |
| | Fe 2 2631.32A: float64 |
| | Fe 2 4243.97A: float64 |
| | Fe 2 4276.84A: float64 |
| | Fe 2 4287.39A: float64 |
| | Fe 2 4319.62A: float64 |
| | Fe 2 4346.86A: float64 |
| | Fe 2 4352.79A: float64 |
| | Fe 2 4358.37A: float64 |
| | Fe 2 4359.33A: float64 |
| | Fe 2 4413.78A: float64 |
| | Fe 2 4416.27A: float64 |
| | Fe 2 4452.10A: float64 |
| | Fe 2 4474.90A: float64 |
| | Fe 2 4814.54A: float64 |
| | Fe 2 4874.50A: float64 |
| | Fe 2 4889.62A: float64 |
| | Fe 2 4905.35A: float64 |
| | Fe 2 4923.92A: float64 |
| | Fe 2 4947.39A: float64 |
| | Fe 2 4973.40A: float64 |
| | Fe 2 5005.52A: float64 |
| | Fe 2 5018.44A: float64 |
| | Fe 2 5020.25A: float64 |
| | Fe 2 5049.30A: float64 |
| | Fe 2 5072.41A: float64 |
| | Fe 2 5111.64A: float64 |
| | Fe 2 5158.01A: float64 |
| | Fe 2 5158.79A: float64 |
| | Fe 2 5169.03A: float64 |
| | Fe 2 5184.80A: float64 |
| | Fe 2 5261.63A: float64 |
| | Fe 2 5273.36A: float64 |
| | Fe 2 5284.10A: float64 |
| | Fe 2 5333.66A: float64 |
| | Fe 2 5376.47A: float64 |
| | Fe 2 5412.67A: float64 |
| | Fe 2 5433.15A: float64 |
| | Fe 2 5527.36A: float64 |
| | Fe 2 6516.08A: float64 |
| | Fe 2 7155.17A: float64 |
| | Fe 2 7172.00A: float64 |
| | Fe 2 7388.17A: float64 |
| | Fe 2 7452.56A: float64 |
| | Fe 2 8616.95A: float64 |
| | Fe 2 8891.93A: float64 |
| | Fe 2 9051.95A: float64 |
| | Fe 2 9226.63A: float64 |
| | Fe 2 9267.56A: float64 |
| | Fe 2 9399.04A: float64 |
| | Fe 2 9470.94A: float64 |
| | Fe 3 4658.05A: float64 |
| | Fe 3 4985.87A: float64 |
| | Fe 3 5270.40A: float64 |
| | Fe 4 2829.36A: float64 |
| | Fe 4 2835.74A: float64 |
| | Fe 4 3094.96A: float64 |
| | Fe 5 3891.28A: float64 |
| | Fe 6 3662.50A: float64 |
| | Fe 6 5176.04A: float64 |
| | Fe 7 3586.32A: float64 |
| | Fe 7 3758.92A: float64 |
| | Fe 7 5720.71A: float64 |
| | Fe 7 6086.97A: float64 |
| | H 1 1.00494m: float64 |
| | H 1 1.09381m: float64 |
| | H 1 1.28181m: float64 |
| | H 1 1.87510m: float64 |
| | H 1 1215.67A: float64 |
| | H 1 2.16553m: float64 |
| | H 1 3734.37A: float64 |
| | H 1 3750.15A: float64 |
| | H 1 3770.63A: float64 |
| | H 1 3797.90A: float64 |
| | H 1 3835.38A: float64 |
| | H 1 3889.05A: float64 |
| | H 1 3970.07A: float64 |
| | H 1 4101.73A: float64 |
| | H 1 4340.46A: float64 |
| | H 1 4861.32A: float64 |
| | H 1 6562.80A: float64 |
| | H 1 9229.02A: float64 |
| | H 1 9545.97A: float64 |
| | He 1 1.08291m: float64 |
| | He 1 1.08303m: float64 |
| | He 1 3187.74A: float64 |
| | He 1 3888.64A: float64 |
| | He 1 5875.61A: float64 |
| | He 1 5875.64A: float64 |
| | He 1 6678.15A: float64 |
| | He 2 1025.27A: float64 |
| | He 2 1084.94A: float64 |
| | He 2 1215.13A: float64 |
| | He 2 1640.41A: float64 |
| | He 2 4685.68A: float64 |
| | Mg 2 2795.53A: float64 |
| | Mg 2 2802.71A: float64 |
| | Mg 5 2782.76A: float64 |
| | Mg 6 1806.00A: float64 |
| | Mg 7 2628.89A: float64 |
| | N 2 6548.05A: float64 |
| | N 2 6583.45A: float64 |
| | N 3 1749.67A: float64 |
| | N 4 1486.50A: float64 |
| | N 5 1238.82A: float64 |
| | N 5 1242.80A: float64 |
| | Ne 3 3868.76A: float64 |
| | Ne 3 3967.47A: float64 |
| | Ne 4 1601.45A: float64 |
| | Ne 5 3345.82A: float64 |
| | Ne 5 3425.88A: float64 |
| | Ni 2 1.19102m: float64 |
| | Ni 2 1.93877m: float64 |
| | Ni 2 6666.80A: float64 |
| | Ni 2 7377.83A: float64 |
| | Ni 2 7411.61A: float64 |
| | O 1 1.12863m: float64 |
| | O 1 1.12864m: float64 |
| | O 1 1.12869m: float64 |
| | O 1 1.12870m: float64 |
| | O 1 1.12873m: float64 |
| | O 1 1302.17A: float64 |
| | O 1 1304.86A: float64 |
| | O 1 1306.03A: float64 |
| | O 1 1641.31A: float64 |
| | O 1 6300.30A: float64 |
| | O 1 6363.78A: float64 |
| | O 1 8446.25A: float64 |
| | O 1 8446.36A: float64 |
| | O 1 8446.76A: float64 |
| | O 2 3726.03A: float64 |
| | O 2 3728.81A: float64 |
| | O 3 1660.81A: float64 |
| | O 3 1666.15A: float64 |
| | O 3 2320.95A: float64 |
| | O 3 4363.21A: float64 |
| | O 3 4958.91A: float64 |
| | O 3 5006.84A: float64 |
| | O 4 1399.78A: float64 |
| | O 4 1401.16A: float64 |
| | O 4 1404.81A: float64 |
| | O 4 1407.38A: float64 |
| | O 5 1218.34A: float64 |
| | O 6 1031.91A: float64 |
| | O 6 1037.61A: float64 |
| | S 2 1.02867m: float64 |
| | S 2 1.03205m: float64 |
| | S 2 1.03364m: float64 |
| | S 2 4068.60A: float64 |
| | S 2 4076.35A: float64 |
| | S 2 6716.44A: float64 |
| | S 2 6730.82A: float64 |
| | S 3 9068.62A: float64 |
| | S 3 9530.62A: float64 |
| | Si 2 1179.59A: float64 |
| | Si 2 1260.42A: float64 |
| | Si 2 1264.74A: float64 |
| | Si 2 1265.00A: float64 |
| | Si 2 1526.71A: float64 |
| | Si 2 1533.43A: float64 |
| | Si 3 1206.50A: float64 |
| | Si 3 1882.71A: float64 |
| | Si 3 1892.03A: float64 |
| | Si 4 1393.75A: float64 |
| | Si 4 1402.77A: float64 |
| | Si 6 1.96247m: float64 |
| | Si 7 2.48071m: float64 |
| | Si 7 2146.64A: float64 |
+-----------------------------+------------------------------------------------------------------+
| line_lums | incident: dict |
| | linecont: dict |
| | nebular: dict |
| | transmitted: dict |
| | total: dict |
| | nebular_continuum: dict |
+-----------------------------+------------------------------------------------------------------+
| line_conts | incident: dict |
| | linecont: dict |
| | nebular: dict |
| | transmitted: dict |
| | total: dict |
| | nebular_continuum: dict |
+-----------------------------+------------------------------------------------------------------+
| parameters | CMB: str |
| | T_floor: int64 |
| | abundance_scalings_carbon: str |
| | abundance_scalings_nitrogen: str |
| | alpha: float64 |
| | axes: ndarray |
| | axes_alternative: ndarray |
| | cloudy_version: str |
| | constant_density: bool |
| | cosmic_rays: bool |
| | depletion_model: str |
| | depletion_scale: float64 |
| | geometry: str |
| | grains: str |
| | hydrogen_density: float64 |
| | incident_axes: ndarray |
| | ionisation_parameter_model: str |
| | iterate_to_convergence: bool |
| | log10age: ndarray |
| | metallicity: ndarray |
| | output_cont: bool |
| | output_linelist: str |
| | parameter_file: str |
| | radius: float64 |
| | reference_abundance: str |
| | reference_ionisation_parameter: float64 |
| | reference_log10age: float64 |
| | reference_log10age_index: int64 |
| | reference_metallicity: float64 |
| | reference_metallicity_index: int64 |
| | resolution: float64 |
| | stop_T: int64 |
| | stop_efrac: int64 |
| | turbulence: int64 |
| | z: float64 |
+-----------------------------+------------------------------------------------------------------+
| log10_specific_ionising_lum | HI: ndarray |
| | HeII: ndarray |
+-----------------------------+------------------------------------------------------------------+
To demonstrate, we choose some age and metallicity and extract the spectra at that grid point. We can then get information on a single line, in this case H-\(\beta\).
[6]:
log10age = 6.0 # log10(age/yr)
metallicity = 0.01
# find nearest grid point
grid_point = grid.get_grid_point(log10ages=log10age, metallicity=metallicity)
line_id = line_ratios.Hb
line = grid.get_line(grid_point, line_id)
print(line)
----------
SUMMARY OF H 1 4861.32A
wavelength: 4861.3 Å
Npart: 1
<log10(luminosity/erg/s)>: 34.52
<equivalent width>: 1193 Å
----------
We can do this for a combination of lines (e.g. a doublet).
Note that this sums the contribution of each line; if you want separate lines, use the get_lines
method described below.
[7]:
line = grid.get_line(
grid_point, [line_ratios.Hb, line_ratios.O3r, line_ratios.O3b]
)
print(line)
----------
SUMMARY OF H 1 4861.32A, O 3 5006.84A, O 3 4958.91A, H 1 4861.32A, O 3 5006.84A, O 3 4958.91A, H 1 4861.32A, O 3 5006.84A, O 3 4958.91A
wavelength: 4942.4 Å
Npart: 1
<log10(luminosity/erg/s)>: 35.47
<equivalent width>: 3421 Å
----------
We can also create a LineCollection
, a collection of lines which have methods for calculating ratios and diagrams. By default this will create a collection for all available lines, but you can also specify which lines you want.
[8]:
lines = grid.get_lines(grid_point)
print(lines)
----------
LINE COLLECTION
number of lines: 215
lines: ['He 2 1025.27A' 'O 6 1031.91A' 'O 6 1037.61A' 'He 2 1084.94A'
'Si 2 1179.59A' 'Si 3 1206.50A' 'He 2 1215.13A' 'H 1 1215.67A'
'O 5 1218.34A' 'N 5 1238.82A' 'N 5 1242.80A' 'Si 2 1260.42A'
'Si 2 1264.74A' 'Si 2 1265.00A' 'O 1 1302.17A' 'O 1 1304.86A'
'O 1 1306.03A' 'C 2 1334.53A' 'C 2 1335.66A' 'C 2 1335.71A'
'Si 4 1393.75A' 'O 4 1399.78A' 'O 4 1401.16A' 'Si 4 1402.77A'
'O 4 1404.81A' 'O 4 1407.38A' 'N 4 1486.50A' 'Si 2 1526.71A'
'Si 2 1533.43A' 'C 4 1548.19A' 'C 4 1550.77A' 'Ne 4 1601.45A'
'He 2 1640.41A' 'O 1 1641.31A' 'C 1 1657.91A' 'O 3 1660.81A'
'O 3 1666.15A' 'Al 2 1670.79A' 'N 3 1749.67A' 'Mg 6 1806.00A'
'Si 3 1882.71A' 'Si 3 1892.03A' 'C 3 1906.68A' 'C 3 1908.73A'
'C 1 1992.01A' 'Si 7 2146.64A' 'O 3 2320.95A' 'C 2 2325.40A'
'C 2 2326.93A' 'Fe 2 2395.63A' 'Fe 2 2399.24A' 'Fe 2 2406.66A'
'Fe 2 2410.52A' 'C 1 2582.90A' 'Fe 2 2598.37A' 'Fe 2 2607.09A'
'Fe 2 2611.87A' 'Fe 2 2613.82A' 'Fe 2 2625.67A' 'Fe 2 2628.29A'
'Mg 7 2628.89A' 'Fe 2 2631.05A' 'Fe 2 2631.32A' 'Mg 5 2782.76A'
'Mg 2 2795.53A' 'Mg 2 2802.71A' 'Fe 4 2829.36A' 'Fe 4 2835.74A'
'Ar 4 2853.66A' 'Fe 4 3094.96A' 'He 1 3187.74A' 'Ne 5 3345.82A'
'Ne 5 3425.88A' 'Fe 7 3586.32A' 'Fe 6 3662.50A' 'O 2 3726.03A'
'O 2 3728.81A' 'H 1 3734.37A' 'H 1 3750.15A' 'Fe 7 3758.92A'
'H 1 3770.63A' 'H 1 3797.90A' 'H 1 3835.38A' 'Ne 3 3868.76A'
'He 1 3888.64A' 'H 1 3889.05A' 'Fe 5 3891.28A' 'Ne 3 3967.47A'
'H 1 3970.07A' 'S 2 4068.60A' 'S 2 4076.35A' 'H 1 4101.73A'
'Fe 2 4243.97A' 'Fe 2 4276.84A' 'Fe 2 4287.39A' 'Fe 2 4319.62A'
'H 1 4340.46A' 'Fe 2 4346.86A' 'Fe 2 4352.79A' 'Fe 2 4358.37A'
'Fe 2 4359.33A' 'O 3 4363.21A' 'Fe 2 4413.78A' 'Fe 2 4416.27A'
'Fe 2 4452.10A' 'Fe 2 4474.90A' 'Fe 3 4658.05A' 'He 2 4685.68A'
'Fe 2 4814.54A' 'H 1 4861.32A' 'Fe 2 4874.50A' 'Fe 2 4889.62A'
'Fe 2 4905.35A' 'Fe 2 4923.92A' 'Fe 2 4947.39A' 'O 3 4958.91A'
'Fe 2 4973.40A' 'Fe 3 4985.87A' 'Fe 2 5005.52A' 'O 3 5006.84A'
'Fe 2 5018.44A' 'Fe 2 5020.25A' 'Fe 2 5049.30A' 'Fe 2 5072.41A'
'Fe 2 5111.64A' 'Fe 2 5158.01A' 'Fe 2 5158.79A' 'Fe 2 5169.03A'
'Fe 6 5176.04A' 'Fe 2 5184.80A' 'Fe 2 5261.63A' 'Fe 3 5270.40A'
'Fe 2 5273.36A' 'Fe 2 5284.10A' 'Fe 2 5333.66A' 'Fe 2 5376.47A'
'Fe 2 5412.67A' 'Fe 2 5433.15A' 'Fe 2 5527.36A' 'Fe 7 5720.71A'
'He 1 5875.61A' 'He 1 5875.64A' 'Fe 7 6086.97A' 'O 1 6300.30A'
'O 1 6363.78A' 'Fe 2 6516.08A' 'N 2 6548.05A' 'H 1 6562.80A'
'N 2 6583.45A' 'Ni 2 6666.80A' 'He 1 6678.15A' 'S 2 6716.44A'
'S 2 6730.82A' 'Ar 3 7135.79A' 'Fe 2 7155.17A' 'Fe 2 7172.00A'
'Ca 2 7291.47A' 'Ca 2 7323.89A' 'Ni 2 7377.83A' 'Fe 2 7388.17A'
'Ni 2 7411.61A' 'Fe 2 7452.56A' 'Ar 3 7751.11A' 'O 1 8446.25A'
'O 1 8446.36A' 'O 1 8446.76A' 'Cl 2 8578.70A' 'Fe 2 8616.95A'
'Fe 2 8891.93A' 'Fe 2 9051.95A' 'S 3 9068.62A' 'Fe 2 9226.63A'
'H 1 9229.02A' 'Fe 2 9267.56A' 'Fe 2 9399.04A' 'Fe 2 9470.94A'
'S 3 9530.62A' 'H 1 9545.97A' 'H 1 1.00494m' 'S 2 1.02867m'
'S 2 1.03205m' 'S 2 1.03364m' 'He 1 1.08291m' 'He 1 1.08303m'
'H 1 1.09381m' 'O 1 1.12863m' 'O 1 1.12864m' 'O 1 1.12869m'
'O 1 1.12870m' 'O 1 1.12873m' 'Ni 2 1.19102m' 'Fe 2 1.25668m'
'Fe 2 1.27877m' 'H 1 1.28181m' 'Fe 2 1.29427m' 'Fe 2 1.32055m'
'Fe 2 1.32777m' 'Fe 2 1.37181m' 'Fe 2 1.53348m' 'Fe 2 1.59948m'
'Fe 2 1.64355m' 'Fe 2 1.66377m' 'Fe 2 1.67688m' 'Fe 2 1.71113m'
'Fe 2 1.74494m' 'Fe 2 1.79711m' 'Fe 2 1.80002m' 'Fe 2 1.80940m'
'H 1 1.87510m' 'Fe 2 1.89541m' 'Ni 2 1.93877m' 'Fe 2 1.95361m'
'Si 6 1.96247m' 'H 1 2.16553m' 'Si 7 2.48071m']
available ratios: ['BalmerDecrement', 'N2', 'S2', 'O1', 'R2', 'R3', 'R23', 'O32', 'Ne3O2']
available diagrams: ['OHNO', 'BPT-NII']
----------
We can measure some predefined line ratios, or loop over all pre-defined ratios:
[9]:
ratio_id = "BalmerDecrement"
ratio = lines.get_ratio(ratio_id)
print(f"{ratio_id}: {ratio:.2f}")
for ratio_id in lines.available_ratios:
ratio = lines.get_ratio(ratio_id)
print(f"{ratio_id}: {ratio:.2f}")
BalmerDecrement: 2.92
BalmerDecrement: 2.92
N2: 0.08
S2: 0.06
O1: 0.01
R2: 0.97
R3: 5.97
R23: 9.77
O32: 6.13
Ne3O2: 0.48
We can also easily measure the ratio of an arbitrary set of lines:
[10]:
lines.get_ratio(["Ne 4 1601.45A", "He 2 1640.41A"])
lines.get_ratio(["Ne 4 1601.45A, He 2 1640.41A", "O 3 1660.81A"])
[10]:
np.float64(0.23419729663272387)
To show the dependence on stellar metallicity we can loop over the metallicity grid:
[11]:
ratio_id = "R23"
ia = 0 # 1 Myr old for test grid
ratios = []
for iZ, Z in enumerate(grid.metallicity):
grid_point = (ia, iZ)
lines = grid.get_lines(grid_point)
ratios.append(lines.get_ratio(ratio_id))
Zsun = grid.metallicity / 0.0124
plt.plot(Zsun, ratios)
plt.xlim([0.01, 1])
plt.ylim([1, 20])
plt.xscale("log")
plt.yscale("log")
plt.xlabel(r"$Z/Z_{\odot}$")
plt.ylabel(rf"{ratio_id}")
# plt.ylabel(rf'${get_ratio_label(ratio_id)}$')
plt.show()
We can also generate diagrams using pairs of line ratios, such as the famous Baldwin, Phillips & Terlevich (BPT) diagram.
line_ratios
also contains some classification regions (e.g. Kewley+13 and Kauffmann+03) that we can plot:
[12]:
diagram_id = "BPT-NII"
ia = 0 # 1 Myr old for test grid
x = []
y = []
for iZ, Z in enumerate(grid.metallicity):
grid_point = (ia, iZ)
lines = grid.get_lines(grid_point)
x_, y_ = lines.get_diagram(diagram_id)
x.append(x_)
y.append(y_)
# plot the Kewley SF/AGN dividing line
logNII_Ha = np.arange(-2.0, 1.0, 0.01)
logOIII_Hb = line_ratios.get_bpt_kewley01(logNII_Ha)
plt.plot(10**logNII_Ha, 10**logOIII_Hb, c="k", lw="2", alpha=0.3)
plt.plot(x, y)
plt.xlim([0.01, 10])
plt.ylim([0.05, 20])
plt.xscale("log")
plt.yscale("log")
# grab x and y labels, this time use "fancy" label ids
xlabel, ylabel = get_diagram_labels(diagram_id)
plt.xlabel(rf"${xlabel}$")
plt.ylabel(rf"${ylabel}$")
plt.show()