Catalogue Fitting

Synference has a method specifically for fitting catalogues of sources - fit_catalogue.

This is designed to be a flexible and fast way to fit your full catalogue.

It can handle:

  1. Transforming observations to match the expected model features.

  2. Prior predictive checks/outlier detection to remove sources that are unlikely to be well modelled.

  3. Optional imputation of missing data.

  4. Rapid posterior inference using trained model.

  5. Optional SED recovery (see this notebook for more details).

  6. Returning structured results.

[1]:
import os

import numpy as np
from IPython.display import display
from synthesizer import get_grids_dir
from unyt import Jy

from synference import SBI_Fitter, load_unc_model_from_hdf5, test_data_dir

print(get_grids_dir())

available_grids = os.listdir(get_grids_dir())
if "test_grid.hdf5" not in available_grids:
    cmd = f"synthesizer-download --test-grids --destination {get_grids_dir()}"
    os.system(cmd)

library_path = os.path.join(get_grids_dir(), "test_grid.hdf5")
/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
/home/runner/.local/share/Synthesizer/grids

We’ll use a subset of the JADES spectroscopic catalogue used in the synference paper for this example.

[2]:
from astropy.table import Table

cat = Table.read(f"{test_data_dir}/jades_spec_catalogue_subset.fits")

The first step is the same as our SED recovery example - we will load our trained model and the noise model used to train the model. We need the noise model to transform our observations to match the model features.

[3]:
library_path = (
    f"{test_data_dir}/grid_BPASS_Chab_DenseBasis_SFH_0.01_z_14_logN_2.7_Calzetti_v3_multinode.hdf5"  # noqa: E501
)

fitter = SBI_Fitter.load_saved_model(
    model_file=f"{test_data_dir}", library_path=library_path, device="cpu"
)

nm_path = f"{test_data_dir}/BPASS_DenseBasis_v4_final_nsf_0_params_empirical_noise_models.h5"
noise_models = load_unc_model_from_hdf5(nm_path)

fitter.feature_array_flags["empirical_noise_models"] = noise_models
2025-11-13 20:09:59,354 | synference | INFO     | Loaded model from /home/runner/.local/share/Synthesizer/data/synference/BPASS_DenseBasis_v4_final_nsf_0_posterior.pkl.
2025-11-13 20:09:59,355 | synference | INFO     | Device: cpu
2025-11-13 20:09:59,398 | synference | WARNING  | IndexError when trying to set train/test arrays.

Now we need to explain our catalogue to synference. We create a ‘conversion_dict’ dictionary which maps the feature names to columns in the table. The expected column names for flux are the SVO format filter names, e.g. JWST/NIRCam.F070W, or just F070W if it is unambiguous. For flux errors it is the same, but with ‘unc_’ prefixed, e.g. unc_JWST/NIRCam.F070W or unc_F070W. Any other features (e.g. redshift) should be mapped to the column name in the catalogue.

In this case our catalogue is almost in the correct format, so we just need to convert the band names to include the facility and instrument. We do this by getting the band names from the fitted model (fitter.feature_names) and replacing the relevant parts of the strings.

We then create our conversion dictionary to map from e.g. ‘unc_F200W’ to ‘unc_JWST/NIRCam.F200W’.

[4]:
def band_to_instrument(band):
    """Band name to instrument mapping."""
    if band in ["F435W", "F606W", "F775W", "F814W", "F850LP"]:
        return f"HST/ACS_WFC.{band}"
    return f"JWST/NIRCam.{band}"


bands = [
    i.split(".")[-1]
    for i in fitter.feature_names
    if not (i.startswith("unc_") or i.startswith("redshift"))
]

print(bands)

conversion_dict = {band: band_to_instrument(band) for band in bands}
conversion_dict.update({f"unc_{band}": f"unc_{band_to_instrument(band)}" for band in bands})
conversion_dict["redshift"] = "redshift"

conversion_dict
['F435W', 'F606W', 'F775W', 'F814W', 'F850LP', 'F090W', 'F115W', 'F150W', 'F200W', 'F277W', 'F335M', 'F356W', 'F410M', 'F444W']
[4]:
{'F435W': 'HST/ACS_WFC.F435W',
 'F606W': 'HST/ACS_WFC.F606W',
 'F775W': 'HST/ACS_WFC.F775W',
 'F814W': 'HST/ACS_WFC.F814W',
 'F850LP': 'HST/ACS_WFC.F850LP',
 'F090W': 'JWST/NIRCam.F090W',
 'F115W': 'JWST/NIRCam.F115W',
 'F150W': 'JWST/NIRCam.F150W',
 'F200W': 'JWST/NIRCam.F200W',
 'F277W': 'JWST/NIRCam.F277W',
 'F335M': 'JWST/NIRCam.F335M',
 'F356W': 'JWST/NIRCam.F356W',
 'F410M': 'JWST/NIRCam.F410M',
 'F444W': 'JWST/NIRCam.F444W',
 'unc_F435W': 'unc_HST/ACS_WFC.F435W',
 'unc_F606W': 'unc_HST/ACS_WFC.F606W',
 'unc_F775W': 'unc_HST/ACS_WFC.F775W',
 'unc_F814W': 'unc_HST/ACS_WFC.F814W',
 'unc_F850LP': 'unc_HST/ACS_WFC.F850LP',
 'unc_F090W': 'unc_JWST/NIRCam.F090W',
 'unc_F115W': 'unc_JWST/NIRCam.F115W',
 'unc_F150W': 'unc_JWST/NIRCam.F150W',
 'unc_F200W': 'unc_JWST/NIRCam.F200W',
 'unc_F277W': 'unc_JWST/NIRCam.F277W',
 'unc_F335M': 'unc_JWST/NIRCam.F335M',
 'unc_F356W': 'unc_JWST/NIRCam.F356W',
 'unc_F410M': 'unc_JWST/NIRCam.F410M',
 'unc_F444W': 'unc_JWST/NIRCam.F444W',
 'redshift': 'redshift'}

Now we can run the inference. We specify the catalogue table, the conversion dictionary, the input flux units (Jy), and then we have some choices.

We can choose to:

  1. Run predictive checks to remove outliers.

  2. Impute or remove missing data.

  3. Run posterior inference, setting the number of posterior samples to draw.

  4. Recover SEDs for each source.

[5]:
fitter.recreate_simulator_from_library(
    override_library_path=library_path, override_grid_path="test_grid.hdf5"
)

post_tab = fitter.fit_catalogue(
    cat,
    columns_to_feature_names=conversion_dict,
    flux_units=Jy,
    check_out_of_distribution=False,
    recover_SEDs=False,
    missing_data_flag=np.nan,
    num_samples=300,
    append_to_input=False,
)
2025-11-13 20:09:59,444 | synference | INFO     | Overriding internal library name from provided file path.
2025-11-13 20:09:59,708 | synference | WARNING  | Failed to load cosmology from HDF5. Using Planck18 instead.
2025-11-13 20:10:09,213 | synference | INFO     | Updated filters: ['HST/ACS_WFC.F435W', 'HST/ACS_WFC.F606W', 'HST/ACS_WFC.F775W', 'HST/ACS_WFC.F814W', 'HST/ACS_WFC.F850LP', 'JWST/NIRCam.F090W', 'JWST/NIRCam.F115W', 'JWST/NIRCam.F150W', 'JWST/NIRCam.F200W', 'JWST/NIRCam.F277W', 'JWST/NIRCam.F335M', 'JWST/NIRCam.F356W', 'JWST/NIRCam.F410M', 'JWST/NIRCam.F444W']
2025-11-13 20:10:09,216 | synference | INFO     | Simulator recreated from library at /home/runner/.local/share/Synthesizer/data/synference/grid_BPASS_Chab_DenseBasis_SFH_0.01_z_14_logN_2.7_Calzetti_v3_multinode.hdf5.
2025-11-13 20:10:09,217 | synference | INFO     | Auto applying inverse log10 transform for log10_Av.
2025-11-13 20:10:09,217 | synference | INFO     | Auto applying inverse log10 transform for log10_mass_weighted_age.
2025-11-13 20:10:09,218 | synference | INFO     | Auto applying inverse log10 transform for log10_floor_sfr_10.
2025-11-13 20:10:09,218 | synference | INFO     | Adding Av to tau_v transform.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
2025-11-13 20:10:09,229 | synference | INFO     | Removing 54 observations with missing data.
Sampling from posterior: 100%|██████████| 76/76 [00:04<00:00, 16.56it/s]
2025-11-13 20:10:13,822 | synference | INFO     | Obtained posterior samples.

We can look at the output table, which is also an astropy.table.Table.

[6]:
post_tab
[6]:
Table length=99
IDlog_mass_16log_mass_50log_mass_84log10metallicity_16log10metallicity_50log10metallicity_84log10_Av_16log10_Av_50log10_Av_84log_sfr_16log_sfr_50log_sfr_84sfh_quantile_25_16sfh_quantile_25_50sfh_quantile_25_84sfh_quantile_50_16sfh_quantile_50_50sfh_quantile_50_84sfh_quantile_75_16sfh_quantile_75_50sfh_quantile_75_84log10_mass_weighted_age_16log10_mass_weighted_age_50log10_mass_weighted_age_84log10_floor_sfr_10_16log10_floor_sfr_10_50log10_floor_sfr_10_84log_surviving_mass_16log_surviving_mass_50log_surviving_mass_84beta_16beta_50beta_84
int64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64
19.93818225860595710.08381319046020510.243552284240723-3.9550020122528076-3.828235387802124-3.565597581863403-0.3131781733036041-0.184641033411026-0.069180442094802850.166934614777565050.518632322549820.76216531276702880.069472571313381190.205313943326473240.446987043619155870.30398342609405520.54643777012825010.76987926721572870.63277117967605590.88510638475418090.96233703851699833.1892847156524663.38181531429290773.5067478847503660.174030547738075280.51065075397491460.75698069810867319.7060162353515629.8278532028198249.96968864440918-1.4129000425338745-1.2808820009231567-1.1722686290740967
29.169478988647469.3802270889282239.533154487609863-3.9187659072875975-3.7546868324279785-3.4933716106414794-2.943922929763794-2.776110053062439-2.2409004497528078-1.0223817014694214-0.7864253520965576-0.60370614528656010.0609172058105468960.208282671868801120.487883340120315530.243001949191093470.51325181126594540.76041124582290650.44616155624389650.78569367527961730.9280726575851443.3406844806671143.55735969543457033.6869903659820555-1.116567554473877-0.8343653082847595-0.69635192871093758.914553070068369.0980391502380379.238429145812988-1.9138937044143676-1.7762314677238464-1.5578833723068237
310.5305300903320310.69282913208007810.83322998046875-3.595937671661377-3.1261976957321167-2.7718205928802490.080122537612915050.171328626573085780.225454200506210321.20775824546813971.53276222944259641.70678815364837640.072603593170642860.226910948753356930.51930483341217040.27327512025833130.59907701611518860.85170631408691410.7943832826614380.94720345735549930.98425491333007812.997534570693973.1758314371109013.3499377632141111.13644842147827151.51174390316009521.682841277122497610.32290634155273410.46907281875610410.588120422363282-0.6779753065109253-0.458346426486969-0.27817421674728393
410.32987617492675810.4723138809204110.58506046295166-2.953227691650391-2.6161922216415405-2.3888746166229247-1.540432834625244-0.5732389688491821-0.2879416954517365-1.436713728904724-1.0432096719741821-0.74306838989257820.027405983656644820.117424532771110530.327608937025070160.14904454767704010.33442716300487520.53594276428222650.31992431282997130.47041922807693480.61715431451797493.55655630111694343.6558357477188113.7220150947570803-1.5357025957107544-1.137833595275879-0.854645693302154610.04312007904052710.1819777488708510.286999282836915-0.458580836057662870.41112050414085391.0012610626220704
510.51481338500976610.6042265892028810.680193977355957-3.9610337162017824-3.7853821516036987-3.342250318527222-0.7240598225593566-0.46453820168972015-0.31559689044952394-0.8330999779701233-0.379890039563179-0.145325805544853220.0214416822791099570.101002745330333710.2353044569492340.130846009850502020.263848319649696350.494911587238311750.213731069564819330.38396897912025450.60373931169509893.32280867576599143.4214379787445073.4789054870605467-0.8404275512695313-0.3925653100013733-0.1615327215194702310.24298820495605410.32255792617797910.391872978210449-0.49662286281585694-0.3015878200531006-0.11881242156028748
68.6739649581909188.9040212631225599.069251289367676-3.033935775756836-2.7565478086471558-2.618418855667114-2.5305645370483396-1.6592541337013245-0.9208667135238647-1.0269253587722778-0.8940448462963104-0.71029618740081790.050375461429357530.203860163688659670.465576709508895850.26201508045196530.49300704896450040.75822698593139650.48295448780059820.76132321357727050.96559082984924323.50142313957214363.70778393745422363.8166400718688966-1.0213359689712525-0.90673828125-0.79659769773483288.4208252334594738.6212944984436048.777588768005371-2.1219652271270752-2.0492581129074097-1.92760910987854
78.2768179702758798.469994544982918.592100143432617-3.9012059211730956-3.622899293899536-3.3821629810333254-2.732761068344116-1.1937393546104431-0.5097035503387451-0.7558682584762573-0.5702216327190399-0.371862486600875840.041310702264308930.16249497234821320.42973520636558530.209013031125068670.43756605684757230.69975447654724120.36275738716125490.64396008849143980.87877755403518683.0761635494232183.23507511615753173.3530206966400145-0.7532573747634888-0.5827709138393402-0.39643867969512948.0576811599731458.220864772796638.330975189208985-2.2304548263549804-2.167076826095581-1.9705236387252807
811.20229705810546911.31963968276977511.424218673706054-3.9453994274139403-3.7193949222564697-3.2380274486541750.0146028514951467530.096169590950012210.185446724295616120.26789532780647280.9605910480022431.69212075233459470.061511306762695320.227248579263687130.493730353116989150.337782628536224370.57512506842613220.76519529819488520.71061218738555910.8081073164939880.8966436934471133.07744432449340843.23038470745086673.33045238494873040.321329854726791540.95497983694076541.65851231575012210.9687413787841811.06915950775146511.162392845153809-0.22055389285087584-0.07106089591979980.06708817481994629
99.97744060516357410.09454250335693410.219714813232422-3.985952320098877-3.9415669441223145-3.77304349899292-0.36748247146606444-0.19631701707839966-0.012043787315487865-0.43180049419403070.159857265651226040.58174026250839230.049927241206169130.15461825579404830.39290237426757810.19736342728137970.414248123764991760.66399593830108640.380954544544219950.6610586345195770.84678087711334233.2493290901184083.38468432426452643.4813685512542722-0.433267980813980050.12489344552159310.53913183212280279.7249091339111339.8237895965576179.936937026977539-1.1846681642532348-1.0447161197662354-0.8543273425102234
......................................................................................................
908.4679383087158218.6122245788574228.712338600158692-3.9118242263793945-3.670263648033142-3.180136957168579-2.9908473682403565-2.956583857536316-2.8570651149749757-0.0283492365479469270.054130891337990760.117890401184558860.090463624000549320.276099920272827150.51641624450683590.43973628520965580.6652216315269470.84318551540374750.82555446863174440.94966879487037660.98407344579696652.78641865730285642.95261776447296143.0897021007537844-0.052106142640113830.0472794435918331150.098151564896106718.2737133407592788.4116573333740238.497819938659667-2.3538817596435546-2.34079372882843-2.319191074371338
919.6867364883422869.7337622642517099.797216911315918-3.9658040142059328-3.8698363304138184-3.7642845249176027-2.303443880081177-1.4480793476104736-0.6218935918807984-1.8089547204971312-0.6563894450664520.078518982827663370.13086721479892730.349245265126228330.6274864125251770.51301644563674930.75346115231513980.87249883413314820.8946433377265930.91982182860374450.94803202390670772.91076721191406263.03931653499603273.1747095584869385-1.8312068796157837-0.67226433753967290.046120420098304729.4701669692993179.5087356567382819.559801445007324-1.7165182733535767-1.653548002243042-1.5891746520996093
9210.21762763977050710.35717868804931610.478487930297852-2.5796295261383055-2.2853704690933228-1.99812218666076660.2220745164155960.27878966927528380.32771290659904481.27112221717834471.4621717333793641.62592863082885740.0492698392271995540.166374757885932920.39337032437324520.206207042932510380.434725493192672730.68963526010513310.412059348821640.64215594530105590.87850818157196043.1513203907012943.29478263854980473.4017351531982421.2508545494079591.417899727821351.560351328849792610.00286251068115310.12413692474365210.226281471252442-0.214619448781013470.0138640664517879490.25478840589523316
938.2692576980590828.4219498634338388.532754821777344-3.9800770568847654-3.8856383562088013-3.686370267868042-2.049650526046753-1.238416314125061-0.5661825037002564-1.6835411643981935-1.4385753870010376-1.21572294235229480.043196612298488620.128943629562854770.34855980753898620.16813578248023990.368970990180969240.65752393007278440.30604412198066710.57359117269515990.86468774557113653.41782227516174333.5597372055053713.638593626022339-1.6923364114761352-1.4618347883224487-1.23305159568786638.0051969528198258.1388139724731458.237160453796387-1.9997316598892212-1.8996492624282837-1.7474086475372315
948.8709095382690438.9818544387817389.082789382934571-2.7534476566314696-2.2134265899658203-2.105312871932983-0.30668712854385377-0.24259769916534424-0.19760012507438660.7550606131553650.89570367336273190.99898349523544320.09367337286472320.319113448262214660.63069460630416870.3829291284084320.69564706087112430.8816076087951660.82866223573684690.97471159696578980.99200644493103032.44851734161376952.6594578027725222.82609470367431650.80282335042953490.90992081165313720.98150921583175658.72020996093758.8275165557861338.914336585998536-1.7104293346405028-1.6195834279060364-1.5417509603500366
958.8763537979125989.072528362274179.26684787750244-3.56313009262085-3.098684549331665-2.753771142959595-1.2248799753189086-0.6096833050251007-0.3049050271511078-1.5739735460281372-1.1651009917259216-0.95168854951858520.05278115734457970.205126918852329250.43910379528999320.271290323734283470.51742160320281980.77083631992340080.55495912551879880.82387819886207580.94303717613220223.5344181537628173.7403389215469363.8651330947875975-1.6079508304595946-1.243908405303955-1.019233307838448.6049431991577158.786533355712898.975468788146973-1.7581797599792481-1.4381957650184631-0.998660900592804
9610.76776229858398410.86295652389526410.960644073486328-2.109587984085083-1.8663303852081299-1.6872119426727294-1.0490061378479003-0.46603237092494965-0.14617968440055848-1.3017631959915161-1.0654341578483582-0.74242644071578980.00993519414216280.02987634576857090.095835635662078850.052333757579326630.115291032940149310.232902173995971680.070376546680927280.137530021369457240.246477280855178843.7346560859680183.77056527137756353.797588701248169-1.507627477645874-1.29646235704422-1.031089353561401410.46898483276367210.55509757995605510.652542839050293-0.449008295536041270.066628780215978620.8890600728988647
9710.84149070739746210.95444154739379911.042369956970214-3.7381189346313475-3.227435350418091-2.8807295989990234-0.7122359299659728-0.2669187933206558-0.12407686084508895-1.1265155267715454-0.8942262530326843-0.56255312681198120.0109516592323780060.039969379082322120.096363350152969360.061031200438737870.111734479665756230.207225565910339330.070747973620891570.130880527198314670.246087591052055353.4524367141723633.48792791366577153.511270275115967-1.1237796783447265-0.8831528425216675-0.568437080383300910.55594348907470710.66708707809448210.7494878005981441.24015327930450451.83534204959869382.189707489013672
98nannannannannannannannannannannannannannannannannannannannannannannannannannannannannannannannannan
9910.62772983551025310.74247980117797910.87334373474121-1.8682724475860595-1.7194148898124695-1.6048885536193849-1.6869652938842774-1.212232232093811-0.92705370664596562.34446867942810042.49858009815216062.59208948135375960.070508904457092290.239928632974624630.48185528278350830.31781587481498720.62025275826454160.85100628852844240.59080162763595580.85819625854492190.96890015602111812.4014737319946292.5595541000366212.71334603309631332.39011483192443832.49279403686523442.568825588226318210.4808663940429710.58238077163696310.701724815368653-2.1085242366790773-2.033019185066223-1.9606974172592164

And we can plot the star-forming main sequence from the fitted catalogue.

[7]:
import matplotlib.pyplot as plt

plt.scatter(post_tab["log_mass_50"], post_tab["log_sfr_50"])
plt.xlabel("Stellar Mass (log M_sun)")
plt.ylabel("SFR (log M_sun/yr)")
[7]:
Text(0, 0.5, 'SFR (log M_sun/yr)')
../_images/posterior_inference_catalogue_fitting_13_1.png

You may notice some of rows and nans. This is because those rows had missing data that we chose not to impute, which can’t be handled by the SBI inference method.

We could set missing_data_mcmc to True to impute those missing values instead.

We can also recover and plot the SEDs, which we’ll do for the first few sources in the catalogue.

[8]:
post_tab, data = fitter.fit_catalogue(
    cat[:4],
    columns_to_feature_names=conversion_dict,
    flux_units=Jy,
    check_out_of_distribution=False,
    recover_SEDs=True,
    plot_SEDs=True,
    missing_data_flag=np.nan,
    num_samples=300,
    append_to_input=False,
)
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
Sampling from posterior: 100%|██████████| 4/4 [00:00<00:00, 18.92it/s]
2025-11-13 20:10:14,203 | synference | INFO     | Obtained posterior samples.

Recovering SEDs from posterior samples...:   0%|          | 0/4 [00:00<?, ?it/s]
2025-11-13 20:10:14,309 | synference | WARNING  | The following parameters are not used by the simulator: ['log10_Av', 'log_sfr', 'sfh_quantile_25', 'sfh_quantile_50', 'sfh_quantile_75', 'log10_mass_weighted_age', 'log10_floor_sfr_10', 'log_surviving_mass', 'beta', 'Av', 'mass_weighted_age', 'floor_sfr_10']
2025-11-13 20:11:09,440 | synference | INFO     | Saving SED plot to /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/models/BPASS_DenseBasis_v4_final/plots//BPASS_DenseBasis_v4_final_SED_0
Recovering SEDs from posterior samples...:  25%|██▌       | 1/4 [00:56<02:49, 56.56s/it]
2025-11-13 20:12:06,258 | synference | INFO     | Saving SED plot to /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/models/BPASS_DenseBasis_v4_final/plots//BPASS_DenseBasis_v4_final_SED_1
Recovering SEDs from posterior samples...:  50%|█████     | 2/4 [01:53<01:52, 56.50s/it]
2025-11-13 20:13:02,653 | synference | INFO     | Saving SED plot to /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/models/BPASS_DenseBasis_v4_final/plots//BPASS_DenseBasis_v4_final_SED_2
Recovering SEDs from posterior samples...:  75%|███████▌  | 3/4 [02:49<00:56, 56.45s/it]
2025-11-13 20:13:56,153 | synference | INFO     | Saving SED plot to /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/models/BPASS_DenseBasis_v4_final/plots//BPASS_DenseBasis_v4_final_SED_3
Recovering SEDs from posterior samples...: 100%|██████████| 4/4 [03:42<00:00, 55.73s/it]

If you recover the SEDs then a nested dictionary with the SED posteriors are also returned. Initial key is the source index or ID, then within that there are keys for ‘wav’, ‘fnu_quantiles’, ‘wav’, ‘phot_wav’, ‘phot_fnu_draws’ and ‘fig’.

[9]:
data[1].keys()
[9]:
dict_keys(['wav', 'fnu_quantiles', 'phot_wav', 'phot_fnu_draws', 'fig'])

Here are the SED plots:

[10]:
for key in data.keys():
    display(data[key]["fig"])
../_images/posterior_inference_catalogue_fitting_20_0.png
../_images/posterior_inference_catalogue_fitting_20_1.png
../_images/posterior_inference_catalogue_fitting_20_2.png
../_images/posterior_inference_catalogue_fitting_20_3.png

We can check the feature array used for inference by setting return_feature_array=True.

[11]:
feature_array, mask = post_tab, data = fitter.fit_catalogue(
    cat,
    columns_to_feature_names=conversion_dict,
    flux_units=Jy,
    check_out_of_distribution=False,
    return_feature_array=True,
    missing_data_flag=np.nan,
    num_samples=300,
    append_to_input=False,
)

feature_array
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
WARNING {'true_flux_units': Jy, 'out_units': 'AB'} arguments will have no effect with this model. Input must be in Jy.
2025-11-13 20:14:01,535 | synference | INFO     | Removing 54 observations with missing data.
[11]:
array([[2.4493113e+01, 2.4163765e+01, 2.3604200e+01, ..., 9.3294436e-04,
        8.9689222e-04, 1.0870000e+00],
       [2.5077990e+01, 2.4549706e+01, 2.3904078e+01, ..., 6.5881172e-03,
        7.1780500e-03, 6.9384003e-01],
       [2.4922672e+01, 2.4493999e+01, 2.3787994e+01, ..., 1.1117980e-03,
        8.8765030e-04, 1.5530000e+00],
       ...,
       [2.6450207e+01, 2.4133791e+01, 2.2739664e+01, ..., 3.6288964e-04,
        2.9280997e-04, 6.6799998e-01],
       [2.7736353e+01, 2.6571774e+01, 2.5916496e+01, ..., 4.7382890e-04,
        3.4990878e-04, 1.6912301e+00],
       [2.3816370e+01, 2.3439030e+01, 2.3062237e+01, ..., 6.9473550e-04,
        6.0235627e-04, 5.7800002e+00]], shape=(76, 29), dtype=float32)

We can also run prior predictive checks to identify outliers, by setting check_out_of_distribution=True. The available list of methods is any of those in PYOD (https://pyod.readthedocs.io/en/latest/). You can set them with the ‘outlier_methods’ argument as a list of strings.