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

using x_cen and y_cen in structure_at #185

Open
danielseifried opened this issue Mar 3, 2022 · 3 comments
Open

using x_cen and y_cen in structure_at #185

danielseifried opened this issue Mar 3, 2022 · 3 comments

Comments

@danielseifried
Copy link

Hello,
I have the following problem: I determine the center of a structure, let's say structure A, using the "x_cen" and "y_cen" routine from PPStatistic. If I take the values stored in the outcome (after rounding to integers) and plug this into the routine "structure_at" e.g. like "structure_at(round(x_cen),round(y_cen))", it does not give me back structure A. Rather I have to use "structure_at(round(y_cen),round(x_cen))", so using the coordinates in a switched manner. I have also a minimal example describing this if needed. I am wondering if I am doing something wrong here or misinterpreting the outcome of the routines. Thanks.

@keflavich
Copy link
Contributor

It would be helpful to provide that minimal example. But I think this is the expected, if only poorly documented, result: structure_at uses numpy indexing.

@danielseifried
Copy link
Author

Hi,
most probable you are right.
Attached you find the minimum example using a 3x3 image with one structure. Please apologize the naming "test-program.txt", GitHub didn't allow me to upload a file ending with ".py"
3x3.txt
test-program.txt

@keflavich
Copy link
Contributor

You can just paste the code here, e.g.:

import numpy as np

from astrodendro import Dendrogram
from astrodendro.analysis import PPStatistic

data = np.array([[0,1,0], [0,0,0], [0,0,0]])

print(data)

d = Dendrogram.compute(data, min_value=0.5, min_delta=0., min_npix=1)

# there is only one structure in total
print(d.trunk[0])
print(d.trunk[0].indices())

stat = PPStatistic(d.trunk[0])

xcen = stat.x_cen.value
ycen = stat.y_cen.value

print(xcen,ycen)

# Gives "None"
print(d.structure_at((round(xcen),round(ycen))))

#Gives the right result, but x- and y-coordinate are switched
print(d.structure_at((round(ycen),round(xcen))))

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

2 participants