NightOperations/Commissioning/pFPA: wcs_fplane.py

File wcs_fplane.py, 1.1 KB (added by stevenj, 7 months ago)
Line 
1#! /usr/bin/env python
2
3#arg 1 RA of IHMP center
4#arg 2 Dec of IHMP center
5#arg 3 angle of IHMP  (all from remedy)
6#arg 4 correction for differential atmospheric dispersion
7#arg 5 RA of target star
8#arg 6 Dec of target star
9
10from astropy import wcs
11import numpy as np
12
13import sys
14
15ARCSECPERDEG = 1.0/3600.0
16
17# make a WCS object with appropriate FITS headers
18tp = wcs.WCS(naxis=2)
19tp.wcs.crpix = [0., 0.]  # central "pixel"
20tp.wcs.crval = [np.float(sys.argv[1]),
21                np.float(sys.argv[2])]  # tangent point
22tp.wcs.ctype = ['RA---TAN', 'DEC--TAN']
23# pixel scale in arcsecond
24
25x_scale=-1.
26
27y_scale=1.
28   
29tp.wcs.cdelt = [ARCSECPERDEG * x_scale,
30                       ARCSECPERDEG * y_scale]
31
32# Put rotation into radians
33rrot = np.deg2rad(np.float(sys.argv[3]))
34# clockwise rotation matrix
35tp.wcs.pc = [[np.cos(rrot), np.sin(rrot)], [-1.0*np.sin(rrot), np.cos(rrot)]]
36
37FPLANE_Y, FPLANE_X = tp.wcs_world2pix(np.float(sys.argv[5]),
38                                      np.float(sys.argv[6]), 1)
39
40#apply atmospheric dispersion correction
41FPLANE_Y += np.float(sys.argv[4])
42
43print('fplane x,y='+str(FPLANE_X)+','+str(FPLANE_Y))
44