2
$\begingroup$

I'm trying to convert some pixel coordinates I have into WCS coordinates, ideally into a WCS region for use in some further analysis.

So far I've been able to load and parse a NuSTAR FITS file, do some analysis to make my selections and get the pixel coordinates for the image. For example, after my analysis I would end up having selected a rectangle of x values from pixels 480 to 518, and y values from 478 to 516.

After that I tried to use the astropy WCS module to convert them, but it doesn't seem to find the required data in the header to actually do the conversion and just says that pixel 480 gives coordinate 480. That or I'm just doing something wrong.

So I looked through the FITS header myself, found that some keys (TCRPX, TCRVL, TCDLT) give the reference pixel, reference pixel degree coordinate and pixel axis scale values.

But now I'm really stuck since what I need to get is a region file like those produced by ds9, in the format of:

# Region file format: DS9 version 4.1
global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1
fk5
circle(19:58:21.593,+35:11:57.46,10")

To then run this through the nuproducts tool.

TL;DR: Does anybody know how to convert the NuSTAR FITS physical pixel coordinates to FK5 coordinates?


EDIT: Wrote some code to extract the coordinates. It converts the pixel to degree fine, but converting the FK5 $\alpha$ angle to sexagesimal doesn't work correctly for... some reason.


EDIT2: Everything works now, here's a notebook where I run through it all in case anybody runs into a similar problem. I go through extracting the right-ascension and declination in degrees from the pixel coordinates given by the FITS file, then converting these degrees to sexagesimal (h:m:s) angles. From my tests it seems to work quite well, results are a tad off due to what I assume are some floating point arithmetic errors.

$\endgroup$
4
  • $\begingroup$ What programming language do you work in? Furthermore, it is not entirely clear to me what you want as output, and I am unfamiliar with this 'nuproducts' tool. Why are the degrees, in which you have converted the pixel coordinates as you say in the EDIT, unsufficient? $\endgroup$
    – user1991
    Commented Dec 7, 2017 at 12:19
  • $\begingroup$ I'm working in Julia now. Basically, NuSTAR data has to be calibrated before it's suitable for scientific analysis and there are a few stages to that calibration, one of the stages requires you to select a source region (as a .reg file, usually created by manually selecting an area using DS9) before you get the final fully calibrated/cleaned data. The FITS files store data as X Y pixel coordinates, but the region file needs to be in WCS, so I convert X, Y to FK5 angles. Problem now is that for converting the angle I get in degrees (which is correct) to hh:mm:ss is different to what DS9 outputs $\endgroup$ Commented Dec 7, 2017 at 12:22
  • $\begingroup$ How much is the discrepancy between DS9 output and what you get? $\endgroup$
    – user1991
    Commented Dec 7, 2017 at 15:07
  • $\begingroup$ Aha, figured out what I did wrong, I was being stupid and converting degrees to h:m:s as if they were angles on a circle, which doesn't work for right-ascension since it goes from -90 to 90, not 0 to 360. Now that I've fixed it (here's a notebook where it works) it's still a bit off around 10^-5, but I guess that's just some floating point errors adding up along the way. $\endgroup$ Commented Dec 7, 2017 at 16:22

2 Answers 2

1
$\begingroup$

You can upload your FITS files to astrometry.net (or use an API) and get the coordinates. You can optionally get new FITS files back with the coordinates included in the metadata. From there you will be able to proceed with your processing.

And, instead of uploading everything, you can also install a copy of the astrometry.net package locally if you're running Linux.

$\endgroup$
1
$\begingroup$

I did this exercise with IRAF by the functions geomap and geotran. There is PYRAF version of the IRAF, but I have never tried the python version. Using these routines, you can find the tranformation equation regardless of the header. What you need to know is some standard objects of known WCS and pixel coordinates.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .