Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_generate_invariants requires at least 5 sources to work, find_transform only 3. #36

Closed
RosCarraro opened this issue Sep 11, 2019 · 6 comments

Comments

@RosCarraro
Copy link

I'm trying to run find_transform on a target image with 4 sources. The check on target_controlp is passed because there are at least 3 sources, but when it enters _generate_invariants the indx variable is forced to length=5(>4), since NUM_NEAREST_NEIGHBORS=5, and there is no check on this. Then the arrange function is not able to find the fifth source.
I'm attaching a screenshot of the errors.
image

@martinberoiz
Copy link
Member

Yes, this is definitely a bug.
I originally intended this to work with 3 sources or more.
I will add a new test for low number of sources and try to implement a solution, but it might take a while.
I'm afraid that for low number of sources I will have to treat it as a separate case.

@leliel12
Copy link
Contributor

leliel12 commented Sep 11, 2019 via email

@RosCarraro
Copy link
Author

RosCarraro commented Sep 11, 2019

So does this mean that if being able to change NUM_NEAREST_NEIGHBORS to len(sources) if len(sources)<5 would not solve the problem?
This would be too bad because most of my data has a low number of sources :(

I was trying to do this in _generate_invariants but I have some scope problem:
image

@martinberoiz
Copy link
Member

Instead of tweaking the source code, you can try changing the value before you call register, like this:

import astroalign as aa
aa.NUM_NEAREST_NEIGHBORS = 3 # (or 4)
aligned = aa.register(source, target)

but I can't guarantee it will work.

The example you gave won't work because you're modifying the variable num instead of the variable NUM_NEAREST_NEIGHBORS.

@martinberoiz
Copy link
Member

Hi,

I released a new version that partially deals with few sources.
So far it's tested when the input is a list of the (x, y) positions of the sources, as opposed to passing the image. It's tested for 3, 4, 5... sources.

Passing the image array can still cause problems since it seems to be picking up fake sources from the noisy background.

Maybe give it a try and see if this fixes your issue. I'll keep the issue open until I fix this completely.

@martinberoiz
Copy link
Member

The new release 2.1 should work with few sources on the image. Please feel free to reopen this issue or open a new one if you still find problems.

Check the new documentation out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants