Git Product home page Git Product logo

autoprof's Introduction

AutoProf

AutoProf is a pipeline for basic and advanced non-parametric galaxy image analysis. Its design allows for fast startup and provides flexibility to explore new ideas and support advanced users. It was written by Connor Stone with contributions from Nikhil Arora, Stephane Courteau, and Jean-Charles Cuillandre.

Install

pip install autoprof

Documentation

See our documentation for a full description of AutoProf's capabilities

Citation

Please see the ADS Bibliographic Record of the AutoProf paper for proper citation.

Notice

This is the AutoProf isophotal code, it works great in its domain which is wherever one would use isophotal fitting. Thus it is suitable for mostly isolated, mostly resolved, objects. If you are limited by the PSF, crowding, or want to model multi-band/epoch data you may want to consider "AstroPhot" a full forward modelling code. Just follow this link to check it out!

autoprof's People

Contributors

connorstoneastro avatar hgao-astro avatar smith42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

autoprof's Issues

ValueError: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

I'm working with @moustakas and we're trying to run the test cases but getting the following crash. Any suggestions?

% git log
commit e02d2be4a0a07e2b7eba64ed63599e73011389d0 (HEAD -> main, origin/main, origin/HEAD)
Author: Connor Stone <[email protected]>
Date:   Thu Jan 13 09:27:23 2022 -0500

% python -c "import matplotlib ; print(matplotlib.__version__)"
3.5.0
% python -c "import numpy ; print(numpy.__version__)"
1.21.2
% python -c "import astropy ; print(astropy.__version__)"
5.0
% python --version
Python 3.9.7

% autoprof test_batch_config.py Batch.log
testbatchimage3: head background at: 0.0 sec
testbatchimage2: head background at: 0.0 sec
testbatchimage1: head background at: 0.0 sec
testbatchimage4: head background at: 0.0 sec
testbatchimage3: head psf at: 5.8 sec
testbatchimage4: head psf at: 5.8 sec
testbatchimage2: head psf at: 5.8 sec
testbatchimage1: head psf at: 5.8 sec
ERROR:root:testbatchimage3: on step psf got error: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.
ERROR:root:testbatchimage4: on step psf got error: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.
ERROR:root:testbatchimage4: with full trace: Traceback (most recent call last):
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/Pipeline.py", line 169, in Process_Image
    dat, res = self.pipeline_methods[self.pipeline_steps[key][step]](dat, results, options)
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/pipeline_steps/PSF.py", line 204, in PSF_StarFind
    Plot_PSF_Stars(
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/Diagnostic_Plots.py", line 82, in Plot_PSF_Stars
    LSBImage(IMG - results["background"], results["background noise"])
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/SharedFunctions.py", line 76, in LSBImage
    plt.imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2640, in imshow
    __ret = gca().imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 5447, in imshow
    im._scale_norm(norm, vmin, vmax)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/cm.py", line 380, in _scale_norm
    raise ValueError(
ValueError: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

ERROR:root:testbatchimage3: with full trace: Traceback (most recent call last):
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/Pipeline.py", line 169, in Process_Image
    dat, res = self.pipeline_methods[self.pipeline_steps[key][step]](dat, results, options)
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/pipeline_steps/PSF.py", line 204, in PSF_StarFind
    Plot_PSF_Stars(
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/Diagnostic_Plots.py", line 82, in Plot_PSF_Stars
    LSBImage(IMG - results["background"], results["background noise"])
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/SharedFunctions.py", line 76, in LSBImage
    plt.imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2640, in imshow
    __ret = gca().imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 5447, in imshow
    im._scale_norm(norm, vmin, vmax)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/cm.py", line 380, in _scale_norm
    raise ValueError(
ValueError: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

ERROR:root:testbatchimage2: on step psf got error: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.
ERROR:root:testbatchimage1: on step psf got error: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.
ERROR:root:testbatchimage2: with full trace: Traceback (most recent call last):
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/Pipeline.py", line 169, in Process_Image
    dat, res = self.pipeline_methods[self.pipeline_steps[key][step]](dat, results, options)
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/pipeline_steps/PSF.py", line 204, in PSF_StarFind
    Plot_PSF_Stars(
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/Diagnostic_Plots.py", line 82, in Plot_PSF_Stars
    LSBImage(IMG - results["background"], results["background noise"])
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/SharedFunctions.py", line 76, in LSBImage
    plt.imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2640, in imshow
    __ret = gca().imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 5447, in imshow
    im._scale_norm(norm, vmin, vmax)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/cm.py", line 380, in _scale_norm
    raise ValueError(
ValueError: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

ERROR:root:testbatchimage1: with full trace: Traceback (most recent call last):
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/Pipeline.py", line 169, in Process_Image
    dat, res = self.pipeline_methods[self.pipeline_steps[key][step]](dat, results, options)
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/pipeline_steps/PSF.py", line 204, in PSF_StarFind
    Plot_PSF_Stars(
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/Diagnostic_Plots.py", line 82, in Plot_PSF_Stars
    LSBImage(IMG - results["background"], results["background noise"])
  File "/Users/keithpritchettjr./code/AutoProf/autoprof/autoprofutils/SharedFunctions.py", line 76, in LSBImage
    plt.imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2640, in imshow
    __ret = gca().imshow(
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
    return func(*args, **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 5447, in imshow
    im._scale_norm(norm, vmin, vmax)
  File "/opt/anaconda3/envs/galaxyphot/lib/python3.9/site-packages/matplotlib/cm.py", line 380, in _scale_norm
    raise ValueError(
ValueError: Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

AutoProf fails to fit isophotes of face-on galaxies

The optimization of isophotal ellipticity fails when the initialized ellipticity is close to 0 or 1. Because the perturbation was done after converting the ellipticity to another parameter space of $[-\infty, +\infty]$ using _inv_x_to_eps and then scaling back using _x_to_eps. The functional form makes any finite perturbation at $\epsilon \rightarrow 0$ and $\epsilon \rightarrow 1$ (corresponds to $-\infty$ and $+\infty$ in the perturbed parameter space) negligible. Since there are few galaxies with global ellipticity close to 1, the problem mostly affects nearly face-on galaxies.

perturbations[-1][i]["ellip"] = _x_to_eps(
_inv_x_to_eps(perturbations[-1][i]["ellip"])
+ np.random.normal(loc=0, scale=perturb_scale)
)

I assume that the purpose of such scaling is to do optimization in a continuous parameter space. However, since the perturbation was done in a Monte-Carlo manner, I presume that it is not critical to do such scaling. I try directly perturbing the ellipticity and when it hits its parameter boundary I simply reflect it against the boundary.

tmp_eps = perturbations[-1][i]["ellip"] + np.random.normal(
    loc=0, scale=perturb_scale
)
if tmp_eps < 0:
    tmp_eps = -tmp_eps % 1
    # tmp_eps = 0
elif tmp_eps > 1:
    tmp_eps = 1 - tmp_eps % 1
    # tmp_eps = 1
perturbations[-1][i]["ellip"] = tmp_eps

This temporary solution seems working. Let me know if you have other ideas. I would be happy to initiate a pull request when ready. Below I show a failed example and a successful fit using the new code above.

fit_ellipse_shalo_099-7_v1_HSC_I_fail
fit_ellipse_shalo_099-7_v1_HSC_I_success

Autoprof Older Version Documentation

Hello,

I was using AutoProf a little while ago with version 0.7.3, which had a ReadtheDocs documentation. Due to an updated version of AutoProf being available, the ReadtheDocs was also updated. In ReadtheDocs, only the latest version of the documentation is available, which made the documentation for AutoProf version 0.7.3 unavailable anywhere. Would it be possible to make this older version of the documentation available?

Thank you.

y axis label of the diagnostic plot for finding global PA

The y label should be FFT_2 phase instead of FFT_1 phase (see below for an example), according to the text in Sect. 2.4 of the AutoProf paper. However, Figure 4 of the AutoProf says it is FFT_1. I believe that it should be FFT2, since FFT1 is mostly useful for finding centers/lopsidedness.
Screen Shot 2023-03-10 at 4 20 23 PM

Axis Ratio issue with fit of Sersic Profile

Hello,

I am using AutoProf v0.7.3 to fit Sersic profiles to a set of galaxies with the Levenberg-Marquardt fitting method. I run into the issue that a large portion of my sample has a fitted axis ratio q = b/a ~ 1, despite not looking like circles in the data.

I believe that this is cause by the initial guess for the fit made by AutoProf misidentifying the semi-major (a) and semi-minor (b) axis. Since the fitting parameters are the semi-major axis (a) and axis ratio (q), when trying to improve on the initial guess with new iterations, the fits get 'stuck' with 'a' parameter being the size of the semi-minor axis and 'q' parameter ~ 1 (or slightly less). Note that the position angle (tilt of the ellipse) is also a parameter in the fit, but it would have to rotate by ~90 degrees to fix this issue which would be unlikely happen with this least square fitting method.

To solve this issue, I changed the prior on the 'q' parameter from 0 < q < 1 (default) to 0 < q < 10. Now the galaxies fits which where stuck at q ~ 1 go to q > 1 but with the 'a' parameter now representing the semi-minor instead of the semi-major axis. Therefor the real axis ratio, which by definition is q = b/a, now is a/b. To make everything consistent, I add in my code after the fit a line 'if q > 1: q = 1/q' so that my axis ratio still represents semi-minor/semi-major axis and are all between 0 and 1.

I have tested this solution against the SExtractor measurement for this axis ratio (ELONGATION = a/b = 1/q), and it seems to work. I have attached a plot with a sample of 400 galaxies to better visualize what I described. In blue are the galaxies with q ~ 1 and red the normal galaxies. The blue data points which were refitted with the new q prior now have a better distribution similar to the red data points, and match better the SExtractor found axis ratio. Note that the data I am using is relatively low signal and contains noise. Visual checks show that this suggested solution fixes the issue.

Best,

Jordan

update_roundness_problem_plot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.