modeID

This module contains the mode identification class for PBjam.

The general mode ID strategy is to model the background + l=2,0 components separately from the l=1 modes, since the latter are often more computationally difficult.

This provides the inputs for the detailed peakbagging stage which is provided as a separate module.

Several plotting options are available to display the results, including echelle, spectrum and corner.

class pbjam.modeID.modeID(f, s, obs, addPriors={}, N_p=7, freqLimits=None, priorPath=None, **kwargs)[source]

Class for identifying modes in solar-like oscillators.

Parameters:
  • f (array-like) – The frequency array of the spectrum.

  • s (array-like) – The values of the power density spectrum.

  • obs (dict) – Dictionary of observational inputs.

  • addPriors (dict, optional) – Additional priors to be added. Default is an empty dictionary.

  • N_p (int, optional) – Number of radial orders to use for mode identification. Default is 7.

  • freqLimits (list, optional) – Frequency limits for mode identification. If None, it is calculated based on ‘numax’ and ‘dnu’.

  • priorPath (str, optional) – Path to prior sample csv. If None, a default path is used.

__call__(model='auto', progress=True, dynamic=False, sampler_kwargs={}, logl_kwargs={}, **kwargs)[source]

Run both the l20 and l1 models.

The results are stored in the modeID.result dictionary after each step is completed.

Parameters:
  • progress (bool, optional) – Whether to show progress during the model run. Default is True.

  • sampler_kwargs (dict, optional) – Additional keyword arguments for the sampler. Default is an empty dictionary.

  • logl_kwargs (dict, optional) – Additional keyword arguments for the log-likelihood function. Default is an empty dictionary.

mergeResults(l20result=None, l1result=None, N=5000)[source]

Merges results from l20 and l1 models into a single result dictionary.

Attempts to include N samples from both models, but will use the lowest common value in case one of the models returns less than N samples.

Note that if l20 and l1 share any parameters (like numax and dnu) the results from the l20 model are used since they are probably a bit more reliable.

Parameters:
  • l20result (dict, optional) – The result dictionary from the l20 model.

  • l1result (dict, optional) – The result dictionary from the L1 model.

  • N (int, optional) – The number of samples to include in the merged results. Default is 5000.

Returns:

R – A dictionary containing merged results from the l20 and l1 models.

Return type:

dict

runl1model(progress=True, dynamic=False, minSamples=5000, sampler_kwargs={}, logl_kwargs={}, model='auto', PCAsamples=500, PCAdims=7, **kwargs)[source]

Runs the l1 model on the selected spectrum.

Should follow the l20 model run.

Parameters:
  • progress (bool, optional) – Whether to show progress during the model run. Default is True.

  • dynamic (bool, optional) – Whether to use dynamic nested sampling. Default is False (static nested sampling).

  • minSamples (int, optional) – The minimum number of samples to generate. Default is 5000.

  • sampler_kwargs (dict, optional) – Additional keyword arguments for the sampler. Default is an empty dictionary.

  • logl_kwargs (dict, optional) – Additional keyword arguments for the log-likelihood function. Default is an empty dictionary.

  • model (str) – Choice of which model to use for estimating the l=1 mode locations. Choices are MS, SG, RGB models.

  • PCAsamples (int, optional) – Number of samples for PCA. Default is 100.

  • PCAdims (int, optional) – Number of dimensions for PCA. Default is 5.

Returns:

result – Parsed results from the l1 model.

Return type:

dict

runl20model(progress=True, dynamic=False, minSamples=5000, sampler_kwargs={}, logl_kwargs={}, PCAsamples=50, PCAdims=6, **kwargs)[source]

Runs the l20 model on the selected spectrum.

Parameters:
  • progress (bool, optional) – Whether to show progress during the model run. Default is True.

  • dynamic (bool, optional) – Whether to use dynamic nested sampling. Default is False (static nested sampling).

  • minSamples (int, optional) – The minimum number of samples to generate. Default is 5000.

  • logl_kwargs (dict, optional) – Additional keyword arguments for the log-likelihood function. Default is an empty dictionary.

  • PCAsamples (int, optional) – Number of samples for PCA. Default is 50.

  • PCAdims (int, optional) – Number of dimensions for PCA. Default is 6.

Returns:

result – Parsed results from the l20 model.

Return type:

dict

selectModel()[source]

Select the appropriate stellar model based on observed properties.

The method classifies the star as either ‘ms’ (main sequence), ‘sg’ (subgiant), or ‘rgb’ (red giant branch) using thresholds based on the large frequency separation (dnu) and effective temperature (Teff).

Returns:

model – The selected model as a string: ‘ms’, ‘sg’, or ‘rgb’.

Return type:

str

Notes

The classification uses linear relations: - Main sequence (MS): dnu > -0.016 * Teff + 157 - Subgiant (SG): dnu > -0.010 * Teff + 74 - Red giant branch (RGB): Default if neither condition is satisfied.

Examples

>>> obj.obs = {'dnu': 100, 'Teff': 5800}
>>> obj.selectModel()
'sg'
>>> obj.obs = {'dnu': 120, 'Teff': 6000}
>>> obj.selectModel()
'ms'
>>> obj.obs = {'dnu': 50, 'Teff': 5000}
>>> obj.selectModel()
'rgb'
storeResult(resultDict, path=None, ID=None)[source]

Stores the results in a specified directory with identifier. The results are stored as a pickled Python dictionary file and a CSV file. The pickle file contains all results, while the CSV file contains only the summary model parameters.

Parameters:
  • resultDict (dict) – The dictionary containing the results to be stored.

  • path (str, optional) – The directory path where the results should be stored. If None, it defaults to the current directory.

  • ID (str, optional) – A unique identifier for the stored results. If None, a random identifier is generated.