1 // Wrapping of WCSTools wcs.c
2 //
3 // Not wrapping the functions that return WCS coords as string because can convert using decimal2hms() etc. in astCoords
4 
5 %feature("autodoc", "0");
6 
7 %module (package="PyWCSTools") wcs
8 
9 %include "carrays.i"
10 %include "typemaps.i"
11 
12 %array_functions(double, doubleArray)
13 
14 /* %feature("autodoc", "1") */
15 
16 %{
17 #include "wcs.h"
18 %}
19 
20 /* WORKING */
21 struct WorldCoor *wcsinit(char *hstring); /* set up a WCS structure from a FITS image header */
22 
23 struct WorldCoor *wcsxinit(double cra, double cdec, double secpix, int xrpix, int yrpix, int nxpix, int nypix, double rotate, int equinox, double epoch, char *proj); /* set up a WCS structure from arguments */
24 struct WorldCoor *wcskinit(int nxpix, int nypix, char *ctype1, char *ctype2, double crpix1, double crpix2, double crval1, double crval2, double *cd, double cdelt1, double cdelt2, double crota, double equinox, double epoch); /* set up a WCS structure from keyword values */
25 
26 int iswcs(struct WorldCoor *wcs);		/* Return 1 if WCS structure is filled, else 0 */
27 int nowcs(struct WorldCoor *wcs);		/* Return 0 if WCS structure is filled, else 1 */
28 
29 %apply double *OUTPUT { double *xpix, double *ypix, int *offscl};
30 void wcs2pix(struct WorldCoor *wcs, double xpos, double ypos, double *xpix, double *ypix, int *offscl);		/* Convert World Coordinates to pixel coordinates */
31 %apply double *OUTPUT { double *xpos, double *ypos};
32 void pix2wcs(struct WorldCoor *wcs, double xpix, double ypix, double *xpos, double *ypos);		/* Convert pixel coordinates to World Coordinates */
33 
34 void wcscent(struct WorldCoor *wcs);		/* Print the image center and size in WCS units */
35 
36 char *getradecsys(struct WorldCoor *wcs);	/* Return current value of coordinate system */
37 void wcsoutinit(struct WorldCoor *wcs, char *coorsys);	/* Initialize WCS output coordinate system for use by pix2wcs */
38 void wcsininit(struct WorldCoor *wcs, char *coorsys);	/* Initialize WCS input coordinate system for use by wcs2pix */
39 char *getwcsout(struct WorldCoor *wcs);	/* Return current value of WCS output coordinate system */
40 char *getwcsin(struct WorldCoor *wcs);	/* Return current value of WCS input coordinate system */
41 
42 %apply double *OUTPUT {double *cra, double *cdec, double *dra, double *ddec};
43 void wcssize(struct WorldCoor *wcs, double *cra, double *cdec, double *dra, double *ddec);		/* Return RA and Dec of image center, size in RA and Dec */
44 %apply double *OUTPUT {double *width, double *height};
45 void wcsfull(struct WorldCoor *wcs, double *cra, double *cdec, double *width, double *height);		/* Return RA and Dec of image center, size in degrees */
46 
47 struct WorldCoor {
48   double    xref;       /* X reference coordinate value (deg) */
49   double    yref;       /* Y reference coordinate value (deg) */
50   double    xrefpix;    /* X reference pixel */
51   double    yrefpix;    /* Y reference pixel */
52   double    xinc;       /* X coordinate increment (deg) */
53   double    yinc;       /* Y coordinate increment (deg) */
54   double    rot;        /* rotation around axis (deg) (N through E) */
55   double    cd[4];      /* rotation matrix */
56   double    dc[4];      /* inverse rotation matrix */
57   double    equinox;    /* Equinox of coordinates default to 1950.0 */
58   double    epoch;      /* Epoch of coordinates default to equinox */
59   double    nxpix;      /* Number of pixels in X-dimension of image */
60   double    nypix;      /* Number of pixels in Y-dimension of image */
61   double    plate_ra;   /* Right ascension of plate center */
62   double    plate_dec;  /* Declination of plate center */
63   double    plate_scale;    /* Plate scale in arcsec/mm */
64   double    x_pixel_offset; /* X pixel offset of image lower right */
65   double    y_pixel_offset; /* Y pixel offset of image lower right */
66   double    x_pixel_size;   /* X pixel_size */
67   double    y_pixel_size;   /* Y pixel_size */
68   double    ppo_coeff[6];   /* pixel to plate coefficients for DSS */
69   double    x_coeff[20];    /* X coefficients for plate model */
70   double    y_coeff[20];    /* Y coefficients for plate model */
71   double    xpix;       /* X (RA) coordinate (pixels) */
72   double    ypix;       /* Y (dec) coordinate (pixels) */
73   double    zpix;       /* Z (face) coordinate (pixels) */
74   double    xpos;       /* X (RA) coordinate (deg) */
75   double    ypos;       /* Y (dec) coordinate (deg) */
76   double    crpix[9];   /* Values of CRPIXn keywords */
77   double    crval[9];   /* Values of CRVALn keywords */
78   double    cdelt[9];   /* Values of CDELTn keywords */
79   double    pc[81];     /* Values of PCiiijjj keywords */
80   double    projp[10];  /* Constants for various projections */
81   int       pvfail;     /* If non-zero, significant inaccuracy likely to occur in projection */
82   double    projppv[2*MAXPV]; /* SCAMP constants for the PV coordinates */
83   struct poly   *inv_x;     /* SCAMP projection correction polynom in x */
84   struct poly   *inv_y;     /* SCAMP projection correction polynom in y */
85   double    longpole;   /* Longitude of North Pole in degrees */
86   double    latpole;    /* Latitude of North Pole in degrees */
87   double    rodeg;      /* Radius of the projection generating sphere */
88   double    imrot;      /* Rotation angle of north pole */
89   double    pa_north;   /* Position angle of north (0=horizontal) */
90   double    pa_east;    /* Position angle of east (0=horizontal) */
91   double    radvel;     /* Radial velocity (km/sec away from observer)*/
92   double    zvel;       /* Radial velocity (v/c away from observer)*/
93   double    zpzd;       /* Colat of FIP (degs) */
94   double    zpr;        /* Radius of FIP (degs) */
95   int       imflip;     /* If not 0, image is reflected around axis */
96   int       prjcode;    /* projection code (-1-32) */
97   int       latbase;    /* Latitude base 90 (NPA), 0 (LAT), -90 (SPA) */
98   int       ncoeff1;    /* Number of x-axis plate fit coefficients */
99   int       ncoeff2;    /* Number of y-axis plate fit coefficients */
100   int       zpnp;        /* ZP polynomial order (0-9) */
101   int       changesys;  /* 1 for FK4->FK5, 2 for FK5->FK4 */
102                 /* 3 for FK4->galactic, 4 for FK5->galactic */
103   int       printsys;   /* 1 to print coordinate system, else 0 */
104   int       ndec;       /* Number of decimal places in PIX2WCST */
105   int       degout;     /* 1 to always print degrees in PIX2WCST */
106   int       tabsys;     /* 1 to put tab between RA & Dec, else 0 */
107   int       rotmat;     /* 0 if CDELT, CROTA; 1 if CD */
108   int       coorflip;   /* 0 if x=RA, y=Dec; 1 if x=Dec, y=RA */
109   int       offscl;     /* 0 if OK, 1 if offscale */
110   int       wcson;      /* 1 if WCS is set, else 0 */
111   int       naxis;      /* Number of axes in image (for WCSLIB 3.0) */
112   int       naxes;      /* Number of axes in image */
113   int       wcsproj;    /* WCS_OLD: AIPS worldpos() and worldpix()
114                    WCS_NEW: Mark Calabretta's WCSLIB subroutines
115                    WCS_BEST: WCSLIB for all but CAR,COE,NCP
116                    WCS_ALT:  AIPS for all but CAR,COE,NCP */
117   int       linmode;    /* 0=system only, 1=units, 2=system+units */
118   int       detector;   /* Instrument detector number */
119   char      instrument[32]; /* Instrument name */
120   char      ctype[9][9];    /* Values of CTYPEn keywords */
121   char      c1type[9];  /*  1st coordinate type code:
122                     RA--, GLON, ELON */
123   char      c2type[9];  /*  2nd coordinate type code:
124                     DEC-, GLAT, ELAT */
125   char      ptype[9];   /*  projection type code:
126                     SIN, TAN, ARC, NCP, GLS, MER, AIT, etc */
127   char      units[9][32];   /* Units if LINEAR */
128   char      radecsys[32];   /* Reference frame: FK4, FK4-NO-E, FK5, GAPPT*/
129   char      radecout[32];   /* Output reference frame: FK4,FK5,GAL,ECL */
130   char      radecin[32];    /* Input reference frame: FK4,FK5,GAL,ECL */
131   double    eqin;       /* Input equinox (match sysin if 0.0) */
132   double    eqout;      /* Output equinox (match sysout if 0.0) */
133   int       sysin;      /* Input coordinate system code */
134   int       syswcs;     /* WCS coordinate system code */
135   int       sysout;     /* Output coordinate system code */
136                 /* WCS_B1950, WCS_J2000, WCS_ICRS, WCS_GALACTIC,
137                  * WCS_ECLIPTIC, WCS_LINEAR, WCS_ALTAZ  */
138   char      center[32]; /* Center coordinates (with frame) */
139   struct wcsprm wcsl;       /* WCSLIB main projection parameters */
140   struct linprm lin;        /* WCSLIB image/pixel conversion parameters */
141   struct celprm cel;        /* WCSLIB projection type */
142   struct prjprm prj;        /* WCSLIB projection parameters */
143   struct IRAFsurface *lngcor;   /* RA/longitude correction structure */
144   struct IRAFsurface *latcor;   /* Dec/latitude correction structure */
145   int       distcode;   /* Distortion code 0=none 1=SIRTF */
146   struct Distort distort;   /* SIRTF distortion coefficients */
147   char *command_format[10]; /* WCS command formats */
148                 /* where %s is replaced by WCS coordinates */
149                 /* where %f is replaced by the image filename */
150                 /* where %x is replaced by image coordinates */
151   double    ltm[4];     /* Image rotation matrix */
152   double    ltv[2];     /* Image offset */
153   int       idpix[2];   /* First pixel to use in image (x, y) */
154   int       ndpix[2];   /* Number of pixels to use in image (x, y) */
155   struct WorldCoor *wcs;    /* WCS upon which this WCS depends */
156   struct WorldCoor *wcsdep; /* WCS depending on this WCS */
157   char      *wcsname;   /* WCS name (defaults to NULL pointer) */
158   char      wcschar;    /* WCS character (A-Z, null, space) */
159   int       logwcs;     /* 1 if DC-FLAG is set for log wavelength */
160 };
161