### Python Interface Quick Start Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md A basic example demonstrating how to initialize BayeSED3 using its Python interface. This is useful for quick tests and understanding the fundamental setup. ```python from bayesed3 import BayeSED3 bayesed3 = BayeSED3() ``` -------------------------------- ### Compile and Install OpenMPI from Source Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Steps to compile and install OpenMPI version 4.1.6 from source code. ```bash cd BayeSED3 wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.gz tar xzvf openmpi-4.1.6.tar.gz cd openmpi-4.1.6 ./configure --prefix=$PWD/../openmpi make make install ``` -------------------------------- ### MultiNest C/C++ Interface Example Source: https://github.com/hanyk/bayesed3/blob/main/README_multinest.txt Starting from v2.18, MultiNest offers a common C/C++ interface located in the 'includes' directory. Example usage can be found in the example_eggboxC and example_eggboxC++ directories. Modifications to multinest.h might be necessary. ```text You may need to check the symbol table for your platform (nm libmulitnest.a | grep nestrun) and edit the multinest.h file to define NESTRUN. Please let us know of any modifications made so they may be included in future releases. ``` -------------------------------- ### Run All BayeSED3 Examples Source: https://github.com/hanyk/bayesed3/blob/main/tests/README.md Execute all BayeSED3 Python examples and generate a summary report. This command should be run from the project root directory. ```bash python tests/run_all_examples.py ``` -------------------------------- ### Pip Install BayeSED3 (Regular) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Perform a regular pip installation of BayeSED3 from the repository root. This method is recommended for production use. ```bash pip install . ``` -------------------------------- ### Manual OpenMPI Installation Source: https://github.com/hanyk/bayesed3/blob/main/index.html Manually install OpenMPI if automatic installation is not preferred. This involves downloading, extracting, configuring, and installing OpenMPI. ```bash wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.gz tar xzvf openmpi-4.1.6.tar.gz cd openmpi-4.1.6 ./configure --prefix=$PWD/../openmpi make make install ``` -------------------------------- ### Run High-Level Python Interface Examples Source: https://github.com/hanyk/bayesed3/blob/main/CLAUDE.md Execute high-level Python interface examples for various functionalities of BayeSED3. ```bash # High-level Python interface examples python tests/quick_start.py python tests/test_agn_fitting.py python tests/test_data_arrays.py python tests/test_custom_model.py python tests/test_multi_model_comparison.py python tests/test_advanced_analytics.py python tests/test_prior_management.py python tests/test_bayesed_bagpipes_comparison.py python tests/run_all_examples.py ``` -------------------------------- ### Start Simple and Extend Gradually Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Begin with basic configurations using builder methods and incrementally add components and advanced parameters. ```python from bayesed.model import SEDModel from bayesed.params import SysErrParams # Step 1: Start simple params = BayeSEDParams.galaxy('input.txt') # Step 2: Add AGN components using SEDModel.create_agn() agn = SEDModel.create_agn(agn_components=['dsk', 'blr']) agn.add_disk_bbb() # Or use add_disk_agn(), add_disk_fann(), add_disk_aknn() params.add_agn(agn) # Auto-assigns IDs # Step 3: Customize advanced parameters params.configure_multinest(nlive=1000, efr=0.3) params.sys_err_obs = SysErrParams(iprior_type=3, min=0.01, max=0.1) ``` -------------------------------- ### Run BayeSED3 (CLI Example) Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Execute BayeSED3 using its command-line interface to plot galaxy data. ```bash python run_test.py gal plot ``` -------------------------------- ### Install OpenMPI via System Package Manager (Fedora) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install OpenMPI using the dnf package manager on Fedora systems. ```bash sudo dnf install openmpi openmpi-devel ``` -------------------------------- ### Filter Definition File Example Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Example path to a filter definition file, which contains wavelength coverage and response functions. ```plaintext observation/test1/filters_COSMOS_CSST_Euclid_LSST_WFIRST.txt ``` -------------------------------- ### AGN Host Decomposition Example Source: https://github.com/hanyk/bayesed3/blob/main/skills/bayesed3/references/binary-cli.md Example for AGN host decomposition, including galaxy, dust, torus, and a QSO template. This demonstrates fitting composite objects with multiple spectral energy distribution components. ```bash ./bin/linux/bayesed_mn_1 -v 2 \ --Ntest 4 \ -i 0,observation/agn_host_decomp/sample.txt \ --filters observation/agn_host_decomp/filters.txt \ --filters_selected observation/agn_host_decomp/filters_selected_total_only.txt \ --ssp 0,0,bc2003_lr_BaSeL_chab,1,1,1,0,0,0,0,0 \ --sfh 0,8,0,1 --dal 0,2,8 \ -gb 0,1,gb,-2,1,1,1000,200 \ -a 1,2,clumpy201410tor,1 \ -t 1,3,QSO1,-1 --dal 3,2,7 \ --sys_err_obs 3,0,0.01,0.2,40 \ --luminosity -1,0.25,0.25 \ --outdir observation/agn_host_decomp/output \ --suffix _total_only \ --multinest 1,0,0,400,0.3,0.5,1000,-1e90,1,1,0,0,-1e90,100000,0.01 \ --save_bestfit 0 --save_sample_par ``` -------------------------------- ### Run BayeSED3 (Python Interface) Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Initiate BayeSED3 using its Python interface. This example shows the basic import statement. ```python from bayesed import BayeSEDInterface; ... ``` -------------------------------- ### Install BayeSED3 using Pip Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Install BayeSED3 system-wide using pip. This method is recommended for convenience and allows usage from any directory. ```bash pip install . ``` ```bash pip install -e . ``` -------------------------------- ### Full AGN + Galaxy + Torus Example Source: https://github.com/hanyk/bayesed3/blob/main/skills/bayesed3/references/agn-fitting.md An example combining host galaxy, AGN components, and a dust torus using the `SEDModel` and `BayeSEDInterface`. This demonstrates assembling a complex model from modular components. ```python from bayesed.model import SEDModel bayesed = BayeSEDInterface(mpi_mode='auto') # Create host galaxy (with dust emission) galaxy = SEDModel.create_galaxy( ssp_model='bc2003_lr_BaSeL_chab', sfh_type='exponential', dal_law='smc' ) galaxy.add_dust_emission() # Create AGN (with torus) agn = SEDModel.create_agn() agn.add_torus_fann(name='clumpy201410tor') # Assemble parameters params = BayeSEDParams( input_type=0, input_file='observation/test2/test.txt', outdir='tests/output_agn_torus', filters='observation/test2/filters.txt', filters_selected='observation/test2/filters_selected.txt', save_sample_par=True ) params.add_galaxy(galaxy) params.add_agn(agn) bayesed.run(params) ``` -------------------------------- ### QSO Multi-Component Spectroscopic Fit Example Source: https://github.com/hanyk/bayesed3/blob/main/skills/bayesed3/references/binary-cli.md Example for fitting a QSO with multiple components, including broad and narrow line regions, and FeII emission. This demonstrates complex spectral fitting with various model components. ```bash ./bin/linux/bayesed_mn_1 -v 2 \ -i 0,observation/test/qso.txt \ --outdir observation/test/output/qso \ --ssp 0,0,bc2003_hr_stelib_chab_neb_2000r,1,1,1,1,0,1,0,0 \ --sfh 0,2,0,0 --dal 0,2,8 \ --rename 0,1,Stellar+Nebular \ -bbb 1,1,bbb,1,0.1,10,1000 --dal 1,2,7 \ -ls1 2,2,BLR,1,observation/test/lines_BLR.txt,300,2,3 \ -k 3,3,FeII,1,1,1,0,0,1,1,1 --kin 3,10,2,0 \ -ls1 4,4,NLR,1,observation/test/lines_NLR.txt,2000,2,2 \ --sys_err_obs 1,0,0.0,0.2,40 \ --multinest 1,0,1,40,0.05,0.5,100,-1e90,1,2,0,0,-1e90,100000,0.01 \ --save_bestfit 0 --save_sample_par ``` -------------------------------- ### Filter Selection File Example Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Example path to a filter selection file, used to specify which filters to include in the analysis. ```plaintext observation/test1/filters_CSST_seleted.txt ``` -------------------------------- ### MPI Parallel Execution Example Source: https://github.com/hanyk/bayesed3/blob/main/skills/bayesed3/references/binary-cli.md Example demonstrating how to run bayesed3 in parallel using MPI. This involves replacing the executable name and prepending the mpirun command. ```bash mpirun --use-hwthread-cpus ./bin/linux/bayesed_mn_n -v 2 \ -i 0,observation/test/gal.txt \ --outdir observation/test/output/gal \ ... (same options as single-process) ``` -------------------------------- ### Install OpenMPI via System Package Manager (macOS Homebrew) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install OpenMPI using the Homebrew package manager on macOS. ```bash brew install openmpi ``` -------------------------------- ### Install OpenMPI via System Package Manager (Ubuntu/Debian) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install OpenMPI using the apt-get package manager on Ubuntu or Debian systems. ```bash sudo apt-get install openmpi-bin openmpi-common libopenmpi-dev ``` -------------------------------- ### Pip Install BayeSED3 (Editable) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Perform an editable pip installation of BayeSED3 from the repository root. This method is ideal for development as changes are immediately visible. ```bash pip install -e . ``` -------------------------------- ### Install HDF5 Utilities (Ubuntu/Debian) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install HDF5 utilities on Ubuntu or Debian systems using the apt-get package manager. These utilities are optional. ```bash sudo apt-get install h5utils ``` -------------------------------- ### Example Input Data Header Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md An example of a header line for an input data file, indicating 54 photometric bands, 490 additional columns, and 3 spectroscopic bands. ```plaintext # test_inoise1 54 490 3 ``` -------------------------------- ### MultiNest Starting Log Source: https://github.com/hanyk/bayesed3/blob/main/observation/agn_host_decomp/demo.ipynb Indicates the start of the MultiNest sampling process. No specific setup is required to view this log. ```text Starting MultiNest ``` -------------------------------- ### Alternative using Builder Methods Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Demonstrates a concise way to start building a galaxy configuration using a builder method, which can then be extended with other components. ```python params = BayeSEDParams.galaxy('combined.txt', ssp_model='bc2003_lr_BaSeL_chab', dal_law='smc') # Then add AGN components... ``` -------------------------------- ### Set Emission Lines from File Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Use the -ls or --lines option to set emission lines from a file. The example specifies parameters for starting group and ID, file, scalability, and spectral resolution. ```bash -ls igroup_start,id_start,file,iscalable,0.0,R,Nsample,Nkin ``` -------------------------------- ### Simple Galaxy Fitting with BayeSED Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Performs a simple galaxy fitting analysis using BayeSED. This example demonstrates the basic setup for galaxy fitting with specified input and output paths, stellar population model, star formation history type, and dust attenuation law. ```python # Simple galaxy fitting params = BayeSEDParams.galaxy( input_file='input.txt', outdir='output', ssp_model='bc2003_hr_stelib_chab_neb_2000r', sfh_type='exponential', dal_law='calzetti' ) bayesed.run(params) ``` -------------------------------- ### Prepare Observation Data and Run Analysis Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Sets up observational data from arrays, creates an input catalog, downloads necessary filters, and runs the BayeSED analysis. This method is recommended for complex setups. ```python import numpy as np from bayesed import BayeSEDInterface, BayeSEDParams from bayesed.data import SEDObservation from bayesed.model import SEDModel from bayesed.utils import create_filters_from_svo import os # Step 1: Create observation data obs = SEDObservation( ids=[1, 2, 3], z_min=[0.1, 0.2, 0.3], z_max=[0.2, 0.3, 0.4], phot_filters=['SLOAN/SDSS.u', 'SLOAN/SDSS.g', 'SLOAN/SDSS.r'], phot_fluxes=np.array([[10.0, 20.0, 30.0], [15.0, 25.0, 35.0], [20.0, 30.0, 40.0]]), phot_errors=np.array([[1.0, 2.0, 3.0], [1.5, 2.5, 3.5], [2.0, 3.0, 4.0]]), input_type=0 # Flux in μJy ) obs.validate() # Step 2: Create input catalog file os.makedirs('observation/my_analysis', exist_ok=True) input_file = obs.to_bayesed_input('observation/my_analysis', 'input_catalog') # Step 3: Download filters (optional) filter_dir = 'observation/my_analysis/filters' os.makedirs(filter_dir, exist_ok=True) create_filters_from_svo( svo_filterIDs=['SLOAN/SDSS.u', 'SLOAN/SDSS.g', 'SLOAN/SDSS.r'], filters_file=os.path.join(filter_dir, 'filters.txt'), filters_selected_file=os.path.join(filter_dir, 'filters_selected.txt') ) # Step 4: Create model using class-based approach (recommended) galaxy = SEDModel.create_galaxy( ssp_model='bc2003_hr_stelib_chab_neb_2000r', sfh_type='exponential', dal_law='calzetti' ) # Step 5: Create parameters and add observation/model params = BayeSEDParams( input_type=0, input_file=input_file, outdir='observation/my_analysis/output', filters=os.path.join(filter_dir, 'filters.txt'), filters_selected=os.path.join(filter_dir, 'filters_selected.txt') ) params.add_galaxy(galaxy) # Step 6: Run analysis bayesed = BayeSEDInterface(mpi_mode='auto') result = bayesed.run(params) ``` -------------------------------- ### Install BayeSED3 Package Source: https://github.com/hanyk/bayesed3/blob/main/CLAUDE.md Install the BayeSED3 package using pip for editable or regular installs, or via conda. ```bash pip install -e . # Editable install for development pip install . # Regular install for production conda build conda/ && conda install --use-local bayesed3 # Conda install ``` -------------------------------- ### Creating New Instances and Extending Before Adding Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Demonstrates creating a galaxy instance, extending it with dust emission, and then using it to build the main parameter configuration. ```python from bayesed.model import SEDModel # Create galaxy instance and extend it before creating params galaxy = SEDModel.create_galaxy( ssp_model='bc2003_hr_stelib_chab_neb_2000r', sfh_type='exponential', dal_law='calzetti' ) galaxy.add_dust_emission() # Add dust emission to instance ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/hanyk/bayesed3/blob/main/index.html Install BayeSED3 and its Python dependencies using pip. This command installs the package in editable mode. ```bash pip install -e . ``` -------------------------------- ### Install OpenMPI via Conda Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install OpenMPI version 4.1.6 using the conda package manager. This is the recommended method for installing OpenMPI. ```bash conda install -c conda-forge openmpi=4.1.6 ``` -------------------------------- ### Display Help Message Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Run this command to display the full list of available command-line options for BayeSED3. ```bash ./bayesed --help ``` -------------------------------- ### Install BayeSED3 Conda Package Source: https://github.com/hanyk/bayesed3/blob/main/conda/README.md Use this command to install the BayeSED3 package for general users. ```bash conda install -c conda-forge bayesed3 ``` -------------------------------- ### Install tkinter (macOS Homebrew) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install the tkinter library on macOS using Homebrew. tkinter is required for the GUI. ```bash brew install python-tk ``` -------------------------------- ### Install OpenMPI Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Install OpenMPI, a required dependency for BayeSED3. This can be done using conda or system package managers. ```bash conda install openmpi=4.1.6 ``` ```bash # Or via system: brew install openmpi (macOS) or apt-get install openmpi-bin (Linux) ``` -------------------------------- ### Complete Workflow with Custom Priors Source: https://github.com/hanyk/bayesed3/blob/main/skills/bayesed3/references/prior-management.md Demonstrates a full workflow including parameter setup, custom prior definition, and running the Bayesian analysis. Ensure priors are set BEFORE calling `bayesed.run()`. ```python from bayesed import BayeSEDInterface, BayeSEDParams, SEDInference bayesed = BayeSEDInterface(mpi_mode='auto') # 1. Create parameters params = BayeSEDParams.galaxy( input_file='observation/test/gal.txt', outdir='tests/output_custom_prior', ssp_model='bc2003_hr_stelib_chab_neb_2000r', sfh_type='exponential', dal_law='calzetti' ) # 2. Customize priors (BEFORE run) inference = SEDInference() inference.priors_init(params) # Set priors based on physical constraints inference.set_prior('log(age/yr)', min_val=8.0, max_val=10.1) # 0.1Gyr - 13Gyr inference.set_prior('log(tau/yr)', min_val=7.0, max_val=10.5) # SFH timescale inference.set_prior('Av_2', min_val=0.0, max_val=4.0) # extinction inference.set_prior('log(Z/Zsun)', min_val=-2.0, max_val=0.5) # metallicity # 3. Run (priors are now active) result = bayesed.run(params) ``` -------------------------------- ### Install tkinter (Fedora) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install the tkinter library for Python 3 on Fedora systems using dnf. tkinter is required for the GUI. ```bash sudo dnf install python3-tkinter ``` -------------------------------- ### Low-Level Configuration Example: Extending Models with Builder Methods Source: https://github.com/hanyk/bayesed3/blob/main/docs/BayeSED3.md Demonstrates how to extend models created with builder methods in the low-level interface of BayeSED3. This allows for custom model components. ```python from bayesed3.core import ModelBuilder builder = ModelBuilder() model = builder.build_stellar_population(library="bc03", age=5.0) # ... further customize or add components to the model ... ``` -------------------------------- ### Install HDF5 Utilities (macOS Homebrew) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install HDF5 utilities on macOS using the Homebrew package manager. These utilities are optional. ```bash brew install h5utils ``` -------------------------------- ### Install HDF5 Utilities (Fedora) Source: https://github.com/hanyk/bayesed3/blob/main/README.md Install HDF5 utilities on Fedora systems using the dnf package manager. These utilities are optional. ```bash sudo dnf install hdf5-tools ``` -------------------------------- ### Configure and Run BayeSED3 with Bash Source: https://github.com/hanyk/bayesed3/blob/main/observation/agn_host_decomp/demo.ipynb This script sets up parameters for BayeSED3, including MultiNest settings, galaxy model components (SSP, SFH, DAL), dust emission, and AGN models. It defines paths for observational data and filters, and specifies the input sample file. Use this script to launch BayeSED3 simulations from the bash shell. ```bash %%bash #./observation/agn_host_decomp/run bayesed="./bin/mac/bayesed_mn_1 -v 2" mpirun="./openmpi/bin/mpirun --use-hwthread-cpus" nlive=400 efr=0.3 tol=0.5 seed=1 verbose=1 multinest="--multinest 1,0,0,$nlive,$efr,$tol,1000,-1e90,$seed,$verbose,0,0,-1e90,100000,0.01" #see README_multinest.txt for the meaning of multinest parameters #models="--ssp 0,0,bc2003_lr_BaSeL_chab,1,1,1,0,0,0,0,0 --sfh 0,8,0,1 --dal 0,2,8 -a 1,2,clumpy201410tor,1 -t 1,3,QSO1,-1 --dal 3,2,7" #models="--ssp 0,0,bc2003_lr_BaSeL_chab,1,1,1,0,0,0,0,0 --sfh 0,8,0,1 --dal 0,2,8 -gb 0,1,gb,-2,1,1,1000,200 -a 1,2,clumpy201410tor,1 -t 1,3,QSO1,-1 --dal 3,2,7" #galaxy model: simple stellar population (SSP), star formation history (SFH), and dust attenuation law (DAL) galaxy="" galaxy+=" --ssp 0,0,bc2003_lr_BaSeL_chab,1,1,1,0,0,0,0,0" galaxy+=" --sfh 0,8,0,1" galaxy+=" --dal 0,2,8" #dust emission model: greybody dust="-gb 0,1,gb,-2,1,1,1000,200" #AGN model AGN_torus="-a 1,2,clumpy201410tor,1" AGN_disk="-t 1,3,QSO1,-1 --dal 3,2,7" models="$galaxy $dust $AGN_torus $AGN_disk" # set the path to the observational data and configuration files obs="./observation/agn_host_decomp" #definition and selection of filters filters="--filters $obs/filters.txt --filters_selected $obs/filters_selected.txt" # set the path of input file input="-i 0,$obs/sample.txt" ```