Cutout2D не центрируется на галактиках - PullRequest
0 голосов
/ 11 февраля 2020

Я использую Cutout2D на изображении .fits, которое у меня есть, и, несмотря на указание значений пикселей в центре моего объекта, оно вырезает совершенно другую галактику. Мой код выглядит следующим образом:

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) 

Галактика, которую я хочу, центрируется на значениях пикселей (3480.136, 2771.585), но при просмотре выреза в DS9 его нет даже на моем исходном изображении. Есть ли способ предотвратить это?

...