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.

Fitting in astropy.modeling much slower in 4.2 than 3.2.3

See original GitHub issue

Description

The speed of the fitting in astropy.modeling was seen to be significantly slower after astropy 4.0 was released. This was commented by multiple developers of the pahfit package. This package is a spectral decomposition tool that fits many lines and continuum components to NIR/MIR spectra of interstellar matter emission.

Expected behavior

Similar run times in both version of astropy

Actual behavior

10x slower when run with astropy 4.2 compared to astropy 3.2.3

astropy4.2

(base) [kgordon@grimy pahfit]$ time scripts/run_pahfit --savefig=png pahfit/data/M101_Nucleus_irs.ipac pahfit/packs/scipack_ExGal_SpitzerIRSSLLL.ipac WARNING: The fit may be unsuccessful; check fit_info[‘message’] for more information. [astropy.modeling.fitting] Number of calls to function has reached maxfev = 200.

real 0m32.365s user 0m33.346s sys 0m1.471s

astropy3.2.3

(astropy323) [kgordon@grimy pahfit]$ time scripts/run_pahfit --savefig=png pahfit/data/M101_Nucleus_irs.ipac pahfit/packs/scipack_ExGal_SpitzerIRSSLLL.ipac WARNING: The fit may be unsuccessful; check fit_info[‘message’] for more information. [astropy.modeling.fitting] Number of calls to function has reached maxfev = 200.

real 0m3.176s user 0m4.046s sys 0m1.211s

notes Used two slightly different versions of python (3.7 for astropy 3.2.3 and 3.8 for astropy 4.2) to get the conda environments to be independent. Clearly not a conda expert yet. Regardless, testing this with different versions of python give very similar answers.

Steps to Reproduce

  1. Use the testastropy branch of karllark/pahfit to run the command given above. This branch works in the two version of astropy tested above

astropy 4.2 result

M101_Nucleus_irs_astropy42

astropy 3.2.3 result

M101_Nucleus_irs_astropy323

System Details

astropy 4.2 conda environment

import platform; print(platform.platform()) Linux-5.10.8-100.fc32.x86_64-x86_64-with-glibc2.10 import sys; print(“Python”, sys.version) Python 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0] import numpy; print(“Numpy”, numpy.version) Numpy 1.20.1 import astropy; print(“astropy”, astropy.version) astropy 4.2 import scipy; print(“Scipy”, scipy.version) Scipy 1.6.0 import matplotlib; print(“Matplotlib”, matplotlib.version) Matplotlib 3.3.4

astropy 3.2.3 conda environment

import platform; print(platform.platform()) Linux-5.10.8-100.fc32.x86_64-x86_64-with-fedora-32-Thirty_Two import sys; print(“Python”, sys.version) Python 3.7.9 (default, Aug 31 2020, 12:42:55) [GCC 7.3.0] import numpy; print(“Numpy”, numpy.version) Numpy 1.20.1 import astropy; print(“astropy”, astropy.version) astropy 3.2.3 import scipy; print(“Scipy”, scipy.version) Scipy 1.6.0 import matplotlib; print(“Matplotlib”, matplotlib.version) Matplotlib 3.3.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
perrygreenfieldcommented, Feb 9, 2021

Not yet. I will have to look at their source code to get a better idea of what is going on.

1reaction
karllarkcommented, Feb 9, 2021

Very different results from profiling. Using snakeviz to view the profiling output.

astropy 4.2

Screenshot from 2021-02-09 11-50-46

astropy 3.2.3

Screenshot from 2021-02-09 11-51-01

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fitting Models to Data — Astropy v5.2
The rules for passing input to fitters are: Non-linear fitters currently work only with single models (not model sets). The linear fitter can...
Read more >
PetroFit: A Python Package for Computing Petrosian Radii ...
These capabilities provide a robust means of modeling and fitting ... that fits background pixels using an Astropy model, and then that ...
Read more >
Astropy Documentation - Read the Docs
12 Models and Fitting (astropy.modeling) ... It is also possible to work directly with units at a lower level, for example, to create...
Read more >
A modular set of synthetic spectral energy distributions for ...
Rather than all being part of a single monolithic set of models, ... (2007, hereafter R07), we presented a tool to rapidly fit...
Read more >
PROCEEDINGS OF SPIE - Caltech AUTHORS
ZTF has a large science focal plane (SFP) that needs to be aligned such ... measures the height at which a star is...
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