SamSweere / xmm-epicpn-simulator

Simulation code for XMM-Newton EPIC-pn data using SIXTE and SIMPUT, designed to create training data for deep learning based super-resolution and de-noising.
https://academic.oup.com/mnras/article/517/3/4054/6694110
4 stars 2 forks source link

Fluxes are calculated once and then used on all agns #8

Closed SamSweere closed 4 months ago

SamSweere commented 4 months ago

02_generate_simput.py

 # Get the fluxes from the agn distribution
            fluxes = get_fluxes(agn_counts_file)
            img_settings: dict = dict(simput_cfg.agn).copy()
            img_settings["fluxes"] = fluxes

Is being called before running simput_generate.

While in generation we are looping over the number of images to generate:

for _ in range(img_settings["n_gen"]):
        # Use the current time as id, such that clashes don't happen
        unique_id = uuid4().int
        output_file_path = run_dir / f"agn_{unique_id}_p0_{emin}ev_p1_{emax}ev.simput"
        simput_files: list[Path] = []

        # TODO: make an option to make agns that are close together
        if img_settings["deblending_n_gen"] > 0:
            # TODO:
            # img_settings["deblending_min_sep"]
            # img_settings["deblending_max_sep"]
            # img_settings["deblending_max_flux_delta"]
            pass

        for i, flux in enumerate(img_settings["fluxes"]):
            logger.info(f"Creating AGN with flux={flux}")
            output_file = run_dir / f"ps_{unique_id}_{i}.simput"
            output_file = simput_ps(

Where we take the fluxes from the settings. However, this will cause all the agn images to have the same distribution of fluxes. In the get_fluxes function we add noise to the number of starts to generate to prevent having the same distribution everywhere. However, in order for this to work we need to calculate the fluxes within the for loop. Not before.

bojobo commented 4 months ago

You're completely right. I wrongly assumed that get_fluxes always returns the same values. Task can be assigned to me if no one is working on it.