Skip to content

Fitting of compound models too restrictive #10414

Closed

Description

@nden

Description

@karllark reported on Slack:

I'm getting an interesting error when fitting a compound model. The error is:

ValueError: Fitting a compound model without units can only be performed on
compound models that only use the arithmetic operators + and -

The model I'm fitting has units for a summed set of models including BlackBody, Drude1D, Gaussian1D models with units of MJy/sr that are then multiplied by a dust attenuation model that does not have units.

An example to reproduce the error:

import numpy as np
from astropy.modeling import fitting, models

fitter = fitting.LevMarLSQFitter()
model = models.BlackBody(temperature=3000 * u.K) * models.Const1D(amplitude=1.0)
    
x = [1.0, 2.0, 3.0] * u.micron
n = np.random.normal(3)
y = model(x) * (1.0 + n)
res = fitter(model, x, y)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions