question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ellipse2D() only fitting amplitude

See original GitHub issue

Description

When I fit a simple ellipse with models.fitting it will fit the amplitude, but none of the other parameters in Ellipse2D()

Expected behavior

It would fit all the parameters!

Actual behavior

It successfully ran, but only fit the ellipse amplitude. It does seem to do an OK job at that.

Steps to Reproduce

import numpy as np
import matplotlib.pyplot as plt
from astropy.modeling import models, fitting
from astropy.modeling.models import Ellipse2D

#make some random ellipse
e = Ellipse2D(amplitude=100., x_0=20, y_0=30, a=12, b=18,
              theta=0.2)
y, x = np.mgrid[0:50, 0:50]
#add some noise 
emap = e(x, y)+np.random.random([50,50])*100

#fit 
fit = fitting.LevMarLSQFitter()

# initialize a linear model
ellip_init = models.Ellipse2D()
e_init = Ellipse2D(amplitude=1200., x_0=20, y_0=30, a=200, b=900,
              theta=2)

# fit the data with the fitter
fitted_ellip = fit(e_init, x, y, emap)

fitted_ellip

System Details

macOS-10.16-x86_64-i386-64bit Python 3.8.3 (default, Jul 2 2020, 11:26:31) [Clang 10.0.0 ] Numpy 1.22.4 pyerfa 2.0.0 astropy 5.1 Scipy 1.7.3 Matplotlib 3.5.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jegpeekcommented, Jul 30, 2022

@eteq gave me some comments on this – he believes it has to do with the mathematical architecture of the problem itself, not astropy. Please stand by while I test his method and then we/you can decide whether to just close this or add some documentation or what?

0reactions
github-actions[bot]commented, Sep 18, 2022

I’m going to close this issue as per my previous message, but if you feel that this issue should stay open, then feel free to re-open and remove the Close? label.

If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fitting an ellipse using astropy [Ellipse2d model]
Although it does not fit the given ellipse-shaped plateau with constant amplitude, but still it gives the correct theta value 1.23386185422e-10 ...
Read more >
Models and Fitting (astropy.modeling) — Astropy v3.2.dev994
LevMarLSQFitter() t = fit_t(t_init, x, y) # Fit the data using a Gaussian g_init ... Ellipse2D ([amplitude, x_0, y_0, a, b, theta]), A...
Read more >
Curve Fitting
Subtracting an X offset will change the amplitude coefficient in the fit. Often the only coefficient of interest is the decay constant (invTau)...
Read more >
Ellipse2D — Astropy v5.2
Ellipse2D (amplitude=1, x_0=0, y_0=0, a=1, b=1, theta=0.0, ... A dictionary {parameter_name: boolean} of parameters to not be varied during fitting.
Read more >
Plotting Confidence Image(?) of an Ellipse Fit
For example, picture a circle. You have uncertainty in {x0,y0,D}. One could naïvely just plot three circles: the fit, the fit minus sigma...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found