How to use the specutils.utils.QuantityModel function in specutils

To help you get started, we’ve selected a few specutils 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 astropy / specutils / specutils / fitting / fitmodels.py View on Github external
#
    # Create the output model which is either the evaulation
    # of the RPN representation of the model (if a compound model)
    # or just the first element if a non-compound model.
    #

    if compound_model:
        model_out = _combine_postfix(model_out_stack)
    else:
        model_out = model_out_stack[0]

    # If the first parameter is not a Quantity, then at this point we will
    # assume none of them are. (It would be inconsistent for fitting to have
    # a model that has some parameters as Quantities and some values).
    if getattr(model_orig, model_orig.param_names[0]).unit is None:
        model_out = QuantityModel(model_out,
                                  spectrum.spectral_axis.unit,
                                  spectrum.flux.unit)

    return model_out
github astropy / specutils / specutils / fitting / fitmodels.py View on Github external
dispersion_unitless = dispersion_unitless[nmask]
        flux_unitless = flux_unitless[nmask]
        if weights is not None:
            weights = weights[nmask]

    fit_model_unitless = fitter(model_unitless, dispersion_unitless,
                                flux_unitless, weights=weights, **kwargs)

    #
    # Now add the units back onto the model....
    #

    if not ignore_units:
        fit_model = _add_units_to_model(fit_model_unitless, model, spectrum)
    else:
        fit_model = QuantityModel(fit_model_unitless,
                                  spectrum.spectral_axis.unit,
                                  spectrum.flux.unit)

    return fit_model