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

[DOCS] More "pythonic" way for creating pixel coordinates in Voronoi binning example #101

Open
Knusper opened this issue Jun 18, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@Knusper
Copy link

Knusper commented Jun 18, 2024

  • Describe the issue with the content

The Voronoi binning example in the tutorial contains the following code:

# First we need to make lists of pixel Coordinates
# note this will be stupid big with large data cubes
# in that case find a smartter way to make these arrays

# ... X is a 1D list of length 150**2
X = []
for x in np.arange(0, cube.shape[2]):
    X+=[x]*cube.shape[2]

x =  np.array(X)

# ... Y is a 1D list of length 150**2
Y=[]
for y in np.arange(0,cube.shape[1]):
    Y+=list(np.arange(0,cube.shape[1]))

y =  np.array(Y)

I don't know if finding a smarter way was meant an exercise for the reader, but I certainly think there is a more efficient way provided by numpy to do this.

  • Location of the issue in the documentation

https://heloises.github.io/hoki/Voronoi_binning_of_SED_data.html#Book-keeping---creating-the-pixel-coordinate,-signal-and-noise-arrays

  • Suggestion to improve or clear confusion

This does the trick:

X, Y = np.indices((cube.shape[2], cube.shape[1]))
x = X.flatten()
y = Y.flatten()

Can provide PR if you want.

@Knusper Knusper added the documentation Improvements or additions to documentation label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant