photometry
eventlab.photometry
Helpful functions for generating mock photometry for COSMIC, including extinction, converting absolute <-> apparent magnitudes, etc. Relies heavily on COGSWORTH's observables.photometry (https://cogsworth.readthedocs.io/en/latest/tutorials/observables/photometry.html) module, which interpolates over MIST bolometric corrections. Repackaged here for utility. Future work may try to integrate MESA Colors.
MISTBolometricCorrectionGrid
dataclass
Download, cache, and ingest MIST bolometric correction grids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bands
|
tuple[str]
|
tuple of photometric bands to include (e.g. ("2MASS_J", "2MASS_Ks"), or ("Bessell_B", "Bessell_V", "Bessel_I")) |
('2MASS_J', '2MASS_Ks')
|
cache_dir
|
Path
|
directory where tarballs, extracted files, and HDF5s are stored (default: ~/.MIST_bc_grids) |
expanduser()
|
Source code in src/eventlab/photometry.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
add_bands_photometry(df, bc_grid, metallicity=0.0142, av=0.0, teff_col='teff_1', mass_col='mass_1', rad_col='rad_1', lum_col='lum_1', suffix='_1', distance=None, silence_bounds_warning=False, bands=None, colors=None)
Add photometry in one or more bands (and any requested colors) to a DataFrame of stars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Must contain |
required |
bc_grid
|
MISTBolometricCorrectionGrid
|
Bolometric correction grid, built with |
required |
metallicity
|
float
|
Metallicity Z (mass fraction) applied to every star. Default (0.0142) is solar. |
0.0142
|
av
|
float
|
Visual extinction applied to every star. Default 0 (no extinction). |
0.0
|
teff_col
|
str
|
Name of the effective temperature column in |
'teff_1'
|
mass_col
|
str
|
Name of the mass column in |
'mass_1'
|
rad_col
|
str
|
Name of the radius column in |
'rad_1'
|
lum_col
|
str
|
Name of the luminosity column in |
'lum_1'
|
suffix
|
str
|
Suffix appended to every output column name (log_g, M_{band}, etc.), so results can be told apart when this is called more than once for different stars/objects. Defaults to '_1', matching COSMIC's convention for the primary; pass '_2' (or your own scheme) for the secondary, set suffix to the empty str if you plan to use once, etc. |
'_1'
|
distance
|
float
|
A single distance in kiloparsecs applied to every star. If given, apparent mags are also added. If None, only absolute mags are computed. |
None
|
silence_bounds_warning
|
bool
|
Whether to silence the out-of-bounds warning from the MIST BC grid. |
False
|
bands
|
tuple[str]
|
The tuple of bands to compute photometry for, e.g. ("Bessell_B", "Bessell_V").
Must match (or be a subset of) the bands |
None
|
colors
|
list[tuple[str, str]]
|
Pairs of bands to difference into a color, e.g. [("Bessell_B", "Bessell_V")]
computes B-V. Each band in a pair must be present in |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
Same DataFrame with added columns: log_g{suffix}, M_{band}{suffix} for each band (and m_{band}{suffix} if distance is given), plus {band0}-{band1}{suffix} for each requested color. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any requested band is not available in |
Examples:
>>> bc_grid = build_photo_grid(bands=("Bessell_B", "Bessell_V", "Bessel_I"))
>>> bcm = add_bands_photometry(bcm, bc_grid, bands=("Bessell_B", "Bessell_V", "Bessel_I"),
... colors=[("Bessell_B", "Bessell_V")],
... teff_col='teff_1', mass_col='mass_1', rad_col='rad_1',
... lum_col='lum_1', suffix='_1')
>>> bcm = add_bands_photometry(bcm, bc_grid, bands=("Bessell_B", "Bessell_V", "Bessel_I"),
... colors=[("Bessell_B", "Bessell_V")],
... teff_col='teff_2', mass_col='mass_2', rad_col='rad_2',
... lum_col='lum_2', suffix='_2')
Source code in src/eventlab/photometry.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
build_photo_grid(bands)
Build a MIST bolometric correction grid for an arbitrary pair of bands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bands
|
tuple[str]
|
A tuple of photometric bands to build the grid for, e.g.
("Bessell_B", "Bessell_V", "Bessel_I") or ("2MASS_J", "2MASS_Ks"). Must both
belong to the same MIST filter set (see |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bc_grid |
MISTBolometricCorrectionGrid
|
Grid set up for the given |
Source code in src/eventlab/photometry.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
get_absolute_bol_mag(lum)
Computes the absolute bolometric magnitude following IAU Resolution B2 (https://www.iau.org/news/announcements/detail/ann15023/)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lum
|
:class:`~astropy.units.Quantity` [luminosity]
|
Luminosity of the star |
required |
Returns:
| Name | Type | Description |
|---|---|---|
M_bol |
:class:`~numpy.ndarray`
|
Absolute bolometric magnitude |
Source code in src/eventlab/photometry.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
get_absolute_mag(m_app, distance)
Convert apparent magnitude to absolute magnitude
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_app
|
:class:`~numpy.ndarray`
|
Apparent magnitude |
required |
distance
|
:class:`~astropy.units.Quantity` [length]
|
Distance |
required |
Returns:
| Name | Type | Description |
|---|---|---|
M_abs |
:class:`~numpy.ndarray`
|
Absolute magnitude |
Source code in src/eventlab/photometry.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
get_apparent_mag(M_abs, distance)
Convert absolute magnitude to apparent magnitude
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
M_abs
|
:class:`~numpy.ndarray`
|
Absolute magnitude |
required |
distance
|
:class:`~astropy.units.Quantity` [length]
|
Distance |
required |
Returns:
| Name | Type | Description |
|---|---|---|
m_app |
:class:`~numpy.ndarray`
|
Apparent magnitude |
Source code in src/eventlab/photometry.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
get_log_g(mass, radius)
Computes log of the surface gravity in cgs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass
|
:class:`~astropy.units.Quantity` [mass]
|
Mass of the star |
required |
radius
|
:class:`~astropy.units.Quantity` [radius]
|
Radius of the star |
required |
Returns:
| Type | Description |
|---|---|
log g : :class:`~numpy.ndarray`
|
Log of the surface gravity in cgs |
Source code in src/eventlab/photometry.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |