autostronomy / autoprof Goto Github PK
View Code? Open in Web Editor NEWAutomatic Isophotal solutions for galaxy images
License: GNU General Public License v3.0
Automatic Isophotal solutions for galaxy images
License: GNU General Public License v3.0
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.
Users that already know the size of their object should be able to set it manually
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 _inv_x_to_eps
and then scaling back using _x_to_eps
. The functional form makes any finite perturbation at
AutoProf/autoprof/pipeline_steps/Isophote_Fit.py
Lines 628 to 631 in 8db0fd2
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.