Cutout2D not centering on galaxies

牧云@^-^@ 提交于 2020-03-05 00:31:14

问题


I'm running Cutout2D on a .fits image I have and despite specifying the pixel values of the centre of my object it's cutting out a completely different galaxy. My code is as follows:

from astropy.io import fits
import numpy as np
from astropy.table import Table
import os
from astropy.nddata.utils import Cutout2D

def merge(list1, list2):
    #merges to lists into pairs so you can have list of corresponding coordinates matched together
    merged_list =[(list1[i], list2[i]) for i in range(0, len(list1))]
    return merged_list

#read in the fits file
insciim = fits.open('/home/myname/science_image.fits')
indata = fits.getdata('/home/myname/science_image.fits')

#Read in the header
hdr = fits.getheader('/home/myname/science_image.fits')
hdr["CTYPE1"] = "RA---TAN-SIP"
hdr["CTYPE2"] = "DEC--TAN-SIP"

#working from a copy to avoid overwriting the images
sciim = np.copy(insciim)
data = np.copy(indata)

xray_sources = '/home/myname/xray_catalogue.csv' #file path to the xray sources catalgoue 
xray_table = Table.read(xray_sources, format="ascii") #imports it as a table into python 

ID = np.array(xray_table['name']) #puts the IDs into a numpy array
ID.astype(str) #makes the array into strings

x_pix = np.array(xray_table['x_pixel'])
x_pix.astype(float)

y_pix = np.array(xray_table['y_pixel'])
y_pix.astype(float)

coordinates = merge(x_pix, y_pix)

size = (200, 200) #size I want the image to be in pixels

cut_test = Cutout2D(data, (3480.136, 2771.585), size)

img_hdu = fits.PrimaryHDU(cut_test.data, header=hdr)
img_hdu.writeto("/home/myname/test_galaxy.fits", overwrite=True) 

The galaxy I want is centred on the pixel values of (3480.136, 2771.585) but when I view the cutout in DS9 its not even on my original image. IS there any way to prevent this from happening?

来源:https://stackoverflow.com/questions/60173243/cutout2d-not-centering-on-galaxies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!