How to use the astromodels.core.model_parser.ModelParser function in astromodels

To help you get started, we’ve selected a few astromodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github threeML / threeML / threeML / analysis_results.py View on Github external
def _load_one_results(fits_extension):
    # Gather analysis type
    analysis_type = fits_extension.header.get("RESUTYPE")

    # Gather the optimized model
    serialized_model = _escape_back_yaml_from_fits(fits_extension.header.get("MODEL"))
    model_dict = my_yaml.load(serialized_model)

    optimized_model = ModelParser(model_dict=model_dict).get_model()

    # Gather statistics values
    statistic_values = collections.OrderedDict()

    measure_values = collections.OrderedDict()

    for key in fits_extension.header.keys():

        if key.find("STAT") == 0:
            # Found a keyword with a statistic for a plugin
            # Gather info about it

            id = int(key.replace("STAT", ""))
            value = float(fits_extension.header.get(key))
            name = fits_extension.header.get("PN%i" % id)
            statistic_values[name] = value