Skip to content

How to save a single source model #670

Description

@HealthyPear

Assume I call the sed method on my gta to get the catalog-like SED

now I want to test a different spectrum

I am doing (feel free to criticize if this is not the usual way to do it)

spectrum_pars = {
    "Prefactor": {
        ... # value, scale, min, max
    },
    "Index1": {
       ...
    },
    "Index2": {
        ...
    },
    "BreakValue": {
        ...
    },
}

gta.set_source_spectrum(
    target_source,
    spectrum_type="BrokenPowerLaw",
    spectrum_pars=spectrum_pars,
    update_source=True
)

and then the usual pre-fit procedures, optimize / fit then ok it works

I want to make this reproducible, so I would like to save just this single source model to a file, so that I can call spectrum_pars from a file

Source. write_xml() seems to be a function for this, but honestly I feel like

with open(output_path / "custom_spectral_model.yaml", mode="w") as f:
    yaml.safe_dump(spectrum_pars, f)

it's better

Of course, I know about gta.write_roi(), but what I want to load is something that I might want to define and save before updating the entire model.

What do you think?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions