I am looking for someone who is proficient in python programming to write me a small script which takes various array values and prints them as space delimited columns into a text file (.txt).
I'm working within the `astropy.io` `fits` module in order to extract various regions within an astronomical image.
I'm then wanting to extract a given specified region and print each pixel in the array as a continuous column (and regions from other images as further columns) to a text file with space as the delimiter. I'm fairly confident in manipulating these images, except for what I am about to ask.
I'm looking to print out various numpy arrays into space delimited columns. For example, I have an array, let's call this "`image_array`", and I have selected, as an example, a 5x5 array using:
hdulist_SDSS_u = fits.open('SDSS_u.fits')
sub_array_a = hdulist_SDSS_u.data[0,615:620,420:425]
sub_array_u = [[ 0.21881846 0.25050985 0.30488651 0.15721292 0.36129788]
[ 0.20289249 0.20764523 0.29301882 0.20700296 0.25146781]
[ 0.30137189 0.29080765 0.15349937 0.2055568 0.25210646]
[ 0.19860348 0.29827366 0.34293352 0.1721678 0.12383141]
[ 0.13158184 0.26189449 0.33571601 0.11402556 0.22013794]]
Now, I'd like to transform this and print this as a column.
I am also opening up another image file and taking the corresponding pixels to give me the values of the image for the same corresponding pixel, i.e.:
hdulist_SDSS_z = fits.open('SDSS_z.fits')
sub_array_z = hdulist_SDSS_z.data[0,615:620,420:425]
I'd like to do this for a number of images I am comparing. However, I'm sure once I have the basic method for printing these arrays as columns delimited by space in a txt file I can then apply this wholesale.
I'd also like to print alongside these columns, the corresponding x and y pixels, i.e., I'm hoping my txt file will contain something like this:
pxlname x y u z
pix615_420 615 420 0.21881846 0.31271553
pix616_420 616 420 0.44872895 0.41526772
pix620_425 620 620 0.34837483 0.38282376
Applications welcome ASAP! I will attach the example printed format I would like to extract so you can see what you would need to automate.