events
- Define events over a
bcm(orbcm-like) dataframe via a boolean mask created with the helperbuild_maskor your own custom mask. Extract contiguous time intervals per binary/star where the mask holds and select summary statistics to report on columns of interest during the events withget_events. Include key information about binary interaction (whether underwent RLOF/CEE/No interaction before/during event, what stages (kstars) accreted or donated at, whether merged and what merger_type was) usinginclude_interaction_info=True(requires thebpp).
eventlab.events
Define an event of interest, and generate a catalog of the event from a COSMIC bcm/bpp including useful, user-specified, properties of the event-hosting-binary before and during the event.
build_mask(events, mask_list, mask_logic='and')
Combine the list of (column, op, val) conditions in mask_list into a single boolean
mask over events, using exact column names, according to the specified logic mask_logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
DataFrame
|
The dataframe to build the mask over (typically the COSMIC |
required |
mask_list
|
list of tuple
|
Each tuple is of the form |
required |
mask_logic
|
str
|
|
'and'
|
Returns:
| Name | Type | Description |
|---|---|---|
mask |
ndarray
|
Boolean array the same length as |
Examples:
>>> rsg_mask_1 = build_mask(bcm,
... [('lum_1', 'greater_equal', 1e4),
... ('lum_1', 'less_equal', 6e5),
... ('teff_1', 'greater_equal', 2900),
... ('teff_1', 'less_equal', 4500)],
... mask_logic='and')
>>> rsg_mask_2 = build_mask(bcm,
... [('lum_2', 'greater_equal', 1e4),
... ('lum_2', 'less_equal', 6e5),
... ('teff_2', 'greater_equal', 2900),
... ('teff_2', 'less_equal', 4500)],
... mask_logic='and')
>>> rsg_mask = rsg_mask_1 | rsg_mask_2
>>> mass_transfer_mask = build_mask(bcm,
... [('RRLO_1', 'greater', 1),
... ('RRLO_2', 'greater', 1)],
... mask_logic='or')
Source code in src/eventlab/events.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_events(bcm, mask, stats_dict=None, include_interaction_info=False, bpp=None)
Generate an event catalog: one row per contiguous interval where
mask holds (event may be instantaneous like CCSNe without issue), for each binary in bcm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bcm
|
DataFrame
|
The COSMIC |
required |
mask
|
ndarray
|
Boolean array, same length as |
required |
stats_dict
|
dict
|
Dictionary of |
None
|
include_interaction_info
|
bool
|
If True, augment each interval with pre-/during-event interaction
and merger history. Requires
|
False
|
bpp
|
DataFrame
|
The COSMIC |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
event_df |
DataFrame
|
One row per contiguous interval, sorted by
|
Examples:
>>> mask_1 = build_mask(bcm, [('kstar_1', 'equal', 7),
... ('mass_1', 'greater_equal', 2),
... ('mass_1', 'less_equal', 8)])
>>> mask_2 = build_mask(bcm, [('kstar_2', 'equal', 7),
... ('mass_2', 'greater_equal', 2),
... ('mass_2', 'less_equal', 8)])
>>> event_df_1 = get_events(bcm,
... mask_1,
... stats_dict={'teff_1': ['min', 'max'], 'lum_1': ['mean', 'median'], 'sep': ['first', 'last']},
... include_interaction_info=True,
... bpp=bpp)
>>> event_df_2 = get_events(bcm,
... mask_2,
... stats_dict={'teff_2': ['min', 'max'], 'lum_2': ['mean', 'median'], 'sep': ['first', 'last']},
... include_interaction_info=True,
... bpp=bpp)
>>> event_df_1['star'] = 1
>>> event_df_2['star'] = 2
>>> event_df = pd.merge(event_df_1, event_df_2, how='outer').sort_values(['bin_num', 'tphys_start']).reset_index(drop=True)
Source code in src/eventlab/events.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 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 | |