[wcstools] 01/09: New upstream version 3.9.0
Ole Streicher
olebole-guest at moszumanska.debian.org
Tue Sep 2 11:32:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
olebole-guest pushed a commit to branch debian
in repository wcstools.
commit be9077fecb5d2e38f8b69101cd2157eebf1a402c
Author: Ole Streicher <debian at liska.ath.cx>
Date: Tue Sep 2 11:13:40 2014 +0200
New upstream version 3.9.0
---
Makefile | 5 +-
NEWS | 24 +-
Readme | 33 +-
actread.o | Bin 0 -> 25832 bytes
addpix.c | 2 +-
ang2str.o | Bin 0 -> 7752 bytes
bincat.c | 2 +-
binread.o | Bin 0 -> 28448 bytes
caphot.o | Bin 0 -> 10480 bytes
catrot.c | 2 +-
catutil.o | Bin 0 -> 84688 bytes
cel.o | Bin 0 -> 6024 bytes
char2sp.c | 2 +-
conpix.c | 2 +-
cphead.c | 2 +-
ctgread.o | Bin 0 -> 47656 bytes
daoread.o | Bin 0 -> 5344 bytes
dateutil.o | Bin 0 -> 71608 bytes
dateutil0.o | Bin 0 -> 70016 bytes
delhead.c | 2 +-
delwcs.c | 2 +-
distort.o | Bin 0 -> 8512 bytes
dsspos.o | Bin 0 -> 8352 bytes
edhead.c | 2 +-
fileutil.o | Bin 0 -> 12888 bytes
findstar.o | Bin 0 -> 24584 bytes
fitsfile.o | Bin 0 -> 44072 bytes
fitswcs.o | Bin 0 -> 22040 bytes
fixpix.c | 2 +-
fortwcs.o | Bin 0 -> 9512 bytes
getcol.c | 10 +-
getdate.c | 99 +-
getfits.c | 56 +-
getfits.o | Bin 0 -> 26784 bytes
getftab.c | 2 +-
gethead.c | 111 +-
getpix.c | 232 ++-
getpix.o | Bin 0 -> 32344 bytes
gettab.c | 2 +-
gsc2cat.c | 2 +-
gsc2read.o | Bin 0 -> 7064 bytes
gscread.o | Bin 0 -> 37752 bytes
hget.o | Bin 0 -> 23520 bytes
hput.o | Bin 0 -> 18784 bytes
hput1.o | Bin 0 -> 18296 bytes
i2f.c | 2 +-
iget.o | Bin 0 -> 6520 bytes
imcat.c | 117 +-
imcat.c => imcat0.c | 2 +-
imextract.c | 2 +-
imfill.c | 2 +-
imgetwcs.o | Bin 0 -> 28032 bytes
imhead.c | 2 +-
imhfile.o | Bin 0 -> 35744 bytes
imio.o | Bin 0 -> 18112 bytes
immatch.c | 2 +-
imresize.c | 2 +-
imrot.c | 2 +-
imrotate.o | Bin 0 -> 22464 bytes
imrotate1.o | Bin 0 -> 22648 bytes
imsetwcs.o | Bin 0 -> 38784 bytes
imsize.c | 2 +-
imsmooth.c | 2 +-
imstack.c | 2 +-
imstar.c | 2 +-
imutil.o | Bin 0 -> 63512 bytes
imwcs.c | 2 +-
isimlist.c => isfile.c | 22 +-
isfits.c | 10 +-
isimlist.c | 2 +-
isnum.c | 2 +-
isrange.c | 2 +-
keyhead.c | 2 +-
libwcs/NEWS | 9 +-
libwcs/catutil.c | 87 +-
libwcs/cd | 0
libwcs/ctgread.c | 12 +-
libwcs/distort | 2409 ++++++++++++++++++++++++
libwcs/fileutil.c | 59 +-
libwcs/fitsfile.c | 49 +-
libwcs/fitsfile.h | 11 +-
libwcs/fitswcs.h | 95 +
libwcs/gsc2read.c | 59 +-
libwcs/head | 0
libwcs/imio.c | 10 +-
libwcs/imutil.c | 35 +-
libwcs/ll | 0
libwcs/lwcs | 0
libwcs/sdssread.c | 22 +-
libwcs/sty2 | 1 +
libwcs/tabread.c | 52 +-
libwcs/tail | 0
libwcs/{wcsinit.c => temp} | 11 +-
libwcs/ucacread.c | 3556 +++++++++++++++++++-----------------
libwcs/ucacread.c20130208 | Bin 0 -> 32768 bytes
libwcs/{ucacread.c => ucacread0.c} | 0
libwcs/vi | 0
libwcs/wcs.h | 12 +-
libwcs/wcscat.h | 9 +-
libwcs/wcsinit.c | 18 +-
libwcs/zpxpos.c | 84 +-
lin.o | Bin 0 -> 5680 bytes
matchcat.c | 2 +-
matchstar.o | Bin 0 -> 57520 bytes
nedname.c | 2 +-
nedpos.c | 2 +-
newfits.c | 2 +-
nut1981.o | Bin 0 -> 19432 bytes
nut2006.o | Bin 0 -> 9312 bytes
platefit.o | Bin 0 -> 10616 bytes
platepos.o | Bin 0 -> 9376 bytes
polfit.o | Bin 0 -> 3968 bytes
poly.o | Bin 0 -> 20984 bytes
proj.o | Bin 0 -> 90488 bytes
remap.c | 18 +-
revup.sed | 2 +-
scat.c | 72 +-
sdssread.o | Bin 0 -> 6384 bytes
sethead.c | 12 +-
setpix.c | 2 +-
simpos.c | 96 +-
simposx.c | 5 +-
sky2xy.c | 11 +-
skybotread.o | Bin 0 -> 13664 bytes
skycoor.c | 2 +-
sortstar.o | Bin 0 -> 21048 bytes
sp2char.c | 2 +-
sph.o | Bin 0 -> 5368 bytes
str2dcpp.o | Bin 0 -> 2744 bytes
subpix.c | 2 +-
sumpix.c | 92 +-
tabread.o | Bin 0 -> 68256 bytes
temp | 0
test.list | 4 +
testrot.c | 2 +-
tmcread.o | Bin 0 -> 34528 bytes
tnxpos.o | Bin 0 -> 23712 bytes
ty2read.o | Bin 0 -> 30000 bytes
uacread.o | Bin 0 -> 33440 bytes
ubcread.o | Bin 0 -> 34832 bytes
ucacread.o | Bin 0 -> 46400 bytes
ucacread0.o | Bin 0 -> 38864 bytes
ujcread.o | Bin 0 -> 21208 bytes
wcs.o | Bin 0 -> 64912 bytes
wcscon.o | Bin 0 -> 42992 bytes
wcscon1.o | Bin 0 -> 44896 bytes
wcshead.c | 2 +-
wcsinit.o | Bin 0 -> 43080 bytes
wcslib.o | Bin 0 -> 21552 bytes
wcstrig.o | Bin 0 -> 5120 bytes
webread.o | Bin 0 -> 24480 bytes
worldpos.o | Bin 0 -> 24592 bytes
xy2sky.c | 3 +-
xy2sky1.c | 2 +-
zpxpos.o | Bin 0 -> 17784 bytes
155 files changed, 5610 insertions(+), 2106 deletions(-)
diff --git a/Makefile b/Makefile
index 74c72e9..4b27fd6 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ all: cphead delwcs delhead edhead fixpix gethead i2f imcat imhead immatch \
keyhead skycoor subpix xy2sky wcshead conpix gettab newfits getfits \
imstack imextract sumpix remap getcol getdate imfill imsmooth imresize \
fileroot filename filext char2sp sp2char crlf isnum isrange isfits \
- simpos nedpos bincat
+ isfile simpos nedpos bincat
addpix: addpix.c $(LIBWCS) libwcs/fitsfile.h
$(CC) $(CFLAGS) -o $(BIN)/addpix addpix.c $(LIBS)
@@ -112,6 +112,9 @@ imextract: imextract.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcscat.h
imstar: imstar.c $(LIBWCS) libwcs/fitsfile.h libwcs/wcs.h libwcs/lwcs.h libwcs/wcscat.h
$(CC) $(CFLAGS) -o $(BIN)/imstar imstar.c $(LIBS)
+isfile: isfile.c $(LIBWCS) libwcs/fitshead.h
+ $(CC) $(CFLAGS) -o $(BIN)/isfile isfile.c $(LIBS)
+
isfits: isfits.c $(LIBWCS) libwcs/fitshead.h
$(CC) $(CFLAGS) -o $(BIN)/isfits isfits.c $(LIBS)
diff --git a/NEWS b/NEWS
index c9c1dd0..4010fc7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,32 @@
-Version 3.8.7 (October 19, 2012)
+Version 3.9.0 (August 29, 2014)
+remap: Update usage to -f WCSfile suggested by Steve Willner (2014-02-19)
+sethead: Fix bug dealing with setting the same keyword in multiple file extensions
+imcat, scat, immatch, imwcs: Implement UCAC4 catalog
+fileutil.c: Add next_line() to return one line of file
+fitfile.c: fix buffer reallocation bug in fitsrhead()
+tabread.c: fix file tests
+gsc2read.c and tabread.c: adjust to GSC2.3.3 format
+
+Version 3.8.9 (September 16, 2013)
+imcat, imwcs, immatch, scat: Work around SDSS server failure
+sdssread.c: Add alternate UK and US catalog servers
+
+Version 3.8.8 (April 30, 2013)
+getdate: Add -s option to subtract (or add) days
+getdate: Add self-conversion for *JD's
+getfits: Print error, not blank file, if requested region is off image
+simpos: Update URL for SIMBAD query
+
+Version 3.8.7 (October 31, 2012)
Rename Man to man to avoid problems with Mac OSX file name convention
filedir: If pathname ends in "/", drop last directory
catutil.c: Skip trailing right bracket in aget*()
dateutil.c: Unused l0 dropped from jd2lst(); ts2ss from jd2mst()
-imio.c: Fix errors with character images in minvec() and maxvec()
+imio.c: Fix errors with short and character images in minvec(), maxvec()
wcs.c: Drop d1 and d2 from wcsdist(); diffi from wcsdist1()
wcs.c: Drop depwcs; it's in main wcs structure
wcsinit.c: Drop unused variable iszpx; fix bug in latmin assignment
+zpxpos.c: Fix code for quadratic near pole
Version 3.8.6 (August 10, 2012)
sumpix: Add options i to print index and e to compute medians
diff --git a/Readme b/Readme
index 3164f05..dc090b8 100644
--- a/Readme
+++ b/Readme
@@ -1,4 +1,4 @@
-WCSTools 3.8.7
+WCSTools 3.9.0
WCSTools is a set of software utilities, written in C, which create,
display and manipulate the world coordinate system of a FITS or IRAF
@@ -14,7 +14,7 @@ in the main directory or, on Solaris machines
make -f Makefile.solaris
-This is version 3.8.7 of the WCSTools package developed by Jessica Mink
+This is version 3.9.0 of the WCSTools package developed by Jessica Mink
(jmink at cfa.harvard.edu) at the Smithsonian Astrophysical Observatory,
with significant code or algorithms from
@@ -39,15 +39,24 @@ all of the variables initialized.
The update history is in the NEWS file, but here is what is new:
-Version 3.8.7 (October 19, 2012)
-Rename Man to man to avoid problems with Mac OSX file name convention
-filedir: If pathname ends in "/", drop last directory
-catutil.c: Skip trailing right bracket in aget*()
-dateutil.c: Unused l0 dropped from jd2lst(); ts2ss from jd2mst()
-imio.c: Fix errors with character images in minvec() and maxvec()
-wcs.c: Drop d1 and d2 from wcsdist(); diffi from wcsdist1()
-wcs.c: Drop depwcs; it's in main wcs structure
-wcsinit.c: Drop unused variable iszpx; fix bug in latmin assignment
+Version 3.9.0 (August 29, 2014)
+remap: Update usage to -f WCSfile suggested by Steve Willner (2014-02-19)
+sethead: Fix bug dealing with setting the same keyword in multiple file extensions
+imcat, scat, immatch, imwcs: Implement UCAC4 catalog
+fileutil.c: Add next_line() to return one line of file
+fitfile.c: fix buffer reallocation bug in fitsrhead()
+tabread.c: fix file tests
+gsc2read.c and tabread.c: adjust to GSC2.3.3 format
+
+Version 3.8.9 (September 16, 2013)
+imcat, imwcs, immatch, scat: Work around SDSS server failure
+sdssread.c: Add alternate UK and US catalog servers
+
+Version 3.8.8 (April 30, 2013)
+getdate: Add -s option to subtract (or add) days
+getdate: Add self-conversion for *JD's
+getfits: Print error, not blank file, if requested region is off image
+simpos: Update URL for SIMBAD query
Documentation, with examples and installation directions, is on the
World Wide Web at
@@ -168,5 +177,5 @@ wcshead Print basic world coordinate system information on one line per image
xy2sky Print sky coordinates for given image pixel coordinates on the command
line or in a list file.
--Jessica Mink, SAO, 2012-10-19
+-Jessica Mink, SAO, 2014-08-29
http://tdc-www.harvard.edu/mink/
diff --git a/actread.o b/actread.o
new file mode 100644
index 0000000..fb94c2f
Binary files /dev/null and b/actread.o differ
diff --git a/addpix.c b/addpix.c
index acfaec6..f11b526 100644
--- a/addpix.c
+++ b/addpix.c
@@ -34,7 +34,7 @@
static void usage();
static int newimage = 0;
static int verbose = 0; /* verbose flag */
-static char *RevMsg = "ADDPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ADDPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static void AddPix();
static int version = 0; /* If 1, print only program name and version */
diff --git a/ang2str.o b/ang2str.o
new file mode 100644
index 0000000..fdff7ca
Binary files /dev/null and b/ang2str.o differ
diff --git a/bincat.c b/bincat.c
index aaa3681..6bc34ae 100644
--- a/bincat.c
+++ b/bincat.c
@@ -48,7 +48,7 @@ extern void setrefpix();
extern void setcdelt();
extern struct WorldCoor *GetFITSWCS();
-static char *RevMsg = "BINCAT WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "BINCAT WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose flag */
static int debug = 0; /* debugging flag */
static int bitpix = 0; /* number of bits per pixel (FITS code, 0=no image) */
diff --git a/binread.o b/binread.o
new file mode 100644
index 0000000..19a6406
Binary files /dev/null and b/binread.o differ
diff --git a/caphot.o b/caphot.o
new file mode 100644
index 0000000..165b55c
Binary files /dev/null and b/caphot.o differ
diff --git a/catrot.c b/catrot.c
index cbcebb6..2bb3768 100644
--- a/catrot.c
+++ b/catrot.c
@@ -46,7 +46,7 @@ static int bitpix = 0; /* number of bits per pixel (FITS code) */
static int fitsout = 0; /* Output FITS file from IRAF input if 1 */
static int nsplit = 0; /* Output multiple FITS files from n-extension file */
static int overwrite = 0; /* allow overwriting of input image file */
-static char *RevMsg = "IMROT WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMROT WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int version = 0; /* If 1, print only program name and version */
static int xshift = 0;
static int yshift = 0;
diff --git a/catutil.o b/catutil.o
new file mode 100644
index 0000000..564ad38
Binary files /dev/null and b/catutil.o differ
diff --git a/cel.o b/cel.o
new file mode 100644
index 0000000..94a9491
Binary files /dev/null and b/cel.o differ
diff --git a/char2sp.c b/char2sp.c
index f3747c8..b760616 100644
--- a/char2sp.c
+++ b/char2sp.c
@@ -39,7 +39,7 @@ static int verbose = 0; /* verbose/debugging flag */
static int version = 0; /* If 1, print only program name and version */
static char spchar = '_';
-static char *RevMsg = "CHAR2SP WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "CHAR2SP WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/conpix.c b/conpix.c
index f7a34e8..e4d49bb 100644
--- a/conpix.c
+++ b/conpix.c
@@ -52,7 +52,7 @@ static int version = 0; /* If 1, print only program name and version */
static int setgnoise = 0; /* If 1, pixels have been set to random noise */
static int addgnoise = 0; /* If 1, pixels have random noise added */
-static char *RevMsg = "CONPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "CONPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/cphead.c b/cphead.c
index 24c9d0b..263002e 100644
--- a/cphead.c
+++ b/cphead.c
@@ -41,7 +41,7 @@ static void CopyValues();
extern char *GetFITShead();
static int verbose = 0; /* verbose/debugging flag */
-static char *RevMsg = "CPHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "CPHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int copyall = 0; /* Copy entire header, overwriting old one */
static int nfile = 0;
static int ndec0 = -9;
diff --git a/ctgread.o b/ctgread.o
new file mode 100644
index 0000000..039e050
Binary files /dev/null and b/ctgread.o differ
diff --git a/daoread.o b/daoread.o
new file mode 100644
index 0000000..40eb056
Binary files /dev/null and b/daoread.o differ
diff --git a/dateutil.o b/dateutil.o
new file mode 100644
index 0000000..a3ead17
Binary files /dev/null and b/dateutil.o differ
diff --git a/dateutil0.o b/dateutil0.o
new file mode 100644
index 0000000..bc77940
Binary files /dev/null and b/dateutil0.o differ
diff --git a/delhead.c b/delhead.c
index 99e9732..291ba9d 100644
--- a/delhead.c
+++ b/delhead.c
@@ -53,7 +53,7 @@ static int nproc = 0;
static int overwrite = 0; /* If 1, overwrite input image */
static int first_file = 1;
-static char *RevMsg = "DELHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "DELHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/delwcs.c b/delwcs.c
index d6d6a04..df9c966 100644
--- a/delwcs.c
+++ b/delwcs.c
@@ -38,7 +38,7 @@ extern int DelWCSFITS ();
static int verbose = 0; /* Verbose/debugging flag */
static int newimage = 0; /* New image flag */
static int readimage = 1; /* Read and write image as well as header */
-static char *RevMsg = "DELWCS WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "DELWCS WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int version = 0; /* If 1, print only program name and version */
int
diff --git a/distort.o b/distort.o
new file mode 100644
index 0000000..4fb1198
Binary files /dev/null and b/distort.o differ
diff --git a/dsspos.o b/dsspos.o
new file mode 100644
index 0000000..0918b45
Binary files /dev/null and b/dsspos.o differ
diff --git a/edhead.c b/edhead.c
index 15fbfd7..e0a1912 100644
--- a/edhead.c
+++ b/edhead.c
@@ -39,7 +39,7 @@ static void EditHead();
static int newimage = 0;
static int verbose = 0; /* verbose flag */
static char *editcom0; /* Editor command from command line */
-static char *RevMsg = "EDHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "EDHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int version = 0; /* If 1, print only program name and version */
diff --git a/fileutil.o b/fileutil.o
new file mode 100644
index 0000000..0952fed
Binary files /dev/null and b/fileutil.o differ
diff --git a/findstar.o b/findstar.o
new file mode 100644
index 0000000..f7769b4
Binary files /dev/null and b/findstar.o differ
diff --git a/fitsfile.o b/fitsfile.o
new file mode 100644
index 0000000..5b12584
Binary files /dev/null and b/fitsfile.o differ
diff --git a/fitswcs.o b/fitswcs.o
new file mode 100644
index 0000000..28b21b7
Binary files /dev/null and b/fitswcs.o differ
diff --git a/fixpix.c b/fixpix.c
index 551a215..e44d51b 100644
--- a/fixpix.c
+++ b/fixpix.c
@@ -47,7 +47,7 @@ static int nfix = 0; /* Number of regions to fix
static int version = 0; /* If 1, print only program name and version */
static int xl[MAXFIX],yl[MAXFIX]; /* Lower left corners of regions (1 based) */
static int xr[MAXFIX],yr[MAXFIX]; /* Upper right corners of regions (1 based) */
-static char *RevMsg = "FIXPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "FIXPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/fortwcs.o b/fortwcs.o
new file mode 100644
index 0000000..4054d0e
Binary files /dev/null and b/fortwcs.o differ
diff --git a/getcol.c b/getcol.c
index 4f3fb56..2785d3e 100644
--- a/getcol.c
+++ b/getcol.c
@@ -1,9 +1,9 @@
/* File getcol.c
- * April 18, 2011
+ * August 12, 2013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1999-2011
+ Copyright (C) 1999-2013
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -37,7 +37,7 @@
#define MAXFILES 2000
#define MAXLINES 100000
-static char *RevMsg = "GETCOL WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "GETCOL WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static void usage();
static int ListFile();
@@ -762,7 +762,7 @@ char *lfile; /* Name of file with lines to list */
/* Check conditions */
ntok = setoken (&tokens, line, cwhite);
if (counttok) {
- printf ("%d", ntok);
+ printf ("%d", ntok-1);
if (verbose)
printf (" columns in %s", filename);
else
@@ -1782,4 +1782,6 @@ void *pd1, *pd2;
* Sep 25 2009 Fix error message about illegal operation
*
* Apr 18 2011 Fix allocation bug for median of too many entries
+ *
+ * Aug 12 2013 Subtract one from returned token count for accuracy
*/
diff --git a/getdate.c b/getdate.c
index 9ba7e61..5a2a117 100644
--- a/getdate.c
+++ b/getdate.c
@@ -1,9 +1,9 @@
/* File getdate.c
- * March 27, 2012
+ * April 30, 3013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1999-2012
+ Copyright (C) 1999-2013
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -66,7 +66,7 @@
#define MST 3
#define LST 4
-static char *RevMsg = "GETDATE WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "GETDATE WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static void usage();
static void ConvertDate();
@@ -85,6 +85,7 @@ static double dec = 0.0;
static int coorsys = WCS_J2000;
extern void sdatedec();
static double longitude = -1.0;
+static double nsub = 0; /* Number of days to subtract */
int
main (ac, av)
@@ -308,6 +309,13 @@ char **av;
ac--;
break;
+ case 's': /* Subtract days from command line date */
+ if (ac < 2)
+ usage();
+ nsub = (int) (atof (*++av));
+ ac--;
+ break;
+
case 't': /* Print time without date */
timeonly++;
break;
@@ -440,7 +448,8 @@ usage ()
fprintf(stderr," -f: Format for output number (C printf)\n");
fprintf(stderr," -h hours: Longitude in hours, west positive\n");
fprintf(stderr," -l degrees: Longitude in degrees, west positive\n");
- fprintf(stderr," -n: Number of decimal places in sec, epoch, JD\n");
+ fprintf(stderr," -n num: Number of decimal places in sec, epoch, JD\n");
+ fprintf(stderr," -s days: Number of days to subtract\n");
fprintf(stderr," -t: Print time without date\n");
fprintf(stderr," -v: Verbose\n");
exit (1);
@@ -596,6 +605,11 @@ char *timestring; /* Input time string */
vtime = 0.0;
}
}
+ if (nsub != 0) {
+ jd = dt2jd (vdate, vtime);
+ jd1 = jd - (double) nsub;
+ jd2dt (jd1, &vdate, &vtime);
+ }
if (verbose)
printf ("%s %s -> ", datestring, timestring);
@@ -727,6 +741,11 @@ char *timestring; /* Input time string */
}
else
fitsdate = datestring;
+ if (nsub != 0) {
+ jd = fd2jd (fitsdate);
+ jd1 = jd - (double) nsub;
+ fitsdate = jd2fd (jd1);
+ }
if (verbose)
printf ("%s -> ", fitsdate);
switch (outtype) {
@@ -1006,6 +1025,8 @@ char *timestring; /* Input time string */
vtime = str2dec (timestring);
jd = jd + vtime / 24.0;
}
+ if (nsub != 0)
+ jd = jd - (double) nsub;
if (verbose)
printf ("%.5f -> ", jd);
switch (outtype) {
@@ -1021,6 +1042,9 @@ char *timestring; /* Input time string */
epoch = jd2epj (jd);
printf (outform, epoch);
break;
+ case DTJD:
+ printf (outform, jd);
+ break;
case DTHJD:
jd = jd2hjd (jd, ra, dec, coorsys);
printf (outform, jd);
@@ -1111,6 +1135,8 @@ char *timestring; /* Input time string */
}
if (verbose)
printf ("%.5f -> ", jd);
+ if (nsub != 0)
+ jd = jd - (double) nsub;
switch (outtype) {
case DTEP:
epoch = mjd2ep (jd);
@@ -1138,6 +1164,9 @@ char *timestring; /* Input time string */
jd = mjd2mhjd (jd, ra, dec, coorsys);
printf (outform, jd);
break;
+ case DTMJD:
+ printf (outform, jd);
+ break;
case DTVIG:
mjd2dt (jd, &vdate, &vtime);
if (outtime == ET) dt2et (&vdate, &vtime);
@@ -1206,6 +1235,8 @@ char *timestring; /* Input time string */
}
if (verbose)
printf ("%.5f -> ", jd);
+ if (nsub != 0)
+ jd = jd - (double) nsub;
switch (outtype) {
case DTEP:
jd = hjd2jd (jd, ra, dec, coorsys);
@@ -1231,6 +1262,9 @@ char *timestring; /* Input time string */
jd = jd2mjd (jd);
printf (outform, jd);
break;
+ case DTHJD:
+ printf (outform, jd);
+ break;
case DTMHJD:
jd = jd2mjd (jd);
printf (outform, jd);
@@ -1314,6 +1348,8 @@ char *timestring; /* Input time string */
}
if (verbose)
printf ("%.5f -> ", jd);
+ if (nsub != 0)
+ jd = jd - (double) nsub;
switch (outtype) {
case DTEP:
jd = mhjd2mjd (jd, ra, dec, coorsys);
@@ -1334,6 +1370,9 @@ char *timestring; /* Input time string */
jd = mjd2jd (jd);
printf (outform, jd);
break;
+ case DTMHJD:
+ printf (outform, jd);
+ break;
case DTJD:
jd = mhjd2mjd (jd, ra, dec, coorsys);
jd = mjd2jd (jd);
@@ -1617,6 +1656,11 @@ char *timestring; /* Input time string */
if (datestring != NULL) {
if (strcmp (datestring, "now"))
ts = atof (datestring);
+ if (nsub != 0) {
+ jd = ts2jd (ts);
+ jd1 = jd - (double) nsub;
+ ts = jd2ts (jd1);
+ }
if (verbose)
printf ("%.3f -> ", ts);
switch (outtype) {
@@ -1697,6 +1741,9 @@ char *timestring; /* Input time string */
break;
case DTDSEC:
ts = atof (datestring);
+ if (nsub != 0) {
+ ts = ts - ((double) nsub * 86400.0);
+ }
switch (outtype) {
case DTFITS:
fitsdate = tsd2fd (ts);
@@ -1712,8 +1759,12 @@ char *timestring; /* Input time string */
if (datestring != NULL) {
if (strcmp (datestring, "now"))
its = atoi (datestring);
+ if (nsub != 0) {
+ its = its - (nsub * 86400);
+ }
if (verbose)
printf ("%d -> ", its);
+ ts = (double) its;
switch (outtype) {
case DTEP:
ts = tsi2ts (ts);
@@ -1805,6 +1856,10 @@ char *timestring; /* Input time string */
}
else
its = (int) ts;
+ if (nsub != 0) {
+ its = its - (nsub * 86400);
+ ts = (double) its;
+ }
if (verbose)
printf ("%d -> ", its);
switch (outtype) {
@@ -2144,6 +2199,11 @@ char *timestring; /* Input time string */
break;
case DTVIG:
ut2dt (&vdate, &vtime);
+ if (nsub != 0) {
+ jd = dt2jd (vdate, vtime);
+ jd1 = jd - (double) nsub;
+ jd2dt (jd1, &vdate, &vtime);
+ }
if (outtime == ET) dt2et (&vdate, &vtime);
if (outtime == GST) dt2gst (&vdate, &vtime);
if (outtime == MST) dt2mst (&vdate, &vtime);
@@ -2156,6 +2216,11 @@ char *timestring; /* Input time string */
break;
case DTFITS:
newfdate = ut2fd ();
+ if (nsub != 0) {
+ jd = fd2jd (newfdate);
+ jd1 = jd - (double) nsub;
+ newfdate = jd2fd (jd1);
+ }
if (outtime == ET) newfdate = fd2et (newfdate);
if (outtime == GST) newfdate = fd2gst (newfdate);
if (outtime == MST) newfdate = fd2mst (newfdate);
@@ -2184,20 +2249,32 @@ char *timestring; /* Input time string */
break;
case DTJD:
jd = ut2jd ();
+ if (nsub != 0) {
+ jd = jd - (double) nsub;
+ }
if (outtime == ET) jd = jd2jed (jd);
printf (outform, jd);
break;
case DTMJD:
jd = ut2mjd ();
+ if (nsub != 0) {
+ jd = jd - (double) nsub;
+ }
printf (outform, jd);
break;
case DTHJD:
jd = ut2jd ();
+ if (nsub != 0) {
+ jd = jd - (double) nsub;
+ }
jd = jd2hjd (jd, ra, dec, coorsys);
printf (outform, jd);
break;
case DT1950:
ts = ut2ts ();
+ if (nsub != 0) {
+ ts = ts - (86400.0 * (double) nsub);
+ }
if (outtime == ET) ts = ts2ets (ts);
if (outtime == GST) ts = ts2gst (ts);
if (outtime == MST) ts = ts2mst (ts);
@@ -2205,14 +2282,25 @@ char *timestring; /* Input time string */
break;
case DTIRAF:
its = ut2tsi ();
+ if (nsub != 0) {
+ its = its - (86400 * nsub);
+ }
printf (outform, its);
break;
case DTUNIX:
lts = ut2tsu ();
+ if (nsub != 0) {
+ its = its - (86400 * nsub);
+ }
printf (outform, lts);
break;
case DTDOY:
ut2doy (&year, &doy);
+ if (nsub != 0) {
+ jd = doy2jd (year, doy);
+ jd1 = jd - (double) nsub;
+ jd2doy (jd1, &year, &doy);
+ }
sprintf (temp, outform, doy);
printf ("%04d %s\n", year, temp);
break;
@@ -2281,4 +2369,7 @@ char *timestring; /* Input time string */
* Jan 24 2012 Add scale factor to convert date RFN's to DT date
* Feb 15 2012 Add option to read ra dec sys before time from file
* Mar 27 2012 Fix bug copying string to ts0 found by Michal Szymanski
+ *
+ * Jan 3 2013 Add -s option to subtract days
+ * Apr 30 2013 Add self-conversion options for JDs
*/
diff --git a/getfits.c b/getfits.c
index 8a68e3c..18fffbe 100644
--- a/getfits.c
+++ b/getfits.c
@@ -1,9 +1,9 @@
/* File getfits.c
- * April 13, 2010
+ * September 17, 2013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 2002-2010
+ Copyright (C) 2002-2013
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -28,8 +28,7 @@
#include <errno.h>
#include <unistd.h>
#include <math.h>
-#include "libwcs/fitsfile.h"
-#include "libwcs/wcs.h"
+#include "libwcs/fitswcs.h"
#include "libwcs/wcscat.h"
#define MAXRANGE 20
@@ -44,7 +43,7 @@ static void nextname(); /* Find next available name (namea, nameb, ...) */
static int ExtractFITS();
static int verbose = 0; /* verbose/debugging flag */
-static char *RevMsg = "GETFITS WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "GETFITS WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int version = 0; /* If 1, print only program name and version */
static char outname[128]; /* Name for output image */
static char outdir[256]; /* Output directory pathname */
@@ -230,7 +229,7 @@ char **av;
}
}
- /* center or center and size of section to extract */
+ /* Center or center and size of section to extract */
else if (isnum (*av)) {
if (ac > 2 && isnum (*(av+1)) && (syscoor = wcscsys (*(av+2))) > 0) {
ra0 = str2ra (*av++);
@@ -253,7 +252,7 @@ char **av;
}
}
- /* range of pixels to extract */
+ /* Range of pixels to extract */
else if (isrange (*av)) {
if (crange == NULL)
crange = str;
@@ -261,12 +260,13 @@ char **av;
rrange = str;
}
+ /* File with list of image files */
else if (*av[0] == '@') {
listfile = *av + 1;
}
/* Image file */
- else if (isfits (*av)) {
+ else if (isfits (*av) || isiraf (*av)) {
if (nfile >= maxnfile) {
maxnfile = maxnfile * 2;
nbytes = maxnfile * sizeof (char *);
@@ -289,17 +289,17 @@ char **av;
if (xdpix && !ydpix)
ydpix = xdpix;
- /* now there are ac remaining file names starting at av[0] */
+ /* Process files from listfile one at a time */
if (listfile && isimlist (listfile)) {
nfile = getfilelines (listfile);
if ((flist = fopen (listfile, "r")) == NULL) {
- fprintf (stderr,"I2F: Image list file %s cannot be read\n",
+ fprintf (stderr,"GETFITS: Image list file %s cannot be read\n",
listfile);
usage ();
}
for (ifile = 0; ifile < nfile; ifile++) {
first_token (flist, 254, filename);
- ExtractFITS (filename,kwd,nkwd);
+ (void) ExtractFITS (filename,kwd,nkwd);
}
fclose (flist);
}
@@ -325,12 +325,15 @@ char *errmsg; /* Error message */
if (*errmsg)
fprintf (stderr, "*** %s ***\n", errmsg);
fprintf (stderr,"Extract FITS files from FITS image files\n");
- fprintf(stderr,"Usage: getfits -sv [-i num] [-o name] [-d dir] file.fits [xrange yrange] [x y dx [dy]] ...\n");
- fprintf(stderr," or : getfits [-sv1][-i num][-o name] [-d path] @fitslist [xrange yrange] [x y dx [dy]]\n");
+ fprintf(stderr,"Usage: getfits -sv [-i num] [-o name] [-d dir] file.fits xrange yrange...\n");
+ fprintf(stderr," or : getfits -sv [-i num] [-o name] [-d dir] file.fits [x y dx [dy] ...\n");
+ fprintf(stderr," or : getfits [-sv1][-i num][-o name] [-d path] @fitslist xrange yrange\n");
+ fprintf(stderr," or : getfits [-sv1][-i num][-o name] [-d path] @fitslist x y dx [dy]\n");
fprintf(stderr," xrange: Columns to extract in format x1-x2\n");
fprintf(stderr," yrange: Rows to extract in format y1-y2\n");
- fprintf(stderr," x y: Center pixel (column row) of region to extract\n");
- fprintf(stderr," hh:mm:ss dd:mm:ss sys: Center pixel in sky coordintes\n");
+ fprintf(stderr," x y: Center pixel of region to extract\n");
+ fprintf(stderr," column row or\n");
+ fprintf(stderr," hh:mm:ss dd:mm:ss system (sky coordinates)\n");
fprintf(stderr," dx dy: Width and height in pixels of region to extract\n");
fprintf(stderr," (Height is same as width if omitted)\n");
fprintf(stderr," -d dir: write FITS file(s) to this directory\n");
@@ -421,7 +424,7 @@ int nkwd;
}
if (ra0 > -99.0 && dec0 > -99.0) {
- wcs = GetWCSFITS (name, header, verbose);
+ wcs = GetWCSFITS (name, verbose);
if (wcs->lngcor != NULL) {
istnx = 1;
}
@@ -467,6 +470,15 @@ int nkwd;
ifrow1 = 1;
ifrow2 = nrows;
}
+
+ /* Return with error if both first and last row off image */
+ if ((ifrow1 < 1 && ifrow2 < 1) ||
+ (ifrow1 > nrows && ifrow2 > nrows)) {
+ fprintf (stderr,"GETFITS: Rows %d-%d off image %s\n",
+ ifrow1, ifrow2, name);
+ return (1);
+ }
+
if (ifrow1 < 1)
ifrow1 = 1;
if (ifrow2 < 1)
@@ -492,6 +504,15 @@ int nkwd;
ifcol1 = 1;
ifcol2 = ncols;
}
+
+ /* Return with error if both first and last column off image */
+ if ((ifcol1 < 1 && ifcol2 < 1) ||
+ (ifcol1 > ncols && ifcol2 > ncols)) {
+ fprintf (stderr,"GETFITS: Columns %d-%d off image %s\n",
+ ifcol1, ifcol2, name);
+ return (1);
+ }
+
if (ifcol1 < 1)
ifcol1 = 1;
if (ifcol2 < 1)
@@ -726,4 +747,7 @@ char *newname;
* Apr 4 2008 Make extracted TNX WCS dependent on original PLATE WCS
*
* Apr 10 2010 Fix bug so WCS is not accessed after it is freed
+ *
+ * Jan 22 2012 Print error, not blank file, if requested region is off image
+ * Sep 17 2013 Include fitswcs.h
*/
diff --git a/getfits.o b/getfits.o
new file mode 100644
index 0000000..04f2422
Binary files /dev/null and b/getfits.o differ
diff --git a/getftab.c b/getftab.c
index f18b477..c0b8172 100644
--- a/getftab.c
+++ b/getftab.c
@@ -40,7 +40,7 @@ static void usage();
static void PrintValues();
static int maxncond = 100;
-static char *RevMsg = "GETFTAB WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "GETFTAB WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int nfile = 0;
diff --git a/gethead.c b/gethead.c
index b7b2b42..5ddff91 100644
--- a/gethead.c
+++ b/gethead.c
@@ -1,9 +1,9 @@
/* File gethead.c
- * August 10, 2012
+ * August 25, 2014
* By Jessica Mink Harvard-Smithsonian Center for Astrophysics)
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1996-2012
+ Copyright (C) 1996-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -47,7 +47,7 @@ extern char *GetFITShead();
static char nextnsp();
static int PrintValues();
-static char *RevMsg = "GETHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "GETHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int nfile = 0;
@@ -72,12 +72,13 @@ static int ncond=0; /* Number of keyword conditions to check */
static int condand=1; /* If 1, AND comparisons, else OR */
static int toeol = 0; /* If 1, return values from ASCII file to EOL */
static int maxml = 20000; /* Maximum length of IRAF multi-line keyword */
-static char **cond; /* Conditions to check */
-static char **ccond; /* Condition characters */
+static char **cond, **newcond; /* Conditions to check */
+static char **ccond, **newccond; /* Condition characters */
static int nproc = 0;
static char *extensions; /* Extension number(s) or name to read */
static char *extension; /* Extension number or name to read */
static int filekey = 0; /* If 1, FILENAME keyword has been requested */
+static char *mstring; /* IRAF keyword multi-line value */
int
main (ac, av)
@@ -85,12 +86,13 @@ int ac;
char **av;
{
char *str;
- char **kwd; /* Keywords to read */
+ char **kwd; /* Keywords to read */
char **kwdnew; /* Keywords to read */
int nkwd = 0;
int nkwd1 = 0;
- char **fn, **newfn, **newcond, **newccond;
- int *ft, *newft;
+ char **fn, **newfn; /* File name arrays */
+ char wcond, **newccond;
+ int *ft, *newft; /* File type vectors to match fn[] */
int ifile;
int lfn;
char filename[256];
@@ -116,10 +118,13 @@ char **av;
int nrmax=10;
struct Range *erange = NULL;
+ mstring = (char *) calloc (maxml, 1);
+
ilistfile = NULL;
klistfile = NULL;
extension = NULL;
extensions = NULL;
+ namext = NULL;
ncond = 0;
nfile = 0;
fn = (char **)calloc (maxnfile, sizeof(char *));
@@ -195,6 +200,8 @@ char **av;
if (ac < 2)
usage();
maxml = (int) (atof (*++av));
+ free (mstring);
+ mstring = (char *) calloc (maxml, 1);
ac--;
break;
@@ -266,7 +273,8 @@ char **av;
listall++;
erange = RangeInit (extensions, nrmax);
nfext = rgetn (erange);
- extension = calloc (1, 8);
+ if (verbose)
+ fprintf (stderr, "Searching extensions %s\n", extensions);
}
else {
extension = extensions;
@@ -274,6 +282,8 @@ char **av;
nfext = 1;
else
nfext = 0;
+ if (verbose)
+ fprintf (stderr, "Searching extension %s\n", extension);
}
break;
@@ -613,6 +623,7 @@ char **av;
filetype = FILE_ASCII;
if (nfext > 1) {
rstart (erange);
+ extension = calloc (1, 8);
for (i = 0; i < nfext; i++) {
j = rgeti4 (erange);
sprintf (extension, "%d", j);
@@ -626,17 +637,23 @@ char **av;
strcat (namext,extroot);
strcat (namext, extension);
if (PrintValues (namext, filetype, nkwd, kwd)) {
- if (namext != NULL)
+ if (namext != NULL) {
free (namext);
+ namext = NULL;
+ }
break;
}
- if (namext != NULL)
+ if (namext != NULL) {
free (namext);
+ namext = NULL;
+ }
}
- if (extension != NULL)
+ if (extension != NULL) {
free (extension);
- if (erange != NULL)
- free (erange);
+ extension = NULL;
+ }
+ /* if (erange != NULL)
+ free (erange); */
}
else
PrintValues (filename, filetype, nkwd, kwd);
@@ -663,6 +680,7 @@ char **av;
/* If there is a range of extensions, use them */
if (nfext > 1) {
rstart (erange);
+ extension = calloc (1, 8);
for (i = 0; i < nfext; i++) {
j = rgeti4 (erange);
sprintf (extension, "%d", j);
@@ -677,17 +695,23 @@ char **av;
strcat (namext, extension);
sprintf (extension, "%d", j);
if (PrintValues (namext, ft[ifile], nkwd, kwd)) {
- if (namext != NULL)
+ if (namext != NULL) {
free (namext);
+ namext = NULL;
+ }
break;
}
- if (namext != NULL)
+ if (namext != NULL) {
free (namext);
+ namext = NULL;
+ }
}
- if (extension != NULL)
+ if (extension != NULL) {
free (extension);
- if (erange != NULL)
- free (erange);
+ extension = NULL;
+ }
+ /* if (erange != NULL)
+ free (erange); */
}
else
(void) PrintValues (fn[ifile], ft[ifile], nkwd, kwd);
@@ -705,6 +729,7 @@ char **av;
if (ilistfile != NULL)
fclose (flist);
+ free (mstring);
return (0);
}
@@ -761,7 +786,6 @@ char *kwd[]; /* Names of keywords for which to print values */
char *filename;
char outline[1000];
char padline[1000];
- char *mstring;
char ctab = (char) 9;
char cspace = (char) 32;
char *subkwd;
@@ -777,9 +801,11 @@ char *kwd[]; /* Names of keywords for which to print values */
char numstr[32], numstr1[32];
int pass, iwcs, nwild, sys1, sys2, ncdec;
- mstring = (char *) calloc (maxml, 1);
-
+ ext = NULL;
namext = NULL;
+ filepath = NULL;
+ header = NULL;
+ mstring[0] = (char) 0;
ext = strchr (name, ',');
if (extension && !ext) {
nch = strlen (name) + 2 + strlen (extension);
@@ -807,6 +833,8 @@ char *kwd[]; /* Names of keywords for which to print values */
filepath = (char *) calloc (1, nch);
strcpy (filepath, namext);
}
+ if (verbose)
+ fprintf (stderr, "Reading from file %s\n", filepath);
if (!tabout && listall)
printfill = 1;
@@ -814,37 +842,42 @@ char *kwd[]; /* Names of keywords for which to print values */
/* Read ASCII file into buffer */
if (filetype == FILE_ASCII) {
if ((header = getfilebuff (filepath)) == NULL) {
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (verbose) fprintf (stderr, "GETHEAD: file %s has no content\n",
filepath);
if (filepath != NULL)
free (filepath);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
return (-1);
}
else if (strlen (header) == 0) {
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (verbose) fprintf (stderr, "GETHEAD: file %s has null at start\n",
filepath);
if (filepath != NULL)
free (filepath);
+ free (header);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
+ header = NULL;
return (-1);
}
}
/* Retrieve FITS header from FITS or IRAF .imh file */
else if ((header = GetFITShead (filepath, verbose)) == NULL) {
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (filepath != NULL)
free (filepath);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
return (-1);
}
@@ -957,26 +990,30 @@ char *kwd[]; /* Names of keywords for which to print values */
pass = 1;
}
if (condand && !pass) {
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (filepath != NULL)
free (filepath);
if (header != NULL)
free (header);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
+ header = NULL;
return (0);
}
}
if (!pass) {
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (filepath != NULL)
free (filepath);
if (header != NULL)
free (header);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
+ header = NULL;
return (0);
}
}
@@ -1320,14 +1357,16 @@ char *kwd[]; /* Names of keywords for which to print values */
printf ("%s\n", outline);
}
- if (mstring != NULL)
- free (mstring);
if (namext != NULL)
free (namext);
if (filepath != NULL)
free (filepath);
if (header != NULL)
free (header);
+ ext = NULL;
+ namext = NULL;
+ filepath = NULL;
+ header = NULL;
return (0);
}
@@ -1446,4 +1485,8 @@ char *string;
* Dec 14 2011 If length of header/file content string is zero, exit with error
*
* Aug 10 2012 Call fk425e() instead of fk425()
+ *
+ * May 7 2014 Fix bug with unallocated extension
+ * May 29 2014 Fix bugs dealing with freeing allocated memory
+ * Aug 25 2014 Fix bug dealing with ranges of extensions
*/
diff --git a/getpix.c b/getpix.c
index c10fe22..e8b2ef9 100644
--- a/getpix.c
+++ b/getpix.c
@@ -1,9 +1,9 @@
/* File getpix.c
- * September 21, 2010
+ * January 10, 2014
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics)
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1996-2010
+ Copyright (C) 1996-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -32,11 +32,16 @@
#include "libwcs/fitsfile.h"
#include "libwcs/wcscat.h"
+#define MAXFILES 2000
+static int maxnfile = MAXFILES;
+#define MAXNPIX 100;
+static int maxnpix = MAXNPIX;
+
static void usage();
static void PrintPix();
static void procpix();
-static char *RevMsg = "GETPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "GETPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static int verbose = 0; /* verbose/debugging flag */
static int version = 0; /* If 1, print only program name and version */
@@ -47,7 +52,8 @@ static int gtcheck = 0; /* If 1, list pixels greater than gtval */
static int ltcheck = 0; /* If 1, list pixels less than ltval */
static int nopunct=0; /* If 1, print output with no punctuation */
static int printrange = 0; /* If 1, print range of values, not values */
-static int printmean = 0; /* If 1, print mean of values, not values*/
+static int printmean = 0; /* If 1, print mean of values, not values */
+static int printname = 0; /* If 1, print file name */
static double gtval = 0.0;
static double ltval = 0.0;
static double ra0 = -99.0; /* Initial center RA in degrees */
@@ -67,8 +73,12 @@ main (ac, av)
int ac;
char **av;
{
- char *str;
- char *fn;
+ char *str, *str1;
+ char listfile[256];
+ char **fn;
+ char filename[256];
+ int ifile, nbytes;
+ FILE *flist;
char *rrange; /* Row range string */
char *crange; /* Column range string */
char *rstr;
@@ -77,7 +87,7 @@ char **av;
int systemp;
int i;
int npix = 0;
- int maxnpix = 100;
+ int nfile;
char linebuff[1024];
char listname[256];
char *line;
@@ -89,8 +99,10 @@ char **av;
int *xp1, *yp1;
double x, y;
- xpix = calloc (maxnpix, sizeof (int));
- ypix = calloc (maxnpix, sizeof (int));
+ nfile = 0;
+ fn = (char **)calloc (maxnfile, sizeof(char *));
+ xpix = (int *)calloc (maxnpix, sizeof (int));
+ ypix = (int *)calloc (maxnpix, sizeof (int));
/* Check for help or version command first */
str = *(av+1);
@@ -103,11 +115,14 @@ char **av;
crange = NULL;
rrange = NULL;
- fn = NULL;
/* crack arguments */
for (av++; --ac > 0; av++) {
str = *av;
+ if (ac > 0)
+ str1 = *(av+1);
+ else
+ str1 = NULL;
/* Output format */
if (str[0] == '%') {
@@ -136,6 +151,10 @@ char **av;
ac--;
break;
+ case 'h': /* Print file name above pixel values */
+ printname++;
+ break;
+
case 'i': /* Identifier precedes x y in file */
identifier++;
break;
@@ -204,13 +223,14 @@ char **av;
}
/* Set search RA, Dec, and equinox if colon in argument */
- else if (strsrch (*av,":") != NULL) {
+ else if (isnum (str) == 3 && isnum (str1) == 3) {
if (ac < 2)
usage ();
else {
- strcpy (rstr, *av);
+ strcpy (rstr, str);
ac--;
- strcpy (dstr, *++av);
+ av++;
+ strcpy (dstr, str1);
ra0 = str2ra (rstr);
dec0 = str2dec (dstr);
ac--;
@@ -228,11 +248,12 @@ char **av;
}
/* Search coordinates in degrees if coordinate system specified */
- else if (isnum (str) == 2 && ac > 1 && isnum (*(av+1)) == 2) {
- rstr = *av++;
- ac--;
- dstr = *av++;
+ else if (isnum (str) == 2 && isnum (str) == 2) {
+ rstr = str;
+ dstr = str1;
ac--;
+ av++;
+ av++;
if (ac > 0 && (systemp = wcscsys (*av)) > 0) {
ra0 = atof (rstr);
dec0 = atof (dstr);
@@ -277,7 +298,7 @@ char **av;
}
/* Coordinate pairs for pixels to print */
- else if (isnum (str) && ac > 1 && isnum (*(av+1))) {
+ else if (isnum (str) && isnum (str1)) {
if (npix+1 > maxnpix) {
maxnpix = 2 * maxnpix;
xp1 = calloc (maxnpix, sizeof (int));
@@ -291,77 +312,114 @@ char **av;
xpix = xp1;
ypix = yp1;
}
- ix = atoi (*av);
- iy = atoi (*(av+1));
+ ix = atoi (str);
+ iy = atoi (str1);
if (ix == 0 || iy == 0) {
- crange = *av++;
- rrange = *av;
+ crange = str1;
+ rrange = str;
}
else {
xpix[npix] = ix;
ypix[npix] = iy;
npix++;
- av++;
}
- ac--;
+ av++;
ac--;
}
/* Range of pixels to print (only one allowed) */
- else if (isrange (str) && ac > 1 && isrange (*(av+1))) {
- crange = *av++;
+ else if (isrange (str) && isrange (str1)) {
+ rrange = str;
+ crange = str1;
ac--;
- rrange = *av;
+ av++;
}
- /* File containing a list of image coordinates */
+ /* File containing a list of files or image coordinates */
else if (str[0] == '@') {
strcpy (listname, str+1);
- nlines = getfilelines (listname);
- fd = fopen (listname, "r");
- if (fd == NULL) {
- fprintf (stderr, "Cannot read file %s\n", listname);
- nlines = 0;
+ if (isimlist (listname)) {
+ strcpy (listfile, listname);
+ listname[0] = (char) 0;
}
- for (iline = 0; iline < nlines; iline++) {
- if (!fgets (linebuff, 1023, fd))
- break;
- line = linebuff;
- if (line[0] == '#')
- continue;
- if (identifier)
- sscanf (line,"%s %s %s", temp, xstr, ystr);
- else
- sscanf (line,"%s %s", xstr, ystr);
- if (npix+1 > maxnpix) {
- maxnpix = 2 * maxnpix;
- xp1 = calloc (maxnpix, sizeof (int));
- yp1 = calloc (maxnpix, sizeof (int));
- for (i = 0; i < maxnpix; i++) {
- xp1[i] = xpix[i];
- yp1[i] = ypix[i];
+ else {
+ nlines = getfilelines (listname);
+ fd = fopen (listname, "r");
+ if (fd == NULL) {
+ fprintf (stderr, "GETPIX: Cannot read file %s\n", listname);
+ nlines = 0;
+ }
+ for (iline = 0; iline < nlines; iline++) {
+ if (!fgets (linebuff, 1023, fd))
+ break;
+ line = linebuff;
+ if (line[0] == '#')
+ continue;
+ if (identifier)
+ sscanf (line,"%s %s %s", temp, xstr, ystr);
+ else
+ sscanf (line,"%s %s", xstr, ystr);
+ if (npix+1 > maxnpix) {
+ maxnpix = 2 * maxnpix;
+ xp1 = calloc (maxnpix, sizeof (int));
+ yp1 = calloc (maxnpix, sizeof (int));
+ for (i = 0; i < maxnpix; i++) {
+ xp1[i] = xpix[i];
+ yp1[i] = ypix[i];
+ }
+ free (xpix);
+ free (ypix);
+ xpix = xp1;
+ ypix = yp1;
}
- free (xpix);
- free (ypix);
- xpix = xp1;
- ypix = yp1;
+ xpix[npix] = atoi (xstr);
+ ypix[npix] = atoi (ystr);
+ npix++;
}
- xpix[npix] = atoi (xstr);
- ypix[npix] = atoi (ystr);
- npix++;
}
ac--;
}
- /* file name */
- else
- fn = str;
-
+ /* Image file name */
+ else if (isfits (str) || isiraf (str)) {
+ if (nfile >= maxnfile) {
+ maxnfile = maxnfile * 2;
+ nbytes = maxnfile * sizeof (char *);
+ fn = (char **) realloc ((void *)fn, nbytes);
+ }
+ fn[nfile] = str;
+ nfile++;
+ }
}
- if (fn && ((crange && rrange) || npix > 0))
- PrintPix (fn, crange, rrange, npix, xpix, ypix);
+ if ((crange && rrange) || npix > 0) {
+
+ /* Process files already read from the command line */
+ if (fn) {
+ for (ifile = 0; ifile < nfile; ifile++) {
+ PrintPix (fn[ifile], crange, rrange, npix, xpix, ypix);
+ }
+ }
+
+ /* Process files from listfile one at a time */
+ else if (isimlist (listfile)) {
+ nfile = getfilelines (listfile);
+ if ((flist = fopen (listfile, "r")) == NULL) {
+ fprintf (stderr,"GETPIX: Image list file %s cannot be read\n",
+ listfile);
+ usage ();
+ }
+ for (ifile = 0; ifile < nfile; ifile++) {
+ first_token (flist, 254, filename);
+ PrintPix (filename, crange, rrange, npix, xpix, ypix);
+ }
+ fclose (flist);
+ }
+ }
+ free (xpix);
+ free (ypix);
+ free (fn);
return (0);
}
@@ -380,6 +438,7 @@ usage ()
fprintf(stderr," -d: Print range of pixel values in specified image region\n");
fprintf(stderr," -f name: Write specified region to a FITS file\n");
fprintf(stderr," -g num: keep pixels with values greater than this\n");
+ fprintf(stderr," -h: print file name on line above pixel values\n");
fprintf(stderr," -i: Ignore first token per line of coordinate file\n");
fprintf(stderr," -l num: keep pixels with values less than this\n");
fprintf(stderr," -m: Print mean of pixel values in specified image region\n");
@@ -460,6 +519,16 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
return;
}
}
+ if (printname) {
+ if (ltcheck & gtcheck)
+ fprintf (stderr, "%s: %f < pixel values < %f\n", name, gtval, ltval);
+ else if (ltcheck)
+ fprintf (stderr, "%s: pixel values < %f\n", name, ltval);
+ else if (gtcheck)
+ fprintf (stderr, "%s: pixel values > %f\n", name, gtval);
+ else
+ fprintf (stderr,"%s:\n", name);
+ }
if (verbose) {
fprintf (stderr,"%s\n",RevMsg);
if (npix > 0)
@@ -520,7 +589,7 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
/* Loop through rows starting with the last one */
for (i = 0; i < npix; i++) {
- dpix = getpix1(image,bitpix,xdim,ydim,bzero,bscale,xpix[i],ypix[i]);
+ dpix = getpix1(image,bitpix,xdim,ydim,bzero,bscale,xpix[i],ypix[i]);
if (gtcheck || ltcheck) {
if ((gtcheck && dpix > gtval) ||
(ltcheck && dpix < ltval)) {
@@ -573,8 +642,6 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
}
if (!pixperline && !ltcheck && !gtcheck)
printf ("\n");
- free (xpix);
- free (ypix);
}
/* Print entire image */
@@ -817,6 +884,8 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
}
else
procpix (&dsum, &dnpix, &dmin, &dmax, dpix);
+ if (printrange || printmean)
+ continue;
if (bitpix > 0) {
if ((c = strchr (pform,'f')) != NULL)
*c = 'd';
@@ -853,7 +922,7 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
}
}
if (!pixperline && !ltcheck && !gtcheck) {
- if (ix % nline != 0)
+ if (!printrange && !printmean && ix % nline != 0)
printf ("\n");
}
}
@@ -863,12 +932,25 @@ int *xpix, *ypix; /* Vectors of x,y coordinate pairs */
if (printmean) {
dmean = dsum / dnpix;
- printf ("Mean= %.4f ", dmean);
+ if (verbose)
+ printf ("Mean= %.4f ", dmean);
+ else
+ printf ("%.4f", dmean);
+ }
+ if (printrange) {
+ if (printmean)
+ printf (" ");
+ if (verbose)
+ printf ("Range = %.4f - %.4f ", dmin, dmax);
+ else
+ printf ("%.4f %.4f", dmin, dmax);
+ }
+ if (printmean || printrange) {
+ if (verbose)
+ printf ("for %d pixels\n", (int) dnpix);
+ else
+ printf ("\n");
}
- if (printrange)
- printf ("Range = %.4f - %.4f ", dmin, dmax);
- if (printmean || printrange)
- printf ("for %d pixels\n", (int) dnpix);
free (header);
free (image);
@@ -948,4 +1030,10 @@ double dpix; /* Current pixel value */
*
* Sep 21 2010 Add option -t to separate numbers by tabs
* Sep 21 2010 Fix bug in computing means and limits
+ *
+ * Feb 22 2012 Print descriptors for mean and limits only in verbose mode
+ * Feb 22 2012 Fix bug to avoid printing all pixels if printing mean and/or limits
+ *
+ * Jan 10 2014 Get same pixels from multiple files
+ * Jan 10 2014 Add command line option @listfile as list of files
*/
diff --git a/getpix.o b/getpix.o
new file mode 100644
index 0000000..ce2ab1a
Binary files /dev/null and b/getpix.o differ
diff --git a/gettab.c b/gettab.c
index facd5e1..55a92c3 100644
--- a/gettab.c
+++ b/gettab.c
@@ -40,7 +40,7 @@ static void usage();
static void PrintValues();
static int maxncond = 100;
-static char *RevMsg = "GETTAB WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "GETTAB WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int nfile = 0;
diff --git a/gsc2cat.c b/gsc2cat.c
index 7a215f4..e3b87cc 100644
--- a/gsc2cat.c
+++ b/gsc2cat.c
@@ -37,7 +37,7 @@ static int nlog = 10000;
static void usage();
void SaveGSC2();
-static char *RevMsg = "GSC2CAT WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "GSC2CAT WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
main (ac, av)
int ac;
diff --git a/gsc2read.o b/gsc2read.o
new file mode 100644
index 0000000..22a126d
Binary files /dev/null and b/gsc2read.o differ
diff --git a/gscread.o b/gscread.o
new file mode 100644
index 0000000..ff143a5
Binary files /dev/null and b/gscread.o differ
diff --git a/hget.o b/hget.o
new file mode 100644
index 0000000..f507e44
Binary files /dev/null and b/hget.o differ
diff --git a/hput.o b/hput.o
new file mode 100644
index 0000000..3fe0236
Binary files /dev/null and b/hput.o differ
diff --git a/hput1.o b/hput1.o
new file mode 100644
index 0000000..23cf06a
Binary files /dev/null and b/hput1.o differ
diff --git a/i2f.c b/i2f.c
index 1bdab01..e54abf5 100644
--- a/i2f.c
+++ b/i2f.c
@@ -34,7 +34,7 @@ static void usage();
static void IRAFtoFITS ();
static int verbose = 0; /* verbose/debugging flag */
-static char *RevMsg = "I2F WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "I2F WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int version = 0; /* If 1, print only program name and version */
static int delirafkey = 0; /* If 1, delete IRAF .imh keywords */
static int deliraffile = 0; /* If 1, delete IRAF .imh files */
diff --git a/iget.o b/iget.o
new file mode 100644
index 0000000..ebd381e
Binary files /dev/null and b/iget.o differ
diff --git a/imcat.c b/imcat.c
index ab4c393..ea15f35 100644
--- a/imcat.c
+++ b/imcat.c
@@ -1,9 +1,9 @@
/* File imcat.c
- * August 10, 2012
+ * July 2, 2014
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1996-2012
+ Copyright (C) 1996-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -64,7 +64,7 @@ extern void setdateobs();
extern void setparm();
extern void setnpix();
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int wfile = 0; /* True to print output file */
@@ -718,14 +718,14 @@ int ngmax; /* Number of entries to allocate */
nalloc = ngmax;
if (!(gm = (double **) calloc (nbuffer, sizeof(double *)))) {
- fprintf (stderr, "Could not calloc %d bytes for gm\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gm\n",
nbuffer*sizeof(double *));
FreeBuffers();
return (0);
}
for (imag = 0; imag < nbuffer; imag++) {
if (!(gm[imag] = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gm\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gm\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
@@ -733,55 +733,55 @@ int ngmax; /* Number of entries to allocate */
}
if (!(gra = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gra\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gra\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gdec = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gdec\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gdec\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gpra = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gpra\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gpra\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gpdec = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gpdec\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gpdec\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gnum = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gnum\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gnum\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gc = (int *) calloc (ngmax, sizeof(int)))) {
- fprintf (stderr, "Could not calloc %d bytes for gc\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gc\n",
ngmax*sizeof(int));
FreeBuffers();
return (0);
}
if (!(gx = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gx\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gx\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gy = (double *) calloc (ngmax, sizeof(double)))) {
- fprintf (stderr, "Could not calloc %d bytes for gy\n",
+ fprintf (stderr, "Could not calloc %zu bytes for gy\n",
ngmax*sizeof(double));
FreeBuffers();
return (0);
}
if (!(gobj = (char **) calloc (ngmax, sizeof(char *)))) {
- fprintf (stderr, "Could not calloc %d bytes for obj\n",
+ fprintf (stderr, "Could not calloc %zu bytes for obj\n",
ngmax*sizeof(char *));
FreeBuffers();
return (0);
@@ -1544,7 +1544,7 @@ char **refcatname; /* reference catalog name */
strcat (headline,"magf magj magv magn ");
else if (refcat == UCAC2)
strcat (headline,"magj magh magk magc ");
- else if (refcat == UCAC3)
+ else if (refcat == UCAC3 || refcat == UCAC4)
strcat (headline,"magb magr magi magj magh magk magm maga ");
else if (refcat == UB1)
strcat (headline,"magb1 magr1 magb2 magr2 magn ");
@@ -1592,13 +1592,13 @@ char **refcatname; /* reference catalog name */
strcat (headline,"size ");
else if (sptype == 1)
strcat (headline,"type ");
- else if (gcset && refcat != UCAC2 && refcat != UCAC3)
+ else if (gcset && refcat != UCAC2 && refcat != UCAC3 && refcat != UCAC4)
strcat (headline,"peak ");
if (mprop)
strcat (headline, "pmra pmdec ");
/* if (refcat == UCAC2 || refcat == UCAC3)
strcat (headline, "epmra epmdec"); */
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline, "ni nc ");
if (refcat == GSC2)
strcat (headline,"class ");
@@ -1656,11 +1656,11 @@ char **refcatname; /* reference catalog name */
strcat (headline," -- -- --");
else if (refcat == TMXSC)
strcat (headline," ------");
- else if (gcset && refcat != UCAC2 && refcat != UCAC3)
+ else if (gcset && refcat != UCAC2 && refcat != UCAC3 && refcat != UCAC4)
strcat (headline, " -----"); /* plate or peak */
if (mprop )
strcat (headline, " ------ ------"); /* Proper motion */
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline, " -- --");
if (refcat == GSC2)
strcat (headline," -----"); /* GSC2 object class */
@@ -1730,7 +1730,7 @@ char **refcatname; /* reference catalog name */
printf ("MagF MagJ MagV MagN Class X Y \n");
else if (refcat == UCAC2)
printf (" MagJ MagH MagK MagC NIm NCt X Y \n");
- else if (refcat == UCAC3)
+ else if (refcat == UCAC3 || refcat == UCAC4)
printf (" MagB MagR MagI MagJ MagH MagK MagM MagA NIm NCt X Y \n");
else if (refcat == UB1)
printf ("MagB1 MagR1 MagB2 MagR2 MagN PM NI SG X Y \n");
@@ -1769,7 +1769,7 @@ char **refcatname; /* reference catalog name */
sprintf (temp, " mag ");
strcat (headline, temp);
}
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
nim = gc[i] / 1000;
nct = gc[i] % 1000;
sprintf (temp, " ni nc", nim, nct);
@@ -1938,7 +1938,7 @@ char **refcatname; /* reference catalog name */
sprintf (temp, " %5.2f",gm[imag][i]);
strcat (headline, temp);
}
- if (gcset && refcat != UCAC2 && refcat != UCAC3) {
+ if (gcset && refcat != UCAC2 && refcat != UCAC3 && refcat != UCAC4) {
sprintf (temp, " %d", gc[i]);
strcat (headline, temp);
}
@@ -1953,7 +1953,7 @@ char **refcatname; /* reference catalog name */
sprintf (temp, " %5.1f %5.1f", pra,pdec);
strcat (headline, temp);
}
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
nim = gc[i] / 1000;
nct = gc[i] % 1000;
/* if (tabout) {
@@ -2077,7 +2077,7 @@ char **refcatname; /* reference catalog name */
strcat (headline, temp);
}
}
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
nim = gc[i] / 1000;
nct = gc[i] % 1000;
sprintf (temp, " %2d %2d", nim, nct);
@@ -2157,6 +2157,10 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
int i;
/* Find sky coordinates of corners and middles of sides */
+ /* 2 4 7 UP = +NAXIS2 ^
+ * 1 6 |
+ * 0 3 5 +-> RIGHT = +NAXIS1
+ */
pix2wcs (wcs, xmin, ymin, &ra[0], &dec[0]);
pix2wcs (wcs, xmin, ycen, &ra[1], &dec[1]);
pix2wcs (wcs, xmin, ymax, &ra[2], &dec[2]);
@@ -2166,8 +2170,17 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
pix2wcs (wcs, xmax, ycen, &ra[6], &dec[6]);
pix2wcs (wcs, xmax, ymax, &ra[7], &dec[7]);
- /* Find minimum and maximum right ascensions watch for wrap-around */
+#define NXRA2(III,JJJ,OP) (ra[III] OP ra[JJJ] ? ra[III] : ra[JJJ])
+#define NXRA3(II,JJ,KK,OP) (ra[II] OP ra[JJ] ? NXRA2(II,KK,OP) : NXRA2(JJ,KK,OP))
+#define MXRA3(I,J,K) NXRA3(I,J,K,>)
+#define MNRA3(I,J,K) NXRA3(I,J,K,>)
+
+ /* Find minimum and maximum right ascensionsand watch for wrap-around */
if (wcs->rot > 315.0 || wcs->rot <= 45.0) {
+ /* 2 4 7 ^+DEC +NAXIS2 ^
+ * 1 6 | |
+ * 0 3 5 +RA <--+ +--> +NAXIS1
+ */
*ramin = ra[5];
if (ra[6] < *ramin)
*ramin = ra[6];
@@ -2180,20 +2193,34 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
*ramax = ra[2];
}
else if (wcs->rot > 45.0 && wcs->rot <= 135.0) {
- *ramin = ra[0];
- if (ra[3] < *ramin)
- *ramin = ra[3];
- if (ra[5] < *ramin)
- *ramin = ra[5];
- *ramax = ra[1];
- if (ra[2] > *ramax)
- *ramax = ra[2];
- if (ra[4] > *ramax)
- *ramax = ra[4];
- if (ra[7] > *ramax)
- *ramax = ra[7];
+ /* 0 1 2 ^+DEC +--> +NAXIS2
+ * 3 4 | |
+ * 5 6 7 +RA <--+ +NAXIS1 V
+ */
+ *ramin = MNRA3(2,4,7);
+ *ramax = MXRA3(0,3,5);
+
+ /* OLD:
+ *ramin = ra[0];
+ if (ra[3] < *ramin)
+ *ramin = ra[3];
+ if (ra[5] < *ramin)
+ *ramin = ra[5];
+ *ramax = ra[1];
+ if (ra[2] > *ramax)
+ *ramax = ra[2];
+ if (ra[4] > *ramax)
+ *ramax = ra[4];
+ if (ra[7] > *ramax)
+ *ramax = ra[7];
+ */
+
}
else if (wcs->rot > 225.0 && wcs->rot <= 315.0) {
+ /* 7 6 5 ^+DEC ^ +NAXIS1
+ * 4 3 | |
+ * 2 1 0 +RA <--+ +NAXIS2 <--+
+ */
*ramin = ra[0];
if (ra[3] < *ramin)
*ramin = ra[3];
@@ -2205,7 +2232,15 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
if (ra[7] > *ramax)
*ramax = ra[7];
}
- else {
+ else { /* 135 - 225 */
+ /* 5 3 0 ^+DEC +NAXIS1 <--+
+ * 6 1 | |
+ * 7 4 2 +RA <--+ V +NAXIS2
+ */
+ *ramin = MNRA3(0,1,2);
+ *ramax = MXRA3(5,6,7);
+
+ /* OLD:
*ramin = ra[2];
if (ra[4] < *ramin)
*ramin = ra[4];
@@ -2216,6 +2251,8 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
*ramax = ra[3];
if (ra[5] > *ramax)
*ramax = ra[5];
+ */
+
}
/* Find minimum and maximum declinations */
@@ -2434,4 +2471,8 @@ double *decmin, *decmax; /* Declination limits in degrees (returned) */
* Jun 3 2010 Do not print position or proper motion errors for UCAC3
*
* Aug 10 2012 Drop declaration of fk425e(); it's not used.
+ *
+ * Oct 20 2013 Fix limit setting code with lots of help from Brian Carcich
+ *
+ * Jul 2 2014 Add UCAC4 catalog
*/
diff --git a/imcat.c b/imcat0.c
similarity index 99%
copy from imcat.c
copy to imcat0.c
index ab4c393..624046c 100644
--- a/imcat.c
+++ b/imcat0.c
@@ -64,7 +64,7 @@ extern void setdateobs();
extern void setparm();
extern void setnpix();
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int wfile = 0; /* True to print output file */
diff --git a/imextract.c b/imextract.c
index a15e7b5..8043ba3 100644
--- a/imextract.c
+++ b/imextract.c
@@ -37,7 +37,7 @@
static void usage();
static int ExtractImage();
-static char *RevMsg = "IMEXTRACT WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMEXTRACT WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose flag */
static int krename = 0;
diff --git a/imfill.c b/imfill.c
index cdefd2a..d2c5028 100644
--- a/imfill.c
+++ b/imfill.c
@@ -63,7 +63,7 @@ static char *badheader; /* FITS bad pixel header */
static double minpixval = -9999.0; /* Minimum good pixel value */
static double maxpixval = -9999.0; /* Maximum good pixel value */
-static char *RevMsg = "IMFILL WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMFILL WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/imgetwcs.o b/imgetwcs.o
new file mode 100644
index 0000000..b866455
Binary files /dev/null and b/imgetwcs.o differ
diff --git a/imhead.c b/imhead.c
index 59583b8..96b595d 100644
--- a/imhead.c
+++ b/imhead.c
@@ -39,7 +39,7 @@ static int nfiles = 0; /* Nuber of files for headers */
static int verbose = 0; /* verbose/debugging flag */
static int fitsout = 0; /* If 1, write exact FITS header */
static int zbitpix = 0; /* If 1, set BITPIX to 0 for dataless header */
-static char *RevMsg = "IMHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "IMHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static int version = 0; /* If 1, print only program name and version */
int
diff --git a/imhfile.o b/imhfile.o
new file mode 100644
index 0000000..10ad0b7
Binary files /dev/null and b/imhfile.o differ
diff --git a/imio.o b/imio.o
new file mode 100644
index 0000000..3899df6
Binary files /dev/null and b/imio.o differ
diff --git a/immatch.c b/immatch.c
index b38a7b1..895a05a 100644
--- a/immatch.c
+++ b/immatch.c
@@ -41,7 +41,7 @@ static void MatchCat();
#define MAXFILES 1000
static int maxnfile = MAXFILES;
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int rot = 0;
diff --git a/imresize.c b/imresize.c
index 24bf822..ed4d4e6 100644
--- a/imresize.c
+++ b/imresize.c
@@ -62,7 +62,7 @@ static int bitpix = 0; /* Bits per output pixel */
static int mean = 0; /* 1 if mean for regrouped pixels */
static int northup = 0; /* 1 to rotate to north up, east left */
-static char *RevMsg = "IMRESIZE WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMRESIZE WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/imrot.c b/imrot.c
index fd3390f..8c01bb9 100644
--- a/imrot.c
+++ b/imrot.c
@@ -38,7 +38,7 @@ static int inverted = 0; /* If 1, invert intensity (-1 * (z-zmax)) */
static int deletewcs = 0; /* If 1, delete FITS WCS keywords in image */
static int rotatewcs = 1; /* If 1, rotate FITS WCS keywords in image */
static int extnum = 0; /* Use extension number instead of EXTNAME for output */
-static char *RevMsg = "IMROT WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMROT WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/imrotate.o b/imrotate.o
new file mode 100644
index 0000000..339c236
Binary files /dev/null and b/imrotate.o differ
diff --git a/imrotate1.o b/imrotate1.o
new file mode 100644
index 0000000..0a76e4c
Binary files /dev/null and b/imrotate1.o differ
diff --git a/imsetwcs.o b/imsetwcs.o
new file mode 100644
index 0000000..8dcca0e
Binary files /dev/null and b/imsetwcs.o differ
diff --git a/imsize.c b/imsize.c
index 0ba4d54..b4bf8ae 100644
--- a/imsize.c
+++ b/imsize.c
@@ -44,7 +44,7 @@ static char coorsys[8];
static double size = 0.0;
static double frac = 0.0;
-static char *RevMsg = "IMSIZE WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMSIZE WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int dss = 0; /* Flag to drop extra stuff for DSS */
diff --git a/imsmooth.c b/imsmooth.c
index 8b6a858..eb88eea 100644
--- a/imsmooth.c
+++ b/imsmooth.c
@@ -55,7 +55,7 @@ static double ghwidth = 1.0; /* Gaussian half-width */
static int filter = 0; /* Filter code */
static int nlog = 100; /* Number of lines between log messages */
-static char *RevMsg = "IMSMOOTH WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMSMOOTH WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/imstack.c b/imstack.c
index b7304f5..68329cf 100644
--- a/imstack.c
+++ b/imstack.c
@@ -37,7 +37,7 @@ static int StackImage();
static int verbose = 0; /* verbose flag */
static int wfits = 1; /* if 1, write FITS header before data */
static char *newname = NULL;
-static char *RevMsg = "IMSTACK WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMSTACK WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int nfiles = 0;
static int nbstack = 0;
static int extend = 0; /* If 1, output multi-extension FITS file */
diff --git a/imstar.c b/imstar.c
index 27f094c..b08e848 100644
--- a/imstar.c
+++ b/imstar.c
@@ -41,7 +41,7 @@
#define MAXFILES 1000
static int maxnfile = MAXFILES;
-static char *RevMsg = "IMSTAR WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "IMSTAR WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose flag */
static int debug = 0; /* debugging flag */
diff --git a/imutil.o b/imutil.o
new file mode 100644
index 0000000..dba03f1
Binary files /dev/null and b/imutil.o differ
diff --git a/imwcs.c b/imwcs.c
index d16c997..06107a5 100644
--- a/imwcs.c
+++ b/imwcs.c
@@ -40,7 +40,7 @@ static int maxnfile = MAXFILES;
static void PrintUsage();
static void FitWCS();
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int writeheader = 0; /* write header fields; else read-only */
diff --git a/isimlist.c b/isfile.c
similarity index 73%
copy from isimlist.c
copy to isfile.c
index 823af20..57c868d 100644
--- a/isimlist.c
+++ b/isfile.c
@@ -1,9 +1,9 @@
-/* File isimlist.c
- * January 30, 2009
+/* File isfile.c
+ * July 9, 2014
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 2009
+ Copyright (C) 2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -20,15 +20,15 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
- * Return 1 if argument is an integer, 2 if it is floating point, else 0
+ * Return 1 if argument is a file, 2 if it is a directory, else 0
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "libwcs/fitshead.h"
+#include "libwcs/fitsfile.h"
-static char *RevMsg = "ISIMLIST WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ISFILE WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
@@ -41,7 +41,7 @@ char **av;
str = *(av+1);
if (!str || !strcmp (str, "help") || !strcmp (str, "-help")) {
fprintf (stderr,"%s\n",RevMsg);
- fprintf (stderr,"Usage: Return file if argument is a list of FITS files, else NULL");
+ fprintf (stderr,"Usage: Return 1 if argument is a file, 2 if a directory, else 0\n");
exit (1);
}
else if (!strcmp (str, "version") || !strcmp (str, "-version")) {
@@ -49,11 +49,11 @@ char **av;
exit (1);
}
- /* check to see if this is a number */
- else if (isimlist (str))
- printf ("%s\n", str);
+ /* check to see if this is a file */
+ else
+ printf ("%d\n", isfile (str));
exit (0);
}
-/* Jan 30 2009 New program
+/* Jul 9 2014 New program
*/
diff --git a/isfits.c b/isfits.c
index e7c87bb..5c1078b 100644
--- a/isfits.c
+++ b/isfits.c
@@ -1,9 +1,9 @@
/* File isfits.c
- * December 14, 2011
+ * August 12, 2013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 2008-2011
+ Copyright (C) 2008-2013
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@
#include <string.h>
#include "libwcs/fitsfile.h"
-static char *RevMsg = "ISFITS WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ISFITS WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
@@ -41,7 +41,7 @@ char **av;
str = *(av+1);
if (!str || !strcmp (str, "help") || !strcmp (str, "-help")) {
fprintf (stderr,"%s\n",RevMsg);
- fprintf (stderr,"Usage: Return 1 if argument is a FITS file, else 0");
+ fprintf (stderr,"Usage: Return 1 if argument is a FITS file, else 0\n");
exit (1);
}
else if (!strcmp (str, "version") || !strcmp (str, "-version")) {
@@ -60,4 +60,6 @@ char **av;
* Oct 29 2010 Include fitsfile.h instead of fitshead.h
*
* Dec 14 2011 Fix comments
+ *
+ * Aug 12 2013 Add linefeed to usage
*/
diff --git a/isimlist.c b/isimlist.c
index 823af20..8f17356 100644
--- a/isimlist.c
+++ b/isimlist.c
@@ -28,7 +28,7 @@
#include <string.h>
#include "libwcs/fitshead.h"
-static char *RevMsg = "ISIMLIST WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ISIMLIST WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/isnum.c b/isnum.c
index 8b1d527..0ada581 100644
--- a/isnum.c
+++ b/isnum.c
@@ -28,7 +28,7 @@
#include <string.h>
#include "libwcs/fitshead.h"
-static char *RevMsg = "ISNUM WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ISNUM WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/isrange.c b/isrange.c
index e2f13f8..8bfd772 100644
--- a/isrange.c
+++ b/isrange.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
-static char *RevMsg = "ISRANGE WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "ISRANGE WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int isrange();
diff --git a/keyhead.c b/keyhead.c
index ccb34fa..7223702 100644
--- a/keyhead.c
+++ b/keyhead.c
@@ -50,7 +50,7 @@ static int logfile = 0;
static int nproc = 0;
static int first_file = 1;
-static char *RevMsg = "KEYHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "KEYHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/libwcs/NEWS b/libwcs/NEWS
index 73db1fe..963ccc6 100644
--- a/libwcs/NEWS
+++ b/libwcs/NEWS
@@ -1,11 +1,16 @@
WCSTools WCS subroutine library release history
-Version 3.8.7 (October 19, 2012)
+Version 3.9.0 (July 25, 2014)
+fileutil.c: Add next_line() to return one line of file
+fitfile.c: fix buffer reallocation bug in fitsrhead()
+
+Version 3.8.7 (October 31, 2012)
dateutil.c: Unused l0 dropped from jd2lst(); ts2ss from jd2mst()
-imio.c: Fix errors with character images in minvec() and maxvec()
+imio.c: Fix errors with short and character images in minvec(), maxvec()
wcs.c: Drop d1 and d2 from wcsdist(); diffi from wcsdist1()
wcs.c: Drop depwcs; it's in main wcs structure
wcsinit.c: Drop unused variable iszpx; fix bug in latmin assignment
+zpxpos.c: Fix code for quadratic near pole
catutil.c: Skip trailing right bracket in aget*()
diff --git a/libwcs/catutil.c b/libwcs/catutil.c
index 8cf2232..b423e38 100644
--- a/libwcs/catutil.c
+++ b/libwcs/catutil.c
@@ -1,8 +1,8 @@
/*** File libwcs/catutil.c
- *** October 2, 2012
+ *** September 23, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1998-2012
+ *** Copyright (C) 1998-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -274,6 +274,14 @@ int *nmag; /* Number of magnitudes in catalog (returned) */
*catprop = 1;
*nmag = 8;
}
+ else if (refcat == UCAC4) {
+ strcpy (title, "USNO UCAC4 Catalog Stars");
+ *syscat = WCS_J2000;
+ *eqcat = 2000.0;
+ *epcat = 2000.0;
+ *catprop = 1;
+ *nmag = 8;
+ }
else if (refcat == UJC) {
strcpy (title, "USNO J Catalog Stars");
*syscat = WCS_J2000;
@@ -510,6 +518,9 @@ char *refcatname; /* Name of reference catalog */
else if (strncasecmp(refcatname,"ucac3",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UCAC3;
+ else if (strncasecmp(refcatname,"ucac4",5)==0 &&
+ strcsrch(refcatname, ".tab") == NULL)
+ refcat = UCAC4;
else if (strncasecmp(refcatname,"usa",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if (strchr (refcatname, '1') != NULL)
@@ -708,6 +719,8 @@ char *refcatname; /* Catalog file name */
strcpy (catname, "USNO-UCAC2");
else if (refcat == UCAC3) /* USNO UCAC3 Star Catalog */
strcpy (catname, "USNO-UCAC3");
+ else if (refcat == UCAC4) /* USNO UCAC4 Star Catalog */
+ strcpy (catname, "USNO-UCAC4");
else if (refcat == UA2) /* USNO A-2.0 Star Catalog */
strcpy (catname, "USNO-A2.0");
else if (refcat == USA1) /* USNO SA-1.0 Star Catalog */
@@ -807,6 +820,8 @@ char *refcatname; /* Catalog file name */
strcpy (catname, "USNO-UCAC2 Stars");
else if (refcat == UCAC3) /* USNO UCAC3 Star Catalog */
strcpy (catname, "USNO-UCAC3 Stars");
+ else if (refcat == UCAC4) /* USNO UCAC4 Star Catalog */
+ strcpy (catname, "USNO-UCAC4 Stars");
else if (refcat == UA2) /* USNO A-2.0 Star Catalog */
strcpy (catname, "USNO-A2.0 Stars");
else if (refcat == USA1) /* USNO SA-1.0 Star Catalog */
@@ -873,6 +888,8 @@ int refcat; /* Catalog code */
strcpy (catid,"ucac2_id ");
else if (refcat == UCAC3)
strcpy (catid,"ucac3_id ");
+ else if (refcat == UCAC4)
+ strcpy (catid,"ucac4_id ");
else if (refcat == UJC)
strcpy (catid,"usnoj_id ");
else if (refcat == TMPSC || refcat == TMPSCE)
@@ -908,7 +925,7 @@ int refcat; /* Catalog code */
{
if (refcat==GSC || refcat==GSCACT || refcat==UJC || refcat==USAC ||
refcat==USA1 || refcat==USA2 ||
- refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3)
+ refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
return (900.0);
else if (refcat==UAC || refcat==UA1 || refcat==UA2)
return (120.0);
@@ -1025,6 +1042,10 @@ char *progname; /* Program name which might contain catalog code */
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ucac3");
}
+ else if (strcsrch (progname,"ucac4") != NULL) {
+ refcatname = (char *) calloc (1,8);
+ strcpy (refcatname, "ucac4");
+ }
else if (strcsrch (progname,"ujc") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ujc");
@@ -1146,6 +1167,14 @@ char *numstr; /* Formatted number (returned) */
sprintf (numstr, "%10.6f", dnum);
}
+ /* USNO-UCAC4 */
+ else if (refcat == UCAC4) {
+ if (nnfld < 0)
+ sprintf (numstr, "%010.6f", dnum);
+ else
+ sprintf (numstr, "%10.6f", dnum);
+ }
+
/* SDSS */
else if (refcat == SDSS) {
sprintf (numstr, "582%015.0f", dnum);
@@ -1331,6 +1360,10 @@ int nndec; /* Number of decimal places ( >= 0) */
else if (refcat == UCAC3)
return (10);
+ /* UCAC4 Catalog */
+ else if (refcat == UCAC4)
+ return (10);
+
/* USNO Plate Catalogs */
else if (refcat == USNO)
return (7);
@@ -1466,6 +1499,10 @@ int refcat; /* Catalog code */
else if (refcat == UCAC3)
return (6);
+ /* UCAC4 Catalog */
+ else if (refcat == UCAC4)
+ return (6);
+
/* USNO UJ 1.0 Catalog */
else if (refcat == UJC)
return (7);
@@ -1635,6 +1672,24 @@ char *magname; /* Name of magnitude, returned */
else if (imag == 8)
strcpy (magname, "MagA");
}
+ else if (refcat==UCAC4) {
+ if (imag == 1)
+ strcpy (magname, "MagB");
+ else if (imag == 2)
+ strcpy (magname, "MagR");
+ else if (imag == 3)
+ strcpy (magname, "MagI");
+ else if (imag == 4)
+ strcpy (magname, "MagJ");
+ else if (imag == 5)
+ strcpy (magname, "MagH");
+ else if (imag == 6)
+ strcpy (magname, "MagK");
+ else if (imag == 7)
+ strcpy (magname, "MagM");
+ else if (imag == 8)
+ strcpy (magname, "MagA");
+ }
else if (refcat==SKYBOT)
strcpy (magname, "MagV");
else
@@ -1764,6 +1819,24 @@ int refcat; /* Catalog code */
else
return (1); /* B */
}
+ else if (refcat==UCAC4) {
+ if (cmag == 'R')
+ return (2);
+ else if (cmag == 'I')
+ return (3);
+ else if (cmag == 'J')
+ return (4);
+ else if (cmag == 'H')
+ return (5);
+ else if (cmag == 'K')
+ return (6);
+ else if (cmag == 'M')
+ return (7);
+ else if (cmag == 'A')
+ return (8);
+ else
+ return (1); /* B */
+ }
else
return (1);
}
@@ -2587,10 +2660,10 @@ char *value; /* String (returned) */
/* Must have "=" or ":" as next nonspace and nonbracket character */
else {
pv = pkey + lkey;
- while (*pv == ' ' || *pv == ']') {
+ while (*pv == ' ' || *pv == ']' || *pv == 'o') {
pv++;
}
- if (*pv != '=' && *pv != ':') {
+ if (*pv != '=' && *pv != ':' && *pv != 'f') {
str = pkey;
pval = NULL;
}
@@ -3482,4 +3555,8 @@ char *from, *last, *to;
* Jul 26 2012 Fix xterm computation in polcomp() from + to *
* (found by Raymond Carlberg of U.Toronto)
* Oct 02 2012 Skip trailing right bracket in aget*()
+ * Oct 23 2012 Add "of" as possible connector in aget*()
+ *
+ * Feb 15 2013 Add UCAC4 catalog
+ * Sep 23 2013 Finish adding UCAC4 catalog
*/
diff --git a/libwcs/cd b/libwcs/cd
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/ctgread.c b/libwcs/ctgread.c
index b42057f..b2bd1c6 100644
--- a/libwcs/ctgread.c
+++ b/libwcs/ctgread.c
@@ -1,8 +1,8 @@
/*** File libwcs/ctgread.c
- *** May 22, 2012
+ *** February 15, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1998-2012
+ *** Copyright (C) 1998-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -153,7 +153,7 @@ int nlog;
nstar = ubcread (catfile,distsort,cra,cdec,dra,ddec,drad,dradi,
sysout,eqout,epout,mag1,mag2,sortmag,nsmax,tnum,
tra,tdec,tpra,tpdec,tmag,tc,nlog);
- else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3)
+ else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
nstar = ucacread (catfile,cra,cdec,dra,ddec,drad,dradi,distsort,
sysout,eqout,epout,mag1,mag2,sortmag,nsmax,
tnum,tra,tdec,tpra,tpdec,tmag,tc,nlog);
@@ -576,7 +576,7 @@ int nlog;
else if (refcat == UJC || refcat == USNO)
nstar = ujcrnum (catfile,nnum,sysout,eqout,epout,
tnum,tra,tdec,tmag,tc,nlog);
- else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3)
+ else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
nstar = ucacrnum (catfile,nnum,sysout,eqout,epout,
tnum,tra,tdec,tpra,tpdec,tmag,tc,nlog);
else if (refcat == TMPSC || refcat == TMPSCE ||
@@ -992,7 +992,7 @@ int nlog;
nstar = ujcbin (catfile,wcs,header,image,mag1,mag2,magscale,nlog);
else if (refcat == UB1 || refcat == YB6)
nstar = ubcbin (catfile,wcs,header,image,mag1,mag2,sortmag,magscale,nlog);
- else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3)
+ else if (refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
nstar = ucacbin (catfile,wcs,header,image,mag1,mag2,sortmag,magscale,nlog);
else if (refcat == TMPSC || refcat == TMIDR2 || refcat == TMXSC)
nstar = tmcbin (refcat,wcs,header,image,mag1,mag2,sortmag,magscale,nlog);
@@ -2129,4 +2129,6 @@ char *in; /* Character string */
* Sep 30 2009 Add UCAC3
*
* May 22 2012 Accept up to 9 magnitudes per entry instead of 4
+ *
+ * Feb 15 2013 Add UCAC4
*/
diff --git a/libwcs/distort b/libwcs/distort
new file mode 100644
index 0000000..470a14b
--- /dev/null
+++ b/libwcs/distort
@@ -0,0 +1,2409 @@
+actread.c: sysout = wcs->syswcs;
+actread.c: eqout = wcs->equinox;
+actread.c: epout = wcs->epoch;
+binread.c: sysout = wcs->syswcs;
+binread.c: eqout = wcs->equinox;
+binread.c: epout = wcs->epoch;
+ctgread.c: sysout = wcs->syswcs;
+ctgread.c: eqout = wcs->equinox;
+ctgread.c: epout = wcs->epoch;
+distort.c: if (wcs->distcode == DISTORT_SIRTF) {
+distort.c: if (wcs->wcsproj == WCS_OLD) {
+distort.c: wcs->wcsproj = WCS_NEW;
+distort.c: wcs->distort.a_order = 0;
+distort.c: wcs->distort.b_order = 0;
+distort.c: wcs->distort.ap_order = 0;
+distort.c: wcs->distort.bp_order = 0;
+distort.c: if (!hgeti4 (hstring, "A_ORDER", &wcs->distort.a_order)) {
+distort.c: m = wcs->distort.a_order;
+distort.c: wcs->distort.a[i][j] = 0.0;
+distort.c: hgetr8 (hstring, keyword, &wcs->distort.a[i][j]);
+distort.c: if (!hgeti4 (hstring, "B_ORDER", &wcs->distort.b_order)) {
+distort.c: m = wcs->distort.b_order;
+distort.c: wcs->distort.b[i][j] = 0.0;
+distort.c: hgetr8 (hstring, keyword, &wcs->distort.b[i][j]);
+distort.c: if (!hgeti4 (hstring, "AP_ORDER", &wcs->distort.ap_order)) {
+distort.c: m = wcs->distort.ap_order;
+distort.c: wcs->distort.ap[i][j] = 0.0;
+distort.c: hgetr8 (hstring, keyword, &wcs->distort.ap[i][j]);
+distort.c: if (!hgeti4 (hstring, "BP_ORDER", &wcs->distort.bp_order)) {
+distort.c: m = wcs->distort.bp_order;
+distort.c: wcs->distort.bp[i][j] = 0.0;
+distort.c: hgetr8 (hstring, keyword, &wcs->distort.bp[i][j]);
+distort.c: if (wcs->distcode == DISTORT_SIRTF) {
+distort.c: m = wcs->distort.ap_order;
+distort.c: n = wcs->distort.bp_order;
+distort.c: temp_x = x - wcs->xrefpix;
+distort.c: temp_y = y - wcs->yrefpix;
+distort.c: s[j] = wcs->distort.ap[m-j][j];
+distort.c: s[j] = (temp_y * s[j]) + wcs->distort.ap[m-j][k];
+distort.c: s[j] = wcs->distort.bp[n-j][j];
+distort.c: s[j] = temp_y*s[j] + wcs->distort.bp[n-j][k];
+distort.c: if (wcs->distcode == DISTORT_SIRTF) {
+distort.c: m = wcs->distort.a_order;
+distort.c: n = wcs->distort.b_order;
+distort.c: temp_u = u - wcs->xrefpix;
+distort.c: temp_v = v - wcs->yrefpix;
+distort.c: s[j] = wcs->distort.a[m-j][j];
+distort.c: s[j] = (temp_v * s[j]) + wcs->distort.a[m-j][k];
+distort.c: s[j] = wcs->distort.b[n-j][j];
+distort.c: s[j] =temp_v*s[j] + wcs->distort.b[n-j][k];
+distort.c: wcs->distcode = DISTORT_NONE;
+distort.c: wcs->distcode = DISTORT_SIRTF;
+distort.c: wcs->distcode = DISTORT_NONE;
+distort.c: if (wcs->distcode == DISTORT_SIRTF) {
+dsspos.c: x = xpix + wcs->x_pixel_offset - 1.0 + 0.5;
+dsspos.c: y = ypix + wcs->y_pixel_offset - 1.0 + 0.5;
+dsspos.c: xmm = (wcs->ppo_coeff[2] - x * wcs->x_pixel_size) / 1000.0;
+dsspos.c: ymm = (y * wcs->y_pixel_size - wcs->ppo_coeff[5]) / 1000.0;
+dsspos.c: xi = wcs->x_coeff[ 0]*xmm + wcs->x_coeff[ 1]*ymm +
+dsspos.c: wcs->x_coeff[ 2] + wcs->x_coeff[ 3]*xmm2 +
+dsspos.c: wcs->x_coeff[ 4]*xmm*ymm + wcs->x_coeff[ 5]*ymm2 +
+dsspos.c: wcs->x_coeff[ 6]*(x2y2) + wcs->x_coeff[ 7]*xmm3 +
+dsspos.c: wcs->x_coeff[ 8]*xmm2*ymm + wcs->x_coeff[ 9]*xmm*ymm2 +
+dsspos.c: wcs->x_coeff[10]*ymm3 + wcs->x_coeff[11]*xmm*(x2y2) +
+dsspos.c: wcs->x_coeff[12]*xmm*x2y2*x2y2;
+dsspos.c: + wcs->x_coeff[13]*mag + wcs->x_coeff[14]*mag*mag +
+dsspos.c: wcs->x_coeff[15]*mag*mag*mag + wcs->x_coeff[16]*mag*xmm +
+dsspos.c: wcs->x_coeff[17]*mag*x2y2 + wcs->x_coeff[18]*mag*xmm*x2y2 +
+dsspos.c: wcs->x_coeff[19]*color; */
+dsspos.c: eta = wcs->y_coeff[ 0]*ymm + wcs->y_coeff[ 1]*xmm +
+dsspos.c: wcs->y_coeff[ 2] + wcs->y_coeff[ 3]*ymm2 +
+dsspos.c: wcs->y_coeff[ 4]*xmm*ymm + wcs->y_coeff[ 5]*xmm2 +
+dsspos.c: wcs->y_coeff[ 6]*(x2y2) + wcs->y_coeff[ 7]*ymm3 +
+dsspos.c: wcs->y_coeff[ 8]*ymm2*xmm + wcs->y_coeff[ 9]*ymm*xmm2 +
+dsspos.c: wcs->y_coeff[10]*xmm3 + wcs->y_coeff[11]*ymm*(x2y2) +
+dsspos.c: wcs->y_coeff[12]*ymm*x2y2*x2y2;
+dsspos.c: + wcs->y_coeff[13]*mag + wcs->y_coeff[14]*mag*mag +
+dsspos.c: wcs->y_coeff[15]*mag*mag*mag + wcs->y_coeff[16]*mag*ymm +
+dsspos.c: wcs->y_coeff[17]*mag*x2y2) + wcs->y_coeff[18]*mag*ymm*x2y2 +
+dsspos.c: wcs->y_coeff[19]*color; */
+dsspos.c: ctan = tan (wcs->plate_dec);
+dsspos.c: ccos = cos (wcs->plate_dec);
+dsspos.c: ra = raoff + wcs->plate_ra;
+dsspos.c: if (wcs->plate_dec == 0.0)
+dsspos.c: wcs->plate_dec = degrad (wcs->yref);
+dsspos.c: syplate = sin (wcs->plate_dec);
+dsspos.c: cyplate = cos (wcs->plate_dec);
+dsspos.c: if (wcs->plate_ra == 0.0)
+dsspos.c: wcs->plate_ra = degrad (wcs->yref);
+dsspos.c: sxdiff = sin (xr - wcs->plate_ra);
+dsspos.c: cxdiff = cos (xr - wcs->plate_ra);
+dsspos.c: if (wcs->plate_scale == 0.0)
+dsspos.c: xmm = xi / wcs->plate_scale;
+dsspos.c: ymm = eta / wcs->plate_scale;
+dsspos.c: f = wcs->x_coeff[0]*xmm + wcs->x_coeff[1]*ymm +
+dsspos.c: wcs->x_coeff[2] + wcs->x_coeff[3]*x2 +
+dsspos.c: wcs->x_coeff[4]*xy + wcs->x_coeff[5]*y2 +
+dsspos.c: wcs->x_coeff[6]*x2y2 + wcs->x_coeff[7]*x3 +
+dsspos.c: wcs->x_coeff[8]*x2y + wcs->x_coeff[9]*y2x +
+dsspos.c: wcs->x_coeff[10]*y3 + wcs->x_coeff[11]*xmm*x2y2 +
+dsspos.c: wcs->x_coeff[12]*xmm*cjunk;
+dsspos.c: + wcs->x_coeff[13]*mag +
+dsspos.c: wcs->x_coeff[14]*mag*mag + wcs->x_coeff[15]*mag*mag*mag +
+dsspos.c: wcs->x_coeff[16]*mag*xmm + wcs->x_coeff[17]*mag*(x2+y2) +
+dsspos.c: wcs->x_coeff[18]*mag*xmm*(x2+y2) + wcs->x_coeff[19]*color;
+dsspos.c: fx = wcs->x_coeff[0] + wcs->x_coeff[3]*2.0*xmm +
+dsspos.c: wcs->x_coeff[4]*ymm + wcs->x_coeff[6]*2.0*xmm +
+dsspos.c: wcs->x_coeff[7]*3.0*x2 + wcs->x_coeff[8]*2.0*xy +
+dsspos.c: wcs->x_coeff[9]*y2 + wcs->x_coeff[11]*(3.0*x2+y2) +
+dsspos.c: wcs->x_coeff[12]*(5.0*x4 +6.0*x2*y2+y4);
+dsspos.c: wcs->x_coeff[16]*mag + wcs->x_coeff[17]*mag*2.0*xmm +
+dsspos.c: wcs->x_coeff[18]*mag*(3.0*x2+y2);
+dsspos.c: fy = wcs->x_coeff[1] + wcs->x_coeff[4]*xmm +
+dsspos.c: wcs->x_coeff[5]*2.0*ymm + wcs->x_coeff[6]*2.0*ymm +
+dsspos.c: wcs->x_coeff[8]*x2 + wcs->x_coeff[9]*2.0*xy +
+dsspos.c: wcs->x_coeff[10]*3.0*y2 + wcs->x_coeff[11]*2.0*xy +
+dsspos.c: wcs->x_coeff[12]*4.0*xy*x2y2;
+dsspos.c: wcs->x_coeff[17]*mag*2.0*ymm +
+dsspos.c: wcs->x_coeff[18]*mag*2.0*xy;
+dsspos.c: g = wcs->y_coeff[0]*ymm + wcs->y_coeff[1]*xmm +
+dsspos.c: wcs->y_coeff[2] + wcs->y_coeff[3]*y2 +
+dsspos.c: wcs->y_coeff[4]*xy + wcs->y_coeff[5]*x2 +
+dsspos.c: wcs->y_coeff[6]*x2y2 + wcs->y_coeff[7]*y3 +
+dsspos.c: wcs->y_coeff[8]*y2x + wcs->y_coeff[9]*x2y +
+dsspos.c: wcs->y_coeff[10]*x3 + wcs->y_coeff[11]*ymm*x2y2 +
+dsspos.c: wcs->y_coeff[12]*ymm*cjunk;
+dsspos.c: wcs->y_coeff[13]*mag + wcs->y_coeff[14]*mag*mag +
+dsspos.c: wcs->y_coeff[15]*mag*mag*mag + wcs->y_coeff[16]*mag*ymm +
+dsspos.c: wcs->y_coeff[17]*mag*x2y2 +
+dsspos.c: wcs->y_coeff[18]*mag*ymm*x2y2 + wcs->y_coeff[19]*color;
+dsspos.c: gx = wcs->y_coeff[1] + wcs->y_coeff[4]*ymm +
+dsspos.c: wcs->y_coeff[5]*2.0*xmm + wcs->y_coeff[6]*2.0*xmm +
+dsspos.c: wcs->y_coeff[8]*y2 + wcs->y_coeff[9]*2.0*xy +
+dsspos.c: wcs->y_coeff[10]*3.0*x2 + wcs->y_coeff[11]*2.0*xy +
+dsspos.c: wcs->y_coeff[12]*4.0*xy*x2y2;
+dsspos.c: wcs->y_coeff[17]*mag*2.0*xmm +
+dsspos.c: wcs->y_coeff[18]*mag*ymm*2.0*xmm;
+dsspos.c: gy = wcs->y_coeff[0] + wcs->y_coeff[3]*2.0*ymm +
+dsspos.c: wcs->y_coeff[4]*xmm + wcs->y_coeff[6]*2.0*ymm +
+dsspos.c: wcs->y_coeff[7]*3.0*y2 + wcs->y_coeff[8]*2.0*xy +
+dsspos.c: wcs->y_coeff[9]*x2 + wcs->y_coeff[11]*(x2+3.0*y2) +
+dsspos.c: wcs->y_coeff[12]*(5.0*y4 + 6.0*x2*y2 + x4);
+dsspos.c: wcs->y_coeff[16]*mag + wcs->y_coeff[17]*mag*2.0*ymm +
+dsspos.c: wcs->y_coeff[18]*mag*(x2+3.0*y2);
+dsspos.c: if (wcs->x_pixel_size == 0.0 || wcs->y_pixel_size == 0.0)
+dsspos.c: x = (wcs->ppo_coeff[2] - xmm*1000.0) / wcs->x_pixel_size;
+dsspos.c: y = (wcs->ppo_coeff[5] + ymm*1000.0) / wcs->y_pixel_size;
+dsspos.c: *xpix = x - wcs->x_pixel_offset + 1.0 - 0.5;
+dsspos.c: *ypix = y - wcs->y_pixel_offset + 1.0 - 0.5;
+dsspos.c: if (*xpix < 0.5 || *xpix > wcs->nxpix+0.5)
+dsspos.c: if (*ypix < 0.5 || *ypix > wcs->nypix+0.5)
+fitswcs.c: if (wcs->xref < 0)
+fitswcs.c: wcs->xref = 360.0 + wcs->xref;
+fitswcs.c: hputra (header,"RA",wcs->xref);
+fitswcs.c: hputdec (header,"DEC",wcs->yref);
+fitswcs.c: hputr8 (header, "EQUINOX", wcs->equinox);
+fitswcs.c: hputr8 (header, "EPOCH", wcs->equinox);
+fitswcs.c: hputr8 (header, "EPOCH", wcs->equinox);
+fitswcs.c: if (wcs->radecsys[0] == 'B' || wcs->radecsys[0] == 'b')
+fitswcs.c: else if (wcs->radecsys[0] == 'I' || wcs->radecsys[0] == 'i')
+fitswcs.c: else if (wcs->radecsys[0] == 'J' || wcs->radecsys[0] == 'j')
+fitswcs.c: hputs (header, "RADECSYS", wcs->radecsys);
+fitswcs.c: hputnr8 (header, "CRVAL1", 9, wcs->xref);
+fitswcs.c: hputnr8 (header, "CRVAL2", 9, wcs->yref);
+fitswcs.c: hputnr8 (header, "CRPIX1", 4, wcs->xrefpix);
+fitswcs.c: hputnr8 (header, "CRPIX2", 4, wcs->yrefpix);
+fitswcs.c: if (wcs->rotmat) {
+fitswcs.c: hputnr8 (header, "CD1_1", 12, wcs->cd[0]);
+fitswcs.c: hputnr8 (header, "CD1_2", 12, wcs->cd[1]);
+fitswcs.c: hputnr8 (header, "CD2_1", 12, wcs->cd[2]);
+fitswcs.c: hputnr8 (header, "CD2_2", 12, wcs->cd[3]);
+fitswcs.c: hputnr8 (header, "CDELT1", 12, wcs->xinc);
+fitswcs.c: hputnr8 (header, "CDELT2", 12, wcs->yinc);
+fitswcs.c: hputnr8 (header, "CROTA1", 6, wcs->rot);
+fitswcs.c: hputnr8 (header, "CROTA2", 6, wcs->rot);
+fitswcs.c: hputnr8 (header, "CD1_1", 12, wcs->cd[0]);
+fitswcs.c: hputnr8 (header, "CD1_2", 12, wcs->cd[1]);
+fitswcs.c: hputnr8 (header, "CD2_1", 12, wcs->cd[2]);
+fitswcs.c: hputnr8 (header, "CD2_2", 12, wcs->cd[3]);
+fitswcs.c: if (-wcs->xinc != wcs->yinc) {
+fitswcs.c: hputnr8 (header, "SECPIX1", 4, -wcs->xinc*3600.0);
+fitswcs.c: hputnr8 (header, "SECPIX2", 4, wcs->yinc*3600.0);
+fitswcs.c: hputnr8 (header, "SECPIX", 6, wcs->yinc*3600.0);
+fitswcs.c: if (wcs->ncoeff1 > 0) {
+fitswcs.c: for (i = 0; i < wcs->ncoeff1; i++) {
+fitswcs.c: hputr8 (header, keyword, wcs->x_coeff[i]);
+fitswcs.c: if (wcs->ncoeff2 > 0) {
+fitswcs.c: for (i = 0; i < wcs->ncoeff2; i++) {
+fitswcs.c: hputr8 (header, keyword, wcs->y_coeff[i]);
+fortwcs.c: strcpy (radecsys, wcs->radecsys);
+fortwcs.c: wcs->degout = *mode;
+fortwcs.c: wcs->linmode = *mode;
+gscread.c: int sysout = wcs->syswcs; /* Image coordinate system */
+gscread.c: double eqout = wcs->equinox; /* Image coordinate equinox */
+gscread.c: double epout = wcs->epoch; /* Image epoch */
+imgetwcs.c: *hp = (int) wcs->nypix;
+imgetwcs.c: *wp = (int) wcs->nxpix;
+imgetwcs.c: if (wcs->sysout < 1 || wcs->sysout == 6 || wcs->sysout == 10)
+imgetwcs.c: wcs->degout = 1;
+imgetwcs.c: *sysout = wcs->syswcs;
+imgetwcs.c: *eqout = wcs->equinox;
+imgetwcs.c: eq1 = wcs->equinox;
+imgetwcs.c: if (wcs->coorflip) {
+imgetwcs.c: ra1 = wcs->crval[1];
+imgetwcs.c: dec1 = wcs->crval[0];
+imgetwcs.c: ra1 = wcs->crval[0];
+imgetwcs.c: dec1 = wcs->crval[1];
+imgetwcs.c: if (verbose && (eq1 != *eqout || wcs->syswcs != *sysout)) {
+imgetwcs.c: if (wcs->degout) {
+imgetwcs.c: wcscstr (cstr, wcs->syswcs, wcs->equinox, wcs->epoch);
+imgetwcs.c: wcs->xrefpix, wcs->yrefpix, rstr, dstr, cstr);
+imgetwcs.c: dx = wcs->nxpix;
+imgetwcs.c: dy = wcs->nypix;
+imgetwcs.c: if (wcs->syswcs > 0 && wcs->syswcs != 6 && wcs->syswcs != 10) {
+imgetwcs.c: wcscon (wcs->syswcs,*sysout,wcs->equinox,*eqout,&ra1,&dec1,wcs->epoch);
+imgetwcs.c: wcscon (wcs->syswcs,*sysout,wcs->equinox,*eqout,&ra2,&dec2,wcs->epoch);
+imgetwcs.c: wcscon (wcs->syswcs,*sysout,wcs->equinox,*eqout,&ra3,&dec3,wcs->epoch);
+imgetwcs.c: wcscon (wcs->syswcs,*sysout,wcs->equinox,*eqout,&ra4,&dec4,wcs->epoch);
+imgetwcs.c: if (wcs->syswcs > 0 && wcs->syswcs != 6 && wcs->syswcs != 10)
+imgetwcs.c: wcscon (wcs->syswcs,*sysout,wcs->equinox,*eqout,cra,cdec,wcs->epoch);
+imgetwcs.c: if (wcs->xref == -999.0 && wcs->yref == -999.0) {
+imgetwcs.c: wcs->xref = *cra;
+imgetwcs.c: wcs->cel.ref[0] = *cra;
+imgetwcs.c: wcs->crval[0] = *cra;
+imgetwcs.c: wcs->yref = *cdec;
+imgetwcs.c: wcs->cel.ref[1] = *cdec;
+imgetwcs.c: wcs->crval[1] = *cdec;
+imgetwcs.c: if (wcs->xrefpix == 0.0 && wcs->yrefpix == 0.0) {
+imgetwcs.c: wcs->xrefpix = 0.5 + (double) wcs->nxpix * 0.5;
+imgetwcs.c: wcs->yrefpix = 0.5 + (double) wcs->nypix * 0.5;
+imgetwcs.c: wcs->xinc = *dra * 2.0 / (double) wcs->nxpix;
+imgetwcs.c: wcs->yinc = *ddec * 2.0 / (double) wcs->nypix;
+imgetwcs.c: wcs->plate_fit = 0; */
+imgetwcs.c: else if (wcs->syswcs != *sysout && wcs->equinox != *eqout) {
+imgetwcs.c: wcscon (wcs->syswcs, *sysout, wcs->equinox, *eqout, &ra1, &dec1, wcs->epoch);
+imgetwcs.c: if (wcs->coorflip) {
+imgetwcs.c: wcs->yref = ra1;
+imgetwcs.c: wcs->xref = dec1;
+imgetwcs.c: wcs->xref = ra1;
+imgetwcs.c: wcs->yref = dec1;
+imgetwcs.c: pix2wcs (wcs, wcs->xrefpix-0.5, wcs->yrefpix, &ra1, &dec1);
+imgetwcs.c: pix2wcs (wcs, wcs->xrefpix+0.5, wcs->yrefpix, &ra2, &dec2);
+imgetwcs.c: wcs->crval[0] = wcs->xref;
+imgetwcs.c: wcs->crval[1] = wcs->yref;
+imgetwcs.c: if (wcs->coorflip) {
+imgetwcs.c: wcs->cel.ref[0] = wcs->crval[1];
+imgetwcs.c: wcs->cel.ref[1] = wcs->crval[0];
+imgetwcs.c: wcs->cel.ref[0] = wcs->crval[0];
+imgetwcs.c: wcs->cel.ref[1] = wcs->crval[1];
+imgetwcs.c: if (wcs->syswcs > 0 && wcs->syswcs != 6 && wcs->syswcs != 10) {
+imgetwcs.c: wcs->cel.flag = 0;
+imgetwcs.c: wcs->wcsl.flag = 0;
+imgetwcs.c: wcs->lin.flag = LINSET;
+imgetwcs.c: wcs->wcsl.flag = WCSSET;
+imgetwcs.c: wcs->equinox = *eqout;
+imgetwcs.c: wcs->syswcs = *sysout;
+imgetwcs.c: wcs->sysout = *sysout;
+imgetwcs.c: wcs->eqout = *eqout;
+imgetwcs.c: wcs->sysin = *sysout;
+imgetwcs.c: wcs->eqin = *eqout;
+imgetwcs.c: wcscstr (cstr,*sysout,*eqout,wcs->epoch);
+imgetwcs.c: strcpy (wcs->radecsys, cstr);
+imgetwcs.c: strcpy (wcs->radecout, cstr);
+imgetwcs.c: strcpy (wcs->radecin, cstr);
+imgetwcs.c: wcsininit (wcs, wcs->radecsys);
+imgetwcs.c: wcsoutinit (wcs, wcs->radecsys);
+imgetwcs.c: naxes = wcs->naxis;
+imgetwcs.c: naxes = wcs->naxes;
+imgetwcs.c: wcs->naxis = naxes;
+imgetwcs.c: hputnr8 (header, "CDELT1", 9, wcs->xinc);
+imgetwcs.c: hputnr8 (header, "CDELT2", 9, wcs->yinc);
+imgetwcs.c: hputnr8 (header, "CROTA2", 9, wcs->rot);
+imgetwcs.c: hputnr8 (header, "CD1_1", 9, wcs->cd[0]);
+imgetwcs.c: hputnr8 (header, "CD1_2", 9, wcs->cd[1]);
+imgetwcs.c: hputnr8 (header, "CD2_1", 9, wcs->cd[2]);
+imgetwcs.c: hputnr8 (header, "CD2_2", 9, wcs->cd[3]);
+imgetwcs.c: if (wcs->degout) {
+imgetwcs.c: wcscstr (cstr,*sysout,*eqout,wcs->epoch);
+imgetwcs.c: wcs->xrefpix, wcs->yrefpix, rstr, dstr, cstr);
+imgetwcs.c: if (wcs->degout) {
+imgetwcs.c: wcscstr (cstr, *sysout, *eqout, wcs->epoch);
+imgetwcs.c: if (wcs->degout) {
+imgetwcs.c: * Oct 6 2003 Change wcs->naxes to wcs->naxis to match WCSLIB 3.2
+imgetwcs.c: * Dec 3 2003 Add wcs->naxes back as an alternative
+imsetwcs.c: refep = wcs->epoch;
+imsetwcs.c: wcs->prjcode = WCS_TAN;
+imsetwcs.c: if (wcs->ncoeff1 > 0)
+imsetwcs.c: wcs->ncoeff1, wcs->ncoeff2);
+imsetwcs.c: 3600.0*wcs->xinc, 3600.0*wcs->yinc, wcs->rot);
+imsetwcs.c: ra2str (rstr, 32, wcs->xref, 3);
+imsetwcs.c: dec2str (dstr, 32, wcs->yref, 2);
+imsetwcs.c: rstr,dstr, refcoor, wcs->xrefpix, wcs->yrefpix);
+imsetwcs.c: ra = wcs->xref;
+imsetwcs.c: dec = wcs->yref;
+imsetwcs.c: rstr,dstr, wcs->xrefpix, wcs->yrefpix);
+imsetwcs.c: rstr,dstr, wcs->xrefpix, wcs->yrefpix);
+imsetwcs.c:/* setdcenter (wcs->xref, wcs->yref);
+imsetwcs.c: setsys (wcs->syswcs);
+imsetwcs.c: setrefpix (wcs->xrefpix, wcs->yrefpix);
+imsetwcs.c: setcd (wcs->cd);
+imsetwcs.c: setsecpix (-3600.0 * wcs->xinc);
+imsetwcs.c: setsecpix2 (3600.0 * wcs->yinc);
+imsetwcs.c: setrot (wcs->rot);
+imsetwcs.c:/* setdcenter (wcs->xref, wcs->yref);
+imsetwcs.c: setsys (wcs->syswcs);
+imsetwcs.c: setrefpix (wcs->xrefpix, wcs->yrefpix);
+imsetwcs.c: setcd (wcs->cd);
+imsetwcs.c: setsecpix (-3600.0 * wcs->xinc);
+imsetwcs.c: setsecpix2 (3600.0 * wcs->yinc);
+imsetwcs.c: setrot (wcs->rot);
+imsetwcs.c: x = 0.5 * wcs->nxpix;
+imsetwcs.c: y = 0.5 * wcs->nypix;
+imsetwcs.c: setsys (wcs->syswcs);
+imsetwcs.c: setsecpix (-3600.0 * wcs->xinc);
+imsetwcs.c: setsecpix2 (3600.0 * wcs->yinc);
+imsetwcs.c: setrot (wcs->rot);
+imsetwcs.c: * Jun 11 2001 Set refep from wcs->epoch after WCS is set
+matchstar1.c: wcs->xref = wcs->xref + (bestdx * wcs->xinc);
+matchstar1.c: if (wcs->xref < 0.0) wcs->xref = 360.0 + wcs->xref;
+matchstar1.c: wcs->yref = wcs->yref + (bestdy * wcs->yinc);
+matchstar1.c: xref_p = wcs->xref;
+matchstar1.c: yref_p = wcs->yref;
+matchstar1.c: xrefpix = wcs->xrefpix;
+matchstar1.c: yrefpix = wcs->yrefpix;
+matchstar1.c: xref0 = wcs->xref;
+matchstar1.c: yref0 = wcs->yref;
+matchstar1.c: xinc0 = wcs->xinc;
+matchstar1.c: yinc0 = wcs->yinc;
+matchstar1.c: rot0 = wcs->rot;
+matchstar1.c: xrefpix0 = wcs->xrefpix;
+matchstar1.c: yrefpix0 = wcs->yrefpix;
+matchstar1.c: cd0[0] = wcs->cd[0];
+matchstar1.c: cd0[1] = wcs->cd[1];
+matchstar1.c: cd0[2] = wcs->cd[2];
+matchstar1.c: cd0[3] = wcs->cd[3];
+matchstar1.c: ra2str (rastr, 16, wcs->xref, 3);
+matchstar1.c: dec2str (decstr, 16, wcs->yref, 2);
+matchstar1.c: rastr,decstr,wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3]);
+matchstar1.c: rastr,decstr,3600.0*wcs->xinc,3600.0*wcs->yinc,wcs->rot);
+matchstar1.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar1.c: xref_p = wcs->xref;
+matchstar1.c: yref_p = wcs->yref;
+matchstar1.c: xrefpix = wcs->xrefpix;
+matchstar1.c: yrefpix = wcs->yrefpix;
+matchstar1.c: ra2str (rastr, 16, wcs->xref, 3);
+matchstar1.c: dec2str (decstr, 16, wcs->yref, 2);
+matchstar1.c: rastr, decstr, 3600.0*wcs->xinc, 3600.0*wcs->yinc, wcs->rot);
+matchstar1.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar1.c:/* double equinox = wcs->equinox; */
+matchstar1.c: xref_p = wcs->xref;
+matchstar1.c: yref_p = wcs->yref;
+matchstar1.c: xrefpix = wcs->xrefpix;
+matchstar1.c: yrefpix = wcs->yrefpix;
+matchstar1.c: xref0 = wcs->xref;
+matchstar1.c: yref0 = wcs->yref;
+matchstar1.c: xinc0 = wcs->xinc;
+matchstar1.c: yinc0 = wcs->yinc;
+matchstar1.c: rot0 = wcs->rot;
+matchstar1.c: xrefpix0 = wcs->xrefpix;
+matchstar1.c: yrefpix0 = wcs->yrefpix;
+matchstar1.c: cd0[0] = wcs->cd[0];
+matchstar1.c: cd0[1] = wcs->cd[1];
+matchstar1.c: cd0[2] = wcs->cd[2];
+matchstar1.c: cd0[3] = wcs->cd[3];
+matchstar1.c: ra2str (rastr, 16, wcs->xref, 3);
+matchstar1.c: dec2str (decstr, 16, wcs->yref, 2);
+matchstar1.c: rastr,decstr,wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3]);
+matchstar1.c: rastr,decstr,3600.0*wcs->xinc,3600.0*wcs->yinc,wcs->rot);
+matchstar1.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar1.c: xref_p = wcs->xref;
+matchstar1.c: yref_p = wcs->yref;
+matchstar1.c: xrefpix = wcs->xrefpix;
+matchstar1.c: yrefpix = wcs->yrefpix;
+matchstar1.c: ra2str (rastr, 16, wcs->xref, 3);
+matchstar1.c: dec2str (decstr, 16, wcs->yref, 2);
+matchstar1.c: rastr, decstr, 3600.0*wcs->xinc, 3600.0*wcs->yinc, wcs->rot);
+matchstar1.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar.c: nbx = wcs->nxpix / tol2;
+matchstar.c: nby = wcs->nypix / tol2;
+matchstar.c: wcs->xref = wcs->xref + (bestdx * wcs->xinc);
+matchstar.c: if (wcs->xref < 0.0) wcs->xref = 360.0 + wcs->xref;
+matchstar.c: wcs->yref = wcs->yref + (bestdy * wcs->yinc);
+matchstar.c: xref_p = wcs->xref;
+matchstar.c: yref_p = wcs->yref;
+matchstar.c: xrefpix = wcs->xrefpix;
+matchstar.c: yrefpix = wcs->yrefpix;
+matchstar.c: xref0 = wcs->xref;
+matchstar.c: yref0 = wcs->yref;
+matchstar.c: xinc0 = wcs->xinc;
+matchstar.c: yinc0 = wcs->yinc;
+matchstar.c: rot0 = wcs->rot;
+matchstar.c: xrefpix0 = wcs->xrefpix;
+matchstar.c: yrefpix0 = wcs->yrefpix;
+matchstar.c: cd0[0] = wcs->cd[0];
+matchstar.c: cd0[1] = wcs->cd[1];
+matchstar.c: cd0[2] = wcs->cd[2];
+matchstar.c: cd0[3] = wcs->cd[3];
+matchstar.c: ra2str (rastr, 31, wcs->xref, 3);
+matchstar.c: dec2str (decstr, 31, wcs->yref, 2);
+matchstar.c: rastr,decstr,wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3]);
+matchstar.c: rastr,decstr,3600.0*wcs->xinc,3600.0*wcs->yinc,wcs->rot);
+matchstar.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar.c: xref_p = wcs->xref;
+matchstar.c: yref_p = wcs->yref;
+matchstar.c: xrefpix = wcs->xrefpix;
+matchstar.c: yrefpix = wcs->yrefpix;
+matchstar.c: ra2str (rastr, 31, wcs->xref, 3);
+matchstar.c: dec2str (decstr, 31, wcs->yref, 2);
+matchstar.c: rastr, decstr, 3600.0*wcs->xinc, 3600.0*wcs->yinc, wcs->rot);
+matchstar.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar.c:/* double equinox = wcs->equinox; */
+matchstar.c: xref_p = wcs->xref;
+matchstar.c: yref_p = wcs->yref;
+matchstar.c: xrefpix = wcs->xrefpix;
+matchstar.c: yrefpix = wcs->yrefpix;
+matchstar.c: xref0 = wcs->xref;
+matchstar.c: yref0 = wcs->yref;
+matchstar.c: xinc0 = wcs->xinc;
+matchstar.c: yinc0 = wcs->yinc;
+matchstar.c: rot0 = wcs->rot;
+matchstar.c: xrefpix0 = wcs->xrefpix;
+matchstar.c: yrefpix0 = wcs->yrefpix;
+matchstar.c: cd0[0] = wcs->cd[0];
+matchstar.c: cd0[1] = wcs->cd[1];
+matchstar.c: cd0[2] = wcs->cd[2];
+matchstar.c: cd0[3] = wcs->cd[3];
+matchstar.c: ra2str (rastr, 31, wcs->xref, 3);
+matchstar.c: dec2str (decstr, 31, wcs->yref, 2);
+matchstar.c: rastr,decstr,wcs->cd[0],wcs->cd[1],wcs->cd[2],wcs->cd[3]);
+matchstar.c: rastr,decstr,3600.0*wcs->xinc,3600.0*wcs->yinc,wcs->rot);
+matchstar.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+matchstar.c: xref_p = wcs->xref;
+matchstar.c: yref_p = wcs->yref;
+matchstar.c: xrefpix = wcs->xrefpix;
+matchstar.c: yrefpix = wcs->yrefpix;
+matchstar.c: ra2str (rastr, 31, wcs->xref, 3);
+matchstar.c: dec2str (decstr, 31, wcs->yref, 2);
+matchstar.c: rastr, decstr, 3600.0*wcs->xinc, 3600.0*wcs->yinc, wcs->rot);
+matchstar.c: fprintf (stderr,"(%8.2f,%8.2f)\n", wcs->xrefpix, wcs->yrefpix);
+NEWS:wcsinit.c: Set wcs->naxes to actual number of image WCS axes, usually 2
+NEWS:In wcs.c, keep wcs->rot between 0 and 360 degrees (360.0 -> 0.0)
+NEWS:Add wcs->naxes back into wcs structure for backward compatibility; it
+NEWS:should always be equal to wcs->naxis.
+NEWS:Change wcs->naxes to wcs->naxis to prepare for WCSLIB 3.*
+platepos.c: int ncoeff1 = wcs->ncoeff1;
+platepos.c: int ncoeff2 = wcs->ncoeff2;
+platepos.c: x = xpix - wcs->crpix[0];
+platepos.c: y = ypix - wcs->crpix[1];
+platepos.c: xi = wcs->x_coeff[ 0] + wcs->x_coeff[ 1]*x +
+platepos.c: wcs->x_coeff[ 2]*y + wcs->x_coeff[ 3]*x2 +
+platepos.c: wcs->x_coeff[ 4]*y2 + wcs->x_coeff[ 5]*x*y;
+platepos.c: xi = xi + wcs->x_coeff[ 6]*x3 + wcs->x_coeff[ 7]*y3;
+platepos.c: xi = xi + wcs->x_coeff[ 8]*x2*y + wcs->x_coeff[ 9]*x*y2 +
+platepos.c: wcs->x_coeff[10]*(r2) + wcs->x_coeff[11]*x*r2 +
+platepos.c: wcs->x_coeff[12]*y*r2;
+platepos.c: eta = wcs->y_coeff[ 0] + wcs->y_coeff[ 1]*x +
+platepos.c: wcs->y_coeff[ 2]*y + wcs->y_coeff[ 3]*x2 +
+platepos.c: wcs->y_coeff[ 4]*y2 + wcs->y_coeff[ 5]*x*y;
+platepos.c: eta = eta + wcs->y_coeff[ 6]*x3 + wcs->y_coeff[ 7]*y3;
+platepos.c: eta = eta + wcs->y_coeff[ 8]*x2*y + wcs->y_coeff[ 9]*y2*x +
+platepos.c: wcs->y_coeff[10]*r2 + wcs->y_coeff[11]*x*r2 +
+platepos.c: wcs->y_coeff[12]*y*r2;
+platepos.c: ra0 = degrad (wcs->crval[0]);
+platepos.c: dec0 = degrad (wcs->crval[1]);
+platepos.c: int ncoeff1 = wcs->ncoeff1;
+platepos.c: int ncoeff2 = wcs->ncoeff2;
+platepos.c: ra0 = degrad (wcs->crval[0]);
+platepos.c: dec0 = degrad (wcs->crval[1]);
+platepos.c: x = xi * wcs->dc[0] + eta * wcs->dc[1];
+platepos.c: y = xi * wcs->dc[2] + eta * wcs->dc[3];
+platepos.c: /* if (wcs->x_coeff[1] == 0.0)
+platepos.c: x = xi - wcs->x_coeff[0];
+platepos.c: x = (xi - wcs->x_coeff[0]) / wcs->x_coeff[1];
+platepos.c: if (wcs->y_coeff[2] == 0.0)
+platepos.c: y = eta - wcs->y_coeff[0];
+platepos.c: y = (eta - wcs->y_coeff[0]) / wcs->y_coeff[2]; */
+platepos.c: f = wcs->x_coeff[0] + wcs->x_coeff[1]*x +
+platepos.c: wcs->x_coeff[2]*y + wcs->x_coeff[3]*x2 +
+platepos.c: wcs->x_coeff[4]*y2 + wcs->x_coeff[5]*xy;
+platepos.c: fx = wcs->x_coeff[1] + wcs->x_coeff[3]*2.0*x +
+platepos.c: wcs->x_coeff[5]*y;
+platepos.c: fy = wcs->x_coeff[2] + wcs->x_coeff[4]*2.0*y +
+platepos.c: wcs->x_coeff[5]*x;
+platepos.c: f = f + wcs->x_coeff[6]*x3 + wcs->x_coeff[7]*y3;
+platepos.c: fx = fx + wcs->x_coeff[6]*3.0*x2;
+platepos.c: fy = fy + wcs->x_coeff[7]*3.0*y2;
+platepos.c: wcs->x_coeff[8]*x2y + wcs->x_coeff[9]*y2x +
+platepos.c: wcs->x_coeff[10]*r2 + wcs->x_coeff[11]*x*r2 +
+platepos.c: wcs->x_coeff[12]*y*r2;
+platepos.c: fx = fx + wcs->x_coeff[8]*2.0*xy +
+platepos.c: wcs->x_coeff[9]*y2 +
+platepos.c: wcs->x_coeff[10]*2.0*x +
+platepos.c: wcs->x_coeff[11]*(3.0*x2+y2) +
+platepos.c: wcs->x_coeff[12]*2.0*xy;
+platepos.c: fy = fy + wcs->x_coeff[8]*x2 +
+platepos.c: wcs->x_coeff[9]*2.0*xy +
+platepos.c: wcs->x_coeff[10]*2.0*y +
+platepos.c: wcs->x_coeff[11]*2.0*xy +
+platepos.c: wcs->x_coeff[12]*(3.0*y2+x2);
+platepos.c: g = wcs->y_coeff[0] + wcs->y_coeff[1]*x +
+platepos.c: wcs->y_coeff[2]*y + wcs->y_coeff[3]*x2 +
+platepos.c: wcs->y_coeff[4]*y2 + wcs->y_coeff[5]*xy;
+platepos.c: gx = wcs->y_coeff[1] + wcs->y_coeff[3]*2.0*x +
+platepos.c: wcs->y_coeff[5]*y;
+platepos.c: gy = wcs->y_coeff[2] + wcs->y_coeff[4]*2.0*y +
+platepos.c: wcs->y_coeff[5]*x;
+platepos.c: g = g + wcs->y_coeff[6]*x3 + wcs->y_coeff[7]*y3;
+platepos.c: gx = gx + wcs->y_coeff[6]*3.0*x2;
+platepos.c: gy = gy + wcs->y_coeff[7]*3.0*y2;
+platepos.c: wcs->y_coeff[8]*x2y + wcs->y_coeff[9]*y2x +
+platepos.c: wcs->y_coeff[10]*r2 + wcs->y_coeff[11]*x*r2 +
+platepos.c: wcs->y_coeff[12]*y*r2;
+platepos.c: gx = gx + wcs->y_coeff[8]*2.0*xy +
+platepos.c: wcs->y_coeff[9]*y2 +
+platepos.c: wcs->y_coeff[10]*2.0*x +
+platepos.c: wcs->y_coeff[11]*(3.0*x2+y2) +
+platepos.c: wcs->y_coeff[12]*2.0*xy;
+platepos.c: gy = gy + wcs->y_coeff[8]*x2 +
+platepos.c: wcs->y_coeff[9]*2.0*xy +
+platepos.c: wcs->y_coeff[10]*2.0*y +
+platepos.c: wcs->y_coeff[11]*2.0*xy +
+platepos.c: wcs->y_coeff[12]*(3.0*y2+x2);
+platepos.c: *xpix = x + wcs->crpix[0];
+platepos.c: *ypix = y + wcs->crpix[1];
+platepos.c: if (*xpix < 0.5 || *xpix > wcs->nxpix+0.5)
+platepos.c: if (*ypix < 0.5 || *ypix > wcs->nypix+0.5)
+platepos.c: wcs->ncoeff1 = ncoeff1;
+platepos.c: wcs->ncoeff2 = ncoeff2;
+platepos.c: wcs->prjcode = WCS_PLT;
+platepos.c: wcs->x_coeff[i] = coeff[i];
+platepos.c: wcs->x_coeff[i] = 0.0;
+platepos.c: wcs->y_coeff[i] = coeff[ncoeff1+i];
+platepos.c: wcs->y_coeff[i] = 0.0;
+platepos.c: *ncoeff1 = wcs->ncoeff1;
+platepos.c: *ncoeff2 = wcs->ncoeff2;
+platepos.c: coeff[i] = wcs->x_coeff[i];
+platepos.c: coeff[*ncoeff1+i] = wcs->y_coeff[i];
+platepos.c: for (i = 0; i < wcs->ncoeff1; i++) {
+platepos.c: hputnr8 (header, keyword, -15, wcs->x_coeff[i]);
+platepos.c: for (i = 0; i < wcs->ncoeff2; i++) {
+platepos.c: hputnr8 (header, keyword, -15, wcs->y_coeff[i]);
+tabread.c: sysout = wcs->syswcs;
+tabread.c: eqout = wcs->equinox;
+tabread.c: epout = wcs->epoch;
+temp: wcs->wcschar = mchar;
+temp: wcs->wcsname = (char *) calloc (strlen (wcsname)+2, 1);
+temp: strcpy (wcs->wcsname, wcsname);
+temp: wcs->cel.flag = 0;
+temp: wcs->lin.flag = 0;
+temp: wcs->wcsl.flag = 0;
+temp: wcs->wcsl.cubeface = -1;
+temp: wcs->ncoeff1 = 0;
+temp: wcs->ncoeff2 = 0;
+temp: wcs->rotmat = 0;
+temp: wcs->rot = 0.0;
+temp: wcs->naxis = naxes;
+temp: wcs->naxes = naxes;
+temp: wcs->lin.naxis = naxes;
+temp: wcs->nxpix = 0;
+temp: hgetr8 (hstring, "NAXIS1", &wcs->nxpix);
+temp: if (wcs->nxpix < 1)
+temp: hgetr8 (hstring, "IMAGEW", &wcs->nxpix);
+temp: if (wcs->nxpix < 1) {
+temp: wcs->nypix = 0;
+temp: hgetr8 (hstring, "NAXIS2", &wcs->nypix);
+temp: if (wcs->nypix < 1)
+temp: hgetr8 (hstring, "IMAGEH", &wcs->nypix);
+temp: if (naxes > 1 && wcs->nypix < 1) {
+temp: if (i == 0 && wcs->nxpix > 1) {
+temp: keyword, wcs->nxpix); */
+temp: j = wcs->nxpix;
+temp: else if (i == 1 && wcs->nypix > 1) {
+temp: keyword, wcs->nypix); */
+temp: j = wcs->nypix;
+temp: wcs->naxes = nax;
+temp: wcs->naxis = nax;
+temp: hgets (hstring, "INSTRUME", 16, wcs->instrument);
+temp: hgeti4 (hstring, "DETECTOR", &wcs->detector);
+temp: wcs->wcsproj = getdefwcs();
+temp: wcs->logwcs = 0;
+temp: hgeti4 (hstring, "DC-FLAG", &wcs->logwcs);
+temp: for (i = 0; i < 81; i++) wcs->pc[i] = 0.0;
+temp: for (i = 0; i < naxes; i++) wcs->pc[(i*naxes)+i] = 1.0;
+temp: for (i = 0; i < 9; i++) wcs->cdelt[i] = 0.0;
+temp: for (i = 0; i < naxes; i++) wcs->cdelt[i] = 1.0;
+temp: if ((wcs->wcs = wcsinitn (hstring, wcsname)) == NULL) {
+temp: depwcs = wcs->wcs;
+temp: depwcs->wcsdep = wcs;
+temp: wcs->wcs = NULL;
+temp: wcs->radvel = 0.0;
+temp: wcs->zvel = 0.0;
+temp: if (hgetr8c (hstring, "VSOURCE", &mchar, &wcs->radvel))
+temp: wcs->zvel = wcs->radvel / cvel;
+temp: else if (hgetr8c (hstring, "ZSOURCE", &mchar, &wcs->zvel))
+temp: wcs->radvel = wcs->zvel * cvel;
+temp: else if (hgetr8 (hstring, "VELOCITY", &wcs->radvel))
+temp: wcs->zvel = wcs->radvel / cvel;
+temp: wcs->prj.p[i] = 0.0;
+temp: strcpy (wcs->ctype[0], ctype1);
+temp: strcpy (wcs->ctype[1], ctype2);
+temp: strcpy (wcs->ctype[2], "");
+temp: hgetsc (hstring, "CTYPE3", &mchar, 9, wcs->ctype[2]);
+temp: strcpy (wcs->ctype[3], "");
+temp: hgetsc (hstring, "CTYPE4", &mchar, 9, wcs->ctype[3]);
+temp: if (wcs->prjcode == WCS_LIN) {
+temp: if (!hgetsc (hstring, "CUNIT1", &mchar, 16, wcs->units[0])) {
+temp: if (!mgetstr (hstring, "WAT1", "units", 16, wcs->units[0])) {
+temp: wcs->units[0][0] = 0;
+temp: if (!strcmp (wcs->units[0], "pixel"))
+temp: wcs->prjcode = WCS_PIX;
+temp: if (!hgetsc (hstring, "CUNIT2", &mchar, 16, wcs->units[1])) {
+temp: if (!mgetstr (hstring, "WAT2", "units", 16, wcs->units[1])) {
+temp: wcs->units[1][0] = 0;
+temp: if (!strcmp (wcs->units[0], "pixel"))
+temp: wcs->prjcode = WCS_PIX;
+temp: wcs->crpix[0] = 1.0;
+temp: hgetr8c (hstring, "CRPIX1", &mchar, &wcs->crpix[0]);
+temp: wcs->crpix[1] = 1.0;
+temp: hgetr8c (hstring, "CRPIX2", &mchar, &wcs->crpix[1]);
+temp: wcs->xrefpix = wcs->crpix[0];
+temp: wcs->yrefpix = wcs->crpix[1];
+temp: wcs->crval[0] = 0.0;
+temp: hgetr8c (hstring, "CRVAL1", &mchar, &wcs->crval[0]);
+temp: wcs->crval[1] = 0.0;
+temp: hgetr8c (hstring, "CRVAL2", &mchar, &wcs->crval[1]);
+temp: if (wcs->syswcs == WCS_NPOLE)
+temp: wcs->crval[1] = 90.0 - wcs->crval[1];
+temp: if (wcs->syswcs == WCS_SPA)
+temp: wcs->crval[1] = wcs->crval[1] - 90.0;
+temp: wcs->xref = wcs->crval[0];
+temp: wcs->yref = wcs->crval[1];
+temp: if (wcs->coorflip) {
+temp: wcs->cel.ref[0] = wcs->crval[1];
+temp: wcs->cel.ref[1] = wcs->crval[0];
+temp: wcs->cel.ref[0] = wcs->crval[0];
+temp: wcs->cel.ref[1] = wcs->crval[1];
+temp: wcs->longpole = 999.0;
+temp: hgetr8c (hstring, "LONPOLE", &mchar, &wcs->longpole);
+temp: wcs->cel.ref[2] = wcs->longpole;
+temp: wcs->latpole = 999.0;
+temp: hgetr8c (hstring, "LATPOLE", &mchar, &wcs->latpole);
+temp: wcs->cel.ref[3] = wcs->latpole;
+temp: wcs->lin.crpix = wcs->crpix;
+temp: wcs->lin.cdelt = wcs->cdelt;
+temp: wcs->lin.pc = wcs->pc;
+temp: wcs->prj.r0 = 0.0;
+temp: hgetr8c (hstring, "PROJR0", &mchar, &wcs->prj.r0);
+temp: hgetr8c (hstring, keyword, &mchar, &wcs->prj.p[i]);
+temp: if (wcs->prjcode == WCS_AZP || wcs->prjcode == WCS_SIN ||
+temp: wcs->prjcode == WCS_COP || wcs->prjcode == WCS_COE ||
+temp: wcs->prjcode == WCS_COD || wcs->prjcode == WCS_COO) {
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+temp: else if (wcs->prjcode == WCS_SZP) {
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+temp: if (wcs->prj.p[3] == 0.0)
+temp: wcs->prj.p[3] = 90.0;
+temp: hgetr8c (hstring, pvkey3, &mchar, &wcs->prj.p[3]);
+temp: else if (wcs->prjcode == WCS_CEA) {
+temp: if (wcs->prj.p[1] == 0.0)
+temp: wcs->prj.p[1] = 1.0;
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: else if (wcs->prjcode == WCS_CYP) {
+temp: if (wcs->prj.p[1] == 0.0)
+temp: wcs->prj.p[1] = 1.0;
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: if (wcs->prj.p[2] == 0.0)
+temp: wcs->prj.p[2] = 1.0;
+temp: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+temp: else if (wcs->prjcode == WCS_AIR) {
+temp: if (wcs->prj.p[1] == 0.0)
+temp: wcs->prj.p[1] = 90.0;
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: else if (wcs->prjcode == WCS_BON) {
+temp: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+temp: else if (wcs->prjcode == WCS_ZPN) {
+temp: hgetr8c (hstring, keyword, &mchar, &wcs->prj.p[i]);
+temp: if (wcs->prjcode == WCS_TNX) {
+temp: wcs->ctype[0][6] = 'A';
+temp: wcs->ctype[0][7] = 'N';
+temp: wcs->ctype[1][6] = 'A';
+temp: wcs->ctype[1][7] = 'N';
+temp: wcs->prjcode = WCS_TAN;
+temp: if (wcs->prjcode == WCS_ZPX) {
+temp: wcs->ctype[0][7] = 'N';
+temp: wcs->ctype[1][7] = 'N';
+temp: wcs->prjcode = WCS_ZPN;
+temp: if (wcs->prjcode == WCS_TPV) {
+temp: wcs->ctype[0][6] = 'A';
+temp: wcs->ctype[0][7] = 'N';
+temp: wcs->ctype[1][6] = 'A';
+temp: wcs->ctype[1][7] = 'N';
+temp: wcs->prjcode = WCS_TAN;
+temp: if (wcs->wcsproj > 0)
+temp: wcs->ncoeff1 = 0;
+temp: wcs->ncoeff2 = 0;
+temp: if (wcs->wcsproj != WCS_OLD &&
+temp: wcs->prjcode = WCS_PLT;
+temp: (void)strcpy (wcs->ptype, "PLATE");
+temp: wcs->x_coeff[i] = 0.0;
+temp: if (hgetr8 (hcoeff, keyword, &wcs->x_coeff[i]))
+temp: wcs->ncoeff1 = i + 1;
+temp: wcs->y_coeff[i] = 0.0;
+temp: if (hgetr8 (hcoeff, keyword, &wcs->y_coeff[i]))
+temp: wcs->ncoeff2 = i + 1;
+temp: platepos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+temp: platepos (wcs->crpix[0], wcs->crpix[1]+1.0, wcs, &ra1, &dec1);
+temp: wcs->yinc = dec1 - dec0;
+temp: wcs->xinc = -wcs->yinc;
+temp: wcs->wcson = 1;
+temp: rot = degrad (wcs->rot);
+temp: platepos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+temp: platepos (wcs->crpix[0]+cos(rot),
+temp: wcs->crpix[1]+sin(rot), wcs, &ra1, &dec1);
+temp: wcs->cdelt[0] = -wcsdist (ra0, dec0, ra1, dec1);
+temp: wcs->xinc = wcs->cdelt[0];
+temp: platepos (wcs->crpix[0]+sin(rot),
+temp: wcs->crpix[1]+cos(rot), wcs, &ra1, &dec1);
+temp: wcs->cdelt[1] = wcsdist (ra0, dec0, ra1, dec1);
+temp: wcs->yinc = wcs->cdelt[1];
+temp: wcs->cd[0] = cd[0];
+temp: wcs->cd[1] = cd[1];
+temp: wcs->cd[2] = cd[2];
+temp: wcs->cd[3] = cd[3];
+temp: (void) matinv (2, wcs->cd, wcs->dc);
+temp: wcs->rotmat = 1;
+temp: if (cdelt1 == 0.0 || (wcs->nypix > 1 && cdelt2 == 0.0)) {
+temp: if (cdelt2 == 0.0 && wcs->nypix > 1)
+temp: wcs->cdelt[2] = 1.0;
+temp: wcs->cdelt[3] = 1.0;
+temp: wcs->pc[i] = 0.0;
+temp: wcs->xinc = 1.0;
+temp: wcs->yinc = 1.0;
+temp: wcs->cdelt[0] = 1.0;
+temp: wcs->cdelt[1] = 1.0;
+temp: wcs->rot = 0.0;
+temp: wcs->rotmat = 0;
+temp: if (wcs->prjcode == WCS_TAN && wcs->naxis == 2) {
+temp: if (wcs->inv_x) {
+temp: poly_end(wcs->inv_x);
+temp: wcs->inv_x = NULL;
+temp: if (wcs->inv_y) {
+temp: poly_end(wcs->inv_y);
+temp: wcs->inv_y = NULL;
+temp: wcs->pvfail = 0;
+temp: wcs->projppv[i] = 0.0;
+temp: wcs->prj.ppv[i] = 0.0;
+temp: if (hgetr8c(hstring, keyword,&mchar, &wcs->projppv[j+k*MAXPV]) == 0) {
+temp: wcs->projppv[j+k*MAXPV] = 0.0;
+temp: if (n > 0 && wcs->distcode != DISTORT_SIRTF) {
+temp: wcs->prj.ppv[k] = wcs->projppv[k+wcs->wcsl.lat*MAXPV];
+temp: wcs->prj.ppv[k+MAXPV] = wcs->projppv[k+wcs->wcsl.lng*MAXPV];
+temp: if (!n && (wcs->prj.ppv[k] || wcs->prj.ppv[k+MAXPV])) {
+temp: wcs->cel.flag = 0;
+temp: if (!strncmp (wcs->ptype,"LINEAR",6) ||
+temp: !strncmp (wcs->ptype,"PIXEL",5)) {
+temp: wcs->degout = -1;
+temp: wcs->ndec = 5;
+temp: wcs->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781;
+temp: else if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+temp: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+temp: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+temp: wcs->epoch = wcs->equinox;
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: wcs->wcson = 1;
+temp: wcs->prjcode = WCS_DSS;
+temp: wcs->plate_ra = hrrad (ra_hours);
+temp: wcs->plate_dec = degrad (dec_deg);
+temp: hgetr8 (hstring,"EQUINOX",&wcs->equinox);
+temp: strcpy (wcs->radecsys,"FK4");
+temp: strcpy (wcs->radecsys,"FK5");
+temp: wcs->epoch = wcs->equinox;
+temp: hgetr8 (hstring,"EPOCH",&wcs->epoch);
+temp: (void)sprintf (wcs->center,"%2.0f:%2.0f:%5.3f %c%2.0f:%2.0f:%5.3f %s",
+temp: rah,ram,ras,decsign,decd,decm,decs,wcs->radecsys);
+temp: hgetr8 (hstring,"PLTSCALE",&wcs->plate_scale);
+temp: hgetr8 (hstring,"XPIXELSZ",&wcs->x_pixel_size);
+temp: hgetr8 (hstring,"YPIXELSZ",&wcs->y_pixel_size);
+temp: hgetr8 (hstring,"CNPIX1",&wcs->x_pixel_offset);
+temp: hgetr8 (hstring,"CNPIX2",&wcs->y_pixel_offset);
+temp: wcs->ppo_coeff[i] = 0.0;
+temp: hgetr8 (hcoeff,keyword,&wcs->ppo_coeff[i]);
+temp: wcs->x_coeff[i] = 0.0;
+temp: hgetr8 (hcoeff, keyword, &wcs->x_coeff[i]);
+temp: wcs->y_coeff[i] = 0.0;
+temp: hgetr8 (hcoeff, keyword, &wcs->y_coeff[i]);
+temp: wcs->wcson = 1;
+temp: (void)strcpy (wcs->c1type, "RA");
+temp: (void)strcpy (wcs->c2type, "DEC");
+temp: (void)strcpy (wcs->ptype, "DSS");
+temp: wcs->degout = 0;
+temp: wcs->ndec = 3;
+temp: strcpy (wcs->ctype[0], "RA---DSS");
+temp: strcpy (wcs->ctype[1], "DEC--DSS");
+temp: wcs->crpix[0] = 0.5 * wcs->nxpix;
+temp: wcs->crpix[1] = 0.5 * wcs->nypix;
+temp: wcs->xrefpix = wcs->crpix[0];
+temp: wcs->yrefpix = wcs->crpix[1];
+temp: dsspos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+temp: wcs->crval[0] = ra0;
+temp: wcs->crval[1] = dec0;
+temp: wcs->xref = wcs->crval[0];
+temp: wcs->yref = wcs->crval[1];
+temp: dsspos (wcs->crpix[0], wcs->crpix[1]+1.0, wcs, &ra1, &dec1);
+temp: wcs->yinc = dec1 - dec0;
+temp: wcs->xinc = -wcs->yinc;
+temp: wcs->wcson = 1;
+temp: rot = degrad (wcs->rot);
+temp: dsspos (wcs->crpix[0]+cos(rot),
+temp: wcs->crpix[1]+sin(rot), wcs, &ra1, &dec1);
+temp: wcs->cdelt[0] = -wcsdist (ra0, dec0, ra1, dec1);
+temp: dsspos (wcs->crpix[0]+sin(rot),
+temp: wcs->crpix[1]+cos(rot), wcs, &ra1, &dec1);
+temp: wcs->cdelt[1] = wcsdist (ra0, dec0, ra1, dec1);
+temp: wcsdeltset (wcs, wcs->cdelt[0], wcs->cdelt[1], wcs->rot);
+temp: if (wcs->rot == 0.)
+temp: wcs->crpix[0] = 0.5 + (wcs->nxpix * 0.5);
+temp: wcs->crpix[1] = 0.5 + (wcs->nypix * 0.5);
+temp: hgetr8 (hstring,"CRPIX1",&wcs->crpix[0]);
+temp: hgetr8 (hstring,"CRPIX2",&wcs->crpix[1]);
+temp: wcs->crpix[0] = dxrefpix - (double) (ix1 - 1);
+temp: wcs->crpix[1] = dyrefpix - (double) (iy1 - 1);
+temp: wcs->xrefpix = wcs->crpix[0];
+temp: wcs->yrefpix = wcs->crpix[1];
+temp: wcs->crval[0] = -999.0;
+temp: if (!hgetra (hstring,"RA",&wcs->crval[0])) {
+temp: wcs->crval[1] = -999.0;
+temp: if (!hgetdec (hstring,"DEC",&wcs->crval[1])) {
+temp: wcs->xref = wcs->crval[0];
+temp: wcs->yref = wcs->crval[1];
+temp: wcs->coorflip = 0;
+temp: wcs->cel.ref[0] = wcs->crval[0];
+temp: wcs->cel.ref[1] = wcs->crval[1];
+temp: wcs->cel.ref[2] = 999.0;
+temp: if (!hgetr8 (hstring,"LONPOLE",&wcs->cel.ref[2]))
+temp: hgetr8 (hstring,"LONGPOLE",&wcs->cel.ref[2]);
+temp: wcs->cel.ref[3] = 999.0;
+temp: hgetr8 (hstring,"LATPOLE",&wcs->cel.ref[3]);
+temp: wcs->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781;
+temp: else if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+temp: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+temp: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+temp: wcs->epoch = wcs->equinox;
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: wcs->coorflip = 0;
+temp: wcs->degout = 0;
+temp: wcs->ndec = 3;
+temp: wcs->wcson = 1;
+temp: wcs->lin.crpix = wcs->crpix;
+temp: wcs->lin.cdelt = wcs->cdelt;
+temp: wcs->lin.pc = wcs->pc;
+temp: wcs->printsys = 1;
+temp: wcs->tabsys = 0;
+temp: wcs->linmode = 0;
+temp: lng = wcs->wcsl.lng;
+temp: lat = wcs->wcsl.lat;
+temp: if (wcs->naxis != NAXISPV) {
+temp: if (strcmp(wcs->wcsl.pcode, "TAN") != 0) {
+temp: if ((wcs->projppv[1+lng*MAXPV] == 0) &&
+temp: (wcs->projppv[1+lat*MAXPV] == 0)) {
+temp: if (wcs->wcs != NULL) {
+temp: pix2wcs(wcs->wcs,0,0,&xmin,&ymin);
+temp: pix2wcs(wcs->wcs,wcs->nxpix,wcs->nypix,&xmax,&ymax);
+temp: xmax = wcs->nxpix;
+temp: ymax = wcs->nypix;
+temp: if (linrev(raw, &wcs->lin, pixin)) {
+temp: wcs->wcsl.pcode);
+temp: raw_to_pv (&wcs->prj,pixin[lng],pixin[lat], outpost, outpost+1);
+temp: linrev(rawmin, &wcs->lin, pixin);
+temp: linfwd(pixin, &wcs->lin, raw);
+temp: wcs->wcsl.pcode);
+temp: wcs->pvfail = 1;
+temp: wcs->prj.inv_x = wcs->inv_x = poly;
+temp: linrev(rawmin, &wcs->lin, pixin);
+temp: linfwd(pixin, &wcs->lin, raw);
+temp: wcs->wcsl.pcode);
+temp: wcs->pvfail = 1;
+temp: wcs->prj.inv_y = wcs->inv_y = poly;
+temp: if (strlen (wcs->radecsys) == 0 || wcs->prjcode == WCS_LIN)
+temp: strcpy (wcs->radecsys, "LINEAR");
+temp: if (wcs->prjcode == WCS_PIX)
+temp: strcpy (wcs->radecsys, "PIXEL");
+temp: wcs->syswcs = wcscsys (wcs->radecsys);
+temp: if (wcs->syswcs == WCS_B1950)
+temp: strcpy (wcs->radecout, "FK4");
+temp: else if (wcs->syswcs == WCS_J2000)
+temp: strcpy (wcs->radecout, "FK5");
+temp: strcpy (wcs->radecout, wcs->radecsys);
+temp: wcs->sysout = wcscsys (wcs->radecout);
+temp: wcs->eqout = wcs->equinox;
+temp: strcpy (wcs->radecin, wcs->radecsys);
+temp: wcs->sysin = wcscsys (wcs->radecin);
+temp: wcs->eqin = wcs->equinox;
+temp: wcs->equinox = atof (eqstring+1);
+temp: wcs->equinox = atof (eqstring+1);
+temp: hgetr8 (hstring, eqkey, &wcs->equinox);
+temp: wcs->equinox = 1950.0;
+temp: hgetr8 (hstring,"EPOCH",&wcs->equinox);
+temp: wcs->equinox = 1950.0;
+temp: wcs->equinox = 2000.0;
+temp: wcs->equinox = 2000.0;
+temp: wcs->equinox = 2000.0;
+temp: wcs->equinox = 2000.0;
+temp: wcs->equinox = 2000.0;
+temp: if (!strncmp (wcs->c1type, "RA",2) || !strncmp (wcs->c1type,"DEC",3))
+temp: if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+temp: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+temp: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+temp: wcs->epoch = wcs->equinox;
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+temp: if (wcs->epoch == 0.0)
+temp: wcs->epoch = wcs->equinox;
+temp: strcpy (wcs->radecsys,systring);
+temp: if (!strncmp (wcs->radecsys,"FK4",3))
+temp: wcs->equinox = 1950.0;
+temp: else if (!strncmp (wcs->radecsys,"FK5",3))
+temp: wcs->equinox = 2000.0;
+temp: else if (!strncmp (wcs->radecsys,"ICRS",4))
+temp: wcs->equinox = 2000.0;
+temp: else if (!strncmp (wcs->radecsys,"GAL",3) && ieq == 0)
+temp: wcs->equinox = 2000.0;
+temp: else if (wcs->syswcs != WCS_NPOLE) {
+temp: strcpy (wcs->radecsys,"FK5");
+temp: strcpy (wcs->radecsys,"FK4");
+temp: if (wcs->c1type[0] == 'G')
+temp: strcpy (wcs->radecsys,"GALACTIC");
+temp: else if (wcs->c1type[0] == 'E')
+temp: strcpy (wcs->radecsys,"ECLIPTIC");
+temp: else if (wcs->c1type[0] == 'S')
+temp: strcpy (wcs->radecsys,"SGALACTC");
+temp: else if (wcs->c1type[0] == 'H')
+temp: strcpy (wcs->radecsys,"HELIOECL");
+temp: else if (wcs->c1type[0] == 'A')
+temp: strcpy (wcs->radecsys,"ALTAZ");
+temp: else if (wcs->c1type[0] == 'L')
+temp: strcpy (wcs->radecsys,"LINEAR");
+temp: wcs->syswcs = wcscsys (wcs->radecsys);
+temp: * Oct 1 2003 Rename wcs->naxes to wcs->naxis to match WCSLIB 3.2
+temp: * Dec 3 2003 Add back wcs->naxes for backward compatibility
+temp: * Feb 15 2007 Check for wcs->wcsproj > 0 instead of CTYPEi != LINEAR or PIXEL
+tmcread.c: sysout = wcs->syswcs;
+tmcread.c: eqout = wcs->equinox;
+tmcread.c: epout = wcs->epoch;
+tnxpos.c: if (wcs->longpole > 360.0) {
+tnxpos.c: if (!igetr8 (str1, "longpole", &wcs->longpole)) {
+tnxpos.c: if (!igetr8 (str2, "longpole", &wcs->longpole))
+tnxpos.c: wcs->longpole = 180.0;
+tnxpos.c: if (!igetr8 (str1, "ro", &wcs->rodeg)) {
+tnxpos.c: if (!igetr8 (str2, "ro", &wcs->rodeg))
+tnxpos.c: wcs->rodeg = 180.0 / PI;
+tnxpos.c: wcs->lngcor = NULL;
+tnxpos.c: wcs->lngcor = wf_gsopen (lngstr);
+tnxpos.c: wcs->lngcor = wf_gsopen (lngstr);
+tnxpos.c: wcs->latcor = NULL;
+tnxpos.c: wcs->latcor = wf_gsopen (latstr);
+tnxpos.c: wcs->latcor = wf_gsopen (latstr);
+tnxpos.c: if (wcs->latcor == NULL && wcs->lngcor == NULL)
+tnxpos.c: xpix = xpix - wcs->crpix[0];
+tnxpos.c: ypix = ypix - wcs->crpix[1];
+tnxpos.c: if (wcs->rotmat) {
+tnxpos.c: x = xpix * wcs->cd[0] + ypix * wcs->cd[1];
+tnxpos.c: y = xpix * wcs->cd[2] + ypix * wcs->cd[3];
+tnxpos.c: if (wcs->cdelt[0] == 0.0 || wcs->cdelt[1] == 0.0) {
+tnxpos.c: xs = xpix * wcs->cdelt[0];
+tnxpos.c: ys = ypix * wcs->cdelt[1];
+tnxpos.c: if (wcs->rot != 0.0) {
+tnxpos.c: double cosr = cos (degrad (wcs->rot));
+tnxpos.c: double sinr = sin (degrad (wcs->rot));
+tnxpos.c: if (wcs->coorflip) {
+tnxpos.c: colatp = degrad (90.0 - wcs->crval[idec]);
+tnxpos.c: longp = degrad(wcs->longpole);
+tnxpos.c: if (wcs->lngcor != NULL)
+tnxpos.c: xp = x + wf_gseval (wcs->lngcor, x, y);
+tnxpos.c: if (wcs->latcor != NULL)
+tnxpos.c: yp = y + wf_gseval (wcs->latcor, x, y);
+tnxpos.c: theta = atan2 (wcs->rodeg, r);
+tnxpos.c: ra = wcs->crval[ira] + raddeg(dlng);
+tnxpos.c: if (wcs->crval[ira] >= 0.0) {
+tnxpos.c: if (wcs->coorflip) {
+tnxpos.c: ra = degrad (xpos - wcs->crval[ira]);
+tnxpos.c: colatp = degrad (90.0 - wcs->crval[idec]);
+tnxpos.c: if (wcs->longpole == 999.0)
+tnxpos.c: longp = degrad(wcs->longpole);
+tnxpos.c: r = wcs->rodeg * cos (theta) / s;
+tnxpos.c: if (wcs->lngcor == NULL && wcs->latcor == NULL) {
+tnxpos.c: if (wcs->coorflip) {
+tnxpos.c: if (wcs->lngcor != NULL) {
+tnxpos.c: f = x + wf_gseval (wcs->lngcor, x, y) - xm;
+tnxpos.c: fx = wf_gsder (wcs->lngcor, x, y, 1, 0);
+tnxpos.c: fy = wf_gsder (wcs->lngcor, x, y, 0, 1);
+tnxpos.c: if (wcs->latcor != NULL) {
+tnxpos.c: g = y + wf_gseval (wcs->latcor, x, y) - ym;
+tnxpos.c: gx = wf_gsder (wcs->latcor, x, y, 1, 0);
+tnxpos.c: gy = wf_gsder (wcs->latcor, x, y, 0, 1);
+tnxpos.c: if (wcs->coorflip) {
+tnxpos.c: if (wcs->rotmat) {
+tnxpos.c: *xpix = x * wcs->dc[0] + y * wcs->dc[1];
+tnxpos.c: *ypix = x * wcs->dc[2] + y * wcs->dc[3];
+tnxpos.c: if (wcs->rot!=0.0) {
+tnxpos.c: double cosr = cos (degrad (wcs->rot));
+tnxpos.c: double sinr = sin (degrad (wcs->rot));
+tnxpos.c: if (wcs->xinc != 0.)
+tnxpos.c: *xpix = *xpix / wcs->xinc;
+tnxpos.c: if (wcs->yinc != 0.)
+tnxpos.c: *ypix = *ypix / wcs->yinc;
+tnxpos.c: *xpix = *xpix + wcs->xrefpix;
+tnxpos.c: *ypix = *ypix + wcs->yrefpix;
+tnxpos.c: if (wcs->lngcor != NULL)
+tnxpos.c: wf_gsclose (wcs->lngcor);
+tnxpos.c: if (wcs->latcor != NULL)
+tnxpos.c: wf_gsclose (wcs->latcor);
+tnxpos.c: wcs->prjcode = WCS_TNX;
+tnxpos.c: wcs->lngcor = wf_gspset (xorder, yorder, xterms, coeff);
+tnxpos.c: ycoeff = coeff + wcs->lngcor->ncoeff;
+tnxpos.c: wcs->latcor = wf_gspset (xorder, yorder, xterms, ycoeff);
+tnxpos.c: * Dec 10 1999 Compute wcs->rot using wcsrotset() in tnxinit()
+ty2read.c: sysout = wcs->syswcs;
+ty2read.c: eqout = wcs->equinox;
+ty2read.c: epout = wcs->epoch;
+uacread.c: sysout = wcs->syswcs;
+uacread.c: eqout = wcs->equinox;
+uacread.c: epout = wcs->epoch;
+ubcread.c: sysout = wcs->syswcs;
+ubcread.c: eqout = wcs->equinox;
+ubcread.c: epout = wcs->epoch;
+ucacread.c: sysout = wcs->syswcs;
+ucacread.c: eqout = wcs->equinox;
+ucacread.c: epout = wcs->epoch;
+ujcread.c: sysout = wcs->syswcs;
+ujcread.c: eqout = wcs->equinox;
+ujcread.c: epout = wcs->epoch;
+wcs.c: if (wcs->wcs) {
+wcs.c: wcsfree (wcs->wcs);
+wcs.c: wcs->wcs = NULL;
+wcs.c: if (wcs->wcsname != NULL)
+wcs.c: free (wcs->wcsname);
+wcs.c: if (wcs->lin.imgpix != NULL)
+wcs.c: free (wcs->lin.imgpix);
+wcs.c: if (wcs->lin.piximg != NULL)
+wcs.c: free (wcs->lin.piximg);
+wcs.c: if (wcs->inv_x != NULL)
+wcs.c: poly_end (wcs->inv_x);
+wcs.c: if (wcs->inv_y != NULL)
+wcs.c: poly_end (wcs->inv_y);
+wcs.c: wcs->cel.flag = 0;
+wcs.c: wcs->lin.flag = 0;
+wcs.c: wcs->wcsl.flag = 0;
+wcs.c: wcs->naxis = 2;
+wcs.c: wcs->naxes = 2;
+wcs.c: wcs->lin.naxis = 2;
+wcs.c: wcs->nxpix = nxpix;
+wcs.c: wcs->nypix = nypix;
+wcs.c: wcs->wcsproj = wcsproj0;
+wcs.c: wcs->crpix[0] = xrpix;
+wcs.c: wcs->crpix[1] = yrpix;
+wcs.c: wcs->xrefpix = wcs->crpix[0];
+wcs.c: wcs->yrefpix = wcs->crpix[1];
+wcs.c: wcs->lin.crpix = wcs->crpix;
+wcs.c: wcs->crval[0] = cra;
+wcs.c: wcs->crval[1] = cdec;
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: wcs->cel.ref[0] = wcs->crval[0];
+wcs.c: wcs->cel.ref[1] = wcs->crval[1];
+wcs.c: wcs->cel.ref[2] = 999.0;
+wcs.c: strcpy (wcs->c1type,"RA");
+wcs.c: strcpy (wcs->c2type,"DEC");
+wcs.c: strcpy (wcs->ptype,proj);
+wcs.c: strcpy (wcs->ctype[0],"RA---");
+wcs.c: strcpy (wcs->ctype[1],"DEC--");
+wcs.c: strcat (wcs->ctype[0],proj);
+wcs.c: strcat (wcs->ctype[1],proj);
+wcs.c: if (wcstype (wcs, wcs->ctype[0], wcs->ctype[1])) {
+wcs.c: wcs->lin.cdelt = wcs->cdelt;
+wcs.c: wcs->lin.pc = wcs->pc;
+wcs.c: wcs->equinox = (double) equinox;
+wcs.c: strcpy (wcs->radecsys,"FK5");
+wcs.c: strcpy (wcs->radecsys,"FK4");
+wcs.c: wcs->epoch = epoch;
+wcs.c: wcs->epoch = 0.0;
+wcs.c: wcs->wcson = 1;
+wcs.c: wcs->syswcs = wcscsys (wcs->radecsys);
+wcs.c: wcsoutinit (wcs, wcs->radecsys);
+wcs.c: wcsininit (wcs, wcs->radecsys);
+wcs.c: wcs->eqout = 0.0;
+wcs.c: wcs->printsys = 1;
+wcs.c: wcs->tabsys = 0;
+wcs.c: wcs->cel.flag = 0;
+wcs.c: wcs->lin.flag = 0;
+wcs.c: wcs->wcsl.flag = 0;
+wcs.c: wcs->naxis = 2;
+wcs.c: wcs->naxes = 2;
+wcs.c: wcs->lin.naxis = 2;
+wcs.c: wcs->nxpix = naxis1;
+wcs.c: wcs->nypix = naxis2;
+wcs.c: wcs->wcsproj = wcsproj0;
+wcs.c: wcs->crpix[0] = crpix1;
+wcs.c: wcs->crpix[1] = crpix2;
+wcs.c: wcs->xrefpix = wcs->crpix[0];
+wcs.c: wcs->yrefpix = wcs->crpix[1];
+wcs.c: wcs->lin.crpix = wcs->crpix;
+wcs.c: if (wcs->latbase == 90)
+wcs.c: else if (wcs->latbase == -90)
+wcs.c: wcs->crval[0] = crval1;
+wcs.c: wcs->crval[1] = crval2;
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: wcs->cel.ref[0] = wcs->crval[0];
+wcs.c: wcs->cel.ref[1] = wcs->crval[1];
+wcs.c: wcs->cel.ref[2] = 999.0;
+wcs.c: wcs->lin.cdelt = wcs->cdelt;
+wcs.c: wcs->lin.pc = wcs->pc;
+wcs.c: wcs->equinox = (double) equinox;
+wcs.c: strcpy (wcs->radecsys,"FK5");
+wcs.c: strcpy (wcs->radecsys,"FK4");
+wcs.c: wcs->epoch = epoch;
+wcs.c: wcs->epoch = 0.0;
+wcs.c: wcs->wcson = 1;
+wcs.c: strcpy (wcs->radecout, wcs->radecsys);
+wcs.c: wcs->syswcs = wcscsys (wcs->radecsys);
+wcs.c: wcsoutinit (wcs, wcs->radecsys);
+wcs.c: wcsininit (wcs, wcs->radecsys);
+wcs.c: wcs->eqout = 0.0;
+wcs.c: wcs->printsys = 1;
+wcs.c: wcs->tabsys = 0;
+wcs.c: strcpy (wcs->ctype[0], ctype1);
+wcs.c: strcpy (wcs->c1type, ctype1);
+wcs.c: strcpy (wcs->ptype, ctype1);
+wcs.c: wcs->prjcode = WCS_LIN;
+wcs.c: wcs->prjcode = WCS_PIX;
+wcs.c: wcs->prjcode = WCS_PIX;
+wcs.c: wcs->c1type[0] = ctype1[0];
+wcs.c: wcs->c1type[1] = ctype1[1];
+wcs.c: wcs->c1type[2] = 0;
+wcs.c: wcs->c1type[2] = ctype1[2];
+wcs.c: wcs->c1type[3] = 0;
+wcs.c: wcs->c1type[3] = ctype1[3];
+wcs.c: wcs->c1type[4] = 0;
+wcs.c: wcs->ptype[0] = ctype1[iproj];
+wcs.c: wcs->ptype[1] = ctype1[iproj+1];
+wcs.c: wcs->ptype[2] = ctype1[iproj+2];
+wcs.c: wcs->ptype[3] = 0;
+wcs.c: sprintf (wcs->ctype[0],"%-4s%4s",wcs->c1type,wcs->ptype);
+wcs.c: if (wcs->ctype[0][i] == ' ') wcs->ctype[0][i] = '-';
+wcs.c: wcs->prjcode = 0; /* default type is linear */
+wcs.c: if (!strncmp(wcs->ptype, ctypes[i], 3))
+wcs.c: wcs->prjcode = i;
+wcs.c: if (wcs->prjcode == WCS_NCP) {
+wcs.c: if (wcs->wcsproj == WCS_BEST)
+wcs.c: wcs->wcsproj = WCS_OLD;
+wcs.c: else if (wcs->wcsproj == WCS_ALT)
+wcs.c: wcs->wcsproj = WCS_NEW;
+wcs.c: else if (wcs->prjcode == WCS_CAR) {
+wcs.c: if (wcs->wcsproj == WCS_BEST)
+wcs.c: wcs->wcsproj = WCS_OLD;
+wcs.c: else if (wcs->wcsproj == WCS_ALT)
+wcs.c: wcs->wcsproj = WCS_NEW;
+wcs.c: else if (wcs->prjcode == WCS_COE) {
+wcs.c: if (wcs->wcsproj == WCS_BEST)
+wcs.c: wcs->wcsproj = WCS_OLD;
+wcs.c: else if (wcs->wcsproj == WCS_ALT)
+wcs.c: wcs->wcsproj = WCS_NEW;
+wcs.c: else if (wcs->wcsproj == WCS_BEST) */
+wcs.c: if (wcs->wcsproj == WCS_BEST)
+wcs.c: wcs->wcsproj = WCS_NEW;
+wcs.c: else if (wcs->wcsproj == WCS_ALT)
+wcs.c: wcs->wcsproj = WCS_OLD;
+wcs.c: /* if (wcs->wcsproj == WCS_OLD && (
+wcs.c: wcs->prjcode != WCS_STG && wcs->prjcode != WCS_AIT &&
+wcs.c: wcs->prjcode != WCS_MER && wcs->prjcode != WCS_GLS &&
+wcs.c: wcs->prjcode != WCS_ARC && wcs->prjcode != WCS_TAN &&
+wcs.c: wcs->prjcode != WCS_TNX && wcs->prjcode != WCS_SIN &&
+wcs.c: wcs->prjcode != WCS_PIX && wcs->prjcode != WCS_LIN &&
+wcs.c: wcs->prjcode != WCS_CAR && wcs->prjcode != WCS_COE &&
+wcs.c: wcs->prjcode != WCS_NCP && wcs->prjcode != WCS_ZPX))
+wcs.c: wcs->wcsproj = WCS_NEW; */
+wcs.c: if (wcs->wcsproj == WCS_OLD && wcs->prjcode == WCS_TNX) {
+wcs.c: wcs->ctype[0][6] = 'A';
+wcs.c: wcs->ctype[0][7] = 'N';
+wcs.c: wcs->prjcode = WCS_TAN;
+wcs.c: if (wcs->wcsproj == WCS_OLD && wcs->prjcode == WCS_ZPX) {
+wcs.c: wcs->ctype[0][6] = 'P';
+wcs.c: wcs->ctype[0][7] = 'N';
+wcs.c: wcs->prjcode = WCS_ZPN;
+wcs.c: wcs->prjcode = WCS_LIN;
+wcs.c: wcs->latbase = 90;
+wcs.c: strcpy (wcs->radecsys,"NPOLE");
+wcs.c: wcs->syswcs = WCS_NPOLE;
+wcs.c: wcs->latbase = -90;
+wcs.c: strcpy (wcs->radecsys,"SPA");
+wcs.c: wcs->syswcs = WCS_SPA;
+wcs.c: wcs->latbase = 0;
+wcs.c: strcpy (wcs->ctype[1], ctype2);
+wcs.c: strcpy (wcs->c2type, ctype2);
+wcs.c: wcs->prjcode = WCS_LIN;
+wcs.c: wcs->prjcode = WCS_PIX;
+wcs.c: wcs->c2type[0] = ctype2[0];
+wcs.c: wcs->c2type[1] = ctype2[1];
+wcs.c: wcs->c2type[2] = 0;
+wcs.c: wcs->c2type[2] = ctype2[2];
+wcs.c: wcs->c2type[3] = 0;
+wcs.c: wcs->c2type[3] = ctype2[3];
+wcs.c: wcs->c2type[4] = 0;
+wcs.c: wcs->ptype[0] = ctype2[iproj];
+wcs.c: wcs->ptype[1] = ctype2[iproj+1];
+wcs.c: wcs->ptype[2] = ctype2[iproj+2];
+wcs.c: wcs->ptype[3] = 0;
+wcs.c: wcs->coorflip = 1;
+wcs.c: wcs->coorflip = 0;
+wcs.c: wcs->degout = 1;
+wcs.c: wcs->ndec = 5;
+wcs.c: wcs->degout = 0;
+wcs.c: wcs->ndec = 3;
+wcs.c: sprintf (wcs->ctype[1],"%-4s%4s",wcs->c2type,wcs->ptype);
+wcs.c: if (wcs->ctype[1][i] == ' ') wcs->ctype[1][i] = '-';
+wcs.c: wcs->prjcode = WCS_LIN;
+wcs.c: wcs->cel.flag = 0;
+wcs.c: wcs->lin.flag = 0;
+wcs.c: wcs->wcsl.flag = 0;
+wcs.c: wcs->crpix[0] = crpix1;
+wcs.c: wcs->crpix[1] = crpix2;
+wcs.c: wcs->xrefpix = wcs->crpix[0];
+wcs.c: wcs->yrefpix = wcs->crpix[1];
+wcs.c: wcs->lin.crpix = wcs->crpix;
+wcs.c: wcs->crval[0] = crval1;
+wcs.c: wcs->crval[1] = crval2;
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: if (wcs->coorflip) {
+wcs.c: wcs->cel.ref[1] = wcs->crval[0];
+wcs.c: wcs->cel.ref[0] = wcs->crval[1];
+wcs.c: wcs->cel.ref[0] = wcs->crval[0];
+wcs.c: wcs->cel.ref[1] = wcs->crval[1];
+wcs.c: wcs->ncoeff1 = 0;
+wcs.c: wcs->ncoeff2 = 0;
+wcs.c: wcs->xinc = 1.0;
+wcs.c: wcs->yinc = 1.0;
+wcs.c: if (!strncmp (wcs->ptype,"LINEAR",6) ||
+wcs.c: !strncmp (wcs->ptype,"PIXEL",5))
+wcs.c: wcs->degout = -1;
+wcs.c: wcs->wcson = 1;
+wcs.c: if (wcs->equinox == equinox)
+wcs.c: if (equinox == 2000.0 && wcs->equinox == 1950.0) {
+wcs.c: if (wcs->coorflip) {
+wcs.c: fk425e (&wcs->crval[1], &wcs->crval[0], wcs->epoch);
+wcs.c: wcs->cel.ref[1] = wcs->crval[0];
+wcs.c: wcs->cel.ref[0] = wcs->crval[1];
+wcs.c: fk425e (&wcs->crval[0], &wcs->crval[1], wcs->epoch);
+wcs.c: wcs->cel.ref[0] = wcs->crval[0];
+wcs.c: wcs->cel.ref[1] = wcs->crval[1];
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: wcs->equinox = 2000.0;
+wcs.c: strcpy (wcs->radecsys, "FK5");
+wcs.c: wcs->syswcs = WCS_J2000;
+wcs.c: wcs->cel.flag = 0;
+wcs.c: wcs->wcsl.flag = 0;
+wcs.c: else if (equinox == 1950.0 && wcs->equinox == 2000.0) {
+wcs.c: if (wcs->coorflip) {
+wcs.c: fk524e (&wcs->crval[1], &wcs->crval[0], wcs->epoch);
+wcs.c: wcs->cel.ref[1] = wcs->crval[0];
+wcs.c: wcs->cel.ref[0] = wcs->crval[1];
+wcs.c: fk524e (&wcs->crval[0], &wcs->crval[1], wcs->epoch);
+wcs.c: wcs->cel.ref[0] = wcs->crval[0];
+wcs.c: wcs->cel.ref[1] = wcs->crval[1];
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: wcs->equinox = 1950.0;
+wcs.c: strcpy (wcs->radecsys, "FK4");
+wcs.c: wcs->syswcs = WCS_B1950;
+wcs.c: wcs->cel.flag = 0;
+wcs.c: wcs->wcsl.flag = 0;
+wcs.c: wcsoutinit (wcs, wcs->radecsys);
+wcs.c: wcsininit (wcs, wcs->radecsys);
+wcs.c: wcs->rotmat = 1;
+wcs.c: wcs->cd[0] = cd[0];
+wcs.c: wcs->cd[1] = cd[1];
+wcs.c: wcs->cd[2] = cd[2];
+wcs.c: wcs->cd[3] = cd[3];
+wcs.c: (void) matinv (2, wcs->cd, wcs->dc);
+wcs.c: wcs->xinc = sqrt (cd[0]*cd[0] + cd[2]*cd[2]);
+wcs.c: wcs->yinc = sqrt (cd[1]*cd[1] + cd[3]*cd[3]);
+wcs.c: if (wcs->coorflip) {
+wcs.c: wcs->wcson = 1;
+wcs.c: wcs->cdelt[0] = wcs->xinc;
+wcs.c: wcs->cdelt[1] = wcs->yinc;
+wcs.c: naxes = wcs->naxis;
+wcs.c: wcs->cdelt[0] = cdelt1;
+wcs.c: wcs->cdelt[1] = cdelt2;
+wcs.c: wcs->cdelt[1] = cdelt1;
+wcs.c: wcs->xinc = wcs->cdelt[0];
+wcs.c: wcs->yinc = wcs->cdelt[1];
+wcs.c: pci = wcs->pc;
+wcs.c: wcs->rotmat = 0;
+wcs.c: wcs->rot = crota;
+wcs.c: if (wcs->rot < 0.0)
+wcs.c: wcs->rot = wcs->rot + 360.0;
+wcs.c: if (wcs->rot >= 360.0)
+wcs.c: wcs->rot = wcs->rot - 360.0;
+wcs.c: crot = cos (degrad(wcs->rot));
+wcs.c: srot = sin (-degrad(wcs->rot));
+wcs.c: srot = sin (degrad(wcs->rot));
+wcs.c: wcs->cd[0] = wcs->cdelt[0] * crot;
+wcs.c: if (wcs->cdelt[0] < 0)
+wcs.c: wcs->cd[1] = -fabs (wcs->cdelt[1]) * srot;
+wcs.c: wcs->cd[1] = fabs (wcs->cdelt[1]) * srot;
+wcs.c: if (wcs->cdelt[1] < 0)
+wcs.c: wcs->cd[2] = fabs (wcs->cdelt[0]) * srot;
+wcs.c: wcs->cd[2] = -fabs (wcs->cdelt[0]) * srot;
+wcs.c: wcs->cd[3] = wcs->cdelt[1] * crot;
+wcs.c: (void) matinv (2, wcs->cd, wcs->dc);
+wcs.c: if (wcs->coorflip) {
+wcs.c: if (wcs->cdelt[0] < 0 && wcs->cdelt[1] > 0) {
+wcs.c: wcs->imflip = 1;
+wcs.c: wcs->imrot = wcs->rot - 90.0;
+wcs.c: if (wcs->imrot < -180.0) wcs->imrot = wcs->imrot + 360.0;
+wcs.c: wcs->pa_north = wcs->rot;
+wcs.c: wcs->pa_east = wcs->rot - 90.0;
+wcs.c: if (wcs->pa_east < -180.0) wcs->pa_east = wcs->pa_east + 360.0;
+wcs.c: else if (wcs->cdelt[0] > 0 && wcs->cdelt[1] < 0) {
+wcs.c: wcs->imflip = 1;
+wcs.c: wcs->imrot = wcs->rot + 90.0;
+wcs.c: if (wcs->imrot > 180.0) wcs->imrot = wcs->imrot - 360.0;
+wcs.c: wcs->pa_north = wcs->rot;
+wcs.c: wcs->pa_east = wcs->rot - 90.0;
+wcs.c: if (wcs->pa_east < -180.0) wcs->pa_east = wcs->pa_east + 360.0;
+wcs.c: else if (wcs->cdelt[0] > 0 && wcs->cdelt[1] > 0) {
+wcs.c: wcs->imflip = 0;
+wcs.c: wcs->imrot = wcs->rot + 90.0;
+wcs.c: if (wcs->imrot > 180.0) wcs->imrot = wcs->imrot - 360.0;
+wcs.c: wcs->pa_north = wcs->imrot;
+wcs.c: wcs->pa_east = wcs->rot + 90.0;
+wcs.c: if (wcs->pa_east > 180.0) wcs->pa_east = wcs->pa_east - 360.0;
+wcs.c: else if (wcs->cdelt[0] < 0 && wcs->cdelt[1] < 0) {
+wcs.c: wcs->imflip = 0;
+wcs.c: wcs->imrot = wcs->rot - 90.0;
+wcs.c: if (wcs->imrot < -180.0) wcs->imrot = wcs->imrot + 360.0;
+wcs.c: wcs->pa_north = wcs->imrot;
+wcs.c: wcs->pa_east = wcs->rot + 90.0;
+wcs.c: if (wcs->pa_east > 180.0) wcs->pa_east = wcs->pa_east - 360.0;
+wcs.c: if (wcs->cdelt[0] < 0 && wcs->cdelt[1] > 0) {
+wcs.c: wcs->imflip = 0;
+wcs.c: wcs->imrot = wcs->rot;
+wcs.c: wcs->pa_north = wcs->rot + 90.0;
+wcs.c: if (wcs->pa_north > 180.0) wcs->pa_north = wcs->pa_north - 360.0;
+wcs.c: wcs->pa_east = wcs->rot + 180.0;
+wcs.c: if (wcs->pa_east > 180.0) wcs->pa_east = wcs->pa_east - 360.0;
+wcs.c: else if (wcs->cdelt[0] > 0 && wcs->cdelt[1] < 0) {
+wcs.c: wcs->imflip = 0;
+wcs.c: wcs->imrot = wcs->rot + 180.0;
+wcs.c: if (wcs->imrot > 180.0) wcs->imrot = wcs->imrot - 360.0;
+wcs.c: wcs->pa_north = wcs->imrot + 90.0;
+wcs.c: if (wcs->pa_north > 180.0) wcs->pa_north = wcs->pa_north - 360.0;
+wcs.c: wcs->pa_east = wcs->imrot + 180.0;
+wcs.c: if (wcs->pa_east > 180.0) wcs->pa_east = wcs->pa_east - 360.0;
+wcs.c: else if (wcs->cdelt[0] > 0 && wcs->cdelt[1] > 0) {
+wcs.c: wcs->imflip = 1;
+wcs.c: wcs->imrot = -wcs->rot;
+wcs.c: wcs->pa_north = wcs->imrot + 90.0;
+wcs.c: if (wcs->pa_north > 180.0) wcs->pa_north = wcs->pa_north - 360.0;
+wcs.c: wcs->pa_east = wcs->rot;
+wcs.c: else if (wcs->cdelt[0] < 0 && wcs->cdelt[1] < 0) {
+wcs.c: wcs->imflip = 1;
+wcs.c: wcs->imrot = wcs->rot + 180.0;
+wcs.c: if (wcs->imrot > 180.0) wcs->imrot = wcs->imrot - 360.0;
+wcs.c: wcs->pa_north = wcs->imrot + 90.0;
+wcs.c: if (wcs->pa_north > 180.0) wcs->pa_north = wcs->pa_north - 360.0;
+wcs.c: wcs->pa_east = wcs->rot + 90.0;
+wcs.c: if (wcs->pa_east > 180.0) wcs->pa_east = wcs->pa_east - 360.0;
+wcs.c: naxes = wcs->naxis;
+wcs.c: naxes = wcs->naxes;
+wcs.c: wcs->naxis = naxes;
+wcs.c: wcs->cdelt[0] = cdelt1;
+wcs.c: wcs->cdelt[1] = cdelt2;
+wcs.c: wcs->cdelt[1] = cdelt1;
+wcs.c: wcs->xinc = wcs->cdelt[0];
+wcs.c: wcs->yinc = wcs->cdelt[1];
+wcs.c: pci = wcs->pc;
+wcs.c: wcs->cd[0] = pc[0] * wcs->cdelt[0];
+wcs.c: wcs->cd[1] = pc[1] * wcs->cdelt[0];
+wcs.c: wcs->cd[2] = pc[naxes] * wcs->cdelt[1];
+wcs.c: wcs->cd[3] = pc[naxes+1] * wcs->cdelt[1];
+wcs.c: wcs->cd[0] = pc[0] * wcs->cdelt[0];
+wcs.c: wcs->cd[1] = 0.0;
+wcs.c: wcs->cd[2] = 0.0;
+wcs.c: wcs->cd[3] = 1.0;
+wcs.c: (void) matinv (2, wcs->cd, wcs->dc);
+wcs.c: wcs->rotmat = 1;
+wcs.c: (void)linset (&wcs->lin);
+wcs.c: wcs->wcson = 1;
+wcs.c: naxes = wcs->naxis;
+wcs.c: naxes = wcs->naxes;
+wcs.c: wcs->naxis = naxes;
+wcs.c: if (wcs->lin.piximg == NULL)
+wcs.c: wcs->lin.piximg = (double*)malloc(mem);
+wcs.c: if (wcs->lin.piximg != NULL) {
+wcs.c: if (wcs->lin.imgpix == NULL)
+wcs.c: wcs->lin.imgpix = (double*)malloc(mem);
+wcs.c: if (wcs->lin.imgpix != NULL) {
+wcs.c: wcs->lin.flag = LINSET;
+wcs.c: wcs->lin.piximg[i] = wcs->cd[i];
+wcs.c: wcs->lin.piximg[i] = 0.0;
+wcs.c: wcs->lin.piximg[0] = wcs->cd[0];
+wcs.c: wcs->lin.piximg[1] = wcs->cd[1];
+wcs.c: wcs->lin.piximg[3] = wcs->cd[2];
+wcs.c: wcs->lin.piximg[4] = wcs->cd[3];
+wcs.c: wcs->lin.piximg[8] = 1.0;
+wcs.c: wcs->lin.piximg[i] = 0.0;
+wcs.c: wcs->lin.piximg[0] = wcs->cd[0];
+wcs.c: wcs->lin.piximg[1] = wcs->cd[1];
+wcs.c: wcs->lin.piximg[4] = wcs->cd[2];
+wcs.c: wcs->lin.piximg[5] = wcs->cd[3];
+wcs.c: wcs->lin.piximg[10] = 1.0;
+wcs.c: wcs->lin.piximg[15] = 1.0;
+wcs.c: (void) matinv (naxes, wcs->lin.piximg, wcs->lin.imgpix);
+wcs.c: wcs->lin.crpix = wcs->crpix;
+wcs.c: wcs->lin.cdelt = wcs->cdelt;
+wcs.c: wcs->lin.pc = wcs->pc;
+wcs.c: wcs->lin.flag = LINSET;
+wcs.c: if (wcs->nxpix < 1.5 || wcs->nypix < 1.5) {
+wcs.c: wcs->imrot = wcs->rot;
+wcs.c: wcs->pa_north = wcs->rot + 90.0;
+wcs.c: wcs->pa_east = wcs->rot + 180.0;
+wcs.c: if (wcs->syswcs == WCS_LINEAR)
+wcs.c: wcs->xinc = fabs (wcs->xinc);
+wcs.c: wcs->yinc = fabs (wcs->yinc);
+wcs.c: xc = wcs->xrefpix;
+wcs.c: yc = wcs->yrefpix;
+wcs.c: if (wcs->coorflip) {
+wcs.c: wcs2pix (wcs, cra+wcs->yinc, cdec, &xe, &ye, &off);
+wcs.c: wcs2pix (wcs, cra, cdec+wcs->xinc, &xn, &yn, &off);
+wcs.c: wcs2pix (wcs, cra+wcs->xinc, cdec, &xe, &ye, &off);
+wcs.c: wcs2pix (wcs, cra, cdec+wcs->yinc, &xn, &yn, &off);
+wcs.c: wcs->pa_north = raddeg (atan2 (yn-yc, xn-xc));
+wcs.c: if (wcs->pa_north < -90.0)
+wcs.c: wcs->pa_north = wcs->pa_north + 360.0;
+wcs.c: wcs->pa_east = raddeg (atan2 (ye-yc, xe-xc));
+wcs.c: if (wcs->pa_east < -90.0)
+wcs.c: wcs->pa_east = wcs->pa_east + 360.0;
+wcs.c: if (wcs->pa_north < -90.0)
+wcs.c: wcs->imrot = 270.0 + wcs->pa_north;
+wcs.c: wcs->imrot = wcs->pa_north - 90.0;
+wcs.c: if (wcs->coorflip) {
+wcs.c: wcs->rot = wcs->imrot + 90.0;
+wcs.c: if (wcs->rot < 0.0)
+wcs.c: wcs->rot = wcs->rot + 360.0;
+wcs.c: wcs->rot = wcs->imrot;
+wcs.c: if (wcs->rot < 0.0)
+wcs.c: wcs->rot = wcs->rot + 360.0;
+wcs.c: if (wcs->rot >= 360.0)
+wcs.c: wcs->rot = wcs->rot - 360.0;
+wcs.c: wcs->imflip = 0;
+wcs.c: if (wcs->pa_east - wcs->pa_north < -80.0 &&
+wcs.c: wcs->pa_east - wcs->pa_north > -100.0)
+wcs.c: wcs->imflip = 1;
+wcs.c: if (wcs->pa_east - wcs->pa_north < 280.0 &&
+wcs.c: wcs->pa_east - wcs->pa_north > 260.0)
+wcs.c: wcs->imflip = 1;
+wcs.c: if (wcs->pa_north - wcs->pa_east > 80.0 &&
+wcs.c: wcs->pa_north - wcs->pa_east < 100.0)
+wcs.c: wcs->imflip = 1;
+wcs.c: if (wcs->coorflip) {
+wcs.c: if (wcs->imflip)
+wcs.c: wcs->yinc = -wcs->yinc;
+wcs.c: if (!wcs->imflip)
+wcs.c: wcs->xinc = -wcs->xinc;
+wcs.c: return (wcs->wcson);
+wcs.c: return (!wcs->wcson);
+wcs.c: wcs->crval[0] = rra;
+wcs.c: wcs->crval[1] = rdec;
+wcs.c: wcs->xref = wcs->crval[0];
+wcs.c: wcs->yref = wcs->crval[1];
+wcs.c: strcpy (wcs->radecsys,coorsys);
+wcs.c: wcs->syswcs = wcscsys (coorsys);
+wcs.c: if (wcs->syswcs == WCS_B1950)
+wcs.c: wcs->equinox = 1950.0;
+wcs.c: wcs->equinox = 2000.0;
+wcs.c: if (wcs->prjcode == WCS_DSS)
+wcs.c: (void)fprintf (stderr,"WCS plate center %s\n", wcs->center);
+wcs.c: xpix = 0.5 * wcs->nxpix;
+wcs.c: ypix = 0.5 * wcs->nypix;
+wcs.c: wcs->ctype[0],wcs->ctype[1],wcstring,wcs->ptype,xpix,ypix);
+wcs.c: (void) pix2wcs (wcs,wcs->nxpix,ypix,&xpos2,&ypos2);
+wcs.c: if (wcs->syswcs == WCS_LINEAR) {
+wcs.c: (void)fprintf (stderr, "WCS width = %.5f %s ",width, wcs->units[0]);
+wcs.c: (void)fprintf (stderr, "WCS width = %.3f %s ",width, wcs->units[0]);
+wcs.c: secpixw = width / (wcs->nxpix - 1.0);
+wcs.c: (void) pix2wcs (wcs,xpix,wcs->nypix,&xpos2,&ypos2);
+wcs.c: if (wcs->syswcs == WCS_LINEAR) {
+wcs.c: (void)fprintf (stderr, " height = %.5f %s ",height, wcs->units[1]);
+wcs.c: (void)fprintf (stderr, " height = %.3f %s ",height, wcs->units[1]);
+wcs.c: secpixh = height / (wcs->nypix - 1.0);
+wcs.c: if (wcs->syswcs == WCS_LINEAR) {
+wcs.c: wcs->xinc,wcs->units[0],wcs->yinc,wcs->units[1]);
+wcs.c: if (wcs->xinc != 0.0 && wcs->yinc != 0.0)
+wcs.c: secpix = (fabs(wcs->xinc) + fabs(wcs->yinc)) * 0.5 * 3600.0;
+wcs.c: else if (wcs->xinc != 0.0 || wcs->yinc != 0.0)
+wcs.c: secpix = (fabs(wcs->xinc) + fabs(wcs->yinc)) * 3600.0;
+wcs.c: xcpix = (0.5 * wcs->nxpix) + 0.5;
+wcs.c: ycpix = (0.5 * wcs->nypix) + 0.5;
+wcs.c: xpix = wcs->nxpix + 0.499999;
+wcs.c: if (strncmp (wcs->ptype,"LINEAR",6) &&
+wcs.c: strncmp (wcs->ptype,"PIXEL",5)) {
+wcs.c: ypix = wcs->nypix + 0.5;
+wcs.c: if (strncmp (wcs->ptype,"LINEAR",6) &&
+wcs.c: strncmp (wcs->ptype,"PIXEL",5))
+wcs.c: (void) pix2wcs (wcs,1.0,wcs->nypix,&xpos2,&ypos2);
+wcs.c: (void) pix2wcs (wcs,wcs->nxpix,1.0,&xpos3,&ypos3);
+wcs.c: (void) pix2wcs (wcs,wcs->nxpix,wcs->nypix,&xpos4,&ypos4);
+wcs.c: if (wcs->syswcs != WCS_LINEAR && wcs->syswcs != WCS_XY) {
+wcs.c: if (wcs->command_format[i] != NULL)
+wcs.c: free (wcs->command_format[i]);
+wcs.c: wcs->command_format[i] = (char *) calloc (lcom+2, 1);
+wcs.c: if (wcs->command_format[i] == NULL)
+wcs.c: wcs->command_format[i][icom] = ' ';
+wcs.c: wcs->command_format[i][icom] = command[icom];
+wcs.c: wcs->command_format[i][lcom] = 0;
+wcs.c: if (wcs->command_format[i] != NULL)
+wcs.c: strcpy (comform, wcs->command_format[i]);
+wcs.c: sysout = wcs->syswcs;
+wcs.c: strcpy (wcs->radecout, wcs->radecsys);
+wcs.c: wcs->eqout = wcs->equinox;
+wcs.c: if (wcs->eqout != 1950.0) {
+wcs.c: wcs->radecout[0] = 'B';
+wcs.c: sprintf (wcs->radecout+1,"%.4f", wcs->equinox);
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: strcpy (wcs->radecout, "B1950");
+wcs.c: if (wcs->eqout != 2000.0) {
+wcs.c: wcs->radecout[0] = 'J';
+wcs.c: sprintf (wcs->radecout+1,"%.4f", wcs->equinox);
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: i = strlen(wcs->radecout) - 1;
+wcs.c: if (wcs->radecout[i] == '0')
+wcs.c: wcs->radecout[i] = (char)0;
+wcs.c: strcpy (wcs->radecout, "J2000");
+wcs.c: if (sysout != wcs->syswcs &&
+wcs.c: (wcs->syswcs == WCS_LINEAR || wcs->syswcs == WCS_ALTAZ))
+wcs.c: strcpy (wcs->radecout, coorsys);
+wcs.c: wcs->eqout = wcsceq (coorsys);
+wcs.c: wcs->sysout = sysout;
+wcs.c: if (wcs->wcson) {
+wcs.c: if (wcs->sysout == WCS_GALACTIC || wcs->sysout == WCS_ECLIPTIC ||
+wcs.c: wcs->sysout == WCS_PLANET) {
+wcs.c: wcs->degout = 1;
+wcs.c: wcs->ndec = 5;
+wcs.c: else if (wcs->sysout == WCS_ALTAZ) {
+wcs.c: wcs->degout = 1;
+wcs.c: wcs->ndec = 5;
+wcs.c: else if (wcs->sysout == WCS_NPOLE || wcs->sysout == WCS_SPA) {
+wcs.c: wcs->degout = 1;
+wcs.c: wcs->ndec = 5;
+wcs.c: wcs->degout = 0;
+wcs.c: wcs->ndec = 3;
+wcs.c: return(wcs->radecout);
+wcs.c: wcs->sysin = wcs->syswcs;
+wcs.c: strcpy (wcs->radecin, wcs->radecsys);
+wcs.c: wcs->eqin = wcs->equinox;
+wcs.c: if (wcs->sysin == WCS_B1950) {
+wcs.c: if (wcs->eqin != 1950.0) {
+wcs.c: wcs->radecin[0] = 'B';
+wcs.c: sprintf (wcs->radecin+1,"%.4f", wcs->equinox);
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: strcpy (wcs->radecin, "B1950");
+wcs.c: else if (wcs->sysin == WCS_J2000) {
+wcs.c: if (wcs->eqin != 2000.0) {
+wcs.c: wcs->radecin[0] = 'J';
+wcs.c: sprintf (wcs->radecin+1,"%.4f", wcs->equinox);
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: i = strlen(wcs->radecin) - 1;
+wcs.c: if (wcs->radecin[i] == '0')
+wcs.c: wcs->radecin[i] = (char)0;
+wcs.c: strcpy (wcs->radecin, "J2000");
+wcs.c: wcs->sysin = sysin;
+wcs.c: wcs->eqin = wcsceq (coorsys);
+wcs.c: strcpy (wcs->radecin, coorsys);
+wcs.c: return (wcs->radecin);
+wcs.c: old = wcs->degout;
+wcs.c: wcs->degout = new;
+wcs.c: if (new == 1 && old == 0 && wcs->ndec == 3)
+wcs.c: wcs->ndec = 6;
+wcs.c: if (new == 0 && old == 1 && wcs->ndec == 5)
+wcs.c: wcs->ndec = 3;
+wcs.c: wcs->ndec = ndec;
+wcs.c: return (wcs->ndec);
+wcs.c: return (wcs->radecsys);
+wcs.c: wcs->linmode = mode;
+wcs.c: if (wcs->offscl) {
+wcs.c: else if (wcs->degout == 1) {
+wcs.c: minlength = 9 + (2 * wcs->ndec);
+wcs.c: deg2str (rastr, 32, xpos, wcs->ndec);
+wcs.c: deg2str (decstr, 32, ypos, wcs->ndec);
+wcs.c: if (wcs->tabsys)
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->degout == 0) {
+wcs.c: minlength = 18 + (2 * wcs->ndec);
+wcs.c: if (wcs->sysout == WCS_J2000 || wcs->sysout == WCS_B1950) {
+wcs.c: ra2str (rastr, 32, xpos, wcs->ndec);
+wcs.c: dec2str (decstr, 32, ypos, wcs->ndec-1);
+wcs.c: dec2str (rastr, 32, xpos, wcs->ndec);
+wcs.c: dec2str (decstr, 32, ypos, wcs->ndec);
+wcs.c: if (wcs->tabsys) {
+wcs.c: if (wcs->tabsys) {
+wcs.c: if (wcs->sysout == WCS_GALACTIC) {
+wcs.c: if (lstr > 9 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout == WCS_ECLIPTIC) {
+wcs.c: if (lstr > 9 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout == WCS_PLANET) {
+wcs.c: if (lstr > 9 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout == WCS_ALTAZ) {
+wcs.c: if (lstr > 7 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout == WCS_NPOLE) {
+wcs.c: if (lstr > 7 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout == WCS_SPA) {
+wcs.c: if (lstr > 7 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: else if (wcs->sysout==WCS_B1950 || wcs->sysout==WCS_J2000) {
+wcs.c: if (lstr > (int) strlen(wcs->radecout)+1 && wcs->printsys) {
+wcs.c: if (wcs->tabsys)
+wcs.c: strcat (wcstring, wcs->radecout);
+wcs.c: num2str (rastr, xpos, 0, wcs->ndec);
+wcs.c: num2str (decstr, ypos, 0, wcs->ndec);
+wcs.c: lunits = strlen (wcs->units[0]) + strlen (wcs->units[1]) + 2;
+wcs.c: if (wcs->syswcs == WCS_LINEAR && wcs->linmode == 1) {
+wcs.c: if (strlen (wcs->units[0]) > 0) {
+wcs.c: strcat (rastr, wcs->units[0]);
+wcs.c: if (strlen (wcs->units[1]) > 0) {
+wcs.c: strcat (decstr, wcs->units[1]);
+wcs.c: if (wcs->tabsys)
+wcs.c: if (wcs->tabsys)
+wcs.c: if (wcs->syswcs == WCS_LINEAR && wcs->linmode != 1 &&
+wcs.c: if (wcs->syswcs == WCS_LINEAR && wcs->linmode == 2 &&
+wcs.c: if (strlen (wcs->units[0]) > 0) {
+wcs.c: strcat (wcstring, wcs->units[0]);
+wcs.c: if (strlen (wcs->units[1]) > 0) {
+wcs.c: strcat (wcstring, wcs->units[1]);
+wcs.c: wcs->xpix = xpix;
+wcs.c: wcs->ypix = ypix;
+wcs.c: wcs->zpix = zpix;
+wcs.c: wcs->offscl = 0;
+wcs.c: if (wcs->wcs != NULL) {
+wcs.c: pix2wcs (wcs->wcs, xpix, ypix, &xpi, &ypi);
+wcs.c: if (wcs->prjcode == WCS_DSS) {
+wcs.c: wcs->offscl = 1;
+wcs.c: else if (wcs->prjcode == WCS_PLT) {
+wcs.c: wcs->offscl = 1;
+wcs.c: else if (wcs->prjcode == WCS_TNX) {
+wcs.c: wcs->offscl = 1;
+wcs.c: else if (wcs->prjcode == WCS_ZPX) {
+wcs.c: wcs->offscl = 1;
+wcs.c: else if (wcs->wcsproj == WCS_OLD || wcs->prjcode <= 0) {
+wcs.c: wcs->offscl = 1;
+wcs.c: wcs->offscl = 1;
+wcs.c: if (wcs->offscl) {
+wcs.c: if (wcs->prjcode > 0) {
+wcs.c: eqin = wcs->equinox;
+wcs.c: eqout = wcs->eqout;
+wcs.c: wcscon (wcs->syswcs,wcs->sysout,eqin,eqout,&xp,&yp,wcs->epoch);
+wcs.c: if (wcs->latbase == 90)
+wcs.c: else if (wcs->latbase == -90)
+wcs.c: wcs->xpos = xp;
+wcs.c: wcs->ypos = yp;
+wcs.c: if (wcs->sysout > 0 && wcs->sysout != 6 && wcs->sysout != 10) {
+wcs.c: wcsc2pix (wcs, xpos, ypos, wcs->radecin, xpix, ypix, offscl);
+wcs.c: if (wcs->latbase == 90)
+wcs.c: else if (wcs->latbase == -90)
+wcs.c: sysin = wcs->syswcs;
+wcs.c: eqin = wcs->equinox;
+wcs.c: wcs->zpix = 1.0;
+wcs.c: eqout = wcs->equinox;
+wcs.c: wcscon (sysin, wcs->syswcs, eqin, eqout, &xp, &yp, wcs->epoch);
+wcs.c: if (wcs->prjcode == WCS_DSS) {
+wcs.c: else if (wcs->prjcode == WCS_PLT) {
+wcs.c: else if (wcs->prjcode == WCS_TNX) {
+wcs.c: else if (wcs->prjcode == WCS_ZPX) {
+wcs.c: else if (wcs->wcsproj == WCS_OLD || wcs->prjcode <= 0) {
+wcs.c: if (wcs->wcs != NULL) {
+wcs.c: wcsc2pix (wcs->wcs, xpi, ypi, NULL, xpix, ypix, offscl);
+wcs.c: else if (*xpix > wcs->nxpix + 0.5 || *ypix > wcs->nypix + 0.5)
+wcs.c: wcs->offscl = *offscl;
+wcs.c: wcs->xpos = xpos;
+wcs.c: wcs->ypos = ypos;
+wcs.c: wcs->xpix = *xpix;
+wcs.c: wcs->ypix = *ypix;
+wcs.c: if (wcs->prjcode == WCS_CSC || wcs->prjcode == WCS_QSC ||
+wcs.c: wcs->prjcode == WCS_TSC)
+wcs.c: offscl = wcsrev ((void *)&wcs->ctype, &wcs->wcsl, pixcrd, &wcs->lin, imgcrd,
+wcs.c: &wcs->prj, &phi, &theta, wcs->crval, &wcs->cel, wcscrd);
+wcs.c: *xpos = wcscrd[wcs->wcsl.lng];
+wcs.c: *ypos = wcscrd[wcs->wcsl.lat];
+wcs.c: if (wcs->wcsl.flag != WCSSET) {
+wcs.c: if (wcsset (wcs->lin.naxis, (void *)&wcs->ctype, &wcs->wcsl) )
+wcs.c: wcscrd[wcs->wcsl.lng] = xpos;
+wcs.c: wcscrd[wcs->wcsl.lat] = ypos;
+wcs.c: offscl = wcsfwd ((void *)&wcs->ctype, &wcs->wcsl, wcscrd, wcs->crval, &wcs->cel,
+wcs.c: &phi, &theta, &wcs->prj, imgcrd, &wcs->lin, pixcrd);
+wcs.c: if (wcs->prjcode == WCS_CSC || wcs->prjcode == WCS_QSC ||
+wcs.c: wcs->prjcode == WCS_TSC)
+wcs.c: wcs->zpix = pixcrd[2] - 1.0;
+wcs.c: wcs->zpix = pixcrd[2];
+wcs.c: return ((int) wcs->zpix);
+wcs.c: wcs->command_format[i] = NULL;
+wcs.c: if (wcs->command_format[i] != NULL) {
+wcs.c: free (wcs->command_format[i]);
+wcs.c: * Nov 5 1996 Set wcs->crot to 1 if rotation matrix is used
+wcs.c: * Jul 30 1998 Set wcs->naxes and lin.naxis in wcsxinit() and wcskinit()
+wcs.c: * Feb 24 2000 If coorsys is null in wcsc2pix, wcs->radecin is assumed
+wcs.c: * Oct 1 2003 Rename wcs->naxes to wcs->naxis to match WCSLIB 3.2
+wcs.c: * Dec 3 2003 Add back wcs->naxes for compatibility
+wcs.c: * Nov 1 2004 Keep wcs->rot between 0 and 360
+wcs.h:/* Projections (1-26 are WCSLIB) (values for wcs->prjcode) */
+wcs.h:/* Distortion codes (values for wcs->distcode) */
+wcs.h: * Feb 20 2001 Add wcs->wcs to main data structure
+wcs.h: * Apr 9 2002 Add wcs->wcsdep for pointer to WCS depending on this WCS
+wcs.h: * Apr 26 2002 Add wcs->wcsname and wcs->wcschar to identify WCS structure
+wcs.h: * May 9 2002 Add wcs->radvel and wcs->zvel for radial velocity in km/sec
+wcs.h: * Apr 1 2003 Add wcs->distort Distort structure for distortion correction
+wcs.h: * Oct 1 2003 Rename wcs->naxes to wcs->naxis to match WCSLIB 3.2
+wcs.h: * Dec 3 2003 Add back wcs->naxes for backward compatibility
+wcsinit.c: wcs->wcschar = mchar;
+wcsinit.c: wcs->wcsname = (char *) calloc (strlen (wcsname)+2, 1);
+wcsinit.c: strcpy (wcs->wcsname, wcsname);
+wcsinit.c: wcs->cel.flag = 0;
+wcsinit.c: wcs->lin.flag = 0;
+wcsinit.c: wcs->wcsl.flag = 0;
+wcsinit.c: wcs->wcsl.cubeface = -1;
+wcsinit.c: wcs->ncoeff1 = 0;
+wcsinit.c: wcs->ncoeff2 = 0;
+wcsinit.c: wcs->rotmat = 0;
+wcsinit.c: wcs->rot = 0.0;
+wcsinit.c: wcs->naxis = naxes;
+wcsinit.c: wcs->naxes = naxes;
+wcsinit.c: wcs->lin.naxis = naxes;
+wcsinit.c: wcs->nxpix = 0;
+wcsinit.c: hgetr8 (hstring, "NAXIS1", &wcs->nxpix);
+wcsinit.c: if (wcs->nxpix < 1)
+wcsinit.c: hgetr8 (hstring, "IMAGEW", &wcs->nxpix);
+wcsinit.c: if (wcs->nxpix < 1) {
+wcsinit.c: wcs->nypix = 0;
+wcsinit.c: hgetr8 (hstring, "NAXIS2", &wcs->nypix);
+wcsinit.c: if (wcs->nypix < 1)
+wcsinit.c: hgetr8 (hstring, "IMAGEH", &wcs->nypix);
+wcsinit.c: if (naxes > 1 && wcs->nypix < 1) {
+wcsinit.c: if (i == 0 && wcs->nxpix > 1) {
+wcsinit.c: keyword, wcs->nxpix); */
+wcsinit.c: j = wcs->nxpix;
+wcsinit.c: else if (i == 1 && wcs->nypix > 1) {
+wcsinit.c: keyword, wcs->nypix); */
+wcsinit.c: j = wcs->nypix;
+wcsinit.c: wcs->naxes = nax;
+wcsinit.c: wcs->naxis = nax;
+wcsinit.c: hgets (hstring, "INSTRUME", 16, wcs->instrument);
+wcsinit.c: hgeti4 (hstring, "DETECTOR", &wcs->detector);
+wcsinit.c: wcs->wcsproj = getdefwcs();
+wcsinit.c: wcs->logwcs = 0;
+wcsinit.c: hgeti4 (hstring, "DC-FLAG", &wcs->logwcs);
+wcsinit.c: for (i = 0; i < 81; i++) wcs->pc[i] = 0.0;
+wcsinit.c: for (i = 0; i < naxes; i++) wcs->pc[(i*naxes)+i] = 1.0;
+wcsinit.c: for (i = 0; i < 9; i++) wcs->cdelt[i] = 0.0;
+wcsinit.c: for (i = 0; i < naxes; i++) wcs->cdelt[i] = 1.0;
+wcsinit.c: if ((wcs->wcs = wcsinitn (hstring, wcsname)) == NULL) {
+wcsinit.c: depwcs = wcs->wcs;
+wcsinit.c: depwcs->wcsdep = wcs;
+wcsinit.c: wcs->wcs = NULL;
+wcsinit.c: wcs->radvel = 0.0;
+wcsinit.c: wcs->zvel = 0.0;
+wcsinit.c: if (hgetr8c (hstring, "VSOURCE", &mchar, &wcs->radvel))
+wcsinit.c: wcs->zvel = wcs->radvel / cvel;
+wcsinit.c: else if (hgetr8c (hstring, "ZSOURCE", &mchar, &wcs->zvel))
+wcsinit.c: wcs->radvel = wcs->zvel * cvel;
+wcsinit.c: else if (hgetr8 (hstring, "VELOCITY", &wcs->radvel))
+wcsinit.c: wcs->zvel = wcs->radvel / cvel;
+wcsinit.c: wcs->prj.p[i] = 0.0;
+wcsinit.c: strcpy (wcs->ctype[0], ctype1);
+wcsinit.c: strcpy (wcs->ctype[1], ctype2);
+wcsinit.c: strcpy (wcs->ctype[2], "");
+wcsinit.c: hgetsc (hstring, "CTYPE3", &mchar, 9, wcs->ctype[2]);
+wcsinit.c: strcpy (wcs->ctype[3], "");
+wcsinit.c: hgetsc (hstring, "CTYPE4", &mchar, 9, wcs->ctype[3]);
+wcsinit.c: if (wcs->prjcode == WCS_LIN) {
+wcsinit.c: if (!hgetsc (hstring, "CUNIT1", &mchar, 16, wcs->units[0])) {
+wcsinit.c: if (!mgetstr (hstring, "WAT1", "units", 16, wcs->units[0])) {
+wcsinit.c: wcs->units[0][0] = 0;
+wcsinit.c: if (!strcmp (wcs->units[0], "pixel"))
+wcsinit.c: wcs->prjcode = WCS_PIX;
+wcsinit.c: if (!hgetsc (hstring, "CUNIT2", &mchar, 16, wcs->units[1])) {
+wcsinit.c: if (!mgetstr (hstring, "WAT2", "units", 16, wcs->units[1])) {
+wcsinit.c: wcs->units[1][0] = 0;
+wcsinit.c: if (!strcmp (wcs->units[0], "pixel"))
+wcsinit.c: wcs->prjcode = WCS_PIX;
+wcsinit.c: wcs->crpix[0] = 1.0;
+wcsinit.c: hgetr8c (hstring, "CRPIX1", &mchar, &wcs->crpix[0]);
+wcsinit.c: wcs->crpix[1] = 1.0;
+wcsinit.c: hgetr8c (hstring, "CRPIX2", &mchar, &wcs->crpix[1]);
+wcsinit.c: wcs->xrefpix = wcs->crpix[0];
+wcsinit.c: wcs->yrefpix = wcs->crpix[1];
+wcsinit.c: wcs->crval[0] = 0.0;
+wcsinit.c: hgetr8c (hstring, "CRVAL1", &mchar, &wcs->crval[0]);
+wcsinit.c: wcs->crval[1] = 0.0;
+wcsinit.c: hgetr8c (hstring, "CRVAL2", &mchar, &wcs->crval[1]);
+wcsinit.c: if (wcs->syswcs == WCS_NPOLE)
+wcsinit.c: wcs->crval[1] = 90.0 - wcs->crval[1];
+wcsinit.c: if (wcs->syswcs == WCS_SPA)
+wcsinit.c: wcs->crval[1] = wcs->crval[1] - 90.0;
+wcsinit.c: wcs->xref = wcs->crval[0];
+wcsinit.c: wcs->yref = wcs->crval[1];
+wcsinit.c: if (wcs->coorflip) {
+wcsinit.c: wcs->cel.ref[0] = wcs->crval[1];
+wcsinit.c: wcs->cel.ref[1] = wcs->crval[0];
+wcsinit.c: wcs->cel.ref[0] = wcs->crval[0];
+wcsinit.c: wcs->cel.ref[1] = wcs->crval[1];
+wcsinit.c: wcs->longpole = 999.0;
+wcsinit.c: hgetr8c (hstring, "LONPOLE", &mchar, &wcs->longpole);
+wcsinit.c: wcs->cel.ref[2] = wcs->longpole;
+wcsinit.c: wcs->latpole = 999.0;
+wcsinit.c: hgetr8c (hstring, "LATPOLE", &mchar, &wcs->latpole);
+wcsinit.c: wcs->cel.ref[3] = wcs->latpole;
+wcsinit.c: wcs->lin.crpix = wcs->crpix;
+wcsinit.c: wcs->lin.cdelt = wcs->cdelt;
+wcsinit.c: wcs->lin.pc = wcs->pc;
+wcsinit.c: wcs->prj.r0 = 0.0;
+wcsinit.c: hgetr8c (hstring, "PROJR0", &mchar, &wcs->prj.r0);
+wcsinit.c: hgetr8c (hstring, keyword, &mchar, &wcs->prj.p[i]);
+wcsinit.c: if (wcs->prjcode == WCS_AZP || wcs->prjcode == WCS_SIN ||
+wcsinit.c: wcs->prjcode == WCS_COP || wcs->prjcode == WCS_COE ||
+wcsinit.c: wcs->prjcode == WCS_COD || wcs->prjcode == WCS_COO) {
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+wcsinit.c: else if (wcs->prjcode == WCS_SZP) {
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+wcsinit.c: if (wcs->prj.p[3] == 0.0)
+wcsinit.c: wcs->prj.p[3] = 90.0;
+wcsinit.c: hgetr8c (hstring, pvkey3, &mchar, &wcs->prj.p[3]);
+wcsinit.c: else if (wcs->prjcode == WCS_CEA) {
+wcsinit.c: if (wcs->prj.p[1] == 0.0)
+wcsinit.c: wcs->prj.p[1] = 1.0;
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: else if (wcs->prjcode == WCS_CYP) {
+wcsinit.c: if (wcs->prj.p[1] == 0.0)
+wcsinit.c: wcs->prj.p[1] = 1.0;
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: if (wcs->prj.p[2] == 0.0)
+wcsinit.c: wcs->prj.p[2] = 1.0;
+wcsinit.c: hgetr8c (hstring, pvkey2, &mchar, &wcs->prj.p[2]);
+wcsinit.c: else if (wcs->prjcode == WCS_AIR) {
+wcsinit.c: if (wcs->prj.p[1] == 0.0)
+wcsinit.c: wcs->prj.p[1] = 90.0;
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: else if (wcs->prjcode == WCS_BON) {
+wcsinit.c: hgetr8c (hstring, pvkey1, &mchar, &wcs->prj.p[1]);
+wcsinit.c: else if (wcs->prjcode == WCS_ZPN) {
+wcsinit.c: hgetr8c (hstring, keyword, &mchar, &wcs->prj.p[i]);
+wcsinit.c: if (wcs->prjcode == WCS_TNX) {
+wcsinit.c: wcs->ctype[0][6] = 'A';
+wcsinit.c: wcs->ctype[0][7] = 'N';
+wcsinit.c: wcs->ctype[1][6] = 'A';
+wcsinit.c: wcs->ctype[1][7] = 'N';
+wcsinit.c: wcs->prjcode = WCS_TAN;
+wcsinit.c: if (wcs->prjcode == WCS_ZPX) {
+wcsinit.c: wcs->ctype[0][7] = 'N';
+wcsinit.c: wcs->ctype[1][7] = 'N';
+wcsinit.c: wcs->prjcode = WCS_ZPN;
+wcsinit.c: if (wcs->prjcode == WCS_TPV) {
+wcsinit.c: wcs->ctype[0][6] = 'A';
+wcsinit.c: wcs->ctype[0][7] = 'N';
+wcsinit.c: wcs->ctype[1][6] = 'A';
+wcsinit.c: wcs->ctype[1][7] = 'N';
+wcsinit.c: wcs->prjcode = WCS_TAN;
+wcsinit.c: if (wcs->wcsproj > 0)
+wcsinit.c: wcs->ncoeff1 = 0;
+wcsinit.c: wcs->ncoeff2 = 0;
+wcsinit.c: if (wcs->wcsproj != WCS_OLD &&
+wcsinit.c: wcs->prjcode = WCS_PLT;
+wcsinit.c: (void)strcpy (wcs->ptype, "PLATE");
+wcsinit.c: wcs->x_coeff[i] = 0.0;
+wcsinit.c: if (hgetr8 (hcoeff, keyword, &wcs->x_coeff[i]))
+wcsinit.c: wcs->ncoeff1 = i + 1;
+wcsinit.c: wcs->y_coeff[i] = 0.0;
+wcsinit.c: if (hgetr8 (hcoeff, keyword, &wcs->y_coeff[i]))
+wcsinit.c: wcs->ncoeff2 = i + 1;
+wcsinit.c: platepos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+wcsinit.c: platepos (wcs->crpix[0], wcs->crpix[1]+1.0, wcs, &ra1, &dec1);
+wcsinit.c: wcs->yinc = dec1 - dec0;
+wcsinit.c: wcs->xinc = -wcs->yinc;
+wcsinit.c: wcs->wcson = 1;
+wcsinit.c: rot = degrad (wcs->rot);
+wcsinit.c: platepos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+wcsinit.c: platepos (wcs->crpix[0]+cos(rot),
+wcsinit.c: wcs->crpix[1]+sin(rot), wcs, &ra1, &dec1);
+wcsinit.c: wcs->cdelt[0] = -wcsdist (ra0, dec0, ra1, dec1);
+wcsinit.c: wcs->xinc = wcs->cdelt[0];
+wcsinit.c: platepos (wcs->crpix[0]+sin(rot),
+wcsinit.c: wcs->crpix[1]+cos(rot), wcs, &ra1, &dec1);
+wcsinit.c: wcs->cdelt[1] = wcsdist (ra0, dec0, ra1, dec1);
+wcsinit.c: wcs->yinc = wcs->cdelt[1];
+wcsinit.c: wcs->cd[0] = cd[0];
+wcsinit.c: wcs->cd[1] = cd[1];
+wcsinit.c: wcs->cd[2] = cd[2];
+wcsinit.c: wcs->cd[3] = cd[3];
+wcsinit.c: (void) matinv (2, wcs->cd, wcs->dc);
+wcsinit.c: wcs->rotmat = 1;
+wcsinit.c: if (cdelt1 == 0.0 || (wcs->nypix > 1 && cdelt2 == 0.0)) {
+wcsinit.c: if (cdelt2 == 0.0 && wcs->nypix > 1)
+wcsinit.c: wcs->cdelt[2] = 1.0;
+wcsinit.c: wcs->cdelt[3] = 1.0;
+wcsinit.c: wcs->pc[i] = 0.0;
+wcsinit.c: wcs->xinc = 1.0;
+wcsinit.c: wcs->yinc = 1.0;
+wcsinit.c: wcs->cdelt[0] = 1.0;
+wcsinit.c: wcs->cdelt[1] = 1.0;
+wcsinit.c: wcs->rot = 0.0;
+wcsinit.c: wcs->rotmat = 0;
+wcsinit.c: if (wcs->prjcode == WCS_TAN && wcs->naxis == 2) {
+wcsinit.c: if (wcs->inv_x) {
+wcsinit.c: poly_end(wcs->inv_x);
+wcsinit.c: wcs->inv_x = NULL;
+wcsinit.c: if (wcs->inv_y) {
+wcsinit.c: poly_end(wcs->inv_y);
+wcsinit.c: wcs->inv_y = NULL;
+wcsinit.c: wcs->pvfail = 0;
+wcsinit.c: wcs->projppv[i] = 0.0;
+wcsinit.c: wcs->prj.ppv[i] = 0.0;
+wcsinit.c: if (hgetr8c(hstring, keyword,&mchar, &wcs->projppv[j+k*MAXPV]) == 0) {
+wcsinit.c: wcs->projppv[j+k*MAXPV] = 0.0;
+wcsinit.c: wcs->prj.ppv[k] = wcs->projppv[k+wcs->wcsl.lat*MAXPV];
+wcsinit.c: wcs->prj.ppv[k+MAXPV] = wcs->projppv[k+wcs->wcsl.lng*MAXPV];
+wcsinit.c: if (!n && (wcs->prj.ppv[k] || wcs->prj.ppv[k+MAXPV])) {
+wcsinit.c: wcs->cel.flag = 0;
+wcsinit.c: if (!strncmp (wcs->ptype,"LINEAR",6) ||
+wcsinit.c: !strncmp (wcs->ptype,"PIXEL",5)) {
+wcsinit.c: wcs->degout = -1;
+wcsinit.c: wcs->ndec = 5;
+wcsinit.c: wcs->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781;
+wcsinit.c: else if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+wcsinit.c: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+wcsinit.c: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+wcsinit.c: wcs->epoch = wcs->equinox;
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: wcs->wcson = 1;
+wcsinit.c: wcs->prjcode = WCS_DSS;
+wcsinit.c: wcs->plate_ra = hrrad (ra_hours);
+wcsinit.c: wcs->plate_dec = degrad (dec_deg);
+wcsinit.c: hgetr8 (hstring,"EQUINOX",&wcs->equinox);
+wcsinit.c: strcpy (wcs->radecsys,"FK4");
+wcsinit.c: strcpy (wcs->radecsys,"FK5");
+wcsinit.c: wcs->epoch = wcs->equinox;
+wcsinit.c: hgetr8 (hstring,"EPOCH",&wcs->epoch);
+wcsinit.c: (void)sprintf (wcs->center,"%2.0f:%2.0f:%5.3f %c%2.0f:%2.0f:%5.3f %s",
+wcsinit.c: rah,ram,ras,decsign,decd,decm,decs,wcs->radecsys);
+wcsinit.c: hgetr8 (hstring,"PLTSCALE",&wcs->plate_scale);
+wcsinit.c: hgetr8 (hstring,"XPIXELSZ",&wcs->x_pixel_size);
+wcsinit.c: hgetr8 (hstring,"YPIXELSZ",&wcs->y_pixel_size);
+wcsinit.c: hgetr8 (hstring,"CNPIX1",&wcs->x_pixel_offset);
+wcsinit.c: hgetr8 (hstring,"CNPIX2",&wcs->y_pixel_offset);
+wcsinit.c: wcs->ppo_coeff[i] = 0.0;
+wcsinit.c: hgetr8 (hcoeff,keyword,&wcs->ppo_coeff[i]);
+wcsinit.c: wcs->x_coeff[i] = 0.0;
+wcsinit.c: hgetr8 (hcoeff, keyword, &wcs->x_coeff[i]);
+wcsinit.c: wcs->y_coeff[i] = 0.0;
+wcsinit.c: hgetr8 (hcoeff, keyword, &wcs->y_coeff[i]);
+wcsinit.c: wcs->wcson = 1;
+wcsinit.c: (void)strcpy (wcs->c1type, "RA");
+wcsinit.c: (void)strcpy (wcs->c2type, "DEC");
+wcsinit.c: (void)strcpy (wcs->ptype, "DSS");
+wcsinit.c: wcs->degout = 0;
+wcsinit.c: wcs->ndec = 3;
+wcsinit.c: strcpy (wcs->ctype[0], "RA---DSS");
+wcsinit.c: strcpy (wcs->ctype[1], "DEC--DSS");
+wcsinit.c: wcs->crpix[0] = 0.5 * wcs->nxpix;
+wcsinit.c: wcs->crpix[1] = 0.5 * wcs->nypix;
+wcsinit.c: wcs->xrefpix = wcs->crpix[0];
+wcsinit.c: wcs->yrefpix = wcs->crpix[1];
+wcsinit.c: dsspos (wcs->crpix[0], wcs->crpix[1], wcs, &ra0, &dec0);
+wcsinit.c: wcs->crval[0] = ra0;
+wcsinit.c: wcs->crval[1] = dec0;
+wcsinit.c: wcs->xref = wcs->crval[0];
+wcsinit.c: wcs->yref = wcs->crval[1];
+wcsinit.c: dsspos (wcs->crpix[0], wcs->crpix[1]+1.0, wcs, &ra1, &dec1);
+wcsinit.c: wcs->yinc = dec1 - dec0;
+wcsinit.c: wcs->xinc = -wcs->yinc;
+wcsinit.c: wcs->wcson = 1;
+wcsinit.c: rot = degrad (wcs->rot);
+wcsinit.c: dsspos (wcs->crpix[0]+cos(rot),
+wcsinit.c: wcs->crpix[1]+sin(rot), wcs, &ra1, &dec1);
+wcsinit.c: wcs->cdelt[0] = -wcsdist (ra0, dec0, ra1, dec1);
+wcsinit.c: dsspos (wcs->crpix[0]+sin(rot),
+wcsinit.c: wcs->crpix[1]+cos(rot), wcs, &ra1, &dec1);
+wcsinit.c: wcs->cdelt[1] = wcsdist (ra0, dec0, ra1, dec1);
+wcsinit.c: wcsdeltset (wcs, wcs->cdelt[0], wcs->cdelt[1], wcs->rot);
+wcsinit.c: if (wcs->rot == 0.)
+wcsinit.c: wcs->crpix[0] = 0.5 + (wcs->nxpix * 0.5);
+wcsinit.c: wcs->crpix[1] = 0.5 + (wcs->nypix * 0.5);
+wcsinit.c: hgetr8 (hstring,"CRPIX1",&wcs->crpix[0]);
+wcsinit.c: hgetr8 (hstring,"CRPIX2",&wcs->crpix[1]);
+wcsinit.c: wcs->crpix[0] = dxrefpix - (double) (ix1 - 1);
+wcsinit.c: wcs->crpix[1] = dyrefpix - (double) (iy1 - 1);
+wcsinit.c: wcs->xrefpix = wcs->crpix[0];
+wcsinit.c: wcs->yrefpix = wcs->crpix[1];
+wcsinit.c: wcs->crval[0] = -999.0;
+wcsinit.c: if (!hgetra (hstring,"RA",&wcs->crval[0])) {
+wcsinit.c: wcs->crval[1] = -999.0;
+wcsinit.c: if (!hgetdec (hstring,"DEC",&wcs->crval[1])) {
+wcsinit.c: wcs->xref = wcs->crval[0];
+wcsinit.c: wcs->yref = wcs->crval[1];
+wcsinit.c: wcs->coorflip = 0;
+wcsinit.c: wcs->cel.ref[0] = wcs->crval[0];
+wcsinit.c: wcs->cel.ref[1] = wcs->crval[1];
+wcsinit.c: wcs->cel.ref[2] = 999.0;
+wcsinit.c: if (!hgetr8 (hstring,"LONPOLE",&wcs->cel.ref[2]))
+wcsinit.c: hgetr8 (hstring,"LONGPOLE",&wcs->cel.ref[2]);
+wcsinit.c: wcs->cel.ref[3] = 999.0;
+wcsinit.c: hgetr8 (hstring,"LATPOLE",&wcs->cel.ref[3]);
+wcsinit.c: wcs->epoch = 1900.0 + (mjd - 15019.81352) / 365.242198781;
+wcsinit.c: else if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+wcsinit.c: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+wcsinit.c: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+wcsinit.c: wcs->epoch = wcs->equinox;
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: wcs->coorflip = 0;
+wcsinit.c: wcs->degout = 0;
+wcsinit.c: wcs->ndec = 3;
+wcsinit.c: wcs->wcson = 1;
+wcsinit.c: wcs->lin.crpix = wcs->crpix;
+wcsinit.c: wcs->lin.cdelt = wcs->cdelt;
+wcsinit.c: wcs->lin.pc = wcs->pc;
+wcsinit.c: wcs->printsys = 1;
+wcsinit.c: wcs->tabsys = 0;
+wcsinit.c: wcs->linmode = 0;
+wcsinit.c: lng = wcs->wcsl.lng;
+wcsinit.c: lat = wcs->wcsl.lat;
+wcsinit.c: if (wcs->naxis != NAXISPV) {
+wcsinit.c: if (strcmp(wcs->wcsl.pcode, "TAN") != 0) {
+wcsinit.c: if ((wcs->projppv[1+lng*MAXPV] == 0) &&
+wcsinit.c: (wcs->projppv[1+lat*MAXPV] == 0)) {
+wcsinit.c: if (wcs->wcs != NULL) {
+wcsinit.c: pix2wcs(wcs->wcs,0,0,&xmin,&ymin);
+wcsinit.c: pix2wcs(wcs->wcs,wcs->nxpix,wcs->nypix,&xmax,&ymax);
+wcsinit.c: xmax = wcs->nxpix;
+wcsinit.c: ymax = wcs->nypix;
+wcsinit.c: if (linrev(raw, &wcs->lin, pixin)) {
+wcsinit.c: wcs->wcsl.pcode);
+wcsinit.c: raw_to_pv (&wcs->prj,pixin[lng],pixin[lat], outpost, outpost+1);
+wcsinit.c: linrev(rawmin, &wcs->lin, pixin);
+wcsinit.c: linfwd(pixin, &wcs->lin, raw);
+wcsinit.c: wcs->wcsl.pcode);
+wcsinit.c: wcs->pvfail = 1;
+wcsinit.c: wcs->prj.inv_x = wcs->inv_x = poly;
+wcsinit.c: linrev(rawmin, &wcs->lin, pixin);
+wcsinit.c: linfwd(pixin, &wcs->lin, raw);
+wcsinit.c: wcs->wcsl.pcode);
+wcsinit.c: wcs->pvfail = 1;
+wcsinit.c: wcs->prj.inv_y = wcs->inv_y = poly;
+wcsinit.c: if (strlen (wcs->radecsys) == 0 || wcs->prjcode == WCS_LIN)
+wcsinit.c: strcpy (wcs->radecsys, "LINEAR");
+wcsinit.c: if (wcs->prjcode == WCS_PIX)
+wcsinit.c: strcpy (wcs->radecsys, "PIXEL");
+wcsinit.c: wcs->syswcs = wcscsys (wcs->radecsys);
+wcsinit.c: if (wcs->syswcs == WCS_B1950)
+wcsinit.c: strcpy (wcs->radecout, "FK4");
+wcsinit.c: else if (wcs->syswcs == WCS_J2000)
+wcsinit.c: strcpy (wcs->radecout, "FK5");
+wcsinit.c: strcpy (wcs->radecout, wcs->radecsys);
+wcsinit.c: wcs->sysout = wcscsys (wcs->radecout);
+wcsinit.c: wcs->eqout = wcs->equinox;
+wcsinit.c: strcpy (wcs->radecin, wcs->radecsys);
+wcsinit.c: wcs->sysin = wcscsys (wcs->radecin);
+wcsinit.c: wcs->eqin = wcs->equinox;
+wcsinit.c: wcs->equinox = atof (eqstring+1);
+wcsinit.c: wcs->equinox = atof (eqstring+1);
+wcsinit.c: hgetr8 (hstring, eqkey, &wcs->equinox);
+wcsinit.c: wcs->equinox = 1950.0;
+wcsinit.c: hgetr8 (hstring,"EPOCH",&wcs->equinox);
+wcsinit.c: wcs->equinox = 1950.0;
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: if (!strncmp (wcs->c1type, "RA",2) || !strncmp (wcs->c1type,"DEC",3))
+wcsinit.c: if (!hgetdate (hstring,"DATE-OBS",&wcs->epoch)) {
+wcsinit.c: if (!hgetdate (hstring,"DATE",&wcs->epoch)) {
+wcsinit.c: if (!hgetr8 (hstring,"EPOCH",&wcs->epoch))
+wcsinit.c: wcs->epoch = wcs->equinox;
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: wcs->epoch = wcs->epoch + (ut / (24.0 * 365.242198781));
+wcsinit.c: if (wcs->epoch == 0.0)
+wcsinit.c: wcs->epoch = wcs->equinox;
+wcsinit.c: strcpy (wcs->radecsys,systring);
+wcsinit.c: if (!strncmp (wcs->radecsys,"FK4",3))
+wcsinit.c: wcs->equinox = 1950.0;
+wcsinit.c: else if (!strncmp (wcs->radecsys,"FK5",3))
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: else if (!strncmp (wcs->radecsys,"ICRS",4))
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: else if (!strncmp (wcs->radecsys,"GAL",3) && ieq == 0)
+wcsinit.c: wcs->equinox = 2000.0;
+wcsinit.c: else if (wcs->syswcs != WCS_NPOLE) {
+wcsinit.c: strcpy (wcs->radecsys,"FK5");
+wcsinit.c: strcpy (wcs->radecsys,"FK4");
+wcsinit.c: if (wcs->c1type[0] == 'G')
+wcsinit.c: strcpy (wcs->radecsys,"GALACTIC");
+wcsinit.c: else if (wcs->c1type[0] == 'E')
+wcsinit.c: strcpy (wcs->radecsys,"ECLIPTIC");
+wcsinit.c: else if (wcs->c1type[0] == 'S')
+wcsinit.c: strcpy (wcs->radecsys,"SGALACTC");
+wcsinit.c: else if (wcs->c1type[0] == 'H')
+wcsinit.c: strcpy (wcs->radecsys,"HELIOECL");
+wcsinit.c: else if (wcs->c1type[0] == 'A')
+wcsinit.c: strcpy (wcs->radecsys,"ALTAZ");
+wcsinit.c: else if (wcs->c1type[0] == 'L')
+wcsinit.c: strcpy (wcs->radecsys,"LINEAR");
+wcsinit.c: wcs->syswcs = wcscsys (wcs->radecsys);
+wcsinit.c: * Oct 1 2003 Rename wcs->naxes to wcs->naxis to match WCSLIB 3.2
+wcsinit.c: * Dec 3 2003 Add back wcs->naxes for backward compatibility
+wcsinit.c: * Feb 15 2007 Check for wcs->wcsproj > 0 instead of CTYPEi != LINEAR or PIXEL
+wcslib.c:* World coordinates. world[wcs->lng] and
+wcslib.c:* world[wcs->lat] are the celestial longitude and
+wcslib.c:* imgcrd double[] Image coordinate. imgcrd[wcs->lng] and
+wcslib.c:* imgcrd[wcs->lat] are the projected x-, and
+wcslib.c:* also returned in imgcrd[wcs->cubeface].
+wcslib.c:* imgcrd double[] Image coordinate. imgcrd[wcs->lng] and
+wcslib.c:* imgcrd[wcs->lat] are the projected x-, and
+wcslib.c:* world double[] World coordinates. world[wcs->lng] and
+wcslib.c:* world[wcs->lat] are the celestial longitude and
+wcslib.c:* world[wcs->lng], latitude returned in
+wcslib.c:* world[wcs->lat].
+wcslib.c:* world[wcs->lat], longitude returned in
+wcslib.c:* world[wcs->lng].
+wcslib.c:* world double[] World coordinates. world[wcs->lng] and
+wcslib.c:* world[wcs->lat] are the celestial longitude and
+wcslib.c:* imgcrd double[] Image coordinate. imgcrd[wcs->lng] and
+wcslib.c:* imgcrd[wcs->lat] are the projected x-, and
+wcslib.c: strcpy(wcs->pcode, "");
+wcslib.c: wcs->lng = -1;
+wcslib.c: wcs->lat = -1;
+wcslib.c: wcs->cubeface = -1;
+wcslib.c: if (wcs->cubeface == -1) {
+wcslib.c: wcs->cubeface = j;
+wcslib.c: if (strcmp(wcs->pcode, "") == 0) {
+wcslib.c: sprintf(wcs->pcode, "%.3s", &ctype[j][5]);
+wcslib.c: wcs->lng = j;
+wcslib.c: strcpy(wcs->lngtyp, "RA");
+wcslib.c: strcpy(wcs->lattyp, "DEC");
+wcslib.c: ndx = &wcs->lat;
+wcslib.c: sprintf(requir, "DEC--%s", wcs->pcode);
+wcslib.c: wcs->lat = j;
+wcslib.c: strcpy(wcs->lngtyp, "RA");
+wcslib.c: strcpy(wcs->lattyp, "DEC");
+wcslib.c: ndx = &wcs->lng;
+wcslib.c: sprintf(requir, "RA---%s", wcs->pcode);
+wcslib.c: wcs->lng = j;
+wcslib.c: sprintf(wcs->lngtyp, "%cLON", ctype[j][0]);
+wcslib.c: sprintf(wcs->lattyp, "%cLAT", ctype[j][0]);
+wcslib.c: ndx = &wcs->lat;
+wcslib.c: sprintf(requir, "%s-%s", wcs->lattyp, wcs->pcode);
+wcslib.c: wcs->lat = j;
+wcslib.c: sprintf(wcs->lngtyp, "%cLON", ctype[j][0]);
+wcslib.c: sprintf(wcs->lattyp, "%cLAT", ctype[j][0]);
+wcslib.c: ndx = &wcs->lng;
+wcslib.c: sprintf(requir, "%s-%s", wcs->lngtyp, wcs->pcode);
+wcslib.c: wcs->lng = j;
+wcslib.c: sprintf(wcs->lngtyp, "%c%cLN", ctype[j][0], ctype[j][1]);
+wcslib.c: sprintf(wcs->lattyp, "%c%cLT", ctype[j][0], ctype[j][1]);
+wcslib.c: ndx = &wcs->lat;
+wcslib.c: sprintf(requir, "%s-%s", wcs->lattyp, wcs->pcode);
+wcslib.c: wcs->lat = j;
+wcslib.c: sprintf(wcs->lngtyp, "%c%cLN", ctype[j][0], ctype[j][1]);
+wcslib.c: sprintf(wcs->lattyp, "%c%cLT", ctype[j][0], ctype[j][1]);
+wcslib.c: ndx = &wcs->lng;
+wcslib.c: sprintf(requir, "%s-%s", wcs->lngtyp, wcs->pcode);
+wcslib.c: if (strncmp(wcs->pcode, "GLS", 3) == 0) {
+wcslib.c: strcpy(wcs->pcode, "SFL");
+wcslib.c: if (strcmp(wcs->pcode, "")) {
+wcslib.c: wcs->flag = WCSSET;
+wcslib.c: wcs->flag = 999;
+wcslib.c: if (wcs->flag != WCSSET) {
+wcslib.c: if (j == wcs->lng) continue;
+wcslib.c: if (j == wcs->lat) continue;
+wcslib.c: if (wcs->flag != 999) {
+wcslib.c: if (strcmp(wcs->pcode, "NCP") == 0) {
+wcslib.c: strcpy(wcs->pcode, "SIN");
+wcslib.c: if ((err = celfwd(wcs->pcode, world[wcs->lng], world[wcs->lat], cel,
+wcslib.c: phi, theta, prj, &imgcrd[wcs->lng], &imgcrd[wcs->lat]))) {
+wcslib.c: if (wcs->cubeface != -1) {
+wcslib.c: if (imgcrd[wcs->lat] < -0.5*offset) {
+wcslib.c: imgcrd[wcs->lat] += offset;
+wcslib.c: imgcrd[wcs->cubeface] = 5.0;
+wcslib.c: } else if (imgcrd[wcs->lat] > 0.5*offset) {
+wcslib.c: imgcrd[wcs->lat] -= offset;
+wcslib.c: imgcrd[wcs->cubeface] = 0.0;
+wcslib.c: } else if (imgcrd[wcs->lng] > 2.5*offset) {
+wcslib.c: imgcrd[wcs->lng] -= 3.0*offset;
+wcslib.c: imgcrd[wcs->cubeface] = 4.0;
+wcslib.c: } else if (imgcrd[wcs->lng] > 1.5*offset) {
+wcslib.c: imgcrd[wcs->lng] -= 2.0*offset;
+wcslib.c: imgcrd[wcs->cubeface] = 3.0;
+wcslib.c: } else if (imgcrd[wcs->lng] > 0.5*offset) {
+wcslib.c: imgcrd[wcs->lng] -= offset;
+wcslib.c: imgcrd[wcs->cubeface] = 2.0;
+wcslib.c: imgcrd[wcs->cubeface] = 1.0;
+wcslib.c: if (wcs->flag != WCSSET) {
+wcslib.c: if (j == wcs->lng) continue;
+wcslib.c: if (j == wcs->lat) continue;
+wcslib.c: if (wcs->flag != 999) {
+wcslib.c: if (wcs->cubeface != -1) {
+wcslib.c: face = (int)(imgcrd[wcs->cubeface] + 0.5);
+wcslib.c: if (fabs(imgcrd[wcs->cubeface]-face) > 1e-10) {
+wcslib.c: imgcrd[wcs->lat] += offset;
+wcslib.c: imgcrd[wcs->lng] += offset;
+wcslib.c: imgcrd[wcs->lng] += offset*2;
+wcslib.c: imgcrd[wcs->lng] += offset*3;
+wcslib.c: imgcrd[wcs->lat] -= offset;
+wcslib.c: if (strcmp(wcs->pcode, "NCP") == 0) {
+wcslib.c: strcpy(wcs->pcode, "SIN");
+wcslib.c: if ((err = celrev(wcs->pcode, imgcrd[wcs->lng], imgcrd[wcs->lat], prj,
+wcslib.c: phi, theta, cel, &world[wcs->lng], &world[wcs->lat]))) {
+wcslib.c: if (wcs->flag != WCSSET) {
+wcslib.c: world[wcs->lat] = lat0;
+wcslib.c: world[wcs->lat] = lat1;
+wcslib.c: world[wcs->lat] = lat0;
+wcslib.c: world[wcs->lat] = lat;
+wcslib.c: world[wcs->lat] = lat0;
+wcslib.c: world[wcs->lat] = lat1;
+wcslib.c: world[wcs->lat] = lat0m;
+wcslib.c: world[wcs->lat] = lat1m;
+wcslib.c: world[wcs->lng] = lng0;
+wcslib.c: world[wcs->lng] = lng1;
+wcslib.c: world[wcs->lng] = lng0;
+wcslib.c: world[wcs->lng] = lng;
+wcslib.c: world[wcs->lng] = lng0;
+wcslib.c: world[wcs->lng] = lng1;
+wcslib.c: world[wcs->lng] = lng0m;
+wcslib.c: world[wcs->lng] = lng1m;
+wcslib.c: if (fabs(fmod(world[wcs->lng]-lng,360.0)) > tol) continue;
+wcslib.c: world[wcs->lat] = lat;
+wcslib.c: if (fabs(world[wcs->lat]-lat) > tol) continue;
+wcslib.c: world[wcs->lng] = lng;
+wcslib.c: lng = world[wcs->lng];
+wcslib.c: lat = world[wcs->lat];
+wcslib.c: world[wcs->lng] = -180.0;
+wcslib.c: world[wcs->lat] = *theta;
+wcslib.c: world[wcs->lng] = lng;
+wcslib.c: world[wcs->lat] = lat;
+wcslib.c: world[wcs->lng] = phi1;
+wcslib.c: world[wcs->lng] = lng;
+wcslib.c: world[wcs->lat] = lat;
+wcslib.c: world[wcs->lng] = phi0 + lambda*dphi;
+wcslib.c: world[wcs->lng] = lng;
+wcslib.c: world[wcs->lat] = lat;
+wcslib.c: phi0 = world[wcs->lng];
+wcslib.c: phi1 = world[wcs->lng];
+worldpos.c: int itype = wcs->prjcode;
+worldpos.c: xref = wcs->xref;
+worldpos.c: yref = wcs->yref;
+worldpos.c: xrefpix = wcs->xrefpix;
+worldpos.c: yrefpix = wcs->yrefpix;
+worldpos.c: xinc = wcs->xinc;
+worldpos.c: yinc = wcs->yinc;
+worldpos.c: rot = degrad (wcs->rot);
+worldpos.c: if (wcs->rotmat) {
+worldpos.c: tx = dx * wcs->cd[0] + dy * wcs->cd[1];
+worldpos.c: dy = dx * wcs->cd[2] + dy * wcs->cd[3];
+worldpos.c: if (wcs->coorflip) {
+worldpos.c: if (wcs->coorflip) {
+worldpos.c: xref = wcs->xref;
+worldpos.c: yref = wcs->yref;
+worldpos.c: xrefpix = wcs->xrefpix;
+worldpos.c: yrefpix = wcs->yrefpix;
+worldpos.c: xinc = wcs->xinc;
+worldpos.c: yinc = wcs->yinc;
+worldpos.c: rot = degrad (wcs->rot);
+worldpos.c: itype = wcs->prjcode;
+worldpos.c: if (wcs->coorflip) {
+worldpos.c: if (wcs->rotmat)
+worldpos.c: l = rap * an * (1.0 - ansq/6.0) * (wcs->cd[0] / fabs(wcs->cd[0]));
+worldpos.c: if (wcs->coorflip) {
+worldpos.c: if (wcs->rotmat) {
+worldpos.c: tx = dx * wcs->dc[0] + dy * wcs->dc[1];
+worldpos.c: dy = dx * wcs->dc[2] + dy * wcs->dc[3];
+worldpos.c: if (*xpix > wcs->nxpix) {
+worldpos.c: if (x <= wcs->nxpix) *xpix = x;
+zpxpos.c: if (wcs->longpole > 360.0) {
+zpxpos.c: if (!igetr8 (str1, "longpole", &wcs->longpole)) {
+zpxpos.c: if (!igetr8 (str2, "longpole", &wcs->longpole))
+zpxpos.c: wcs->longpole = 180.0;
+zpxpos.c: if (!igetr8 (str1, "ro", &wcs->rodeg)) {
+zpxpos.c: if (!igetr8 (str2, "ro", &wcs->rodeg))
+zpxpos.c: wcs->rodeg = 180.0 / PI;
+zpxpos.c: if (!igetr8 (str1, key, &wcs->prj.p[i]))
+zpxpos.c: wcs->prj.p[i] = 0.0;
+zpxpos.c: wcs->lngcor = NULL;
+zpxpos.c: wcs->lngcor = wf_gsopen (lngstr);
+zpxpos.c: wcs->lngcor = wf_gsopen (lngstr);
+zpxpos.c: wcs->latcor = NULL;
+zpxpos.c: wcs->latcor = wf_gsopen (latstr);
+zpxpos.c: wcs->latcor = wf_gsopen (latstr);
+zpxpos.c: for (i = 9; i >= 0 && wcs->prj.p[i] == 0.; i--);
+zpxpos.c: wcs->zpnp = i;
+zpxpos.c: d1 = wcs->prj.p[1];
+zpxpos.c: for (j = wcs->zpnp; j >= 1; j--) {
+zpxpos.c: d2 = d2 * zd2 + j * wcs->prj.p[j];
+zpxpos.c: for (j = wcs->zpnp; j >= 1; j--) {
+zpxpos.c: d = d * zd + j * wcs->prj.p[j];
+zpxpos.c: for (j = wcs->zpnp; j >= 0; j--)
+zpxpos.c: r = r * zd + wcs->prj.p[j];
+zpxpos.c: wcs->zpzd = zd;
+zpxpos.c: wcs->zpr = r;
+zpxpos.c: if (wcs->latcor == NULL && wcs->lngcor == NULL)
+zpxpos.c: xpix = xpix - wcs->crpix[0];
+zpxpos.c: ypix = ypix - wcs->crpix[1];
+zpxpos.c: if (wcs->rotmat) {
+zpxpos.c: x = xpix * wcs->cd[0] + ypix * wcs->cd[1];
+zpxpos.c: y = xpix * wcs->cd[2] + ypix * wcs->cd[3];
+zpxpos.c: if (wcs->cdelt[0] == 0.0 || wcs->cdelt[1] == 0.0) {
+zpxpos.c: xs = xpix * wcs->cdelt[0];
+zpxpos.c: ys = ypix * wcs->cdelt[1];
+zpxpos.c: if (wcs->rot != 0.0) {
+zpxpos.c: double cosr = cos (degrad (wcs->rot));
+zpxpos.c: double sinr = sin (degrad (wcs->rot));
+zpxpos.c: if (wcs->coorflip) {
+zpxpos.c: colatp = degrad (90.0 - wcs->crval[idec]);
+zpxpos.c: longp = degrad(wcs->longpole);
+zpxpos.c: k = wcs->zpnp;
+zpxpos.c: if (wcs->lngcor != NULL)
+zpxpos.c: xp = x + wf_gseval (wcs->lngcor, x, y);
+zpxpos.c: if (wcs->latcor != NULL)
+zpxpos.c: yp = y + wf_gseval (wcs->latcor, x, y);
+zpxpos.c: r = sqrt (x * x + y * y) / wcs->rodeg;
+zpxpos.c: zd = (r - wcs->prj.p[0]) / wcs->prj.p[1];
+zpxpos.c: a = wcs->prj.p[2];
+zpxpos.c: b = wcs->prj.p[1];
+zpxpos.c: c = wcs->prj.p[0] - r;
+zpxpos.c: r1 = wcs->prj.p[0];
+zpxpos.c: zd2 = wcs->zpzd;
+zpxpos.c: r2 = wcs->zpr;
+zpxpos.c: rt = (rt * zd) + wcs->prj.p[i];
+zpxpos.c: ra = wcs->crval[ira] + raddeg(dlng);
+zpxpos.c: if (wcs->crval[ira] >= 0.0) {
+zpxpos.c: if (wcs->coorflip) {
+zpxpos.c: ra = degrad (xpos - wcs->crval[ira]);
+zpxpos.c: colatp = degrad (90.0 - wcs->crval[idec]);
+zpxpos.c: if (wcs->longpole == 999.0)
+zpxpos.c: longp = degrad(wcs->longpole);
+zpxpos.c: r = r * s + wcs->prj.p[i];
+zpxpos.c: r = wcs->rodeg * r;
+zpxpos.c: if (wcs->lngcor == NULL && wcs->latcor == NULL) {
+zpxpos.c: if (wcs->coorflip) {
+zpxpos.c: if (wcs->lngcor != NULL) {
+zpxpos.c: f = x + wf_gseval (wcs->lngcor, x, y) - xm;
+zpxpos.c: fx = wf_gsder (wcs->lngcor, x, y, 1, 0);
+zpxpos.c: fy = wf_gsder (wcs->lngcor, x, y, 0, 1);
+zpxpos.c: if (wcs->latcor != NULL) {
+zpxpos.c: g = y + wf_gseval (wcs->latcor, x, y) - ym;
+zpxpos.c: gx = wf_gsder (wcs->latcor, x, y, 1, 0);
+zpxpos.c: gy = wf_gsder (wcs->latcor, x, y, 0, 1);
+zpxpos.c: if (wcs->coorflip) {
+zpxpos.c: if (wcs->rotmat) {
+zpxpos.c: *xpix = x * wcs->dc[0] + y * wcs->dc[1];
+zpxpos.c: *ypix = x * wcs->dc[2] + y * wcs->dc[3];
+zpxpos.c: if (wcs->rot!=0.0) {
+zpxpos.c: double cosr = cos (degrad (wcs->rot));
+zpxpos.c: double sinr = sin (degrad (wcs->rot));
+zpxpos.c: if (wcs->xinc != 0.)
+zpxpos.c: *xpix = *xpix / wcs->xinc;
+zpxpos.c: if (wcs->yinc != 0.)
+zpxpos.c: *ypix = *ypix / wcs->yinc;
+zpxpos.c: *xpix = *xpix + wcs->xrefpix;
+zpxpos.c: *ypix = *ypix + wcs->yrefpix;
+zpxpos.c: if (wcs->lngcor != NULL)
+zpxpos.c: wf_gsclose (wcs->lngcor);
+zpxpos.c: if (wcs->latcor != NULL)
+zpxpos.c: wf_gsclose (wcs->latcor);
diff --git a/libwcs/fileutil.c b/libwcs/fileutil.c
index a4189a1..cf52903 100644
--- a/libwcs/fileutil.c
+++ b/libwcs/fileutil.c
@@ -1,8 +1,8 @@
/*** File libwcs/fileutil.c
- *** January 11, 2007
+ *** August 28, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1999-2007
+ *** Copyright (C) 1999-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -43,7 +43,9 @@
* Subroutine: isfile (filename)
* Return 1 if file is a readable file, else 0
* Subroutine: first_token (diskfile, ncmax, token)
- * Return first token from the next line of an ASCII file
+ * Return the first token from the next line of an ASCII file
+ * Subroutine: next_line (diskfile, ncmax, line)
+ * Read the next line of an ASCII file and return its length
* Subroutine: stc2s (spchar, string)
* Replace character in string with space
* Subroutine: sts2c (spchar, string)
@@ -320,16 +322,61 @@ isfile (filename)
char *filename; /* Name of file to check */
{
+ struct stat statbuff;
+
if (!strcasecmp (filename, "stdin"))
return (1);
else if (access (filename, R_OK))
return (0);
+ else if (stat (filename, &statbuff))
+ return (0);
+ else {
+ if (S_ISDIR(statbuff.st_mode) && S_IFDIR)
+ return (2);
+ else
+ return (1);
+ }
+}
+
+
+/* NEXT_LINE -- Read the next line of an ASCII file, returning length */
+/* Lines beginning with # are ignored*/
+
+int
+next_line (diskfile, ncmax, line)
+
+FILE *diskfile; /* File descriptor for ASCII file */
+int ncmax; /* Maximum number of characters returned */
+char *line; /* Next line (returned) */
+{
+ char *lastchar;
+
+ /* If line can be read, add null at the end of the first token */
+ if (fgets (line, ncmax, diskfile) != NULL) {
+ while (line[0] == '#') {
+ (void) fgets (line, ncmax, diskfile);
+ }
+
+ /* If only character is a control character, return a NULL string */
+ if ((strlen(line)==1) && (line[0]<32)){
+ line[0] = (char)0;
+ return (1);
+ }
+ lastchar = line + strlen (line) - 1;
+
+ /* Remove trailing spaces or control characters */
+ while (*lastchar <= 32)
+ *lastchar-- = 0;
+
+ return (strlen (line));
+ }
else
- return (1);
+ return (0);
}
/* FIRST_TOKEN -- Return first token from the next line of an ASCII file */
+/* Lines beginning with # are ignored */
int
first_token (diskfile, ncmax, token)
@@ -342,7 +389,7 @@ char *token; /* First token on next line (returned) */
/* If line can be read, add null at the end of the first token */
if (fgets (token, ncmax, diskfile) != NULL) {
- if (token[0] == '#') {
+ while (token[0] == '#') {
(void) fgets (token, ncmax, diskfile);
}
@@ -815,4 +862,6 @@ int maxchars; /* Maximum length of token */
*
* Jan 5 2007 Change stc2s() and sts2c() to pass single character as pointer
* Jan 11 2007 Move token access subroutines from catutil.c
+ *
+ * Aug 28 2014 Return length from next_line(): 0=unsuccessful
*/
diff --git a/libwcs/fitsfile.c b/libwcs/fitsfile.c
index 0ff9479..c832687 100644
--- a/libwcs/fitsfile.c
+++ b/libwcs/fitsfile.c
@@ -1,8 +1,8 @@
/*** File libwcs/fitsfile.c
- *** September 15, 2011
+ *** July 25, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1996-2011
+ *** Copyright (C) 1996-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -211,11 +211,13 @@ int *nbhead; /* Number of bytes before start of data (returned) */
/* Read FITS header from input file one FITS block at a time */
irec = 0;
ibhead = 0;
- while (irec < 200) {
+ while (irec < 500) {
nbytes = FITSBLOCK;
for (ntry = 0; ntry < 10; ntry++) {
for (i = 0; i < 2884; i++) fitsbuf[i] = 0;
nbr = read (fd, fitsbuf, nbytes);
+ if (verbose)
+ fprintf (stderr,"FITSRHEAD: %d header bytes read\n",nbr);
/* Short records allowed only if they have the last header line */
if (nbr < nbytes) {
@@ -275,34 +277,46 @@ int *nbhead; /* Number of bytes before start of data (returned) */
break;
}
- /* Move current FITS record into header string */
+ /* Replace control characters and nulls with spaces */
for (i = 0; i < 2880; i++)
if (fitsbuf[i] < 32 || i > nbr) fitsbuf[i] = 32;
if (nbr < 2880)
nbr = 2880;
+
+ /* Move current FITS record into header string */
strncpy (headnext, fitsbuf, nbr);
*nbhead = *nbhead + nbr;
nrec = nrec + 1;
- *(headnext+nbr) = 0;
+ *(headnext+nbr+1) = 0;
ibhead = ibhead + 2880;
+ if (verbose)
+ fprintf (stderr,"FITSRHEAD: %d bytes in header\n",ibhead);
/* Check to see if this is the final record in this header */
headend = ksearch (fitsbuf,"END");
if (headend == NULL) {
- /* Increase size of header buffer by 4 blocks if too small */
+ /* Double size of header buffer if too small */
if (nrec * FITSBLOCK > nbh) {
- nbh0 = nbh;
- nbh = (nrec + 4) * FITSBLOCK + 4;
+ nbh0 = nbh - 4;
+ nbh = (nrec * 2 * FITSBLOCK) + 4;
newhead = (char *) calloc (1,(unsigned int) nbh);
- for (i = 0; i < nbh0; i++)
- newhead[i] = header[i];
- free (header);
- header = newhead;
- (void) hlength (header, nbh);
- headnext = header + *nbhead - FITSBLOCK;
+ if (newhead) {
+ for (i = 0; i < nbh0; i++)
+ newhead[i] = header[i];
+ free (header);
+ newhead[nbh-3] = (char) 0;
+ header = newhead;
+ (void) hlength (header, nbh);
+ headnext = header + ((nrec-1) * FITSBLOCK);
+ }
+ else {
+ fprintf (stderr,"FITSRHEAD: %d bytes cannot be allocated for header\n",nbh);
+ exit (1);
+ }
}
- headnext = headnext + FITSBLOCK;
+ else
+ headnext = headnext + FITSBLOCK;
}
else {
@@ -317,7 +331,8 @@ int *nbhead; /* Number of bytes before start of data (returned) */
pheader = (char *) calloc ((unsigned int) nbprim, 1);
for (i = 0; i < lprim; i++)
pheader[i] = header[i];
- strncpy (pheader, header, lprim);
+ for (i = lprim; i < nbprim; i++)
+ pheader[i] = ' ';
}
/* If header has no data, start with the next record */
@@ -2305,4 +2320,6 @@ char *from, *last, *to;
* Sep 15 2011 In fitsrsect() declare impos and nblin off_t
* Sep 15 2011 In fitsrtail() declare offset off_t
* Sep 15 2011 Declare global variable ibhead off_t
+ *
+ * Jul 25 2014 Fix bug when reallocating buffer for long headers
*/
diff --git a/libwcs/fitsfile.h b/libwcs/fitsfile.h
index c000d18..cd67f37 100644
--- a/libwcs/fitsfile.h
+++ b/libwcs/fitsfile.h
@@ -1,8 +1,8 @@
/*** File fitsfile.h FITS and IRAF file access subroutines
- *** September 25, 2009
+ *** June 20, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1996-2009
+ *** Copyright (C) 1996-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -412,6 +412,10 @@ float ftgetr4( /* Extract column for keyword from FITS table line
char *filename); /* Name of file to check */
int isgif( /* Return 1 if GIF image file, else 0 */
char *filename); /* Name of file to check */
+ int next_line ( /* Return the next line of an ASCII file */
+ FILE *diskfile, /* File descriptor for ASCII file */
+ int ncmax, /* Maximum number of characters returned */
+ char *line); /* Next line (returned) */
int first_token( /* Return first token from the next line of an ASCII file */
FILE *diskfile, /* File descriptor for ASCII file */
int ncmax, /* Maximum number of characters returned */
@@ -1028,6 +1032,7 @@ extern int isfile();
extern int istiff();
extern int isjpeg();
extern int isgif();
+extern int next_line();
extern int first_token();
/* Subroutines for access to tokens within a string from fileutil.c */
@@ -1283,4 +1288,6 @@ void compnut(); /* Compute nutation in longitude and obliquity and mean obliquit
* Sep 8 2008 Add ag2hr(), ang2deg(), deg2ang(), and hr2ang()
*
* Sep 25 2009 Add moveb()
+ *
+ * Jun 20 2014 Add next_line()
*/
diff --git a/libwcs/fitswcs.h b/libwcs/fitswcs.h
new file mode 100644
index 0000000..778613f
--- /dev/null
+++ b/libwcs/fitswcs.h
@@ -0,0 +1,95 @@
+/*** File fitswcs.h FITS header WCS access subroutines
+ *** September 24, 2013
+ *** By Jessica Mink, jmink at cfa.harvard.edu
+ *** Harvard-Smithsonian Center for Astrophysics
+ *** Copyright (C) 1996-2013
+ *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Correspondence concerning WCSTools should be addressed as follows:
+ Internet email: jmink at cfa.harvard.edu
+ Postal address: Jessica Mink
+ Smithsonian Astrophysical Observatory
+ 60 Garden St.
+ Cambridge, MA 02138 USA
+ */
+
+#ifndef fitswcs_h_
+#define fitswcs_h_
+#include "fitsfile.h"
+#include "wcs.h"
+
+#ifdef __cplusplus /* C++ prototypes */
+extern "C" {
+#endif
+
+
+#ifdef __STDC__ /* Full ANSI prototypes */
+
+/* Subroutines in fitswcs.c */
+
+ /* Open a FITS or IRAF image file and return its WCS structure */
+ struct WorldCoor *GetWCSFITS (
+ char *filename, /* FITS or IRAF file filename */
+ int verbose); /* Print extra information if nonzero */
+
+ /* Open a FITS or IRAF image file and return a FITS header */
+ char *GetFITShead (
+ char *filename, /* FITS or IRAF file filename */
+ int verbose); /* Print error messages if nonzero */
+
+ /* Delete all standard WCS keywords from a FITS header */
+ /* and return the number of header keywords deleted */
+ int DelWCSFITS (
+ char *header, /* FITS header to edit */
+ int verbose); /* Print error messages if nonzero */
+
+ /* Check the WCS fields, print any that are found if verbose > 0, */
+ /* and return 0 if all are found, else -1 */
+ int PrintWCS (
+ char *header, /* FITS header to read */
+ int verbose); /* Print WCS keyword values if nonzero */
+
+ /* Set FITS C* fields, assuming RA/DEC refers to the reference pixel, CRPIX1/CRPIX2 */
+ void SetFITSWCS (
+ char *header, /* FITS header to edit */
+ struct WorldCoor *wcs); /* WCS structure */
+
+#else /* K&R prototypes */
+
+/* Subroutines in fitswcs.c */
+/* Open a FITS or IRAF image file and return its WCS structure */
+extern struct WorldCoor *GetWCSFITS();
+/* Open a FITS or IRAF image file and return a FITS header */
+extern char *GetFITShead();
+/* Delete all standard WCS keywords from a FITS header */
+extern int DelWCSFITS();
+/* Check the WCS fields and print any that are found if verbose */
+extern int PrintWCS();
+/* Set FITS C* fields, assuming RA/DEC is at the reference pixel, CRPIX1/CRPIX2 */
+extern void SetFITSWCS();
+
+
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* fitswcs_h_ */
+
+/* Sep 24 2013 New header file for access to middleman subroutines
+ */
diff --git a/libwcs/gsc2read.c b/libwcs/gsc2read.c
index e4b6a2d..b2c8ea4 100644
--- a/libwcs/gsc2read.c
+++ b/libwcs/gsc2read.c
@@ -1,8 +1,8 @@
/*** File libwcs/gsc2read.c
- *** August 17, 2009
+ *** August 29, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 2001-2009
+ *** Copyright (C) 2001-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -43,7 +43,7 @@ static void parsex();
#define LINE 1024
/* URL for GSC II search engine at STScI Catalogs and Surveys Branch */
-char gsc23url[64]="http://gsss.stsci.edu/webservices/GSC2/GSC2DataReturn.aspx";
+char gsc23url[64]="http://gsss.stsci.edu/webservices/vo/CatalogSearch.aspx";
/* GSC2READ -- Read GSC II catalog stars over the web */
@@ -85,7 +85,6 @@ int nlog; /* 1 for diagnostics */
double ras, ds;
char sr[4], sd[4];
double ra, dec, mag, ddra;
- char rastr[32], decstr[32];
char *gsc2url;
/* Set URL for search command */
@@ -106,24 +105,17 @@ int nlog; /* 1 for diagnostics */
dec = cdec;
if (sysout != WCS_J2000)
wcscon (sysout, WCS_J2000, eqout, 2000.0, &ra, &dec, epout);
- ra2str (rastr, 32, ra, 3);
- dec2str (decstr, 32, dec, 2);
- parsex (rastr, sr, &rah, &ram, &ras);
- sprintf (srchurl, "?RAH=%d&RAM=%d&RAS=%.3f&", rah, ram, ras);
- parsex (decstr, sd, &dd, &dm, &ds);
- sprintf (temp, "DSN=%1s&DD=%d&DM=%d&DS=%.3f&", sd, dd, dm, ds);
+ sprintf (srchurl, "?RA=%.6f&DEC=%.6f&", ra, dec);
strcat (srchurl, temp);
if (drad != 0.0) {
- dr = drad * 60.0;
+ dr = drad;
}
else {
ddra = dra * cos (degrad (cdec));
- dr = sqrt (ddra*ddra + ddec*ddec) * 60.0;
+ dr = sqrt (ddra*ddra + ddec*ddec);
}
- sprintf (temp, "EQ=2000&SIZE=%.3f&SRCH=Radius&FORMAT=TSV&CAT=GSC23&", dr);
- strcat (srchurl, temp);
- sprintf (temp, "HSTID=&GSC1ID=");
+ sprintf (temp, "EQ=2000&SR=%.3f&SRCH=Radius&FORMAT=TSV&CAT=GSC23&", dr);
strcat (srchurl, temp);
if (nlog > 0)
@@ -314,21 +306,45 @@ gsc2t2t (tsvbuff)
{
char *tabbuff; /* Output tab-separated table */
- int lbuff, i, j;
+ int lbuff, i, ih, j, k, kfirst;
+ char tsvbi, tsvbj;
char ctab = (char) 9;
char clf = '\n';
char ccr = '\r';
char csp = ' ';
+ char cdash = '-';
+ char colon = ':';
/* Allocate buffer for tab-separated table with header */
lbuff = strlen (tsvbuff);
- tabbuff = (char *) calloc (lbuff, 1);
+ tabbuff = (char *) calloc (2*lbuff, 1);
- /* Copy input into new buffer dropping extra carriage returns */
+ /* Copy input into new buffer dropping first line and extra carriage returns */
+ /* Add a line of dashes after the header line */
i = 0;
+ ih = 0;
for (j = 0; j < lbuff; j++) {
- if (tsvbuff[j] != csp && tsvbuff[j] != ccr)
- tabbuff[i++] = tsvbuff[j];
+ tsvbj = tsvbuff[j];
+ if (tsvbj == clf) {
+ ih++;
+ if (ih == 1)
+ kfirst = j + 1;
+ if (ih == 2) {
+ tabbuff[i++] = clf;
+ for (k = kfirst; k < j; k++) {
+ if (tsvbuff[k] == ctab)
+ tabbuff[i++] = ctab;
+ else
+ tabbuff[i++] = cdash;
+ }
+ }
+ }
+ if (ih > 0 && tsvbj != csp && tsvbj != ccr) {
+ if (tsvbi == ctab && tsvbj == ctab)
+ tabbuff[i++] = '0';
+ tabbuff[i++] = tsvbj;
+ tsvbi = tsvbj;
+ }
}
tabbuff[i++] = (char) 0;
@@ -370,4 +386,7 @@ gsc2t2t (tsvbuff)
* Oct 24 2008 Add gsc2t2t to drop extra characters from returned table
*
* Aug 17 2009 Set proper motion to 0.0 for all versions
+ *
+ * Aug 29 2014 Update to read GSC2.3.3
+ * Aug 29 2014 Add line of dashes after header to returned table
*/
diff --git a/libwcs/head b/libwcs/head
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/imio.c b/libwcs/imio.c
index 13182ff..3243283 100644
--- a/libwcs/imio.c
+++ b/libwcs/imio.c
@@ -1,5 +1,5 @@
/*** File wcslib/imio.c
- *** October 19, 2012
+ *** October 30, 2012
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
*** Copyright (C) 1996-2012
@@ -750,7 +750,7 @@ int pix1; /* Offset of first pixel to check */
int npix; /* Number of pixels to check */
{
- short *im2, imin2, *ip2, *il2;
+ short *im2, imin2, ip2;
int *im4, imin4, ip4;
unsigned short *imu, iminu, ipu;
float *imr, iminr, ipr;
@@ -779,8 +779,8 @@ int npix; /* Number of pixels to check */
imin2 = *im2;
for (ipix = pix1; ipix < pix2; ipix++) {
ip2 = *(im2 + ipix);
- if (*ip2 < imin2)
- imin2 = *ip2;
+ if (ip2 < imin2)
+ imin2 = ip2;
}
dmin = (double) imin2;
break;
@@ -1539,4 +1539,6 @@ imswapped ()
*
* Apr 12 2012 Fix 8-bit variables to be unsigned char
* Oct 19 2012 Fix errors with character images in minvec() and maxvec()
+ * Oct 31 2012 Fix errors with short images in minvec() and maxvec()
+ * Oct 31 2012 Drop unused variable il2 from minvec()
*/
diff --git a/libwcs/imutil.c b/libwcs/imutil.c
index 5f3aa80..67a7d70 100644
--- a/libwcs/imutil.c
+++ b/libwcs/imutil.c
@@ -1,8 +1,8 @@
/*** File libwcs/imutil.c
- *** May 16, 2012
+ *** June 17, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 2006-2012
+ *** Copyright (C) 2006-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
*/
@@ -1183,7 +1183,7 @@ int ndy; /* Number of rows over which to compute the median */
for (jy = jy1; jy < jy2; jy++) {
img = x + (jy * nx) + jx1;
for (jx = jx1; jx < jx2; jx++) {
- if (*img != bpvalr4) {
+ if (*img != bpvalr4 && !isnan(*img)) {
*vecj++ = *img;
n++;
}
@@ -1269,7 +1269,7 @@ int ndy; /* Number of rows over which to compute the median */
for (jy = jy1; jy < jy2; jy++) {
img = x + (jy * nx) + jx1;
for (jx = jx1; jx < jx2; jx++) {
- if (*img != bpval) {
+ if (*img != bpval && !isnan(*img)) {
*vecj++ = *img;
n++;
}
@@ -1812,7 +1812,7 @@ int ndy; /* Number of rows over which to compute the median */
for (jy = jy1; jy < jy2; jy++) {
img = x + (jy * nx) + jx1;
for (jx = jx1; jx < jx2; jx++) {
- if (*img != bpvalr4) {
+ if (*img != bpvalr4 && !isnan (*img)) {
sum = sum + (double) *img;
n++;
}
@@ -1873,7 +1873,7 @@ int ndy; /* Number of rows over which to compute the median */
for (jy = jy1; jy < jy2; jy++) {
img = x + (jy * nx) + jx1;
for (jx = jx1; jx < jx2; jx++) {
- if (*img != bpval) {
+ if (*img != bpval && !isnan (*img)) {
sum = sum + (double) *img;
n++;
}
@@ -2225,9 +2225,9 @@ int nx,ny; /* Number of columns and rows in image */
ixi = ix + ixbox[i];
iyi = iy + iybox[i];
if (ixi > -1 && iyi > -1 && ixi < nx && iyi < ny) {
- img = image + (iyi * ny) + ixi;
+ img = image + (iyi * nx) + ixi;
if (*img != bpvali2) {
- flux = (double) *img;
+ flux = (double) image[ixi + (iyi * nx)];
twt = twt + gwt[i];
tpix = tpix + gwt[i] * flux;
np++;
@@ -2270,9 +2270,9 @@ int nx,ny; /* Number of columns and rows in image */
ixi = ix + ixbox[i];
iyi = iy + iybox[i];
if (ixi > -1 && iyi > -1 && ixi < nx && iyi < ny) {
- img = image + (iyi * ny) + ixi;
+ img = image + (iyi * nx) + ixi;
if (*img != bpvali4) {
- flux = (double) *img;
+ flux = (double) image[ixi + (iyi * nx)];
twt = twt + gwt[i];
tpix = tpix + gwt[i] * flux;
np++;
@@ -2315,9 +2315,10 @@ int nx,ny; /* Number of columns and rows in image */
ixi = ix + ixbox[i];
iyi = iy + iybox[i];
if (ixi > -1 && iyi > -1 && ixi < nx && iyi < ny) {
- img = image + (iyi * ny) + ixi;
- if (*img != bpvalr4) {
- flux = (double) image[ixi + (iyi * ny)];
+ img = image + (iyi * nx) + ixi;
+ /* printf ("%04d,%04d %04d,%04d: %g\n", ix, iy, ixi, iyi, *img); */
+ if (*img != bpvalr4 && !isnan (*img)) {
+ flux = (double) image[ixi + (iyi * nx)];
twt = twt + gwt[i];
tpix = tpix + gwt[i] * flux;
np++;
@@ -2360,9 +2361,9 @@ int nx,ny; /* Number of columns and rows in image */
ixi = ix + ixbox[i];
iyi = iy + iybox[i];
if (ixi > -1 && iyi > -1 && ixi < nx && iyi < ny) {
- img = image + (iyi * ny) + ixi;
- if (*img != bpval) {
- flux = image[ixi + (iyi * ny)];
+ img = image + (iyi * nx) + ixi;
+ if (*img != bpval && !isnan (*img)) {
+ flux = image[ixi + (iyi * nx)];
twt = twt + gwt[i];
tpix = tpix + gwt[i] * flux;
np++;
@@ -3042,4 +3043,6 @@ double rad;
*
* May 15 2012 Add medpix() and meanpix() to generalize across pixel size
* May 16 2012 Add medpixi1() and meanpixi1() to handle 8-bit images
+ *
+ * Jun 17 2014 Ignore NaN pixels
*/
diff --git a/libwcs/ll b/libwcs/ll
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/lwcs b/libwcs/lwcs
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/sdssread.c b/libwcs/sdssread.c
index 1df0e29..56120dc 100644
--- a/libwcs/sdssread.c
+++ b/libwcs/sdssread.c
@@ -1,8 +1,8 @@
/*** File libwcs/sdssread.c
- *** October 22, 2007
+ *** September 16, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 2004-2007
+ *** Copyright (C) 2004-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -56,9 +56,17 @@ char sdssburl[64]="http://cas.sdss.org/dr5/en/tools/search/x_rect.asp"; */
char sdssrurl[64]="http://cas.sdss.org/dr6/en/tools/search/x_radial.asp";
char sdssburl[64]="http://cas.sdss.org/dr6/en/tools/search/x_rect.asp"; */
-/* SDSS DR7 search engine URL */
-char sdssrurl[64]="http://cas.sdss.org/dr7/en/tools/search/x_radial.asp";
-char sdssburl[64]="http://cas.sdss.org/dr7/en/tools/search/x_rect.asp";
+/* SDSS DR7 search engine main server URL */
+/* char sdssrurl[64]="http://cas.sdss.org/dr7/en/tools/search/x_radial.asp";
+char sdssburl[64]="http://cas.sdss.org/dr7/en/tools/search/x_rect.asp"; */
+
+/* SDSS DR7 search engine US alternate URL */
+char sdssrurl[64]="http://sdss.lib.uchicago.edu/dr7/en/tools/search/x_radial.asp";
+char sdssburl[64]="http://sdss.lib.uchicago.edu/dr7/en/tools/search/x_rect.asp";
+
+/* SDSS DR7 search engine UK alternate URL */
+/* char sdssrurl[64]="http://www.sdss.org.uk/dr7/en/tools/search/x_radial.asp";
+char sdssburl[64]="http://www.sdss.org.uk/dr7/en/tools/search/x_rect.asp"; */
/* SDSS magnitudes */
char sdssmag[6]="ugriz";
@@ -259,4 +267,8 @@ sdssc2t (csvbuff)
* Jan 9 2007 Drop refcatname from argument list; it is not used
* Jan 10 2007 Drop gnum argument from sdssread(); gobj replaced it
* Oct 22 2007 Change path to Data Release 6
+ *
+ * May 01 2012 Change path to Data Release 7
+ *
+ * Sep 16 2013 Add alternate servers for SDASS
*/
diff --git a/libwcs/sty2 b/libwcs/sty2
new file mode 120000
index 0000000..cf5ad56
--- /dev/null
+++ b/libwcs/sty2
@@ -0,0 +1 @@
+/home/mink/bin.redhat/sty2
\ No newline at end of file
diff --git a/libwcs/tabread.c b/libwcs/tabread.c
index e499663..2bde657 100644
--- a/libwcs/tabread.c
+++ b/libwcs/tabread.c
@@ -1,8 +1,8 @@
/*** File libwcs/tabread.c
- *** September 22, 2010
+ *** August 29, 2014
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1996-2010
+ *** Copyright (C) 1996-2014
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -1367,7 +1367,8 @@ int nbbuff; /* Number of bytes in buffer; 0=read whole file */
strncpy (keyword, startab->colname[i], startab->lcol[i]);
else
strncpy (keyword, startab->colname[i], 15);
- if (strcsrch (keyword, "mag") && !strcsrch (keyword, "err")) {
+ if (strcsrch (keyword, "mag") && !strcsrch (keyword, "err")
+ && !strcsrch (keyword, "code")) {
strcpy (sc->keymag[sc->nmag], keyword);
sc->entmag[sc->nmag] = icol;
sc->nmag++;
@@ -1384,6 +1385,7 @@ int nbbuff; /* Number of bytes in buffer; 0=read whole file */
}
else if ((keyword[0] == 'M' || keyword[0] == 'm') &&
!strcsrch (keyword, "err") &&
+ !strcsrch (keyword, "code") &&
!strcsrch (keyword, "flag")) {
strcpy (sc->keymag[sc->nmag], keyword);
sc->entmag[sc->nmag] = icol;
@@ -1947,6 +1949,7 @@ int nbbuff; /* Number of bytes in buffer; 0=read whole file */
char *tabnew, *tabline, *lastline;
char *tabcomma, *nextline;
char *thisname, *tabname;
+ char tabcstr[4];
int thistab, itab, nchar, nbtab;
int formfeed = (char) 12;
struct TabTable *tabtable;
@@ -2128,6 +2131,12 @@ int nbbuff; /* Number of bytes in buffer; 0=read whole file */
if (tabcomma != NULL) *tabcomma = ',';
return (NULL);
}
+ tabcstr[0] = tabline[1];
+ tabcstr[1] = (char) 0;
+ if ( tabline[1] != '-' && tabline[1] != (char)9 ) {
+ sprintf (taberr,"TABOPEN: No - line in tab table %s",tabfile);
+ return (NULL);
+ }
tabtable->tabhead = lastline;
tabtable->tabdash = tabline;
tabtable->tabdata = strchr (tabline, newline) + 1;
@@ -2715,20 +2724,43 @@ istab (filename)
char *filename; /* Name of file to check */
{
- struct TabTable *tabtable;
+ FILE *diskfile;
+ char *line;
+ int ncmax=63;
/* First check file extension */
if (strsrch (filename, ".tab"))
return (1);
- /* If no .tab file extension, try opening the file */
+ /* If no .tab file extension, look for tab on first line */
else {
- if ((tabtable = tabopen (filename, 10000)) != NULL) {
- tabclose (tabtable);
+ /* Open file */
+ if ((diskfile = fopen (filename, "r")) == NULL)
+ return (0);
+
+ /* Allocate buffer for first line of file */
+ line = (char *)calloc (1, 63);
+
+ /* Return 0 if no characters in first line */
+ if (!next_line (diskfile, ncmax, line)) {
+ fclose (diskfile);
+ free (line);
+ return (0);
+ }
+
+ /* Return 0 if there is a tab in the first line */
+ if (strchr (line, (char)9)) {
+ fclose (diskfile);
+ free (line);
return (1);
}
- else
+
+ /* Otherwise, return 0 */
+ else {
+ fclose (diskfile);
+ free (line);
return (0);
+ }
}
}
@@ -2904,4 +2936,8 @@ char *filename; /* Name of file to check */
* Sep 30 2009 Fix bugs freeing object names for first pass and farthest star
*
* Sep 22 2010 Fix bug when checking file which is not tab table
+ *
+ * Jun 20 2014 Not a tab table if no tab in first line
+ * Aug 28 2014 Fix istab() and tabread()
+ * Aug 29 2014 Exclude "code" from magnitude keywords
*/
diff --git a/libwcs/tail b/libwcs/tail
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/wcsinit.c b/libwcs/temp
similarity index 99%
copy from libwcs/wcsinit.c
copy to libwcs/temp
index 0b6c0af..47ea896 100644
--- a/libwcs/wcsinit.c
+++ b/libwcs/temp
@@ -1,8 +1,8 @@
/*** File libwcs/wcsinit.c
- *** October 19, 2012
+ *** February 7, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1998-2012
+ *** Copyright (C) 1998-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -100,7 +100,7 @@ const char *hstring; /* character string containing FITS header information
const char *name; /* Name of WCS conversion to be matched
(case-independent) */
{
- char *upname, *uppercase();
+ char *upname;
char cwcs, charwcs;
int iwcs;
char keyword[12];
@@ -784,7 +784,7 @@ char *wchar; /* Suffix character for one of multiple WCS */
}
/* If any PVi_j are set, add them to the structure */
- if (n > 0) {
+ if (n > 0 && wcs->distcode != DISTORT_SIRTF) {
n = 0;
for (k = MAXPV; k >= 0; k--) {
@@ -1608,4 +1608,7 @@ char *mchar; /* Suffix character for one of multiple WCS */
* Sep 1 2011 Add TPV as TAN with SCAMP PVs
*
* Oct 19 2012 Drop unused variable iszpx; fix bug in latmin assignment
+ *
+ * Feb 1 2013 Externalize uppercase()
+ * Feb 7 2013 Do not set SWARP PPVij parameters if SIP distortion is used
*/
diff --git a/libwcs/ucacread.c b/libwcs/ucacread.c
index 9e1d3fb..1ca048f 100644
--- a/libwcs/ucacread.c
+++ b/libwcs/ucacread.c
@@ -1,1637 +1,1919 @@
-/*** File libwcs/ucacread.c
- *** May 20, 2011
- *** By Jessica Mink, jmink at cfa.harvard.edu
- *** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 2003-2011
- *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Correspondence concerning WCSTools should be addressed as follows:
- Internet email: jmink at cfa.harvard.edu
- Postal address: Jessica Mink
- Smithsonian Astrophysical Observatory
- 60 Garden St.
- Cambridge, MA 02138 USA
-
- * ucacread() Read UCAC Star Catalog stars in a rectangle on the sky
- * ucacrnum() Read UCAC Star Catalog stars by number
- * ucacbin() Fill a FITS WECS image with UCAC Star Catalog stars
- * ucaczones() Make list of zones covered by a range of declinations
- * ucacsra (sc,st,zone,rax0) Find UCAC star closest to specified right ascension
- * ucacopen(zone, nstars) Open UCAC catalog file, returning number of entries
- * ucacclose (sc) Close UCAC catalog file
- * ucacstar (sc,st,zone,istar) Get UCAC catalog entry for one star
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "fitsfile.h"
-#include "wcs.h"
-#include "wcscat.h"
-
-#define MAXZONE 100
-#define ABS(a) ((a) < 0 ? (-(a)) : (a))
-
-typedef struct {
- int rasec, decsec;
- short cmag;
- unsigned char era, edec, nobs, rflg, ncat, cflg;
- short epra, epdec;
- int rapm, decpm;
- unsigned char erapm, edecpm, qrapm, qdecpm;
- int id2m;
- short jmag, hmag, kmag, qm, cc;
-} UCAC2star;
-
-typedef struct {
- int rasec, decsec;
- short mmag, amag, sigmag;
- char objt, dsf;
- short sigra, sigdec;
- char na1, nu1, us1, cn1;
- short cepra, cepdec;
- int rapm, decpm;
- short sigpmr, sigpmd;
- int id2m;
- short jmag, hmag, kmag;
- char jq, hq, kq;
- char e2mpho[3];
- short bmag, rmag, imag;
- char clbl;
- char bq, rq, iq;
- char catflg[10];
- char g1, c1, leda, x2m;
- int rn;
-} UCAC3star;
-
-
-/* pathname of UCAC1 decompressed data files or search engine URL */
-char ucac1path[64]="/data/astrocat/ucac1";
-
-/* pathname of UCAC2 decompressed data files or search engine URL */
-char ucac2path[64]="/data/astrocat/ucac2";
-
-/* pathname of UCAC3 decompressed data files or search engine URL */
-char ucac3path[64]="/data/astrocat/ucac3";
-
-char *ucacpath;
-static int ucat = 0;
-
-static double *gdist; /* Array of distances to stars */
-static int ndist = 0;
-static int cswap = 0; /* Byte reverse catalog to Mac/Sun/network order if 1 */
-
-static int ucaczones();
-struct StarCat *ucacopen();
-void ucacclose();
-static int ucacsra();
-static int ucacstar();
-static void ucacswap4();
-static void ucacswap2();
-
-
-/* UCACREAD -- Read UCAC Star Catalog stars */
-
-int
-ucacread (refcatname,cra,cdec,dra,ddec,drad,dradi,distsort,sysout,eqout,epout,
- mag1,mag2,sortmag,nstarmax,gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog)
-
-char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
-double cra; /* Search center J2000 right ascension in degrees */
-double cdec; /* Search center J2000 declination in degrees */
-double dra; /* Search half width in right ascension in degrees */
-double ddec; /* Search half-width in declination in degrees */
-double drad; /* Limiting separation in degrees (ignore if 0) */
-double dradi; /* Inner edge of annulus in degrees (ignore if 0) */
-int distsort; /* 1 to sort stars by distance from center */
-int sysout; /* Search coordinate system */
-double eqout; /* Search coordinate equinox */
-double epout; /* Proper motion epoch (0.0 for no proper motion) */
-double mag1,mag2; /* Limiting magnitudes (none if equal) */
-int sortmag; /* Magnitude by which to sort (1 or 2) */
-int nstarmax; /* Maximum number of stars to be returned */
-double *gnum; /* Array of Guide Star numbers (returned) */
-double *gra; /* Array of right ascensions (returned) */
-double *gdec; /* Array of declinations (returned) */
-double *gpra; /* Array of right ascension proper motions (returned) */
-double *gpdec; /* Array of declination proper motions (returned) */
-double **gmag; /* Array of b and v magnitudes (returned) */
-int *gtype; /* Array of object types (returned) */
-int nlog; /* 1 for diagnostics */
-{
- double ra1,ra2; /* Limiting right ascensions of region in degrees */
- double dec1,dec2; /* Limiting declinations of region in degrees */
- double dist = 0.0; /* Distance from search center in degrees */
- double faintmag=0.0; /* Faintest magnitude */
- double maxdist=0.0; /* Largest distance */
- int faintstar=0; /* Faintest star */
- int farstar=0; /* Most distant star */
- int nz; /* Number of UCAC regions in search */
- int zlist[MAXZONE]; /* List of region numbers */
- int sysref = WCS_J2000; /* Catalog coordinate system */
- double eqref = 2000.0; /* Catalog equinox */
- double epref = 2000.0; /* Catalog epoch */
- double secmarg = 60.0; /* Arcsec/century margin for proper motion */
- struct StarCat *starcat; /* Star catalog data structure */
- struct Star *star; /* Single star cata structure */
- double errra, errdec, errpmr, errpmd;
- int nim, ncat;
- int verbose;
- int wrap;
- int iz;
- int magsort;
- int jstar;
- int nrmax = MAXZONE;
- int nstar,i, ntot, imag;
- int istar, istar1, istar2;
- int jtable,iwrap, nread;
- int pass;
- int zone;
- int pole;
- int nmag, nmag1;
- double num, ra, dec, rapm, decpm, mag;
- double rra1, rra2, rdec1, rdec2;
- double rdist, ddist;
- char cstr[32], rastr[32], decstr[32];
- char ucacenv[16];
- char *str;
-
- ntot = 0;
- if (nlog > 0)
- verbose = 1;
- else
- verbose = 0;
-
- /* Set catalog code and path to catalog */
- if (strncmp (refcatname,"ucac2",5)==0 ||
- strncmp (refcatname,"UCAC2",5)==0) {
- ucat = UCAC2;
- ucacpath = ucac2path;
- strcpy (ucacenv, "UCAC2_PATH");
- nmag = 4;
- nmag1 = 4;
- }
- else if (strncmp (refcatname,"ucac3",5)==0 ||
- strncmp (refcatname,"UCAC3",5)==0) {
- ucat = UCAC3;
- ucacpath = ucac3path;
- strcpy (ucacenv, "UCAC3_PATH");
- nmag = 8;
- nmag1 = 12;
- }
- else {
- ucat = UCAC1;
- ucacpath = ucac1path;
- strcpy (ucacenv, "UCAC1_PATH");
- nmag = 1;
- nmag1 = 1;
- }
-
- /* If pathname is set in environment, override local value */
- if ((str = getenv (ucacenv)) != NULL )
- ucacpath = str;
-
- /* If pathname is a URL, search and return */
- if (!strncmp (ucacpath, "http:",5)) {
- return (webread (ucacpath,refcatname,distsort,cra,cdec,dra,ddec,drad,
- dradi,sysout,eqout,epout,mag1,mag2,sortmag,nstarmax,
- gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog));
- }
-
- wcscstr (cstr, sysout, eqout, epout);
-
- SearchLim (cra,cdec,dra,ddec,sysout,&ra1,&ra2,&dec1,&dec2,verbose);
-
- /* Set pole flag if search crosses north or south pole */
- if (cdec + ddec > 90.0)
- pole = 1;
- else if (cdec - ddec < -90.0)
- pole = 2;
- else
- pole = 0;
-
- /* Make mag1 always the smallest magnitude */
- if (mag2 < mag1) {
- mag = mag2;
- mag2 = mag1;
- mag1 = mag;
- }
-
- if (sortmag < 1)
- magsort = 0;
- else if (sortmag > nmag)
- magsort = nmag - 1;
- else
- magsort = sortmag - 1;
-
- /* Allocate table for distances of stars from search center */
- if (nstarmax > ndist) {
- if (ndist > 0)
- free ((void *)gdist);
- gdist = (double *) malloc (nstarmax * sizeof (double));
- if (gdist == NULL) {
- fprintf (stderr,"UCACREAD: cannot allocate separation array\n");
- return (0);
- }
- ndist = nstarmax;
- }
-
- /* Allocate catalog entry buffer */
- star = (struct Star *) calloc (1, sizeof (struct Star));
- star->num = 0.0;
-
- nstar = 0;
- jstar = 0;
-
- /* Get RA and Dec limits in catalog (J2000) coordinates */
- rra1 = ra1;
- rra2 = ra2;
- rdec1 = dec1;
- rdec2 = dec2;
- RefLim (cra,cdec,dra,ddec,sysout,sysref,eqout,eqref,epout,epref,secmarg,
- &rra1, &rra2, &rdec1, &rdec2, &wrap, verbose);
-
- /* Find UCAC Star Catalog zones in which to search */
- nz = ucaczones (rdec1,rdec2,nrmax,zlist,verbose);
- if (nz <= 0) {
- fprintf (stderr,"UCACREAD: no UCAC zone for %.2f-%.2f %.2f %.2f\n",
- rra1, rra2, rdec1, rdec2);
- return (0);
- }
-
- /* Write header if printing star entries as found */
- if (nstarmax < 1) {
- char *revmessage;
- revmessage = getrevmsg();
- printf ("catalog UCAC1\n");
- ra2str (rastr, 31, cra, 3);
- printf ("ra %s\n", rastr);
- dec2str (decstr, 31, cdec, 2);
- printf ("dec %s\n", decstr);
- printf ("rpmunit mas/year\n");
- printf ("dpmunit mas/year\n");
- if (drad != 0.0) {
- printf ("radmin %.1f\n", drad*60.0);
- if (dradi > 0)
- printf ("radimin %.1f\n", dradi*60.0);
- }
- else {
- printf ("dramin %.1f\n", dra*60.0* cosdeg (cdec));
- printf ("ddecmin %.1f\n", ddec*60.0);
- }
- printf ("radecsys %s\n", cstr);
- printf ("equinox %.3f\n", eqout);
- printf ("epoch %.3f\n", epout);
- printf ("program scat %s\n", revmessage);
- printf ("ucac_id ra dec ");
- if (ucat == UCAC1) {
- printf ("mag ura udec arcmin\n");
- printf ("---------- ------------ ------------ ");
- printf ("----- ------ ------ ------\n");
- }
- else if (ucat == UCAC2) {
- printf ("raerr decerr magc ");
- printf ("magj magh magk mag ");
- printf ("pmra pmdec pmrerr pmderr ");
- printf ("ni nc arcsec\n");
- printf ("---------- ------------ ------------ ");
- printf ("------ ------ ----- ----- ----- ");
- printf ("----- ----- ------ ------ ----- ----- ");
- printf ("-- -- ------\n");
- }
- else if (ucat == UCAC3) {
- printf ("raerr decerr magb magr magi ");
- printf ("magj magh magk maga magm ");
- printf ("mag pmra pmdec pmrerr pmderr ");
- printf ("ni nc arcsec\n");
- printf ("---------- ------------ ------------ ");
- printf ("------ ------ ----- ------ ----- ");
- printf ("----- ----- ----- ----- ----- ");
- printf ("----- ----- ----- ------ ------ ");
- printf ("-- -- ------\n");
- }
- }
-
- /* Loop through zone list */
- nstar = 0;
- for (iz = 0; iz < nz; iz++) {
-
- /* Get path to zone catalog */
- zone = zlist[iz];
- if ((starcat = ucacopen (zone)) != 0) {
-
- jstar = 0;
- jtable = 0;
- for (iwrap = 0; iwrap <= wrap; iwrap++) {
-
- /* Find first star based on RA */
- if (pole || (iwrap && wrap))
- istar1 = 1;
- else {
- istar1 = ucacsra (starcat, star, zone, rra1);
- if (istar1 > 5)
- istar1 = istar1 - 5;
- else
- istar1 = 1;
- }
-
- /* Find last star based on RA */
- if (pole || (!iwrap && wrap))
- istar2 = starcat->nstars;
- else {
- istar2 = ucacsra (starcat, star, zone, rra2);
- if (istar2 < starcat->nstars - 5)
- istar2 = istar2 + 5;
- else
- istar2 = starcat->nstars;
- }
-
- if (istar1 == 0 || istar2 == 0)
- break;
-
- nread = istar2 - istar1 + 1;
-
- /* Loop through zone catalog for this region */
- for (istar = istar1; istar <= istar2; istar++) {
- jtable ++;
-
- if (ucacstar (starcat, star, zone, istar)) {
- fprintf(stderr,"UCACREAD: Cannot read star %d\n",istar);
- break;
- }
-
- /* ID number */
- num = star->num;
-
- /* Magnitude */
- mag = star->xmag[magsort];
-
- /* Check magnitude limits */
- pass = 1;
- if (mag1 != mag2 && (mag < mag1 || mag > mag2))
- pass = 0;
-
- /* Check position limits */
- if (pass) {
-
- /* Get position in output coordinate system */
- ra = star->ra;
- dec = star->dec;
- rapm = star->rapm;
- decpm = star->decpm;
- errra = star->errra;
- errdec = star->errdec;
- errpmr = star->errpmr;
- errpmd = star->errpmd;
- nim = star->nimage;
- ncat = star->ncat;
- wcsconp (sysref, sysout, eqref, eqout, epref, epout,
- &ra, &dec, &rapm, &decpm);
-
- /* Compute distance from search center */
- if (drad > 0 || distsort) {
- dist = wcsdist (cra,cdec,ra,dec);
- }
- else {
- dist = 0.0;
- }
-
- /* Check radial distance to search center */
- if (drad > 0) {
- if (dist > drad) {
- if (nstarmax > 0)
- pass = 0;
- }
- if (dradi > 0.0 && dist < dradi) {
- if (nstarmax > 0)
- pass = 0;
- }
- }
-
- /* Check distance along RA and Dec axes */
- else {
- ddist = wcsdist (cra,cdec,cra,dec);
- if (ddist > ddec) {
- if (nstarmax > 0)
- pass = 0;
- }
- rdist = wcsdist (cra,dec,ra,dec);
- if (rdist > dra) {
- if (nstarmax > 0)
- pass = 0;
- }
- }
- }
-
- if (pass) {
-
- /* Write star position and magnitude to stdout */
- if (nstarmax < 1) {
- ra2str (rastr, 31, ra, 3);
- dec2str (decstr, 31, dec, 2);
- dist = wcsdist (cra,cdec,ra,dec) * 3600.0;
- printf ("%010.6f %s %s", num,rastr,decstr);
- if (ucat == UCAC2 || ucat == UCAC3)
- printf (" %5.3f %5.3f",
- errra * 3600.0 * cosdeg (dec), errdec * 3600.0);
- if (ucat == UCAC1)
- printf (" %5.2f", mag);
- else
- printf (" %5.2f %5.2f %5.2f %5.2f",
- star->xmag[0], star->xmag[1],
- star->xmag[2], star->xmag[3]);
- if (ucat == UCAC3)
- printf (" %5.2f %5.2f %5.2f %5.2f",
- star->xmag[4], star->xmag[5],
- star->xmag[6], star->xmag[7]);
- printf (" %5.2f %6.1f %6.1f",
- mag, rapm*3600000.0*cosdeg (dec), decpm*3600000.0);
- printf (" %6.1f %6.1f",
- errpmr*3600000.0, errpmd*3600000.0);
- printf (" %2d %2d %.3f\n",
- nim, ncat, dist);
- }
-
- /* Save star position and magnitude in table */
- else if (nstar < nstarmax) {
- gnum[nstar] = num;
- gra[nstar] = ra;
- gdec[nstar] = dec;
- gpra[nstar] = rapm;
- gpdec[nstar] = decpm;
- if (ucat == UCAC1)
- gmag[0][nstar] = mag;
- else {
- for (imag = 0; imag < nmag; imag++)
- gmag[imag][nstar] = star->xmag[imag];
-
- gmag[nmag][nstar] = star->errra;
- gmag[nmag+1][nstar] = star->errdec;
- gmag[nmag+2][nstar] = star->errpmr;
- gmag[nmag+3][nstar] = star->errpmd;
- gtype[nstar] = (1000 * nim) + ncat;
- }
- gdist[nstar] = dist;
- if (dist > maxdist) {
- maxdist = dist;
- farstar = nstar;
- }
- if (mag > faintmag) {
- faintmag = mag;
- faintstar = nstar;
- }
- }
-
- /* If too many stars and distance sorting,
- replace farthest star */
- else if (distsort) {
- if (dist < maxdist) {
- gnum[farstar] = num;
- gra[farstar] = ra;
- gdec[farstar] = dec;
- gpra[farstar] = rapm;
- gpdec[farstar] = decpm;
- if (ucat == UCAC1)
- gmag[0][farstar] = mag;
- else {
- for (imag = 0; imag < nmag; imag++)
- gmag[imag][farstar] = star->xmag[imag];
- gmag[nmag][farstar] = star->errra;
- gmag[nmag+1][farstar] = star->errdec;
- gmag[nmag+2][farstar] = star->errpmr;
- gmag[nmag+3][farstar] = star->errpmd;
- gtype[farstar] = (1000 * nim) + ncat;
- }
- gdist[farstar] = dist;
-
- /* Find new farthest star */
- maxdist = 0.0;
- for (i = 0; i < nstarmax; i++) {
- if (gdist[i] > maxdist) {
- maxdist = gdist[i];
- farstar = i;
- }
- }
- }
- }
-
- /* Else if too many stars, replace faintest star */
- else if (mag < faintmag) {
- gnum[faintstar] = num;
- gra[faintstar] = ra;
- gdec[faintstar] = dec;
- gpra[faintstar] = rapm;
- gpdec[faintstar] = decpm;
- if (ucat == UCAC1)
- gmag[0][faintstar] = mag;
- else {
- for (imag = 0; imag < nmag; imag++)
- gmag[imag][faintstar] = star->xmag[imag];
- gmag[nmag][faintstar] = star->errra;
- gmag[nmag+1][faintstar] = star->errdec;
- gmag[nmag+2][faintstar] = star->errpmr;
- gmag[nmag+3][faintstar] = star->errpmd;
- gtype[faintstar] = (1000 * nim) + ncat;
- }
- gdist[faintstar] = dist;
- faintmag = 0.0;
-
- /* Find new faintest star */
- for (i = 0; i < nstarmax; i++) {
- if (gmag[magsort][i] > faintmag) {
- faintmag = gmag[magsort][i];
- faintstar = i;
- }
- }
- }
-
- nstar++;
- if (nlog == 1)
- fprintf (stderr,"UCACREAD: %11.6f: %9.5f %9.5f %5.2f\n",
- num,ra,dec,mag);
-
- /* End of accepted star processing */
- }
-
- /* Log operation */
- jstar++;
- if (nlog > 0 && istar%nlog == 0)
- fprintf (stderr,"UCACREAD: %5d / %5d / %5d sources\r",
- nstar,jstar,starcat->nstars);
-
- /* End of star loop */
- }
-
- /* End of 0:00 RA wrap loop */
- }
-
- /* End of successful zone file loop */
- ntot = ntot + starcat->nstars;
- if (nlog > 0)
- fprintf (stderr,"UCACREAD: %4d / %4d: %5d / %5d / %5d sources from zone %4d \n",
- iz+1,nz,nstar,jstar,starcat->nstars,zlist[iz]);
-
- /* Close region input file */
- ucacclose (starcat);
- }
-
- /* End of zone loop */
- }
-
- /* Summarize transfer */
- if (nlog > 0) {
- if (nz > 1)
- fprintf (stderr,"UCACREAD: %d zones: %d / %d found\n",nz,nstar,ntot);
- else
- fprintf (stderr,"UCACREAD: 1 region: %d / %d found\n",nstar,ntot);
- if (nstar > nstarmax)
- fprintf (stderr,"UCACREAD: %d stars found; only %d returned\n",
- nstar,nstarmax);
- }
- return (nstar);
-}
-
-/* UCACRNUM -- Read HST Guide Star Catalog stars from CDROM */
-
-int
-ucacrnum (refcatname,nstars,sysout,eqout,epout,
- gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog)
-
-char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
-int nstars; /* Number of stars to find */
-int sysout; /* Search coordinate system */
-double eqout; /* Search coordinate equinox */
-double epout; /* Proper motion epoch (0.0 for no proper motion) */
-double *gnum; /* Array of Guide Star numbers (returned) */
-double *gra; /* Array of right ascensions (returned) */
-double *gdec; /* Array of declinations (returned) */
-double *gpra; /* Array of right ascension proper motions (returned) */
-double *gpdec; /* Array of declination proper motions (returned) */
-double **gmag; /* Array of B and V magnitudes (returned) */
-int *gtype; /* Array of object types (returned) */
-int nlog; /* 1 for diagnostics */
-{
- int sysref=WCS_J2000; /* Catalog coordinate system */
- double eqref=2000.0; /* Catalog equinox */
- double epref=2000.0; /* Catalog epoch */
- struct StarCat *starcat;
- struct Star *star;
- char *str;
- char ucacenv[16];
-
- int verbose;
- int zone, zone0;
- int jstar, imag, nmag, nmag1;
- int istar, nstar;
- double num, ra, dec, rapm, decpm, mag;
-
- if (nlog == 1)
- verbose = 1;
- else
- verbose = 0;
-
- /* Set catalog code and path to catalog */
- if (strncmp (refcatname,"ucac3",5)==0 ||
- strncmp (refcatname,"UCAC3",5)==0) {
- ucat = UCAC3;
- ucacpath = ucac3path;
- strcpy (ucacenv, "UCAC3_PATH");
- nmag = 8;
- nmag1 = 12;
- }
- else if (strncmp (refcatname,"ucac2",5)==0 ||
- strncmp (refcatname,"UCAC2",5)==0) {
- ucat = UCAC2;
- ucacpath = ucac2path;
- strcpy (ucacenv, "UCAC2_PATH");
- nmag = 4;
- nmag1 = 4;
- }
- else {
- ucat = UCAC1;
- ucacpath = ucac1path;
- strcpy (ucacenv, "UCAC1_PATH");
- nmag = 1;
- nmag1 = 1;
- }
-
- /* If pathname is set in environment, override local value */
- if ((str = getenv(ucacenv)) != NULL )
- ucacpath = str;
-
- /* If pathname is a URL, search and return */
- if (!strncmp (ucacpath, "http:",5))
- return (webrnum (ucacpath,refcatname,nstars,sysout,eqout,epout,1,
- gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog));
-
- /* Allocate catalog entry buffer */
- star = (struct Star *) calloc (1, sizeof (struct Star));
- star->num = 0.0;
- nstar = 0;
- zone0 = 0;
- starcat = NULL;
-
-/* Loop through star list */
- for (jstar = 0; jstar < nstars; jstar++) {
- zone = (int) (gnum[jstar] + 0.0000001);
-
- /* Find numbered stars (rrr.nnnnnn) */
- istar = (int) ((gnum[jstar] - (double) zone + 0.0000001) * 1000000.0);
- if (istar > 0) {
- if (zone != zone0) {
- if (starcat != NULL)
- ucacclose (starcat);
- starcat = ucacopen (zone);
- }
- if (starcat == NULL) {
- fprintf (stderr,"UCACRNUM: Zone %d file not found\n", zone);
- return (0);
- }
- if (ucacstar (starcat, star, zone, istar)) {
- fprintf (stderr,"UCACRNUM: Cannot read star %d.%06d\n", zone, istar);
- gra[jstar] = 0.0;
- gdec[jstar] = 0.0;
- if (ucat == UCAC1)
- gmag[0][jstar] = 0.0;
- else {
- for (imag = 0; imag < nmag; imag++)
- gmag[imag][jstar] = 0.0;
- }
- gtype[jstar] = 0;
- continue;
- }
-
- /* If star has been found in catalog */
-
- /* ID number */
- num = star->num;
-
- /* Position in degrees at designated epoch */
- ra = star->ra;
- dec = star->dec;
- rapm = star->rapm;
- decpm = star->decpm;
- wcsconp (sysref, sysout, eqref, eqout, epref, epout,
- &ra, &dec, &rapm, &decpm);
-
- /* Magnitude */
- mag = star->xmag[0];
-
- /* Save star position and magnitude in table */
- gnum[jstar] = num;
- gra[jstar] = ra;
- gdec[jstar] = dec;
- gpra[jstar] = rapm;
- gpdec[jstar] = decpm;
- gmag[0][jstar] = mag;
- gtype[jstar] = (1000 * star->nimage) + star->ncat;
- if (ucat == UCAC1)
- gmag[0][jstar] = star->xmag[0];
- else {
- for (imag = 0; imag < nmag; imag++)
- gmag[imag][jstar] = star->xmag[imag];
- gmag[nmag][jstar] = star->errra;
- gmag[nmag+1][jstar] = star->errdec;
- gmag[nmag+2][jstar] = star->errpmr;
- gmag[nmag+3][jstar] = star->errpmd;
- gtype[jstar] = (1000 * star->nimage) + star->ncat;
- }
- if (nlog == 1) {
- if (ucat == UCAC1)
- fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f %s \n",
- num, ra, dec, mag, star->isp);
- else if (ucat == UCAC2) {
- fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f",
- num, ra, dec, star->xmag[0]);
- fprintf (stderr," %5.2f %5.2f %5.2f",
- star->xmag[1],star->xmag[2],star->xmag[3]);
- fprintf (stderr," %d %d\n",star->nimage,star->ncat);
- }
- else
- fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f %5.2f",
- num, ra, dec, star->xmag[0],star->xmag[1]);
- fprintf (stderr," %5.2f %5.2f %5.2f",
- star->xmag[2], star->xmag[3], star->xmag[4]);
- fprintf (stderr," %5.2f %5.2f %5.2f",
- star->xmag[5], star->xmag[6], star->xmag[7]);
- fprintf (stderr," %d %d\n",star->nimage,star->ncat);
- }
- }
-
- /* End of star loop */
- }
-
-/* Summarize search */
- ucacclose (starcat);
- if (nlog > 0)
- fprintf (stderr,"UCACRNUM: %d / %d found\n",nstar,starcat->nstars);
-
- return (nstars);
-}
-
-
-/* UCACBIN -- Fill a FITS WCS image with UCAC Star Catalog stars */
-
-int
-ucacbin (refcatname, wcs, header, image, mag1, mag2, sortmag, magscale, nlog)
-
-char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
-struct WorldCoor *wcs; /* World coordinate system for image */
-char *header; /* FITS header for output image */
-char *image; /* Output FITS image */
-double mag1,mag2; /* Limiting magnitudes (none if equal) */
-int sortmag; /* Magnitude by which to sort (1 or 2) */
-double magscale; /* Scaling factor for magnitude to pixel flux
- * (number of catalog objects per bin if 0) */
-int nlog; /* 1 for diagnostics */
-{
- double cra; /* Search center J2000 right ascension in degrees */
- double cdec; /* Search center J2000 declination in degrees */
- double dra; /* Search half width in right ascension in degrees */
- double ddec; /* Search half-width in declination in degrees */
- int sysout; /* Search coordinate system */
- double eqout; /* Search coordinate equinox */
- double epout; /* Proper motion epoch (0.0 for no proper motion) */
- double ra1,ra2; /* Limiting right ascensions of region in degrees */
- double dec1,dec2; /* Limiting declinations of region in degrees */
- int nz; /* Number of UCAC regions in search */
- int zlist[MAXZONE]; /* List of region numbers */
- int sysref = WCS_J2000; /* Catalog coordinate system */
- double eqref = 2000.0; /* Catalog equinox */
- double epref = 2000.0; /* Catalog epoch */
- double secmarg = 60.0; /* Arcsec/century margin for proper motion */
- struct StarCat *starcat; /* Star catalog data structure */
- struct Star *star; /* Single star cata structure */
- int verbose;
- int wrap;
- int ix, iy, iz;
- int magsort;
- int jstar;
- int nrmax = MAXZONE;
- int nstar, ntot;
- int istar, istar1, istar2;
- int jtable,iwrap, nread;
- int pass;
- int zone;
- double num, ra, dec, rapm, decpm, mag;
- double rra1, rra2, rdec1, rdec2;
- double rdist, ddist;
- char cstr[32];
- char ucacenv[16];
- char *str;
- double xpix, ypix, flux;
- int offscl;
- int bitpix, w, h; /* Image bits/pixel and pixel width and height */
- double logt = log(10.0);
-
- ntot = 0;
- if (nlog > 0)
- verbose = 1;
- else
- verbose = 0;
-
- /* Set catalog code and path to catalog */
- if (strncmp (refcatname,"ucac3",5)==0 ||
- strncmp (refcatname,"UCAC3",5)==0) {
- ucat = UCAC3;
- ucacpath = ucac3path;
- strcpy (ucacenv, "UCAC3_PATH");
- }
- else if (strncmp (refcatname,"ucac2",5)==0 ||
- strncmp (refcatname,"UCAC2",5)==0) {
- ucat = UCAC2;
- ucacpath = ucac2path;
- strcpy (ucacenv, "UCAC2_PATH");
- }
- else {
- ucat = UCAC1;
- ucacpath = ucac1path;
- strcpy (ucacenv, "UCAC1_PATH");
- }
-
- /* If pathname is set in environment, override local value */
- if ((str = getenv (ucacenv)) != NULL )
- ucacpath = str;
-
- /* Set image parameters */
- bitpix = 0;
- (void)hgeti4 (header, "BITPIX", &bitpix);
- w = 0;
- (void)hgeti4 (header, "NAXIS1", &w);
- h = 0;
- (void)hgeti4 (header, "NAXIS2", &h);
-
- /* Set catalog search limits from image WCS information */
- sysout = wcs->syswcs;
- eqout = wcs->equinox;
- epout = wcs->epoch;
- wcscstr (cstr, sysout, eqout, epout);
- wcssize (wcs, &cra, &cdec, &dra, &ddec);
- SearchLim (cra,cdec,dra,ddec,sysout,&ra1,&ra2,&dec1,&dec2,verbose);
-
- /* Make mag1 always the smallest magnitude */
- if (mag2 < mag1) {
- mag = mag2;
- mag2 = mag1;
- mag1 = mag;
- }
-
- if (sortmag < 1)
- magsort = 0;
- else if (sortmag > 4)
- magsort = 3;
- else
- magsort = sortmag - 1;
-
- /* Allocate catalog entry buffer */
- star = (struct Star *) calloc (1, sizeof (struct Star));
- star->num = 0.0;
-
- nstar = 0;
- jstar = 0;
-
- /* Get RA and Dec limits in catalog (J2000) coordinates */
- rra1 = ra1;
- rra2 = ra2;
- rdec1 = dec1;
- rdec2 = dec2;
- RefLim (cra,cdec,dra,ddec,sysout,sysref,eqout,eqref,epout,epref,secmarg,
- &rra1, &rra2, &rdec1, &rdec2, &wrap, verbose);
-
- /* Find UCAC Star Catalog zones in which to search */
- nz = ucaczones (rdec1,rdec2,nrmax,zlist,verbose);
- if (nz <= 0) {
- fprintf (stderr,"UCACBIN: no UCAC zone for %.2f-%.2f %.2f %.2f\n",
- rra1, rra2, rdec1, rdec2);
- return (0);
- }
-
- /* Loop through zone list */
- nstar = 0;
- for (iz = 0; iz < nz; iz++) {
-
- /* Get path to zone catalog */
- zone = zlist[iz];
- if ((starcat = ucacopen (zone)) != 0) {
-
- jstar = 0;
- jtable = 0;
- for (iwrap = 0; iwrap <= wrap; iwrap++) {
-
- /* Find first star based on RA */
- if (iwrap == 0 || wrap == 0)
- istar1 = ucacsra (starcat, star, zone, rra1);
- else
- istar1 = 1;
-
- /* Find last star based on RA */
- if (iwrap == 1 || wrap == 0)
- istar2 = ucacsra (starcat, star, zone, rra2);
- else
- istar2 = starcat->nstars;
-
- if (istar1 == 0 || istar2 == 0)
- break;
-
- nread = istar2 - istar1 + 1;
-
- /* Loop through zone catalog for this region */
- for (istar = istar1; istar <= istar2; istar++) {
- jtable ++;
-
- if (ucacstar (starcat, star, zone, istar)) {
- fprintf(stderr,"UCACBIN: Cannot read star %d\n",istar);
- break;
- }
-
- /* ID number */
- num = star->num;
-
- /* Magnitude */
- mag = star->xmag[magsort];
-
- /* Check magnitude limits */
- pass = 1;
- if (mag1 != mag2 && (mag < mag1 || mag > mag2))
- pass = 0;
-
- /* Check position limits */
- if (pass) {
-
- /* Get position in output coordinate system */
- rapm = star->rapm;
- decpm = star->decpm;
- ra = star->ra;
- dec = star->dec;
- wcsconp (sysref, sysout, eqref, eqout, epref, epout,
- &ra, &dec, &rapm, &decpm);
-
- /* Check distance along RA and Dec axes */
- ddist = wcsdist (cra,cdec,cra,dec);
- if (ddist > ddec)
- pass = 0;
- rdist = wcsdist (cra,dec,ra,dec);
- if (rdist > dra)
- pass = 0;
- }
-
- /* Save star in FITS image */
- if (pass) {
- wcs2pix (wcs, ra, dec, &xpix, &ypix, &offscl);
- if (!offscl) {
- if (magscale > 0.0)
- flux = magscale * exp (logt * (-mag / 2.5));
- else
- flux = 1.0;
- ix = (int) (xpix + 0.5);
- iy = (int) (ypix + 0.5);
- addpix1 (image, bitpix, w,h, 0.0,1.0, xpix,ypix, flux);
- nstar++;
- jstar++;
- }
- else {
- ix = 0;
- iy = 0;
- }
- if (nlog == 1) {
- fprintf (stderr,"UCACBIN: %11.6f: %9.5f %9.5f %s",
- num,ra,dec,cstr);
- if (magscale > 0.0)
- fprintf (stderr, " %5.2f", mag);
- if (!offscl)
- flux = getpix1 (image, bitpix, w, h, 0.0, 1.0, ix, iy);
- else
- flux = 0.0;
- fprintf (stderr," (%d,%d): %f\n", ix, iy, flux);
- }
-
- /* End of accepted star processing */
- }
-
- /* Log operation */
- jstar++;
- if (nlog > 0 && istar%nlog == 0)
- fprintf (stderr,"UCACBIN: %5d / %5d / %5d sources\r",
- nstar,jstar,starcat->nstars);
-
- /* End of star loop */
- }
-
- /* End of 0:00 RA wrap loop */
- }
-
- /* End of successful zone file loop */
- ntot = ntot + starcat->nstars;
- if (nlog > 0)
- fprintf (stderr,"UCACBIN: %4d / %4d: %5d / %5d / %5d sources from zone %4d \n",
- iz+1,nz,nstar,jstar,starcat->nstars,zlist[iz]);
-
- /* Close region input file */
- ucacclose (starcat);
- }
-
- /* End of zone loop */
- }
-
- /* Summarize transfer */
- if (nlog > 0) {
- if (nz > 1)
- fprintf (stderr,"UCACBIN: %d zones: %d / %d found\n",nz,nstar,ntot);
- else
- fprintf (stderr,"UCACBIN: 1 region: %d / %d found\n",nstar,ntot);
- }
- return (nstar);
-}
-
-
-/* UCACZONE -- Compute the zones over which to search
- * in the specified range of coordinates.
- * Build lists containing the first star and number of stars for each range.
- */
-
-static int
-ucaczones (dec1, dec2, nzmax, zones, verbose)
-
-double dec1, dec2; /* Declination limits in degrees */
-int nzmax; /* Maximum number of zones to find */
-int *zones; /* Zone numbers (returned)*/
-int verbose; /* 1 for diagnostics */
-
-{
- int nz; /* Number of declination zones found (returned) */
- int iz, iz1, iz2;
- int i;
- double spd1, spd2;
-
- for (i = 0; i < nzmax; i++)
- zones[i] = 0;
-
-/* Find first and last declination zone to search */
- spd1 = 90.0 + dec1;
- iz1 = (int) ((spd1 * 2.0) + 0.99999);
- if (iz1 < 1) iz1 = 1;
- spd2 = 90.0 + dec2;
- iz2 = (int) ((spd2 * 2.0) + 0.99999);
- if (ucat == UCAC1 && iz2 > 169) iz2 = 169;
- if (ucat == UCAC2 && iz2 > 288) iz2 = 288;
- if (ucat == UCAC3 && iz2 > 360) iz2 = 360;
- if (iz1 > iz2)
- return (0);
-
- nz = iz2 - iz1 + 1;
- if (verbose) {
- fprintf (stderr,"UCACZONES: searching %d zones: %d - %d\n",nz,iz1,iz2);
- fprintf(stderr,"UCACZONES: Dec: %.5f - %.5f\n", dec1,dec2);
- }
-
- i = 0;
- for (iz = iz1; iz <= iz2; iz++) {
- zones[i] = iz;
- i++;
- }
-
- return (nz);
-}
-
-
-/* UCACSRA -- Find UCAC star closest to specified right ascension */
-
-static int
-ucacsra (sc, st, zone, rax0)
-
-struct StarCat *sc; /* Star catalog descriptor */
-struct Star *st; /* Current star entry */
-int zone; /* Declination zone */
-double rax0; /* Right ascension in degrees for which to search */
-{
- int istar, istar1, istar2, nrep;
- double rax, ra1, ra, rdiff, rdiff1, rdiff2, sdiff;
- char rastrx[32];
- int debug = 0;
- int maxrep = 100;
- int binary = 0;
-
- rax = rax0;
- if (debug)
- ra2str (rastrx, 31, rax, 3);
- istar1 = 1;
- ucacstar (sc, st, zone, istar1);
- ra1 = st->ra;
- if (ra1 < 0.0000001)
- ra1 = 360.0;
- nrep = 0;
- if (debug) {
- char rastr[32];
- ra2str (rastr, 31, ra1, 3);
- fprintf (stderr,"UCACSRA %d %d: %s (%s)\n",
- nrep,istar1,rastr,rastrx);
- }
- istar = sc->nstars;
- while (istar != istar1 && nrep < maxrep) {
- if (ucacstar (sc, st, zone, istar)) {
- if (debug) {
- fprintf (stderr," no star at %d\n", istar);
- }
- break;
- }
- else {
- ra = st->ra;
- if (ra < 0.0000001)
- ra = 360.0;
- if (debug) {
- char rastr[32];
- ra2str (rastr, 31, ra, 3);
- fprintf (stderr,"UCACSRA %d %d: %s (%s)\n",
- nrep,istar,rastr,rastrx);
- }
- if (ra == ra1) {
- if (debug) {
- fprintf (stderr," ra1= %.5f ra= %.5f rax= %.5f\n",
- ra1,ra,rax);
- fprintf (stderr," rdiff= %.5f rdiff1= %.5f rdiff2= %.5f\n",
- rdiff,rdiff1,rdiff2);
- fprintf (stderr, "ra == ra1 break\n");
- }
- break;
- }
- rdiff = ra1 - ra;
- rdiff1 = ra1 - rax;
- rdiff2 = ra - rax;
- /* if (nrep > 20 && ABS (rdiff2) < 0.01) && ABS(rdiff2) > ABS(rdiff1)) { */
- /* istar = istar1; */
- if (ABS (rdiff2) < 0.005) {
- if (debug) {
- fprintf (stderr," ra1= %.5f ra= %.5f rax= %.5f\n",
- ra1,ra,rax);
- fprintf (stderr," rdiff= %.5f rdiff1= %.5f rdiff2= %.5f\n",
- rdiff,rdiff1,rdiff2);
- fprintf (stderr, "nrep= %d, abs(rdiff2) = %.5f\n",
- nrep, ABS(rdiff2));
- }
- break;
- }
- nrep++;
- sdiff = (double)(istar - istar1) * rdiff1 / rdiff;
- if (sdiff > 0)
- istar2 = istar1 + (int) (sdiff + 0.5);
- else
- istar2 = istar1 + (int) (sdiff - 0.5);
-
- /* If RA distribution is skewed, switch to binary search */
- if (binary || istar2 < 1 || istar2 > sc->nstars) {
- binary = 1;
- if (ABS (rdiff2) < ABS (rdiff1)) {
- if (ra < rax)
- istar2 = istar1 + (ABS (istar1 - istar) / 2);
- else
- istar2 = istar1 - (ABS (istar1 - istar) / 2);
- }
- else {
- if (ra1 < rax)
- istar2 = istar1 + (ABS (istar1 - istar) / 2);
- else
- istar2 = istar1 - (ABS (istar1 - istar) / 2);
- }
- }
-
- if (debug) {
- fprintf (stderr," ra1= %.5f ra= %.5f rax= %.5f\n",
- ra1,ra,rax);
- fprintf (stderr," rdiff= %.5f rdiff1= %.5f rdiff2= %.5f\n",
- rdiff,rdiff1,rdiff2);
- fprintf (stderr," istar1= %d istar= %d istar2= %d\n",
- istar1,istar,istar2);
- }
- if (istar1 == istar2)
- break;
- ra1 = ra;
- istar1 = istar;
- istar = istar2;
- if (istar == istar1)
- break;
- }
- }
- return (istar);
-}
-
-
-/* UCACOPEN -- Open UCAC catalog file, returning number of entries */
-
-struct StarCat *
-ucacopen (zone)
-
-int zone; /* Number of catalog zone to read */
-
-{
- FILE *fcat;
- struct StarCat *sc;
- int lfile, lpath;
- char *zonefile;
- char *zonepath; /* Full pathname for catalog file */
-
- /* Set pathname for catalog file */
- lpath = strlen (ucacpath) + 16;
- zonepath = (char *) malloc (lpath);
- if (ucat == UCAC1)
- sprintf (zonepath, "%s/u1/z%03d", ucacpath, zone);
- else if (ucat == UCAC2)
- sprintf (zonepath, "%s/u2/z%03d", ucacpath, zone);
- else
- sprintf (zonepath, "%s/z%03d", ucacpath, zone);
-
- /* Set UCAC catalog header information */
- sc = (struct StarCat *) calloc (1, sizeof (struct StarCat));
- sc->byteswapped = 0;
-
- /* Set number of stars in this zone catalog */
- if (ucat == UCAC1)
- sc->nbent = 67;
- else if (ucat == UCAC2)
- sc->nbent = 44;
- else
- sc->nbent = 84;
- lfile = getfilesize (zonepath);
- if (lfile < 2) {
- fprintf (stderr,"UCAC zone catalog %s has no entries\n",zonepath);
- free (sc);
- sc = NULL;
- return (NULL);
- }
- else
- sc->nstars = lfile / sc->nbent;
-
- /* Open UCAC file */
- if (!(fcat = fopen (zonepath, "r"))) {
- fprintf (stderr,"UCACOPEN: UCAC file %s cannot be read\n",zonepath);
- free (sc);
- return (NULL);
- }
-
- /* Separate filename from pathname and save in structure */
- zonefile = strrchr (zonepath,'/');
- if (zonefile)
- zonefile = zonefile + 1;
- else
- zonefile = zonepath;
- if (strlen (zonefile) < 24)
- strcpy (sc->isfil, zonefile);
- else
- strncpy (sc->isfil, zonefile, 23);
-
- /* Set other catalog information in structure */
- sc->inform = 'J';
- sc->coorsys = WCS_J2000;
- sc->epoch = 2000.0;
- sc->equinox = 2000.0;
- sc->ifcat = fcat;
- sc->sptype = 0;
- if (ucat == UCAC1)
- sc->nmag = 1;
- else if (ucat == UCAC2)
- sc->nmag = 4;
- else
- sc->nmag = 8;
-
- /* UCAC stars are RA-sorted within declination zones */
- sc->rasorted = 1;
-
-/* Check to see if byte-swapping is necessary */
- cswap = 0;
- if (ucat == UCAC2) {
- UCAC2star us2; /* UCAC2 catalog entry for one star */
- int nbr;
-
- nbr = fread (&us2, 1, sc->nbent, sc->ifcat);
- if (nbr < 1) {
- fprintf (stderr,
- "UCACOPEN: cannot read star 1 from UCAC2 zone catalog %s\n",
- zonepath);
- return (0);
- }
-
- /* RA should be between 0 and 360 degrees in milliarcseconds */
- if (us2.rasec > 360 * 3600000 || us2.rasec < 0)
- cswap = 1;
-
- /* Dec should be between -90 and +90 degrees in milliarcseconds */
- else if (us2.decsec > 90 * 3600000 || us2.decsec < -90 * 3600000)
- cswap = 1;
-
- /* J H K magnitudes should be near-positive */
- else if (us2.jmag < -1000 || us2.hmag < -1000 || us2.kmag < -1000)
- cswap = 1;
- else
- cswap = 0;
-
- /* if (cswap)
- fprintf (stderr,
- "UCACOPEN: swapping bytes in UCAC2 zone catalog %s\n",
- zonepath); */
- }
- else if (ucat == UCAC3) {
- UCAC3star us3; /* UCAC3 catalog entry for one star */
- int nbr;
-
- nbr = fread (&us3, 1, sc->nbent, sc->ifcat);
- if (nbr < 1) {
- fprintf (stderr,
- "UCACOPEN: cannot read star 1 from UCAC3 zone catalog %s\n",
- zonepath);
- return (0);
- }
-
- /* RA should be between 0 and 360 degrees in milliarcseconds */
- if (us3.rasec > 360 * 3600000 || us3.rasec < 0)
- cswap = 1;
-
- /* Dec should be between -90 and +90 degrees in milliarcseconds */
- else if (us3.decsec > 180 * 3600000 || us3.decsec < -180 * 3600000)
- cswap = 1;
-
- /* J H K magnitudes should be near-positive */
- else if (us3.jmag < -1000 || us3.hmag < -1000 || us3.kmag < -1000)
- cswap = 1;
- else
- cswap = 0;
-
- /* if (cswap)
- fprintf (stderr,
- "UCACOPEN: swapping bytes in UCAC2 zone catalog %s\n",zomepath); */
- }
-
- sc->istar = 0;
- free (zonepath);
- return (sc);
-}
-
-
-void
-ucacclose (sc)
-struct StarCat *sc; /* Star catalog descriptor */
-{
- fclose (sc->ifcat);
- free (sc);
- return;
-}
-
-
-/* UCACSTAR -- Get UCAC catalog entry for one star;
- return 0 if successful */
-
-static int
-ucacstar (sc, st, zone, istar)
-
-struct StarCat *sc; /* Star catalog descriptor */
-struct Star *st; /* Current star entry */
-int zone; /* Declination zone */
-int istar; /* Star sequence number in UCAC catalog region file */
-{
- char line[256];
- int nbr, nbskip;
- UCAC2star us2; /* UCAC2 catalog entry for one star */
- UCAC3star us3; /* UCAC3 catalog entry for one star */
-
- /* Drop out if catalog pointer is not set */
- if (sc == NULL)
- return (1);
-
- /* Drop out if catalog is not open */
- if (sc->ifcat == NULL)
- return (2);
-
- /* Drop out if star number is too small or too large */
- if (istar < 1 || istar > sc->nstars) {
- fprintf (stderr, "UCAC star %d is not in catalog\n",istar);
- return (-1);
- }
-
- /* Move file pointer to start of correct star entry */
- nbskip = sc->nbent * (istar - 1);
- if (fseek (sc->ifcat,nbskip,SEEK_SET))
- return (-1);
-
- if (ucat == UCAC1)
- nbr = fread (line, 1, sc->nbent, sc->ifcat);
- else if (ucat == UCAC2)
- nbr = fread (&us2, 1, sc->nbent, sc->ifcat);
- else
- nbr = fread (&us3, 1, sc->nbent, sc->ifcat);
- if (nbr < sc->nbent) {
- fprintf (stderr, "UCACSTAR %d / %d bytes read\n",nbr, sc->nbent);
- return (-2);
- }
-
- /* Star ID number = region.sequence */
- st->num = (double) zone + (0.000001 * (double) istar);
-
- /* Read UCAC1 position and proper motion from ASCII file */
- if (ucat == UCAC1) {
-
- /* Read position in degrees */
- st->ra = atof (line) / 3600000.0;
- st->dec = (atof (line+10) / 3600000.0) - 90.0;
-
- /* Read proper motion and convert it to to degrees/year */
- st->rapm = (atof (line+41) / 3600000.0) / cosdeg (st->dec);
- st->decpm = atof (line+48) / 3600000.0;
-
- /* Set V magnitude */
- st->xmag[0] = atof (line+20) * 0.01;
- }
-
- /* Read UCAC2 position, proper motion, and magnitudes from binary file */
- else if (ucat == UCAC2) {
- if (cswap) {
- ucacswap4 (&us2.rasec);
- ucacswap4 (&us2.decsec);
- ucacswap4 (&us2.rapm);
- ucacswap4 (&us2.decpm);
- ucacswap2 (&us2.cmag);
- ucacswap2 (&us2.jmag);
- ucacswap2 (&us2.hmag);
- ucacswap2 (&us2.kmag);
- }
- st->ra = (double) us2.rasec / 3600000.0;
- st->dec = (double) us2.decsec / 3600000.0;
- st->errra = (double) us2.era / 3600000.0; /* mas */
- st->errra = st->errra / cosdeg (st->dec); /* to RA deg */
- st->errdec = (double) us2.edec / 3600000.0; /* mas */
- st->rapm = (double) us2.rapm / 36000000.0; /* 0.1mas/yr */
- st->decpm = (double) us2.decpm / 36000000.0; /* 0.1mas/yr */
- st->errpmr = (double) us2.erapm / 36000000.0; /* 0.1mas/yr */
- st->errpmr = st->errpmr / cosdeg (st->dec); /* to RA deg */
- st->errpmd = (double) us2.edecpm / 36000000.0; /* 0.1mas/yr */
- st->xmag[0] = ((double) us2.jmag) / 1000.0;
- st->xmag[1] = ((double) us2.hmag) / 1000.0;
- st->xmag[2] = ((double) us2.kmag) / 1000.0;
- st->xmag[3] = ((double) us2.cmag) / 100.0;
- st->nimage = (int) us2.nobs;
- st->ncat = (int) us2.ncat;
- }
-
- /* Read UCAC3 position, proper motion, and magnitudes from binary file */
- else {
- if (cswap) {
- ucacswap4 (&us3.rasec);
- ucacswap4 (&us3.decsec);
- ucacswap4 (&us3.rapm);
- ucacswap4 (&us3.decpm);
- ucacswap2 (&us3.sigra);
- ucacswap2 (&us3.sigdec);
- ucacswap2 (&us3.sigpmr);
- ucacswap2 (&us3.sigpmd);
- ucacswap2 (&us3.mmag);
- ucacswap2 (&us3.amag);
- ucacswap2 (&us3.jmag);
- ucacswap2 (&us3.hmag);
- ucacswap2 (&us3.kmag);
- ucacswap2 (&us3.bmag);
- ucacswap2 (&us3.rmag);
- ucacswap2 (&us3.imag);
- }
- st->ra = (double) us3.rasec / 3600000.0; /* mas */
- st->dec = (double) us3.decsec / 3600000.0; /* mas */
- st->dec = st->dec - 90.0;
- st->errra = (double) us3.sigra / 3600000.0; /* mas */
- st->errra = st->errra / cosdeg (st->dec); /* to RA deg */
- st->errdec = (double) us3.sigdec / 3600000.0; /* mas */
- st->rapm = (double) us3.rapm / 36000000.0; /* 0.1mas/yr */
- st->rapm = st->rapm / cosdeg (st->dec); /* to RA deg */
- st->decpm = (double) us3.decpm / 36000000.0; /* 0.1mas/yr */
- st->errpmr = (double) us3.sigpmr / 36000000.0; /* 0.1mas/yr */
- st->errpmr = st->errpmr / cosdeg (st->dec); /* to RA deg */
- st->errpmd = (double) us3.sigpmd / 36000000.0; /* 0.1mas/yr */
- st->nimage = (int) us3.nu1;
- st->ncat = (int) us3.us1;
- if (us3.bmag == 0)
- st->xmag[0] = 99.990;
- else
- st->xmag[0] = ((double) us3.bmag) / 1000.0;
- if (us3.rmag == 0)
- st->xmag[1] = 99.990;
- else
- st->xmag[1] = ((double) us3.rmag) / 1000.0;
- if (us3.imag == 0)
- st->xmag[2] = 99.990;
- else
- st->xmag[2] = ((double) us3.imag) / 1000.0;
- if (us3.jmag == 0)
- st->xmag[3] = 99.990;
- else
- st->xmag[3] = ((double) us3.jmag) / 1000.0;
- if (us3.hmag == 0)
- st->xmag[4] = 99.990;
- else
- st->xmag[4] = ((double) us3.hmag) / 1000.0;
- if (us3.kmag == 0)
- st->xmag[5] = 99.990;
- else
- st->xmag[5] = ((double) us3.kmag) / 1000.0;
- if (us3.mmag == 0)
- st->xmag[6] = 99.990;
- else
- st->xmag[6] = ((double) us3.mmag) / 1000.0;
- if (us3.amag == 0)
- st->xmag[7] = 99.990;
- else
- st->xmag[7] = ((double) us3.amag) / 1000.0;
- }
-
- return (0);
-}
-
-
-/* UCACSWAP2 -- Swap bytes in Integer*2 number in place */
-
-static void
-ucacswap2 (string)
-
-
-char *string; /* Address of starting point of bytes to swap */
-
-{
- char *sbyte, temp;
-
- sbyte = string;
- temp = sbyte[0];
- sbyte[0] = sbyte[1];
- sbyte[1] = temp;
- return;
-}
-
-
-/* UCACSWAP4 -- Reverse bytes of Integer*4 or Real*4 number in place */
-
-static void
-ucacswap4 (string)
-
-char *string; /* Address of Integer*4 or Real*4 vector */
-
-{
- char temp0, temp1, temp2, temp3;
-
- temp3 = string[0];
- temp2 = string[1];
- temp1 = string[2];
- temp0 = string[3];
- string[0] = temp0;
- string[1] = temp1;
- string[2] = temp2;
- string[3] = temp3;
-
- return;
-}
-
-/* Apr 24 2003 New subroutines, based on ty2read.c and uacread.c
- * May 30 2003 Add UCAC2, compute file size rather than reading it from file
- * Jun 2 2003 Print proper motions as mas/year
- * Aug 22 2003 Add radi argument for inner edge of search annulus
- * Sep 25 2003 Add ucacbin() to fill an image with sources
- * Oct 6 2003 Update ubcread() and ubcbin() for improved RefLim()
- * Nov 10 2003 Fix byte-swapping test in ucacopen() found by Ed Beshore
- * Nov 18 2003 Initialize image size and bits/pixel from header in ucacbin()
- * Dec 1 2003 Add missing tab to n=-1 header
- * Dec 12 2003 Fix bug in wcs2pix() call in ucacbin()
- *
- * Jan 4 2005 Fix bug in if statement on line 626 found by Dan Katz at JPL
- *
- * Jun 20 2006 Drop unused variables
- * Sep 26 2006 Increase length of rastr and destr from 16 to 32
- * Nov 16 2006 Fix binning
- *
- * Jan 8 2007 Drop unused variable in ucacbin()
- * Jan 10 2007 Add match=1 argument to webrnum()
- * Jul 11 2007 Add magnitude byte-swap check
- *
- * Oct 5 2009 Add UCAC3
- * Oct 15 2009 Read extra stars in RA
- * Oct 22 2009 Set UCAC3 magnitudes to 99.99 if zero
- * Oct 30 2009 Add position and proper motion error to Star structure
- * Nov 2 2009 Print UCAC3 errors if n = -1
- * Nov 5 2009 Return number of images and catalogs in gtype
- * Nov 5 2009 Return errors in position and proper motion as magnitudes
- * Nov 5 2009 Return UCAC2 and UCAC3 RA proper motion and error as RA degrees
- *
- * Mar 26 2010 Add more braces to if/else statements
- *
- * Mar 16 2011 Improve UCACSRA to get star number closest to RA
- * Mar 17 2011 Fix bug to find stars in regions which cross a pole
- * Apr 27 2011 Fix bug to find stars in unevenly distributed zone
- * May 20 2011 Fix format statement with extra format items
- */
+/*** File libwcs/ucacread.c
+ *** July 25, 2013
+ *** By Jessica Mink, jmink at cfa.harvard.edu
+ *** Harvard-Smithsonian Center for Astrophysics
+ *** Copyright (C) 2003-2013
+ *** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Correspondence concerning WCSTools should be addressed as follows:
+ Internet email: jmink at cfa.harvard.edu
+ Postal address: Jessica Mink
+ Smithsonian Astrophysical Observatory
+ 60 Garden St.
+ Cambridge, MA 02138 USA
+
+ * ucacread() Read UCAC Star Catalog stars in a rectangle on the sky
+ * ucacrnum() Read UCAC Star Catalog stars by number
+ * ucacbin() Fill a FITS WECS image with UCAC Star Catalog stars
+ * ucaczones() Make list of zones covered by a range of declinations
+ * ucacsra (sc,st,zone,rax0) Find UCAC star closest to specified right ascension
+ * ucacopen(zone, nstars) Open UCAC catalog file, returning number of entries
+ * ucacclose (sc) Close UCAC catalog file
+ * ucacstar (sc,st,zone,istar) Get UCAC catalog entry for one star
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdint.h>
+#include "fitsfile.h"
+#include "wcs.h"
+#include "wcscat.h"
+
+#define MAXZONE 900
+#define ABS(a) ((a) < 0 ? (-(a)) : (a))
+
+/* #define UCAC_DEBUG 1 */
+typedef struct {
+ int rasec, decsec;
+ short cmag;
+ unsigned char era, edec, nobs, rflg, ncat, cflg;
+ short epra, epdec;
+ int rapm, decpm;
+ unsigned char erapm, edecpm, qrapm, qdecpm;
+ int id2m;
+ short jmag, hmag, kmag, qm, cc;
+} UCAC2star;
+
+typedef struct {
+ int rasec, decsec;
+ short mmag, amag, sigmag;
+ char objt, dsf;
+ short sigra, sigdec;
+ char na1, nu1, us1, cn1;
+ short cepra, cepdec;
+ int rapm, decpm;
+ short sigpmr, sigpmd;
+ int id2m;
+ short jmag, hmag, kmag;
+ char jq, hq, kq;
+ char e2mpho[3];
+ short bmag, rmag, imag;
+ char clbl;
+ char bq, rq, iq;
+ char catflg[10];
+ char g1, c1, leda, x2m;
+ int rn;
+} UCAC3star;
+/* The following is from ucac4.h */
+#pragma pack( 1)
+typedef struct {
+ int32_t ra, spd; /* RA/dec at J2000.0, ICRS, in milliarcsec */
+ uint16_t mag1, mag2; /* UCAC fit model & aperture mags, .001 mag */
+ uint8_t mag_sigma;
+ uint8_t obj_type, double_star_flag;
+ int8_t ra_sigma, dec_sigma; /* sigmas in RA and dec at central epoch */
+ uint8_t n_ucac_total; /* Number of UCAC observations of this star */
+ uint8_t n_ucac_used; /* # UCAC observations _used_ for this star */
+ uint8_t n_cats_used; /* # catalogs (epochs) used for prop motion */
+ uint16_t epoch_ra; /* Central epoch for mean RA, minus 1900, .01y */
+ uint16_t epoch_dec; /* Central epoch for mean DE, minus 1900, .01y */
+ int16_t pm_ra; /* prop motion, .1 mas/yr = .01 arcsec/cy */
+ int16_t pm_dec; /* prop motion, .1 mas/yr = .01 arcsec/cy */
+ int8_t pm_ra_sigma; /* sigma in same units */
+ int8_t pm_dec_sigma;
+ uint32_t twomass_id; /* 2MASS pts_key star identifier */
+ uint16_t mag_j, mag_h, mag_k; /* 2MASS J, H, K_s mags, in millimags */
+ uint8_t icq_flag[3];
+ uint8_t e2mpho[3]; /* 2MASS error photometry (in centimags) */
+ uint16_t apass_mag[5]; /* in millimags */
+ uint8_t apass_mag_sigma[5]; /* also in millimags */
+ uint8_t yale_gc_flags; /* Yale SPM g-flag * 10 + c-flag */
+ uint32_t catalog_flags;
+ uint8_t leda_flag; /* LEDA galaxy match flag */
+ uint8_t twomass_ext_flag; /* 2MASS extended source flag */
+ uint32_t id_number;
+ uint16_t ucac2_zone;
+ uint32_t ucac2_number;
+} UCAC4star;
+#pragma pack( )
+/* Fields in the u4hpm.dat file */
+#define MAX_U4HPM_RECORDS 50
+#define MAX_U4HPM_LINE 512
+typedef struct u4hpm {
+ int rnm; /* unique star identifier (col. 51 main data) */
+ int zn; /* UCAC4 zone number for this star */
+ int rnz; /* unning record number along that zone for this star */
+ int pmrc; /* actual proper motion in RA*cos(dec) [0.1 mas/yr] */
+ int pmd; /* actual proper motion in Dec [0.1 mas/yr] */
+ int ra; /* col. 1 of main data file (redundant) */
+ int dec; /* col. 2 of main data file (redundant) */
+ int maga; /* col. 4 of main data file (redundant) */
+} U4HPM,*PU4HPM;
+
+
+int hpmLines = 0;
+U4HPM u4hpm_table[MAX_U4HPM_RECORDS];
+
+
+/* pathname of UCAC1 decompressed data files or search engine URL */
+char ucac1path[64]="/data/astrocat/ucac1";
+
+/* pathname of UCAC2 decompressed data files or search engine URL */
+char ucac2path[64]="/data/astrocat/ucac2";
+
+/* pathname of UCAC3 decompressed data files or search engine URL */
+char ucac3path[64]="/data/astrocat/ucac3";
+
+/* pathname of UCAC4 decompressed data files or search engine URL */
+char ucac4path[64]="/data/astrocat/ucac4/u4b";
+
+char *ucacpath;
+static int ucat = 0;
+
+static double *gdist; /* Array of distances to stars */
+static int ndist = 0;
+static int cswap = 0; /* Byte reverse catalog to Mac/Sun/network order if 1 */
+
+static int ucaczones();
+struct StarCat *ucacopen();
+void ucacclose();
+static int ucacsra();
+static int ucacstar();
+static void ucacswap4();
+static void ucacswap2();
+
+
+/* UCACREAD -- Read UCAC Star Catalog stars */
+
+int
+ucacread (refcatname,cra,cdec,dra,ddec,drad,dradi,distsort,sysout,eqout,epout,
+ mag1,mag2,sortmag,nstarmax,gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog)
+
+ char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
+ double cra; /* Search center J2000 right ascension in degrees */
+ double cdec; /* Search center J2000 declination in degrees */
+ double dra; /* Search half width in right ascension in degrees */
+ double ddec; /* Search half-width in declination in degrees */
+ double drad; /* Limiting separation in degrees (ignore if 0) */
+ double dradi; /* Inner edge of annulus in degrees (ignore if 0) */
+ int distsort; /* 1 to sort stars by distance from center */
+ int sysout; /* Search coordinate system */
+ double eqout; /* Search coordinate equinox */
+ double epout; /* Proper motion epoch (0.0 for no proper motion) */
+ double mag1,mag2; /* Limiting magnitudes (none if equal) */
+ int sortmag; /* Magnitude by which to sort (1 or 2) */
+ int nstarmax; /* Maximum number of stars to be returned */
+ double *gnum; /* Array of Guide Star numbers (returned) */
+ double *gra; /* Array of right ascensions (returned) */
+ double *gdec; /* Array of declinations (returned) */
+ double *gpra; /* Array of right ascension proper motions (returned) */
+ double *gpdec; /* Array of declination proper motions (returned) */
+ double **gmag; /* Array of magnitudes (returned) */
+ int *gtype; /* Array of object types (returned) */
+ int nlog; /* 1 for diagnostics */
+{
+ double ra1,ra2; /* Limiting right ascensions of region in degrees */
+ double dec1,dec2; /* Limiting declinations of region in degrees */
+ double dist = 0.0; /* Distance from search center in degrees */
+ double faintmag=0.0; /* Faintest magnitude */
+ double maxdist=0.0; /* Largest distance */
+ int faintstar=0; /* Faintest star */
+ int farstar=0; /* Most distant star */
+ int nz; /* Number of UCAC regions in search */
+ int zlist[MAXZONE]; /* List of region numbers */
+ int sysref = WCS_J2000; /* Catalog coordinate system */
+ double eqref = 2000.0; /* Catalog equinox */
+ double epref = 2000.0; /* Catalog epoch */
+ double secmarg = 60.0; /* Arcsec/century margin for proper motion */
+ struct StarCat *starcat; /* Star catalog data structure */
+ struct Star *star; /* Single star data structure */
+ double errra, errdec, errpmr, errpmd;
+ int nim, ncat;
+ int verbose;
+ int wrap;
+ int iz;
+ int magsort;
+ int jstar;
+ int nrmax = MAXZONE;
+ int nstar,i, ntot, imag;
+ int istar, istar1, istar2;
+ int jtable,iwrap, nread;
+ int pass;
+ int zone;
+ int nmag;
+ double num, ra, dec, rapm, decpm, mag;
+ double rra1, rra2, rdec1, rdec2;
+ double rdist, ddist;
+ char cstr[32], rastr[32], decstr[32];
+ char ucacenv[16];
+ char *str;
+
+ ntot = 0;
+ if (nlog > 0)
+ verbose = 1;
+ else
+ verbose = 0;
+
+ /* Set catalog code and path to catalog */
+ if (strncmp (refcatname,"ucac2",5)==0 ||
+ strncmp (refcatname,"UCAC2",5)==0) {
+ ucat = UCAC2;
+ ucacpath = ucac2path;
+ strcpy (ucacenv, "UCAC2_PATH");
+ nmag = 4;
+ }
+ else if (strncmp (refcatname,"ucac3",5)==0 ||
+ strncmp (refcatname,"UCAC3",5)==0) {
+ ucat = UCAC3;
+ ucacpath = ucac3path;
+ strcpy (ucacenv, "UCAC3_PATH");
+ nmag = 8;
+ }
+ else if (strncmp (refcatname,"ucac4",5)==0 ||
+ strncmp (refcatname,"UCAC4",5)==0) {
+ ucat = UCAC4;
+ ucacpath = ucac4path;
+ strcpy (ucacenv, "UCAC4_PATH");
+ nmag = 8;
+ }
+ else {
+ ucat = UCAC1;
+ ucacpath = ucac1path;
+ strcpy (ucacenv, "UCAC1_PATH");
+ nmag = 1;
+ }
+
+ /* If pathname is set in environment, override local value */
+ if ((str = getenv (ucacenv)) != NULL )
+ ucacpath = str;
+
+ /* If pathname is a URL, search and return */
+ if (!strncmp (ucacpath, "http:",5)) {
+ return (webread (ucacpath,refcatname,distsort,cra,cdec,dra,ddec,drad,
+ dradi,sysout,eqout,epout,mag1,mag2,sortmag,nstarmax,
+ gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog));
+ }
+
+ wcscstr (cstr, sysout, eqout, epout);
+
+ SearchLim (cra,cdec,dra,ddec,sysout,&ra1,&ra2,&dec1,&dec2,verbose);
+
+ /* Make mag1 always the smallest magnitude */
+ if (mag2 < mag1) {
+ mag = mag2;
+ mag2 = mag1;
+ mag1 = mag;
+ }
+
+ if (sortmag < 1)
+ magsort = 0;
+ else if (sortmag > nmag)
+ magsort = nmag - 1;
+ else
+ magsort = sortmag - 1;
+
+ /* Allocate table for distances of stars from search center */
+ if (nstarmax > ndist) {
+ if (ndist > 0)
+ free ((void *)gdist);
+ gdist = (double *) malloc (nstarmax * sizeof (double));
+ if (gdist == NULL) {
+ fprintf (stderr,"UCACREAD: cannot allocate separation array\n");
+ return (0);
+ }
+ ndist = nstarmax;
+ }
+
+ /* Allocate catalog entry buffer */
+ star = (struct Star *) calloc (1, sizeof (struct Star));
+ star->num = 0.0;
+
+ nstar = 0;
+ jstar = 0;
+
+ /* Get RA and Dec limits in catalog (J2000) coordinates */
+ rra1 = ra1;
+ rra2 = ra2;
+ rdec1 = dec1;
+ rdec2 = dec2;
+ RefLim (cra,cdec,dra,ddec,sysout,sysref,eqout,eqref,epout,epref,secmarg,
+ &rra1, &rra2, &rdec1, &rdec2, &wrap, verbose);
+
+ /* Find UCAC Star Catalog zones in which to search */
+ nz = ucaczones (rdec1,rdec2,nrmax,zlist,verbose);
+ if (nz <= 0) {
+ fprintf (stderr,"UCACREAD: no UCAC zone for %.2f-%.2f %.2f %.2f\n",
+ rra1, rra2, rdec1, rdec2);
+ return (0);
+ }
+
+ /* Write header if printing star entries as found */
+ if (nstarmax < 1) {
+ char *revmessage;
+ revmessage = getrevmsg();
+ printf ("catalog UCAC1\n");
+ ra2str (rastr, 31, cra, 3);
+ printf ("ra %s\n", rastr);
+ dec2str (decstr, 31, cdec, 2);
+ printf ("dec %s\n", decstr);
+ printf ("rpmunit mas/year\n");
+ printf ("dpmunit mas/year\n");
+ if (drad != 0.0) {
+ printf ("radmin %.1f\n", drad*60.0);
+ if (dradi > 0)
+ printf ("radimin %.1f\n", dradi*60.0);
+ }
+ else {
+ printf ("dramin %.1f\n", dra*60.0* cosdeg (cdec));
+ printf ("ddecmin %.1f\n", ddec*60.0);
+ }
+ printf ("radecsys %s\n", cstr);
+ printf ("equinox %.3f\n", eqout);
+ printf ("epoch %.3f\n", epout);
+ printf ("program scat %s\n", revmessage);
+ printf ("ucac_id ra dec ");
+ if (ucat == UCAC1) {
+ printf ("mag ura udec arcmin\n");
+ printf ("---------- ------------ ------------ ");
+ printf ("----- ------ ------ ------\n");
+ }
+ else if (ucat == UCAC2) {
+ printf ("raerr decerr magc ");
+ printf ("magj magh magk mag ");
+ printf ("pmra pmdec pmrerr pmderr ");
+ printf ("ni nc arcsec\n");
+ printf ("---------- ------------ ------------ ");
+ printf ("------ ------ ----- ----- ----- ");
+ printf ("----- ----- ------ ------ ----- ----- ");
+ printf ("-- -- ------\n");
+ }
+ else if (ucat == UCAC3) {
+ printf ("raerr decerr magb magr magi ");
+ printf ("magj magh magk maga magm ");
+ printf ("mag pmra pmdec pmrerr pmderr ");
+ printf ("ni nc arcsec\n");
+ printf ("---------- ------------ ------------ ");
+ printf ("------ ------ ----- ------ ----- ");
+ printf ("----- ----- ----- ----- ----- ");
+ printf ("----- ----- ----- ------ ------ ");
+ printf ("-- -- ------\n");
+ }
+ else if (ucat == UCAC4) {
+ printf ("raerr decerr magb magr magi ");
+ printf ("magj magh magk maga magm ");
+ printf ("mag pmra pmdec pmrerr pmderr ");
+ printf ("ni nc arcsec\n");
+ printf ("---------- ------------ ------------ ");
+ printf ("------ ------ ----- ------ ----- ");
+ printf ("----- ----- ----- ----- ----- ");
+ printf ("----- ----- ----- ------ ------ ");
+ printf ("-- -- ------\n");
+ }
+ }
+
+ /* Loop through zone list */
+ nstar = 0;
+ for (iz = 0; iz < nz; iz++) {
+
+ /* Get path to zone catalog */
+ zone = zlist[iz];
+#ifdef UCAC_DEBUG
+ if (zone == 183) {
+ fprintf(stderr,"at zone %d\n",zone);
+ }
+#endif /* UCAC_DEBUG */
+ if ((starcat = ucacopen (zone)) != 0) {
+
+ jstar = 0;
+ jtable = 0;
+ for (iwrap = 0; iwrap <= wrap; iwrap++) {
+
+ /* Find first star based on RA */
+ if (iwrap == 0 || wrap == 0) {
+ istar1 = ucacsra (starcat, star, zone, rra1);
+ if (istar > 5)
+ istar = istar - 5;
+ else
+ istar = 1;
+ }
+ else
+ istar1 = 1;
+
+ /* Find last star based on RA */
+ if (iwrap == 1 || wrap == 0) {
+ istar2 = ucacsra (starcat, star, zone, rra2);
+ if (istar2 < starcat->nstars - 5)
+ istar2 = istar2 + 5;
+ else
+ istar2 = starcat->nstars;
+ }
+ else
+ istar2 = starcat->nstars;
+
+ if (istar1 == 0 || istar2 == 0)
+ break;
+
+ nread = istar2 - istar1 + 1;
+
+ /* Loop through zone catalog for this region */
+ for (istar = istar1; istar <= istar2; istar++) {
+ jtable ++;
+
+ if (ucacstar (starcat, star, zone, istar)) {
+ fprintf(stderr,"UCACREAD: Cannot read star %d\n",istar);
+ break;
+ }
+
+ /* ID number */
+ num = star->num;
+
+ /* Magnitude */
+ mag = star->xmag[magsort];
+
+ /* Check magnitude limits */
+ pass = 1;
+ if (mag1 != mag2 && (mag < mag1 || mag > mag2))
+ pass = 0;
+
+ /* Check position limits */
+ if (pass) {
+
+ /* Get position in output coordinate system */
+ ra = star->ra;
+ dec = star->dec;
+ rapm = star->rapm;
+ decpm = star->decpm;
+ errra = star->errra;
+ errdec = star->errdec;
+ errpmr = star->errpmr;
+ errpmd = star->errpmd;
+ nim = star->nimage;
+ ncat = star->ncat;
+ wcsconp (sysref, sysout, eqref, eqout, epref, epout,
+ &ra, &dec, &rapm, &decpm);
+
+ /* Compute distance from search center */
+ if (drad > 0 || distsort)
+ dist = wcsdist (cra,cdec,ra,dec);
+ else
+ dist = 0.0;
+
+ /* Check radial distance to search center */
+ if (drad > 0) {
+ if (dist > drad)
+ pass = 0;
+ if (dradi > 0.0 && dist < dradi)
+ pass = 0;
+ }
+
+ /* Check distance along RA and Dec axes */
+ else {
+ ddist = wcsdist (cra,cdec,cra,dec);
+ if (ddist > ddec)
+ pass = 0;
+ rdist = wcsdist (cra,dec,ra,dec);
+ if (rdist > dra)
+ pass = 0;
+ }
+ }
+
+ if (pass) {
+
+ /* Write star position and magnitude to stdout */
+ if (nstarmax < 1) {
+ ra2str (rastr, 31, ra, 3);
+ dec2str (decstr, 31, dec, 2);
+ dist = wcsdist (cra,cdec,ra,dec) * 3600.0;
+ printf ("%010.6f %s %s", num,rastr,decstr);
+ if (ucat == UCAC2 || ucat == UCAC3 || ucat == UCAC4)
+ printf (" %5.3f %5.3f",
+ errra * 3600.0 * cosdeg (dec), errdec * 3600.0);
+ if (ucat == UCAC1)
+ printf (" %5.2f", mag);
+ else
+ printf (" %5.2f %5.2f %5.2f %5.2f",
+ star->xmag[0], star->xmag[1],
+ star->xmag[2], star->xmag[3]);
+ if (ucat == UCAC3)
+ printf (" %5.2f %5.2f %5.2f %5.2f",
+ star->xmag[4], star->xmag[5],
+ star->xmag[6], star->xmag[7]);
+ if (ucat == UCAC4)
+ printf (" %5.2f %5.2f %5.2f %5.2f",
+ star->xmag[4], star->xmag[5],
+ star->xmag[6], star->xmag[7]);
+ printf (" %5.2f %6.1f %6.1f",
+ mag, rapm*3600000.0*cosdeg (dec), decpm*3600000.0);
+ printf (" %6.1f %6.1f",
+ errpmr*3600000.0, errpmd*3600000.0);
+ printf (" %2d %2d %.3f\n",
+ nim, ncat, dist);
+ }
+
+ /* Save star position and magnitude in table */
+ else if (nstar < nstarmax) {
+ gnum[nstar] = num;
+ gra[nstar] = ra;
+ gdec[nstar] = dec;
+ gpra[nstar] = rapm;
+ gpdec[nstar] = decpm;
+ if (ucat == UCAC1)
+ gmag[0][nstar] = mag;
+ else {
+ for (imag = 0; imag < nmag; imag++)
+ gmag[imag][nstar] = star->xmag[imag];
+
+ gmag[nmag][nstar] = star->errra;
+ gmag[nmag+1][nstar] = star->errdec;
+ gmag[nmag+2][nstar] = star->errpmr;
+ gmag[nmag+3][nstar] = star->errpmd;
+ gtype[nstar] = (1000 * nim) + ncat;
+ }
+ gdist[nstar] = dist;
+ if (dist > maxdist) {
+ maxdist = dist;
+ farstar = nstar;
+ }
+ if (mag > faintmag) {
+ faintmag = mag;
+ faintstar = nstar;
+ }
+ }
+
+ /* If too many stars and distance sorting,
+ replace farthest star */
+ else if (distsort) {
+ if (dist < maxdist) {
+ gnum[farstar] = num;
+ gra[farstar] = ra;
+ gdec[farstar] = dec;
+ gpra[farstar] = rapm;
+ gpdec[farstar] = decpm;
+ if (ucat == UCAC1)
+ gmag[0][farstar] = mag;
+ else {
+ for (imag = 0; imag < nmag; imag++)
+ gmag[imag][farstar] = star->xmag[imag];
+ gmag[nmag][farstar] = star->errra;
+ gmag[nmag+1][farstar] = star->errdec;
+ gmag[nmag+2][farstar] = star->errpmr;
+ gmag[nmag+3][farstar] = star->errpmd;
+ gtype[farstar] = (1000 * nim) + ncat;
+ }
+ gdist[farstar] = dist;
+
+ /* Find new farthest star */
+ maxdist = 0.0;
+ for (i = 0; i < nstarmax; i++) {
+ if (gdist[i] > maxdist) {
+ maxdist = gdist[i];
+ farstar = i;
+ }
+ }
+ }
+ }
+
+ /* Else if too many stars, replace faintest star */
+ else if (mag < faintmag) {
+ gnum[faintstar] = num;
+ gra[faintstar] = ra;
+ gdec[faintstar] = dec;
+ gpra[faintstar] = rapm;
+ gpdec[faintstar] = decpm;
+ if (ucat == UCAC1)
+ gmag[0][faintstar] = mag;
+ else {
+ for (imag = 0; imag < nmag; imag++)
+ gmag[imag][faintstar] = star->xmag[imag];
+ gmag[nmag][faintstar] = star->errra;
+ gmag[nmag+1][faintstar] = star->errdec;
+ gmag[nmag+2][faintstar] = star->errpmr;
+ gmag[nmag+3][faintstar] = star->errpmd;
+ gtype[faintstar] = (1000 * nim) + ncat;
+ }
+ gdist[faintstar] = dist;
+ faintmag = 0.0;
+
+ /* Find new faintest star */
+ for (i = 0; i < nstarmax; i++) {
+ if (gmag[magsort][i] > faintmag) {
+ faintmag = gmag[magsort][i];
+ faintstar = i;
+ }
+ }
+ }
+
+ nstar++;
+ if (nlog == 1)
+ fprintf (stderr,"UCACREAD: %11.6f: %9.5f %9.5f %5.2f\n",
+ num,ra,dec,mag);
+
+ /* End of accepted star processing */
+ }
+
+ /* Log operation */
+ jstar++;
+ if (nlog > 0 && istar%nlog == 0)
+ fprintf (stderr,"UCACREAD: %5d / %5d / %5d sources\r",
+ nstar,jstar,starcat->nstars);
+
+ /* End of star loop */
+ }
+
+ /* End of 0:00 RA wrap loop */
+ }
+
+ /* End of successful zone file loop */
+ ntot = ntot + starcat->nstars;
+ if (nlog > 0)
+ fprintf (stderr,"UCACREAD: %4d / %4d: %5d / %5d / %5d sources from zone %4d \n",
+ iz+1,nz,nstar,jstar,starcat->nstars,zlist[iz]);
+
+ /* Close region input file */
+ ucacclose (starcat);
+ }
+
+ /* End of zone loop */
+ }
+
+ /* Summarize transfer */
+ if (nlog > 0) {
+ if (nz > 1)
+ fprintf (stderr,"UCACREAD: %d zones: %d / %d found\n",nz,nstar,ntot);
+ else
+ fprintf (stderr,"UCACREAD: 1 region: %d / %d found\n",nstar,ntot);
+ if (nstar > nstarmax)
+ fprintf (stderr,"UCACREAD: %d stars found; only %d returned\n",
+ nstar,nstarmax);
+ }
+ return (nstar);
+}
+
+/* UCACRNUM -- Read HST Guide Star Catalog stars from CDROM */
+
+int
+ucacrnum (refcatname,nstars,sysout,eqout,epout,
+ gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog)
+
+ char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
+ int nstars; /* Number of stars to find */
+ int sysout; /* Search coordinate system */
+ double eqout; /* Search coordinate equinox */
+ double epout; /* Proper motion epoch (0.0 for no proper motion) */
+ double *gnum; /* Array of Guide Star numbers (returned) */
+ double *gra; /* Array of right ascensions (returned) */
+ double *gdec; /* Array of declinations (returned) */
+ double *gpra; /* Array of right ascension proper motions (returned) */
+ double *gpdec; /* Array of declination proper motions (returned) */
+ double **gmag; /* Array of B and V magnitudes (returned) */
+ int *gtype; /* Array of object types (returned) */
+ int nlog; /* 1 for diagnostics */
+{
+ int sysref=WCS_J2000; /* Catalog coordinate system */
+ double eqref=2000.0; /* Catalog equinox */
+ double epref=2000.0; /* Catalog epoch */
+ struct StarCat *starcat;
+ struct Star *star;
+ char *str;
+ char ucacenv[16];
+
+ int verbose;
+ int zone, zone0;
+ int jstar, imag, nmag;
+ int istar, nstar;
+ double num, ra, dec, rapm, decpm, mag;
+
+ if (nlog == 1)
+ verbose = 1;
+ else
+ verbose = 0;
+
+ /* Set catalog code and path to catalog */
+ if (strncmp (refcatname,"ucac4",5)==0 ||
+ strncmp (refcatname,"UCAC4",5)==0) {
+ ucat = UCAC4;
+ ucacpath = ucac4path;
+ strcpy (ucacenv, "UCAC4_PATH");
+ nmag = 8;
+ }
+ if (strncmp (refcatname,"ucac3",5)==0 ||
+ strncmp (refcatname,"UCAC3",5)==0) {
+ ucat = UCAC3;
+ ucacpath = ucac3path;
+ strcpy (ucacenv, "UCAC3_PATH");
+ nmag = 8;
+ }
+ else if (strncmp (refcatname,"ucac2",5)==0 ||
+ strncmp (refcatname,"UCAC2",5)==0) {
+ ucat = UCAC2;
+ ucacpath = ucac2path;
+ strcpy (ucacenv, "UCAC2_PATH");
+ nmag = 4;
+ }
+ else {
+ ucat = UCAC1;
+ ucacpath = ucac1path;
+ strcpy (ucacenv, "UCAC1_PATH");
+ nmag = 1;
+ }
+
+ /* If pathname is set in environment, override local value */
+ if ((str = getenv(ucacenv)) != NULL )
+ ucacpath = str;
+
+ /* If pathname is a URL, search and return */
+ if (!strncmp (ucacpath, "http:",5))
+ return (webrnum (ucacpath,refcatname,nstars,sysout,eqout,epout,1,
+ gnum,gra,gdec,gpra,gpdec,gmag,gtype,nlog));
+
+ /* Allocate catalog entry buffer */
+ star = (struct Star *) calloc (1, sizeof (struct Star));
+ star->num = 0.0;
+ nstar = 0;
+ zone0 = 0;
+ starcat = NULL;
+
+ /* Loop through star list */
+ for (jstar = 0; jstar < nstars; jstar++) {
+ zone = (int) (gnum[jstar] + 0.0000001);
+
+ /* Find numbered stars (rrr.nnnnnn) */
+ istar = (int) ((gnum[jstar] - (double) zone + 0.0000001) * 1000000.0);
+ if (istar > 0) {
+ if (zone != zone0) {
+ if (starcat != NULL)
+ ucacclose (starcat);
+ starcat = ucacopen (zone);
+ }
+ if (starcat == NULL) {
+ fprintf (stderr,"UCACRNUM: Zone %d file not found\n", zone);
+ return (0);
+ }
+ if (ucacstar (starcat, star, zone, istar)) {
+ fprintf (stderr,"UCACRNUM: Cannot read star %d.%06d\n", zone, istar);
+ gra[jstar] = 0.0;
+ gdec[jstar] = 0.0;
+ if (ucat == UCAC1)
+ gmag[0][jstar] = 0.0;
+ else {
+ for (imag = 0; imag < nmag; imag++)
+ gmag[imag][jstar] = 0.0;
+ }
+ gtype[jstar] = 0;
+ continue;
+ }
+
+ /* If star has been found in catalog */
+
+ /* ID number */
+ num = star->num;
+
+ /* Position in degrees at designated epoch */
+ ra = star->ra;
+ dec = star->dec;
+ rapm = star->rapm;
+ decpm = star->decpm;
+ wcsconp (sysref, sysout, eqref, eqout, epref, epout,
+ &ra, &dec, &rapm, &decpm);
+
+ /* Magnitude */
+ mag = star->xmag[0];
+
+ /* Save star position and magnitude in table */
+ gnum[jstar] = num;
+ gra[jstar] = ra;
+ gdec[jstar] = dec;
+ gpra[jstar] = rapm;
+ gpdec[jstar] = decpm;
+ gmag[0][jstar] = mag;
+ gtype[jstar] = (1000 * star->nimage) + star->ncat;
+ if (ucat == UCAC1)
+ gmag[0][jstar] = star->xmag[0];
+ else {
+ for (imag = 0; imag < nmag; imag++)
+ gmag[imag][jstar] = star->xmag[imag];
+ gmag[nmag][jstar] = star->errra;
+ gmag[nmag+1][jstar] = star->errdec;
+ gmag[nmag+2][jstar] = star->errpmr;
+ gmag[nmag+3][jstar] = star->errpmd;
+ gtype[jstar] = (1000 * star->nimage) + star->ncat;
+ }
+ if (nlog == 1) {
+ if (ucat == UCAC1)
+ fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f %s \n",
+ num, ra, dec, mag, star->isp);
+ else if (ucat == UCAC2) {
+ fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f",
+ num, ra, dec, star->xmag[0]);
+ fprintf (stderr," %5.2f %5.2f %5.2f %d %d",
+ star->xmag[1],star->xmag[2],star->xmag[3]);
+ fprintf (stderr," %d %d\n",star->nimage,star->ncat);
+ }
+ else if (ucat == UCAC3) {
+ fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f %5.2f",
+ num, ra, dec, star->xmag[0],star->xmag[1]);
+ fprintf (stderr," %5.2f %5.2f %5.2f",
+ star->xmag[2], star->xmag[3], star->xmag[4]);
+ fprintf (stderr," %5.2f %5.2f %5.2f",
+ star->xmag[5], star->xmag[6], star->xmag[7]);
+ fprintf (stderr," %d %d\n",star->nimage,star->ncat);
+ }
+ else if (ucat == UCAC4) {
+ fprintf (stderr,"UCACRNUM: %11.6f: %9.5f %9.5f %5.2f %5.2f",
+ num, ra, dec, star->xmag[0],star->xmag[1]);
+ fprintf (stderr," %5.2f %5.2f %5.2f",
+ star->xmag[2], star->xmag[3], star->xmag[4]);
+ fprintf (stderr," %5.2f %5.2f %5.2f",
+ star->xmag[5], star->xmag[6], star->xmag[7]);
+ fprintf (stderr," %d %d\n",star->nimage,star->ncat);
+ } else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+ }
+ }
+
+ /* End of star loop */
+ }
+
+ /* Summarize search */
+ ucacclose (starcat);
+ if (nlog > 0)
+ fprintf (stderr,"UCACRNUM: %d / %d found\n",nstar,starcat->nstars);
+
+ return (nstars);
+}
+
+
+/* UCACBIN -- Fill a FITS WCS image with UCAC Star Catalog stars */
+
+int
+ucacbin (refcatname, wcs, header, image, mag1, mag2, sortmag, magscale, nlog)
+
+ char *refcatname; /* Name of catalog (UAC, USAC, UAC2, USAC2) */
+ struct WorldCoor *wcs; /* World coordinate system for image */
+ char *header; /* FITS header for output image */
+ char *image; /* Output FITS image */
+ double mag1,mag2; /* Limiting magnitudes (none if equal) */
+ int sortmag; /* Magnitude by which to sort (1 or 2) */
+ double magscale; /* Scaling factor for magnitude to pixel flux
+ * (number of catalog objects per bin if 0) */
+ int nlog; /* 1 for diagnostics */
+{
+ double cra; /* Search center J2000 right ascension in degrees */
+ double cdec; /* Search center J2000 declination in degrees */
+ double dra; /* Search half width in right ascension in degrees */
+ double ddec; /* Search half-width in declination in degrees */
+ int sysout; /* Search coordinate system */
+ double eqout; /* Search coordinate equinox */
+ double epout; /* Proper motion epoch (0.0 for no proper motion) */
+ double ra1,ra2; /* Limiting right ascensions of region in degrees */
+ double dec1,dec2; /* Limiting declinations of region in degrees */
+ int nz; /* Number of UCAC regions in search */
+ int zlist[MAXZONE]; /* List of region numbers */
+ int sysref = WCS_J2000; /* Catalog coordinate system */
+ double eqref = 2000.0; /* Catalog equinox */
+ double epref = 2000.0; /* Catalog epoch */
+ double secmarg = 60.0; /* Arcsec/century margin for proper motion */
+ struct StarCat *starcat; /* Star catalog data structure */
+ struct Star *star; /* Single star cata structure */
+ int verbose;
+ int wrap;
+ int ix, iy, iz;
+ int magsort;
+ int jstar;
+ int nrmax = MAXZONE;
+ int nstar, ntot;
+ int istar, istar1, istar2;
+ int jtable,iwrap, nread;
+ int pass;
+ int zone;
+ double num, ra, dec, rapm, decpm, mag;
+ double rra1, rra2, rdec1, rdec2;
+ double rdist, ddist;
+ char cstr[32];
+ char ucacenv[16];
+ char *str;
+ double xpix, ypix, flux;
+ int offscl;
+ int bitpix, w, h; /* Image bits/pixel and pixel width and height */
+ double logt = log(10.0);
+
+ ntot = 0;
+ if (nlog > 0)
+ verbose = 1;
+ else
+ verbose = 0;
+
+ /* Set catalog code and path to catalog */
+ if (strncmp (refcatname,"ucac4",5)==0 ||
+ strncmp (refcatname,"UCAC4",5)==0) {
+ ucat = UCAC4;
+ ucacpath = ucac4path;
+ strcpy (ucacenv, "UCAC4_PATH");
+ }
+ if (strncmp (refcatname,"ucac3",5)==0 ||
+ strncmp (refcatname,"UCAC3",5)==0) {
+ ucat = UCAC3;
+ ucacpath = ucac3path;
+ strcpy (ucacenv, "UCAC3_PATH");
+ }
+ else if (strncmp (refcatname,"ucac2",5)==0 ||
+ strncmp (refcatname,"UCAC2",5)==0) {
+ ucat = UCAC2;
+ ucacpath = ucac2path;
+ strcpy (ucacenv, "UCAC2_PATH");
+ }
+ else {
+ ucat = UCAC1;
+ ucacpath = ucac1path;
+ strcpy (ucacenv, "UCAC1_PATH");
+ }
+
+ /* If pathname is set in environment, override local value */
+ if ((str = getenv (ucacenv)) != NULL )
+ ucacpath = str;
+
+ /* Set image parameters */
+ bitpix = 0;
+ (void)hgeti4 (header, "BITPIX", &bitpix);
+ w = 0;
+ (void)hgeti4 (header, "NAXIS1", &w);
+ h = 0;
+ (void)hgeti4 (header, "NAXIS2", &h);
+
+ /* Set catalog search limits from image WCS information */
+ sysout = wcs->syswcs;
+ eqout = wcs->equinox;
+ epout = wcs->epoch;
+ wcscstr (cstr, sysout, eqout, epout);
+ wcssize (wcs, &cra, &cdec, &dra, &ddec);
+ SearchLim (cra,cdec,dra,ddec,sysout,&ra1,&ra2,&dec1,&dec2,verbose);
+
+ /* Make mag1 always the smallest magnitude */
+ if (mag2 < mag1) {
+ mag = mag2;
+ mag2 = mag1;
+ mag1 = mag;
+ }
+
+ if (sortmag < 1)
+ magsort = 0;
+ else if (sortmag > 4)
+ magsort = 3;
+ else
+ magsort = sortmag - 1;
+
+ /* Allocate catalog entry buffer */
+ star = (struct Star *) calloc (1, sizeof (struct Star));
+ star->num = 0.0;
+
+ nstar = 0;
+ jstar = 0;
+
+ /* Get RA and Dec limits in catalog (J2000) coordinates */
+ rra1 = ra1;
+ rra2 = ra2;
+ rdec1 = dec1;
+ rdec2 = dec2;
+ RefLim (cra,cdec,dra,ddec,sysout,sysref,eqout,eqref,epout,epref,secmarg,
+ &rra1, &rra2, &rdec1, &rdec2, &wrap, verbose);
+
+ /* Find UCAC Star Catalog zones in which to search */
+ nz = ucaczones (rdec1,rdec2,nrmax,zlist,verbose);
+ if (nz <= 0) {
+ fprintf (stderr,"UCACBIN: no UCAC zone for %.2f-%.2f %.2f %.2f\n",
+ rra1, rra2, rdec1, rdec2);
+ return (0);
+ }
+
+ /* Loop through zone list */
+ nstar = 0;
+ for (iz = 0; iz < nz; iz++) {
+
+ /* Get path to zone catalog */
+ zone = zlist[iz];
+ if ((starcat = ucacopen (zone)) != 0) {
+
+ jstar = 0;
+ jtable = 0;
+ for (iwrap = 0; iwrap <= wrap; iwrap++) {
+
+ /* Find first star based on RA */
+ if (iwrap == 0 || wrap == 0)
+ istar1 = ucacsra (starcat, star, zone, rra1);
+ else
+ istar1 = 1;
+
+ /* Find last star based on RA */
+ if (iwrap == 1 || wrap == 0)
+ istar2 = ucacsra (starcat, star, zone, rra2);
+ else
+ istar2 = starcat->nstars;
+
+ if (istar1 == 0 || istar2 == 0)
+ break;
+
+ nread = istar2 - istar1 + 1;
+
+ /* Loop through zone catalog for this region */
+ for (istar = istar1; istar <= istar2; istar++) {
+ jtable ++;
+
+ if (ucacstar (starcat, star, zone, istar)) {
+ fprintf(stderr,"UCACBIN: Cannot read star %d\n",istar);
+ break;
+ }
+
+ /* ID number */
+ num = star->num;
+
+ /* Magnitude */
+ mag = star->xmag[magsort];
+
+ /* Check magnitude limits */
+ pass = 1;
+ if (mag1 != mag2 && (mag < mag1 || mag > mag2))
+ pass = 0;
+
+ /* Check position limits */
+ if (pass) {
+
+ /* Get position in output coordinate system */
+ rapm = star->rapm;
+ decpm = star->decpm;
+ ra = star->ra;
+ dec = star->dec;
+ wcsconp (sysref, sysout, eqref, eqout, epref, epout,
+ &ra, &dec, &rapm, &decpm);
+
+ /* Check distance along RA and Dec axes */
+ ddist = wcsdist (cra,cdec,cra,dec);
+ if (ddist > ddec)
+ pass = 0;
+ rdist = wcsdist (cra,dec,ra,dec);
+ if (rdist > dra)
+ pass = 0;
+ }
+
+ /* Save star in FITS image */
+ if (pass) {
+ wcs2pix (wcs, ra, dec, &xpix, &ypix, &offscl);
+ if (!offscl) {
+ if (magscale > 0.0)
+ flux = magscale * exp (logt * (-mag / 2.5));
+ else
+ flux = 1.0;
+ ix = (int) (xpix + 0.5);
+ iy = (int) (ypix + 0.5);
+ addpix1 (image, bitpix, w,h, 0.0,1.0, xpix,ypix, flux);
+ nstar++;
+ jstar++;
+ }
+ else {
+ ix = 0;
+ iy = 0;
+ }
+ if (nlog == 1) {
+ fprintf (stderr,"UCACBIN: %11.6f: %9.5f %9.5f %s",
+ num,ra,dec,cstr);
+ if (magscale > 0.0)
+ fprintf (stderr, " %5.2f", mag);
+ if (!offscl)
+ flux = getpix1 (image, bitpix, w, h, 0.0, 1.0, ix, iy);
+ else
+ flux = 0.0;
+ fprintf (stderr," (%d,%d): %f\n", ix, iy, flux);
+ }
+
+ /* End of accepted star processing */
+ }
+
+ /* Log operation */
+ jstar++;
+ if (nlog > 0 && istar%nlog == 0)
+ fprintf (stderr,"UCACBIN: %5d / %5d / %5d sources\r",
+ nstar,jstar,starcat->nstars);
+
+ /* End of star loop */
+ }
+
+ /* End of 0:00 RA wrap loop */
+ }
+
+ /* End of successful zone file loop */
+ ntot = ntot + starcat->nstars;
+ if (nlog > 0)
+ fprintf (stderr,"UCACBIN: %4d / %4d: %5d / %5d / %5d sources from zone %4d \n",
+ iz+1,nz,nstar,jstar,starcat->nstars,zlist[iz]);
+
+ /* Close region input file */
+ ucacclose (starcat);
+ }
+
+ /* End of zone loop */
+ }
+
+ /* Summarize transfer */
+ if (nlog > 0) {
+ if (nz > 1)
+ fprintf (stderr,"UCACBIN: %d zones: %d / %d found\n",nz,nstar,ntot);
+ else
+ fprintf (stderr,"UCACBIN: 1 region: %d / %d found\n",nstar,ntot);
+ }
+ return (nstar);
+}
+
+
+/* UCACZONE -- Compute the zones over which to search
+ * in the specified range of coordinates.
+ * Build lists containing the first star and number of stars for each range.
+ */
+
+static int
+ucaczones (dec1, dec2, nzmax, zones, verbose)
+
+ double dec1, dec2; /* Declination limits in degrees */
+ int nzmax; /* Maximum number of zones to find */
+ int *zones; /* Zone numbers (returned)*/
+ int verbose; /* 1 for diagnostics */
+
+{
+ int nz; /* Number of declination zones found (returned) */
+ int iz, iz1, iz2;
+ int i;
+ double spd1, spd2;
+
+ for (i = 0; i < nzmax; i++)
+ zones[i] = 0;
+
+ /* Find first and last declination zone to search */
+ spd1 = 90.0 + dec1;
+ iz1 = (int) ((spd1 * 2.0) + 0.99999);
+ if (iz1 < 1) iz1 = 1;
+ spd2 = 90.0 + dec2;
+ iz2 = (int) ((spd2 * 2.0) + 0.99999);
+ if (ucat == UCAC1 && iz2 > 169) iz2 = 169;
+ if (ucat == UCAC2 && iz2 > 288) iz2 = 288;
+ if (ucat == UCAC3 && iz2 > 360) iz2 = 360;
+ if (ucat == UCAC4) {
+ iz1 = (int) ((spd1 * 5.0) + 0.99999);
+ if (iz1 < 1) iz1 = 1;
+ spd2 = 90.0 + dec2;
+ iz2 = (int) ((spd2 * 5.0) + 0.99999);
+ if (iz2 > 900) {
+ iz2 = 900;
+ }
+ }
+
+ if (iz1 > iz2)
+ return (0);
+
+ nz = iz2 - iz1 + 1;
+ if (verbose) {
+ fprintf (stderr,"UCACZONES: searching %d zones: %d - %d\n",nz,iz1,iz2);
+ fprintf(stderr,"UCACZONES: Dec: %.5f - %.5f\n", dec1,dec2);
+ }
+
+ i = 0;
+ for (iz = iz1; iz <= iz2; iz++) {
+ zones[i] = iz;
+ i++;
+ }
+
+ return (nz);
+}
+
+
+/* UCACSRA -- Find UCAC star closest to specified right ascension */
+
+static int
+ucacsra (sc, st, zone, rax0)
+
+ struct StarCat *sc; /* Star catalog descriptor */
+ struct Star *st; /* Current star entry */
+ int zone; /* Declination zone */
+ double rax0; /* Right ascension in degrees for which to search */
+{
+ int istar, istar1, istar2, nrep;
+ double rax, ra1, ra2, ra, rdiff, rdiff1, rdiff2, sdiff;
+ char rastrx[32];
+ int debug = 0;
+ int maxnrep;
+#ifdef UCAC_DEBUG
+ if (zone == 183) {
+ debug = 1;
+ fprintf(stderr,"Entering UCACSRA, zone %d\n",zone);
+ } else {
+ debug = 0;
+ }
+#endif /* UCAC_DEBUG */
+
+ rax = rax0;
+ if (debug)
+ ra2str (rastrx, 31, rax, 3);
+ istar1 = 1;
+ ucacstar (sc, st, zone, istar1);
+ ra1 = st->ra;
+ istar2 = sc->nstars;
+ maxnrep = sc->nstars;
+ istar = (istar1+istar2)/2;
+ nrep = 0;
+ while (istar != istar1 && nrep < maxnrep) {
+ if (ucacstar (sc, st, zone, istar)) {
+ break;
+ } else {
+ ra = st->ra;
+ if (ra == ra1)
+ break;
+ if (debug) {
+ char rastr[32];
+ ra2str (rastr, 31, ra, 3);
+ fprintf (stderr,"UCACSRA %d %d: %s (%s)\n",
+ nrep,istar,rastr,rastrx);
+ }
+ nrep++;
+ if (ra > rax) {
+ istar2 = istar;
+ ra2 = ra;
+ } else {
+ istar1 = istar;
+ ra1 = ra;
+ }
+ istar = (istar1+istar2)/2;
+ if (debug) {
+ fprintf (stderr," ra1= %.5f ra2= %.5f rax= %.5f\n",
+ ra1,ra2,rax);
+ fprintf (stderr," istar1= %d istar= %d istar2= %d\n",
+ istar1,istar,istar2);
+ }
+ if (istar < 1)
+ istar = 1;
+ if (istar > sc->nstars)
+ istar = sc->nstars;
+ if (istar == istar1)
+ break;
+ }
+ }
+ return (istar);
+}
+
+
+/* UCACOPEN -- Open UCAC catalog file, returning number of entries */
+
+struct StarCat *
+ucacopen (zone)
+
+ int zone; /* Number of catalog zone to read */
+
+{
+ FILE *fcat;
+ struct StarCat *sc;
+ int lfile, lpath;
+ char *zonefile;
+ char *zonepath; /* Full pathname for catalog file */
+
+ /* Set pathname for catalog file */
+ lpath = strlen (ucacpath) + 16;
+ zonepath = (char *) malloc (lpath);
+ if (ucat == UCAC1)
+ sprintf (zonepath, "%s/u1/z%03d", ucacpath, zone);
+ else if (ucat == UCAC2)
+ sprintf (zonepath, "%s/u2/z%03d", ucacpath, zone);
+ else if (ucat == UCAC3)
+ sprintf (zonepath, "%s/z%03d", ucacpath, zone);
+ else if (ucat == UCAC4)
+ sprintf (zonepath, "%s/z%03d", ucacpath, zone);
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+ /* Set UCAC catalog header information */
+ sc = (struct StarCat *) calloc (1, sizeof (struct StarCat));
+ sc->byteswapped = 0;
+
+ /* Set number of stars in this zone catalog */
+ if (ucat == UCAC1)
+ sc->nbent = 67;
+ else if (ucat == UCAC2)
+ sc->nbent = 44;
+ else if (ucat == UCAC3)
+ sc->nbent = 84;
+ else if (ucat == UCAC4)
+ sc->nbent = sizeof(UCAC4star);
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+ lfile = getfilesize (zonepath);
+ if (lfile < 2) {
+ fprintf (stderr,"UCAC zone catalog %s has no entries\n",zonepath);
+ free (sc);
+ sc = NULL;
+ return (NULL);
+ }
+ else
+ sc->nstars = lfile / sc->nbent;
+
+ /* Open UCAC file */
+ if (!(fcat = fopen (zonepath, "r"))) {
+ fprintf (stderr,"UCACOPEN: UCAC file %s cannot be read\n",zonepath);
+ free (sc);
+ return (NULL);
+ }
+
+ /* Separate filename from pathname and save in structure */
+ zonefile = strrchr (zonepath,'/');
+ if (zonefile)
+ zonefile = zonefile + 1;
+ else
+ zonefile = zonepath;
+ if (strlen (zonefile) < 24)
+ strcpy (sc->isfil, zonefile);
+ else
+ strncpy (sc->isfil, zonefile, 23);
+
+ /* Set other catalog information in structure */
+ sc->inform = 'J';
+ sc->coorsys = WCS_J2000;
+ sc->epoch = 2000.0;
+ sc->equinox = 2000.0;
+ sc->ifcat = fcat;
+ sc->sptype = 0;
+ if (ucat == UCAC1)
+ sc->nmag = 1;
+ else if (ucat == UCAC2)
+ sc->nmag = 4;
+ else if (ucat == UCAC3)
+ sc->nmag = 8;
+ else if (ucat == UCAC4)
+ sc->nmag = 8;
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+
+
+ /* UCAC stars are RA-sorted within declination zones */
+ sc->rasorted = 1;
+
+ /* Check to see if byte-swapping is necessary */
+ cswap = 0;
+ if (ucat == UCAC2) {
+ UCAC2star us2; /* UCAC2 catalog entry for one star */
+ int nbr;
+
+ nbr = fread (&us2, 1, sc->nbent, sc->ifcat);
+ if (nbr < 1) {
+ fprintf (stderr,
+ "UCACOPEN: cannot read star 1 from UCAC2 zone catalog %s\n",
+ zonepath);
+ return (0);
+ }
+
+ /* RA should be between 0 and 360 degrees in milliarcseconds */
+ if (us2.rasec > 360 * 3600000 || us2.rasec < 0)
+ cswap = 1;
+
+ /* Dec should be between -90 and +90 degrees in milliarcseconds */
+ else if (us2.decsec > 90 * 3600000 || us2.decsec < -90 * 3600000)
+ cswap = 1;
+
+ /* J H K magnitudes should be near-positive */
+ else if (us2.jmag < -1000 || us2.hmag < -1000 || us2.kmag < -1000)
+ cswap = 1;
+ else
+ cswap = 0;
+
+ /* if (cswap)
+ fprintf (stderr,
+ "UCACOPEN: swapping bytes in UCAC2 zone catalog %s\n",
+ zonepath); */
+ }
+ else if (ucat == UCAC3) {
+ UCAC3star us3; /* UCAC3 catalog entry for one star */
+ int nbr;
+
+ nbr = fread (&us3, 1, sc->nbent, sc->ifcat);
+ if (nbr < 1) {
+ fprintf (stderr,
+ "UCACOPEN: cannot read star 1 from UCAC3 zone catalog %s\n",
+ zonepath);
+ return (0);
+ }
+
+ /* RA should be between 0 and 360 degrees in milliarcseconds */
+ if (us3.rasec > 360 * 3600000 || us3.rasec < 0)
+ cswap = 1;
+
+ /* Dec should be between -90 and +90 degrees in milliarcseconds */
+ else if (us3.decsec > 180 * 3600000 || us3.decsec < -180 * 3600000)
+ cswap = 1;
+
+ /* J H K magnitudes should be near-positive */
+ else if (us3.jmag < -1000 || us3.hmag < -1000 || us3.kmag < -1000)
+ cswap = 1;
+ else
+ cswap = 0;
+
+ /* if (cswap)
+ fprintf (stderr,
+ "UCACOPEN: swapping bytes in UCAC2 zone catalog %s\n",zomepath); */
+ }
+ else if (ucat == UCAC4) {
+ UCAC4star us4; /* UCAC4 catalog entry for one star */
+ int nbr;
+
+ nbr = fread (&us4, 1, sc->nbent, sc->ifcat);
+ if (nbr < 1) {
+ fprintf (stderr,
+ "UCACOPEN: cannot read star 1 from UCAC4 zone catalog %s\n",
+ zonepath);
+ return (0);
+ }
+
+ /* RA should be between 0 and 360 degrees in milliarcseconds */
+ if (us4.ra > 360 * 3600000 || us4.ra < 0)
+ cswap = 1;
+
+ /* Dec should be between -90 and +90 degrees in milliarcseconds */
+ else if (us4.spd > 180 * 3600000 || us4.spd < 0)
+ cswap = 1;
+
+ /* J H K magnitudes should be near-positive */
+ else if (us4.mag_j < -1000 || us4.mag_h < -1000 || us4.mag_k < -1000)
+ cswap = 1;
+ else
+ cswap = 0;
+
+ if (cswap)
+ fprintf (stderr,
+ "UCACOPEN: swapping bytes in UCAC4 zone catalog %s\n",zonepath);
+ }
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+
+ sc->istar = 0;
+ free (zonepath);
+ return (sc);
+}
+
+
+void
+ucacclose (sc)
+ struct StarCat *sc; /* Star catalog descriptor */
+{
+ fclose (sc->ifcat);
+ free (sc);
+ return;
+}
+
+
+/* UCACSTAR -- Get UCAC catalog entry for one star;
+ return 0 if successful */
+
+static int
+ucacstar (sc, st, zone, istar)
+
+ struct StarCat *sc; /* Star catalog descriptor */
+ struct Star *st; /* Current star entry */
+ int zone; /* Declination zone */
+ int istar; /* Star sequence number in UCAC catalog region file */
+{
+
+
+ char line[256];
+ int nbr, nbskip;
+ UCAC2star us2; /* UCAC2 catalog entry for one star */
+ UCAC3star us3; /* UCAC3 catalog entry for one star */
+ UCAC4star us4; /* UCAC4 catalog entry for one star */
+
+ int hpmIndex;
+ int lineLen;
+ int nvals;
+ FILE *hpmHandle;
+ char inLine[MAX_U4HPM_LINE];
+ char *inBuffer;
+ PU4HPM pU4hpm = NULL;
+ char hpmpath[] = "/data/astrocat/ucac4/u4i/u4hpm.dat";
+
+
+ /* Drop out if catalog pointer is not set */
+ if (sc == NULL)
+ return (1);
+
+ /* Drop out if catalog is not open */
+ if (sc->ifcat == NULL)
+ return (2);
+
+ /* Drop out if star number is too small or too large */
+ if (istar < 1 || istar > sc->nstars) {
+ fprintf (stderr, "UCAC star %d is not in catalog\n",istar);
+ return (-1);
+ }
+
+ /* Move file pointer to start of correct star entry */
+ nbskip = sc->nbent * (istar - 1);
+ if (fseek (sc->ifcat,nbskip,SEEK_SET))
+ return (-1);
+
+ if (ucat == UCAC1)
+ nbr = fread (line, 1, sc->nbent, sc->ifcat);
+ else if (ucat == UCAC2)
+ nbr = fread (&us2, 1, sc->nbent, sc->ifcat);
+ else if (ucat == UCAC3)
+ nbr = fread (&us3, 1, sc->nbent, sc->ifcat);
+ else if (ucat == UCAC4)
+ nbr = fread (&us4, 1, sc->nbent, sc->ifcat);
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+ if (nbr < sc->nbent) {
+ fprintf (stderr, "UCACSTAR %d / %d bytes read\n",nbr, sc->nbent);
+ return (-2);
+ }
+#if 0
+ if ((zone == 552) && (istar == 43247)) {
+ printf("At zone %d and istar %d\n",zone,istar);
+ }
+#endif
+
+
+ /* Star ID number = region.sequence */
+ st->num = (double) zone + (0.000001 * (double) istar);
+
+ /* Read UCAC1 position and proper motion from ASCII file */
+ if (ucat == UCAC1) {
+
+ /* Read position in degrees */
+ st->ra = atof (line) / 3600000.0;
+ st->dec = (atof (line+10) / 3600000.0) - 90.0;
+
+ /* Read proper motion and convert it to to degrees/year */
+ st->rapm = (atof (line+41) / 3600000.0) / cosdeg (st->dec);
+ st->decpm = atof (line+48) / 3600000.0;
+
+ /* Set V magnitude */
+ st->xmag[0] = atof (line+20) * 0.01;
+ }
+
+ /* Read UCAC2 position, proper motion, and magnitudes from binary file */
+ else if (ucat == UCAC2) {
+ if (cswap) {
+ ucacswap4 (&us2.rasec);
+ ucacswap4 (&us2.decsec);
+ ucacswap4 (&us2.rapm);
+ ucacswap4 (&us2.decpm);
+ ucacswap2 (&us2.cmag);
+ ucacswap2 (&us2.jmag);
+ ucacswap2 (&us2.hmag);
+ ucacswap2 (&us2.kmag);
+ }
+ st->ra = (double) us2.rasec / 3600000.0;
+ st->dec = (double) us2.decsec / 3600000.0;
+ st->errra = (double) us2.era / 3600000.0; /* mas */
+ st->errra = st->errra / cosdeg (st->dec); /* to RA deg */
+ st->errdec = (double) us2.edec / 3600000.0; /* mas */
+ st->rapm = (double) us2.rapm / 36000000.0; /* 0.1mas/yr */
+ st->decpm = (double) us2.decpm / 36000000.0; /* 0.1mas/yr */
+ st->errpmr = (double) us2.erapm / 36000000.0; /* 0.1mas/yr */
+ st->errpmr = st->errpmr / cosdeg (st->dec); /* to RA deg */
+ st->errpmd = (double) us2.edecpm / 36000000.0; /* 0.1mas/yr */
+ st->xmag[0] = ((double) us2.jmag) / 1000.0;
+ st->xmag[1] = ((double) us2.hmag) / 1000.0;
+ st->xmag[2] = ((double) us2.kmag) / 1000.0;
+ st->xmag[3] = ((double) us2.cmag) / 100.0;
+ st->nimage = (int) us2.nobs;
+ st->ncat = (int) us2.ncat;
+ }
+
+ /* Read UCAC3 position, proper motion, and magnitudes from binary file */
+ else if (ucat == UCAC3) {
+ if (cswap) {
+ ucacswap4 (&us3.rasec);
+ ucacswap4 (&us3.decsec);
+ ucacswap4 (&us3.rapm);
+ ucacswap4 (&us3.decpm);
+ ucacswap2 (&us3.sigra);
+ ucacswap2 (&us3.sigdec);
+ ucacswap2 (&us3.sigpmr);
+ ucacswap2 (&us3.sigpmd);
+ ucacswap2 (&us3.mmag);
+ ucacswap2 (&us3.amag);
+ ucacswap2 (&us3.jmag);
+ ucacswap2 (&us3.hmag);
+ ucacswap2 (&us3.kmag);
+ ucacswap2 (&us3.bmag);
+ ucacswap2 (&us3.rmag);
+ ucacswap2 (&us3.imag);
+ }
+ st->ra = (double) us3.rasec / 3600000.0; /* mas */
+ st->dec = (double) us3.decsec / 3600000.0; /* mas */
+ st->dec = st->dec - 90.0;
+ st->errra = (double) us3.sigra / 3600000.0; /* mas */
+ st->errra = st->errra / cosdeg (st->dec); /* to RA deg */
+ st->errdec = (double) us3.sigdec / 3600000.0; /* mas */
+ st->rapm = (double) us3.rapm / 36000000.0; /* 0.1mas/yr */
+ st->rapm = st->rapm / cosdeg (st->dec); /* to RA deg */
+ st->decpm = (double) us3.decpm / 36000000.0; /* 0.1mas/yr */
+ st->errpmr = (double) us3.sigpmr / 36000000.0; /* 0.1mas/yr */
+ st->errpmr = st->errpmr / cosdeg (st->dec); /* to RA deg */
+ st->errpmd = (double) us3.sigpmd / 36000000.0; /* 0.1mas/yr */
+ st->nimage = (int) us3.nu1;
+ st->ncat = (int) us3.us1;
+ if (us3.bmag == 0)
+ st->xmag[0] = 99.990;
+ else
+ st->xmag[0] = ((double) us3.bmag) / 1000.0;
+ if (us3.rmag == 0)
+ st->xmag[1] = 99.990;
+ else
+ st->xmag[1] = ((double) us3.rmag) / 1000.0;
+ if (us3.imag == 0)
+ st->xmag[2] = 99.990;
+ else
+ st->xmag[2] = ((double) us3.imag) / 1000.0;
+ if (us3.jmag == 0)
+ st->xmag[3] = 99.990;
+ else
+ st->xmag[3] = ((double) us3.jmag) / 1000.0;
+ if (us3.hmag == 0)
+ st->xmag[4] = 99.990;
+ else
+ st->xmag[4] = ((double) us3.hmag) / 1000.0;
+ if (us3.kmag == 0)
+ st->xmag[5] = 99.990;
+ else
+ st->xmag[5] = ((double) us3.kmag) / 1000.0;
+ if (us3.mmag == 0)
+ st->xmag[6] = 99.990;
+ else
+ st->xmag[6] = ((double) us3.mmag) / 1000.0;
+ if (us3.amag == 0)
+ st->xmag[7] = 99.990;
+ else
+ st->xmag[7] = ((double) us3.amag) / 1000.0;
+ }
+ else if (ucat == UCAC4) {
+ if (cswap) {
+ ucacswap4 (&us4.ra);
+ ucacswap4 (&us4.spd);
+ ucacswap4 (&us4.pm_ra);
+ ucacswap4 (&us4.pm_dec);
+ ucacswap4 (&us4.id_number);
+ ucacswap2 (&us4.ra_sigma);
+ ucacswap2 (&us4.dec_sigma);
+ ucacswap2 (&us4.pm_ra_sigma);
+ ucacswap2 (&us4.pm_dec_sigma);
+ ucacswap2 (&us4.mag1);
+ ucacswap2 (&us4.mag2);
+ ucacswap2 (&us4.mag_j);
+ ucacswap2 (&us4.mag_h);
+ ucacswap2 (&us4.mag_k);
+ ucacswap2 (&us4.apass_mag[0]);
+ ucacswap2 (&us4.apass_mag[3]);
+ ucacswap2 (&us4.apass_mag[4]);
+ }
+ st->ra = (double) us4.ra / 3600000.0; /* mas */
+ st->dec = (double) us4.spd / 3600000.0; /* mas */
+ st->dec = st->dec - 90.0;
+ st->errra = (double) us4.ra_sigma / 3600000.0; /* mas */
+ st->errra = st->errra / cosdeg (st->dec); /* to RA deg */
+ st->errdec = (double) us4.dec_sigma / 3600000.0; /* mas */
+
+ /* Must get proper motions from a different catalog */
+ if ((us4.pm_ra == 32767) || (us4.pm_dec == 32767)) {
+ if (hpmLines == 0) {
+ /* Read in the high proper motion catalog */
+ hpmHandle = fopen(hpmpath,"rt");
+ if (hpmHandle == NULL) {
+ printf("ERROR: failed to open %s\n",hpmpath);
+ exit(-1);
+ }
+ hpmLines = 0;
+ while(1) {
+ if (hpmLines >= MAX_U4HPM_RECORDS) {
+ printf("ERROR: MAX_U4HPM_RECORDS exceeded\n");
+ exit(-1);
+ }
+ pU4hpm = &u4hpm_table[hpmLines];
+ memset(pU4hpm,0,sizeof(U4HPM));
+ inBuffer = fgets(inLine,MAX_U4HPM_LINE,hpmHandle);
+ if (inBuffer == NULL) {
+ break;
+ }
+ lineLen = strlen(inBuffer);
+ /* Trim off the carriage return */
+ if (inBuffer[lineLen-1] == 10) {
+ inBuffer[lineLen-1] = 0;
+ lineLen--;
+ }
+ /* Trim off the line feed */
+ if (inBuffer[lineLen-1] == 13) {
+ inBuffer[lineLen-1] = 0;
+ lineLen--;
+ }
+ nvals = sscanf(inBuffer,"%d %d %d %d %d %d %d %d",
+ &pU4hpm->rnm,
+ &pU4hpm->zn,
+ &pU4hpm->rnz,
+ &pU4hpm->pmrc,
+ &pU4hpm->pmd,
+ &pU4hpm->ra,
+ &pU4hpm->dec,
+ &pU4hpm->maga);
+ if (nvals != 8) {
+ fprintf(stderr,"Error reading line %d of u4hpm %s\n",hpmLines,inLine);
+ } else {
+ hpmLines++;
+ }
+ }
+ fclose(hpmHandle);
+ }
+ for (hpmIndex = 0; hpmIndex < hpmLines; hpmIndex++) {
+ pU4hpm = &u4hpm_table[hpmIndex];
+ if ((zone == pU4hpm->zn) &&
+ (us4.id_number == pU4hpm->rnm) &&
+ (us4.ra == pU4hpm->ra) &&
+ (us4.spd == pU4hpm->dec) &&
+ (us4.mag2 == pU4hpm->maga)) {
+ /* We have a match */
+ st->rapm = (1.0 * pU4hpm->pmrc) / 36000000.0; /* 0.1 mas/yr */
+ st->rapm = st->rapm / cosdeg (st->dec); /* to RA deg */
+ st->decpm = (1.0 * pU4hpm->pmd) / 36000000.0; /* 0.1 mas/yr */
+ break;
+ }
+ }
+ if (hpmIndex == hpmLines) {
+ fprintf(stderr,"ERROR: no proper motion found for zone %d entry %d\n",zone,us4.id_number);
+ }
+
+ } else {
+
+ st->rapm = (double) us4.pm_ra / 36000000.0; /* 0.1mas/yr */
+ st->rapm = st->rapm / cosdeg (st->dec); /* to RA deg */
+ st->decpm = (double) us4.pm_dec / 36000000.0; /* 0.1mas/yr */
+ }
+ st->errpmr = (double) (us4.pm_ra_sigma+128) / 36000000.0; /* 0.1mas/yr */
+ st->errpmr = st->errpmr / cosdeg (st->dec); /* to RA deg */
+ st->errpmd = (double) (us4.pm_dec_sigma+128) / 36000000.0; /* 0.1mas/yr */
+ st->nimage = (int) us4.n_ucac_used;
+ st->ncat = (int) us4.n_cats_used;
+ if (us4.apass_mag[0] == 20000)
+ st->xmag[0] = 99.990;
+ else
+ st->xmag[0] = ((double) us4.apass_mag[0]) / 1000.0;
+ if (us4.apass_mag[3] == 20000)
+ st->xmag[1] = 99.990;
+ else
+ st->xmag[1] = ((double) us4.apass_mag[3]) / 1000.0;
+ if (us4.apass_mag[4] == 20000)
+ st->xmag[2] = 99.990;
+ else
+ st->xmag[2] = ((double) us4.apass_mag[4]) / 1000.0;
+ if (us4.mag_j == 0)
+ st->xmag[3] = 99.990;
+ else
+ st->xmag[3] = ((double) us4.mag_j) / 1000.0;
+ if (us4.mag_h == 0)
+ st->xmag[4] = 99.990;
+ else
+ st->xmag[4] = ((double) us4.mag_h) / 1000.0;
+ if (us4.mag_k == 0)
+ st->xmag[5] = 99.990;
+ else
+ st->xmag[5] = ((double) us4.mag_k) / 1000.0;
+ if (us4.mag1 == 20000)
+ st->xmag[6] = 99.990;
+ else
+ st->xmag[6] = ((double) us4.mag1) / 1000.0;
+ if (us4.mag2 == 20000)
+ st->xmag[7] = 99.990;
+ else
+ st->xmag[7] = ((double) us4.mag2) / 1000.0;
+
+ /* DASCH specific. Since we are sorting on mag[6], try using APASS B or mag[7] first */
+ if (st->xmag[7] < 90.0) {
+ st->xmag[6] = st->xmag[7];
+ }
+ if (st->xmag[0] < 90.0) {
+ st->xmag[6] = st->xmag[0];
+ }
+
+ }
+ else {
+ fprintf(stderr,"ucacread CATALOG NUMBER ERROR %d in line %d\n",ucat,__LINE__);
+ exit(-1);
+ }
+
+
+#if 0
+ if ((zone == 256) && (istar == 149200)) {
+ printf("At zone %d and istar %d\n",zone,istar);
+ }
+#endif
+
+#ifdef UCAC_DEBUG
+ if (zone == 183) {
+ fprintf(stderr,"istar %6d, ra %.3f dec %.3f\n",istar,st->ra,st->dec);
+
+ }
+#endif /* UCAC_DEBUG */
+
+ return (0);
+}
+
+
+/* UCACSWAP2 -- Swap bytes in Integer*2 number in place */
+
+static void
+ucacswap2 (string)
+
+
+ char *string; /* Address of starting point of bytes to swap */
+
+{
+ char *sbyte, temp;
+
+ sbyte = string;
+ temp = sbyte[0];
+ sbyte[0] = sbyte[1];
+ sbyte[1] = temp;
+ return;
+}
+
+
+/* UCACSWAP4 -- Reverse bytes of Integer*4 or Real*4 number in place */
+
+static void
+ucacswap4 (string)
+
+ char *string; /* Address of Integer*4 or Real*4 vector */
+
+{
+ char temp0, temp1, temp2, temp3;
+
+ temp3 = string[0];
+ temp2 = string[1];
+ temp1 = string[2];
+ temp0 = string[3];
+ string[0] = temp0;
+ string[1] = temp1;
+ string[2] = temp2;
+ string[3] = temp3;
+
+ return;
+}
+
+/* Apr 24 2003 New subroutines, based on ty2read.c and uacread.c
+ * May 30 2003 Add UCAC2, compute file size rather than reading it from file
+ * Jun 2 2003 Print proper motions as mas/year
+ * Aug 22 2003 Add radi argument for inner edge of search annulus
+ * Sep 25 2003 Add ucacbin() to fill an image with sources
+ * Oct 6 2003 Update ubcread() and ubcbin() for improved RefLim()
+ * Nov 10 2003 Fix byte-swapping test in ucacopen() found by Ed Beshore
+ * Nov 18 2003 Initialize image size and bits/pixel from header in ucacbin()
+ * Dec 1 2003 Add missing tab to n=-1 header
+ * Dec 12 2003 Fix bug in wcs2pix() call in ucacbin()
+ *
+ * Jan 4 2005 Fix bug in if statement on line 626 found by Dan Katz at JPL
+ *
+ * Jun 20 2006 Drop unused variables
+ * Sep 26 2006 Increase length of rastr and destr from 16 to 32
+ * Nov 16 2006 Fix binning
+ *
+ * Jan 8 2007 Drop unused variable in ucacbin()
+ * Jan 10 2007 Add match=1 argument to webrnum()
+ * Jul 11 2007 Add magnitude byte-swap check
+ *
+ * Oct 5 2009 Add UCAC3
+ * Oct 15 2009 Read extra stars in RA
+ * Oct 22 2009 Set UCAC3 magnitudes to 99.99 if zero
+ * Oct 30 2009 Add position and proper motion error to Star structure
+ * Nov 2 2009 Print UCAC3 errors if n = -1
+ * Nov 5 2009 Return number of images and catalogs in gtype
+ * Nov 5 2009 Return errors in position and proper motion as magnitudes
+ * Nov 5 2009 Return UCAC2 and UCAC3 RA proper motion and error as RA degrees
+ * Dec 14 2009 Drop nmag1 from ucacread() and ucacrnum(); it wasn't being used
+ * Jan 29 2013 Add UCAC4 support see "DASCH" tag for DASCH-specific changes
+ */
diff --git a/libwcs/ucacread.c20130208 b/libwcs/ucacread.c20130208
new file mode 100644
index 0000000..6243a8f
Binary files /dev/null and b/libwcs/ucacread.c20130208 differ
diff --git a/libwcs/ucacread.c b/libwcs/ucacread0.c
similarity index 100%
copy from libwcs/ucacread.c
copy to libwcs/ucacread0.c
diff --git a/libwcs/vi b/libwcs/vi
new file mode 100644
index 0000000..e69de29
diff --git a/libwcs/wcs.h b/libwcs/wcs.h
index 1943c8d..cef3dae 100644
--- a/libwcs/wcs.h
+++ b/libwcs/wcs.h
@@ -1,8 +1,8 @@
/*** File libwcs/wcs.h
- *** September 9, 2011
+ *** February 1, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1994-2011
+ *** Copyright (C) 1994-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -295,6 +295,8 @@ extern "C" {
const char* hstring, /* FITS header */
int len, /* Length of FITS header */
char *wcschar); /* WCS character (A-Z) */
+ char *uppercase ( /* Convert string of any case to uppercase */
+ const char *string); /* String to convert */
/* WCS subroutines in wcs.c */
void wcsfree ( /* Free a WCS structure and its contents */
@@ -735,7 +737,8 @@ struct WorldCoor *wcsinitc(); /* set up a WCS structure from a FITS image header
struct WorldCoor *wcsninitc(); /* set up a WCS structure from a FITS image header */
struct WorldCoor *wcsxinit(); /* set up a WCS structure from arguments */
struct WorldCoor *wcskinit(); /* set up a WCS structure from keyword values */
-void wcsfree(void); /* Free a WCS structure and its contents */
+char *uppercase(); /* Convert string of any case to uppercase */
+void wcsfree(void); /* Free a WCS structure and its contents */
int wcstype(); /* Set projection type from header CTYPEs */
void wcscdset(); /* Set scaling and rotation from CD matrix */
void wcsdeltset(); /* set scaling and rotation from CDELTs and CROTA2 */
@@ -960,4 +963,7 @@ extern int zpxpix(); /* Inverse transform (world to physical) gnomonic projectio
* Mar 14 2011 Add SCAMP polynomial projection coefficients
* Sep 1 2011 Add TPV TAN projectioin with SCAT PV terms
* Sep 9 2011 Fix comment on TPV declaration
+ *
+ * Feb 1 2013 Add uppercase() from wcsinit()
+ * Feb 25 2013 Pass const string to uppercase()
*/
diff --git a/libwcs/wcscat.h b/libwcs/wcscat.h
index 46638bf..4b01bdd 100644
--- a/libwcs/wcscat.h
+++ b/libwcs/wcscat.h
@@ -1,7 +1,7 @@
/*** File libwcs/wcscat.h
- *** May 16, 2012
+ *** February 15, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
- *** Copyright (C) 1998-2012
+ *** Copyright (C) 1998-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -206,11 +206,12 @@ struct TabTable {
#define SKY2K 30 /* SKY2000 Master Catalog */
#define SKYBOT 31 /* SKYBOT Solar System Objects */
#define UCAC3 32 /* USNO CCD Astrograph Catalog 3.0 (2009) */
+#define UCAC4 33 /* USNO CCD Astrograph Catalog 4.0 (2013) */
#define TABCAT -1 /* StarBase tab table catalog */
#define BINCAT -2 /* TDC binary catalog */
#define TXTCAT -3 /* TDC ASCII catalog */
#define WEBCAT -4 /* Tab catalog via the web */
-#define NUMCAT 31 /* Number of predefined catalogs */
+#define NUMCAT 33 /* Number of predefined catalogs */
#define EP_EP 1 /* Output epoch as fractional year */
#define EP_JD 2 /* Output epoch as Julian Date */
@@ -1697,4 +1698,6 @@ double polcomp(); /* Evaluate polynomial from polfit coefficients */
* Apr 06 2010 Add fillblank argument to agets()
*
* May 16 2012 Add valmin and valmax to Range data structure
+ *
+ * Feb 15 2013 Add UCAC4 to list of catalog codes
*/
diff --git a/libwcs/wcsinit.c b/libwcs/wcsinit.c
index 0b6c0af..b356488 100644
--- a/libwcs/wcsinit.c
+++ b/libwcs/wcsinit.c
@@ -1,8 +1,8 @@
/*** File libwcs/wcsinit.c
- *** October 19, 2012
+ *** July 24, 2013
*** By Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
- *** Copyright (C) 1998-2012
+ *** Copyright (C) 1998-2013
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -100,7 +100,7 @@ const char *hstring; /* character string containing FITS header information
const char *name; /* Name of WCS conversion to be matched
(case-independent) */
{
- char *upname, *uppercase();
+ char *upname;
char cwcs, charwcs;
int iwcs;
char keyword[12];
@@ -143,7 +143,7 @@ const char *name; /* Name of WCS conversion to be matched
char *
uppercase (string)
-char *string;
+const char *string;
{
int lstring, i;
char *upstring;
@@ -758,7 +758,7 @@ char *wchar; /* Suffix character for one of multiple WCS */
/* SCAMP convention */
if (wcs->prjcode == WCS_TAN && wcs->naxis == 2) {
- int n;
+ int n = 0;
if (wcs->inv_x) {
poly_end(wcs->inv_x);
wcs->inv_x = NULL;
@@ -783,8 +783,8 @@ char *wchar; /* Suffix character for one of multiple WCS */
}
}
- /* If any PVi_j are set, add them to the structure */
- if (n > 0) {
+ /* If any PVi_j are set, add them in the structure if no SIRTF distortion*/
+ if (n > 0 && wcs->distcode != DISTORT_SIRTF) {
n = 0;
for (k = MAXPV; k >= 0; k--) {
@@ -1608,4 +1608,8 @@ char *mchar; /* Suffix character for one of multiple WCS */
* Sep 1 2011 Add TPV as TAN with SCAMP PVs
*
* Oct 19 2012 Drop unused variable iszpx; fix bug in latmin assignment
+ *
+ * Feb 1 2013 Externalize uppercase()
+ * Feb 07 2013 Avoid SWARP distortion if SIRTF distortion is present
+ * Jul 25 2013 Initialize n=0 when checking for SCAMP distortion terms (fix from Martin Kuemmel)
*/
diff --git a/libwcs/zpxpos.c b/libwcs/zpxpos.c
index 0994293..a6f7168 100644
--- a/libwcs/zpxpos.c
+++ b/libwcs/zpxpos.c
@@ -1,10 +1,10 @@
/*** File wcslib/zpxpos.c
- *** March 8, 2011
+ *** October 31, 2012
*** By Frank Valdes, valdes at noao.edu
*** Modified from tnxpos.c by Jessica Mink, jmink at cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
*** After IRAF mwcs/wfzpx.x
- *** Copyright (C) 1998-2011
+ *** Copyright (C) 1998-2012
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
@@ -182,12 +182,12 @@ struct WorldCoor *wcs; /* pointer to WCS structure */
d2 = 0.;
for (j = wcs->zpnp; j >= 1; j--) {
d2 = d2 * zd2 + j * wcs->prj.p[j];
- }
+ }
if (d2 <= 0.)
break;
zd1 = zd2;
d1 = d2;
- }
+ }
/* Find where the derivative is 0. */
if (d2 <= 0.0) {
@@ -196,20 +196,22 @@ struct WorldCoor *wcs; /* pointer to WCS structure */
d = 0.;
for (j = wcs->zpnp; j >= 1; j--) {
d = d * zd + j * wcs->prj.p[j];
- }
+ }
if (fabs(d) < TOL)
break;
if (d < 0.) {
zd2 = zd;
d2 = d;
- } else {
+ }
+ else {
zd1 = zd;
d1 = d;
+ }
}
}
/* No negative derivative. */
- } else
+ else
zd = PI;
r = 0.;
@@ -217,7 +219,7 @@ struct WorldCoor *wcs; /* pointer to WCS structure */
r = r * zd + wcs->prj.p[j];
wcs->zpzd = zd;
wcs->zpr = r;
- }
+ }
/* Compute image rotation */
wcsrotset (wcs);
@@ -288,7 +290,7 @@ double *xpos, *ypos; /*o world coordinates (ra, dec) */
}
}
- /* get the axis numbers */
+ /* Get the axis numbers */
if (wcs->coorflip) {
ira = 1;
idec = 0;
@@ -317,20 +319,22 @@ double *xpos, *ypos; /*o world coordinates (ra, dec) */
y = yp;
r = sqrt (x * x + y * y) / wcs->rodeg;
- /* Solve. */
+ /* Solve */
/* Constant no solution */
if (k < 1) {
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
+ }
- /* Linear. */
- } else if (k == 1) {
+ /* Linear */
+ else if (k == 1) {
zd = (r - wcs->prj.p[0]) / wcs->prj.p[1];
+ }
- /* Quadratic. */
- } else if (k == 2) {
+ /* Quadratic */
+ else if (k == 2) {
a = wcs->prj.p[2];
b = wcs->prj.p[1];
@@ -340,33 +344,42 @@ double *xpos, *ypos; /*o world coordinates (ra, dec) */
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
- }
+ }
d = sqrt (d);
- /* Choose solution closest to the pole.
+ /* Choose solution closest to the pole */
zd1 = (-b + d) / (2. * a);
zd2 = (-b - d) / (2. * a);
- zd = min (zd1, zd2);
- if (zd < -TOL)
- zd = max (zd1, zd2);
+ if (zd1 < zd2)
+ zd = zd1;
+ else
+ zd = zd2;
+ if (zd < -TOL) {
+ if (zd1 > zd2)
+ zd = zd1;
+ else
+ zd = zd2;
+ }
if (zd < 0.) {
if (zd < -TOL) {
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
+ }
+ zd = 0.;
}
- zd = 0.
- } else if (zd > PI) {
- if (zd > (PI + TOL) {
+ else if (zd > PI) {
+ if (zd > (PI + TOL)) {
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
+ }
+ zd = PI;
}
- zd = PI
}
- /* Higher order solve iteratively. */
- } else {
+ /* Higher order solve iteratively */
+ else {
zd1 = 0.;
r1 = wcs->prj.p[0];
@@ -378,16 +391,18 @@ double *xpos, *ypos; /*o world coordinates (ra, dec) */
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
- }
+ }
zd = zd1;
- } else if (r > r2) {
+ }
+ else if (r > r2) {
if (r > (r2 + TOL)) {
*xpos = BADCVAL;
*ypos = BADCVAL;
return (1);
- }
+ }
zd = zd2;
- } else {
+ }
+ else {
for (j=0; j<100; j++) {
lambda = (r2 - r) / (r2 - r1);
if (lambda < 0.1)
@@ -403,20 +418,21 @@ double *xpos, *ypos; /*o world coordinates (ra, dec) */
break;
r1 = rt;
zd1 = zd;
- } else {
+ }
+ else {
if ((rt - r) < TOL)
break;
r2 = rt;
zd2 = zd;
- }
+ }
lambda = zd2 - zd1;
lambda = fabs (zd2 - zd1);
if (fabs (zd2 - zd1) < TOL)
break;
+ }
}
}
- }
-
+
/* Compute phi */
if (r == 0.0)
phi = 0.0;
@@ -714,4 +730,6 @@ struct IRAFsurface *sf; /* the surface descriptor */
/*
* Mar 8 2011 Created from tnxpos.c and wfzpx.x
+ *
+ * Oct 31 2012 End comment on line 346 after pole; fix code thereafter
*/
diff --git a/lin.o b/lin.o
new file mode 100644
index 0000000..742cb5f
Binary files /dev/null and b/lin.o differ
diff --git a/matchcat.c b/matchcat.c
index 27e007c..a832dcf 100644
--- a/matchcat.c
+++ b/matchcat.c
@@ -36,7 +36,7 @@ static double matchrad = 5.0; /* Initial match radius is 5 arcseconds */
int version = 0; /* If 1, print only program name and version */
static void usage();
-static char *RevMsg = "MATCHCAT WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "MATCHCAT WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
main (ac, av)
int ac;
diff --git a/matchstar.o b/matchstar.o
new file mode 100644
index 0000000..8df5c5f
Binary files /dev/null and b/matchstar.o differ
diff --git a/nedname.c b/nedname.c
index a9be5a3..0654a98 100644
--- a/nedname.c
+++ b/nedname.c
@@ -9,7 +9,7 @@
#include "libned/ned_client.h"
#include "libwcs/wcs.h"
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
extern int ned_errno;
static void PrintUsage();
diff --git a/nedpos.c b/nedpos.c
index a4c3162..88c132b 100644
--- a/nedpos.c
+++ b/nedpos.c
@@ -10,7 +10,7 @@
#include "libwcs/wcs.h"
#include "libwcs/fitsfile.h"
-static char *RevMsg = "NEDPOS 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "NEDPOS 3.9.0, 29 August 2014, Jessica Mink SAO";
extern int ned_errno;
static void PrintUsage();
diff --git a/newfits.c b/newfits.c
index 5ce42e3..255add4 100644
--- a/newfits.c
+++ b/newfits.c
@@ -47,7 +47,7 @@ extern void setcdelt();
extern void setproj();
extern struct WorldCoor *GetFITSWCS();
-static char *RevMsg = "NEWFITS WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "NEWFITS WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int verbose = 0; /* verbose/debugging flag */
static int bitpix = 0; /* number of bits per pixel (FITS code, 0=no image) */
static int version = 0; /* If 1, print only program name and version */
diff --git a/nut1981.o b/nut1981.o
new file mode 100644
index 0000000..cf15743
Binary files /dev/null and b/nut1981.o differ
diff --git a/nut2006.o b/nut2006.o
new file mode 100644
index 0000000..473e6bb
Binary files /dev/null and b/nut2006.o differ
diff --git a/platefit.o b/platefit.o
new file mode 100644
index 0000000..5269b02
Binary files /dev/null and b/platefit.o differ
diff --git a/platepos.o b/platepos.o
new file mode 100644
index 0000000..d8083a3
Binary files /dev/null and b/platepos.o differ
diff --git a/polfit.o b/polfit.o
new file mode 100644
index 0000000..6f9c363
Binary files /dev/null and b/polfit.o differ
diff --git a/poly.o b/poly.o
new file mode 100644
index 0000000..d25a6e2
Binary files /dev/null and b/poly.o differ
diff --git a/proj.o b/proj.o
new file mode 100644
index 0000000..ed3fa4f
Binary files /dev/null and b/proj.o differ
diff --git a/remap.c b/remap.c
index 2bbd338..1d26a6c 100644
--- a/remap.c
+++ b/remap.c
@@ -1,9 +1,9 @@
/* File remap.c
- * October 15, 2010
+ * February 19, 2014
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1999-2010
+ Copyright (C) 1999-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -28,8 +28,7 @@
#include <errno.h>
#include <unistd.h>
#include <math.h>
-#include "libwcs/fitsfile.h"
-#include "libwcs/wcs.h"
+#include "libwcs/fitswcs.h"
#define REMAP_CLOSEST 1
#define REMAP_FLUX 2
@@ -50,7 +49,7 @@ static char *outname0 = "remap.fits";
static char *outname;
static char *wcsproj; /* WCS projection name */
-static char *RevMsg = "REMAP WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "REMAP WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
static int nfiles = 0;
static int fitsout = 1;
static double secpix = 0;
@@ -58,7 +57,6 @@ static double secpix2 = 0;
static int bitpix0 = 0; /* Output BITPIX, =input if 0 */
static int RemapImage();
static void getsection();
-extern struct WorldCoor *GetFITSWCS();
static struct WorldCoor *wcsout = NULL;
static char *irafheader; /* IRAF image header */
static char *headout; /* FITS output header */
@@ -374,8 +372,8 @@ char *message; /* Error message */
if (message != NULL)
fprintf (stderr, "ERROR: %c %s\n", arg, message);
fprintf (stderr,"Remap FITS or IRAF images into single FITS image using WCS\n");
- fprintf(stderr,"Usage: remap [-vf][-a rot][[-b][-j] ra dec][-i bits][-l num] file1.fit file2.fit ... filen.fit\n");
- fprintf(stderr," or : remap [-vf][-a rot][[-b][-j] ra dec][-i bits][-l num] @filelist\n");
+ fprintf(stderr,"Usage: remap [-v][-f WCSfile][-a rot][[-b][-j] ra dec][-i bits][-l num] file1.fit file2.fit ... filen.fit\n");
+ fprintf(stderr," or : remap [-v][-f WCSfile][-a rot][[-b][-j] ra dec][-i bits][-l num] @filelist\n");
fprintf(stderr," -a: Output rotation angle in degrees (default 0)\n");
fprintf(stderr," -b ra dec: Output center in B1950 (FK4) RA and Dec\n");
fprintf(stderr," -e long lat: Output center in ecliptic longitude and latitude\n");
@@ -945,4 +943,8 @@ double *y2; /* Upper right y coordinate (returned) */
* Jan 10 2007 Drop unused variable dy
*
* Oct 15 2010 Use center coordinates of original image if not set
+ *
+ * Sep 17 2013 Include fitswcs.h
+ *
+ * Feb 19 2014 Update usage to -f WCSfile suggested by Steve Willner
*/
diff --git a/revup.sed b/revup.sed
index 2dedc81..8a8346c 100644
--- a/revup.sed
+++ b/revup.sed
@@ -1 +1 @@
-1,$s/3\.8\.6, 2 October 2012/3\.8\.7, 19 October 2012/
+1,$s/3\.9\.0, 28 August 2014/3\.9\.0, 29 August 2014/
diff --git a/scat.c b/scat.c
index da1af6d..e52cbfb 100644
--- a/scat.c
+++ b/scat.c
@@ -1,9 +1,9 @@
/* File scat.c
- * April 21, 2011
+ * February 1, 2013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1996-2011
+ Copyright (C) 1996-2013
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@
#include "libwcs/fitsfile.h"
#include "libwcs/wcscat.h"
-static char *RevMsg = "WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static void PrintUsage();
static int scatparm();
@@ -1064,6 +1064,7 @@ char *command; /* Command where error occurred or NULL */
fprintf(dev," -mx mag1[,mag2]: Magnitude #x limit(s) (only one set allowed, default none) \n");
fprintf(dev," -n num: Number of brightest stars to print (-1=all as found)\n");
fprintf(dev," -o name: Object name \n");
+ fprintf(dev," -p: Sort by distance from search center\n");
fprintf(dev," -q year: Equinox of output positions in FITS date format or years\n");
fprintf(dev," -r rad: Search radius (<0=-half-width) in arcsec\n");
fprintf(dev," -r radi-rado: Inner and outer edges of search annulus in arcsec\n");
@@ -2141,6 +2142,8 @@ double eqout; /* Equinox for output coordinates */
printf ("raerr decerr magj magh magk magc ");
else if (refcat == UCAC3)
printf ("raerr decerr magb magr magi magj magh magk magm maga ");
+ else if (refcat == UCAC4)
+ printf ("raerr decerr magb magr magi magj magh magk magm maga ");
else if (nmagr > 0) {
for (imag = 0; imag < nmagr; imag++) {
if (starcat[icat] != NULL &&
@@ -2156,7 +2159,7 @@ double eqout; /* Equinox for output coordinates */
printf ("spt ");
if (mprop == 1)
printf ("pmra pmdec ");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
printf ("epmra epmdec ni nc ");
if (refcat == UB1)
printf ("pm ni sg ");
@@ -2204,7 +2207,7 @@ double eqout; /* Equinox for output coordinates */
headline[nnfld] = (char) 0;
printf ("%s", headline);
printf (" ------------ ------------ ");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
printf ("----- ----- ");
if (refcat == GSC2)
printf ("----- ----- ----- ----- ");
@@ -2227,7 +2230,7 @@ double eqout; /* Equinox for output coordinates */
printf ("--------- ");
if (mprop == 1)
printf ("------ ------ ");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
printf ("----- ----- -- -- ");
if (refcat == UB1)
printf ("-- -- -- ");
@@ -2370,7 +2373,7 @@ double eqout; /* Equinox for output coordinates */
else
printf (" %s %s %s",
numstr, rastr, decstr);
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
era = gm[nmagr][0] * cosdeg (gdec[i]) * 3600.0;
edec = gm[nmagr+1][0] * 3600.0;
printf (" %5.3f %5.3f", era, edec);
@@ -2483,7 +2486,7 @@ double eqout; /* Equinox for output coordinates */
else
printf (" %6.1f %6.1f", pra, pdec);
}
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
epmr = gm[nmagr+2][0] * cosdeg (gdec[i]) * 3600000.0;
epmd = gm[nmagr+3][0] * 3600000.0;
nim = gc[0] / 1000;
@@ -2903,7 +2906,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline," ra1950 dec1950 ");
else
strcat (headline," ra dec ");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline," raerr decerr");
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2)
@@ -2924,7 +2927,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline," magf magj magn magv ");
else if (refcat == UCAC2)
strcat (headline," magj magh magk magc ");
- else if (refcat == UCAC3)
+ else if (refcat == UCAC3 || refcat == UCAC4)
strcat (headline," magb magr magi magj magh magk magm maga ");
else if (refcat == SKYBOT)
strcat (headline," magv gdist hdist ");
@@ -2966,7 +2969,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline," velocity");
if (mprop == 1)
strcat (headline," pmra pmdec ");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline," epmra epmdec ni nc");
if (refcat == GSC2)
strcat (headline," class");
@@ -2993,7 +2996,7 @@ double eqout; /* Equinox for output coordinates */
strcpy (headline, "-------------------------");
headline[nnfld] = (char) 0;
strcat (headline," ------------ ------------");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline," ----- -----");
if (refcat == TMPSC || refcat == TMIDR2)
strcat (headline," ------- ------- -------");
@@ -3025,7 +3028,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline," --------");
if (mprop == 1)
strcat (headline," ------ ------");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline," ----- ----- -- --");
if (refcat == GSC2)
strcat (headline," -----");
@@ -3081,6 +3084,10 @@ double eqout; /* Equinox for output coordinates */
strcpy (headline, "UCAC1_num ");
else if (refcat == UCAC2)
strcpy (headline, "UCAC2_num ");
+ else if (refcat == UCAC3)
+ strcpy (headline, "UCAC3_num ");
+ else if (refcat == UCAC4)
+ strcpy (headline, "UCAC4_num ");
else if (refcat == TMPSC || refcat == TMPSCE)
strcpy (headline, "2MASS_num. ");
else if (refcat == TMXSC)
@@ -3175,8 +3182,8 @@ double eqout; /* Equinox for output coordinates */
strcat (headline, " MagB MagV MagPh MagPv");
else if (refcat==UCAC2)
strcat (headline, " MagJ MagH MagK MagC");
- else if (refcat == UCAC3)
- strcat (headline," MagB MagR MagI MagJ MagH MagK MagM MagA");
+ else if (refcat == UCAC3 || refcat == UCAC4)
+ strcat (headline," MagB MagR MagI MagJ MagH MagK MagM MagA");
else if (refcat==SKYBOT)
strcat (headline, " MagV GDist HDist");
else if (refcat==TMPSC || refcat == TMIDR2)
@@ -3200,15 +3207,15 @@ double eqout; /* Equinox for output coordinates */
if (starcat != NULL &&
strlen(starcat[icat]->keymag[imag]) > 0) {
strcat (headline," ");
- sprintf (temp, " %s ", starcat[icat]->keymag[imag]);
+ sprintf (temp, "%s", starcat[icat]->keymag[imag]);
strcat (headline, temp);
}
else if (nmagr > 1) {
- sprintf (temp, " Mag%d", imag+1);
+ sprintf (temp, " Mag%d", imag+1);
strcat (headline, temp);
}
else
- strcat (headline, " Mag");
+ strcat (headline, " Mag");
}
}
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
@@ -3225,7 +3232,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline, " Size");
else if (typecol == 1)
strcat (headline, " Type");
- else if (gcset && refcat != UCAC2 && refcat != UCAC3)
+ else if (gcset && refcat != UCAC2 && refcat != UCAC3 && refcat != UCAC4)
strcat (headline, " Peak");
if (printepoch)
strcat (headline, " Epoch ");
@@ -3233,7 +3240,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline, " pmRA pmDec"); */
if (mprop == 2)
strcat (headline, " Velocity");
- if (refcat == UCAC2 || refcat == UCAC3)
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
strcat (headline, " nim ncat");
if (ranges == NULL)
strcat (headline, " Arcsec");
@@ -3309,7 +3316,7 @@ double eqout; /* Equinox for output coordinates */
}
/* For USNO UCAC2 and UCAC3 catalogs, set errors and number of epochs */
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
era = gm[nmagr][i] * cosdeg (gdec[i]) * 3600.0;
edec = gm[nmagr+1][i] * 3600.0;
epmr = gm[nmagr+2][i] * cosdeg (gdec[i]) * 3600000.0;
@@ -3367,7 +3374,7 @@ double eqout; /* Equinox for output coordinates */
if (votab) {
sprintf (headline, "<tr>\n<td>%s</td><td>%s</td><td>%s</td>",
numstr,rastr,decstr);
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
sprintf (temp,"<td>%5.1f</td><td>%5.1f</td>", era, edec);
strcat (headline, temp);
}
@@ -3397,7 +3404,7 @@ double eqout; /* Equinox for output coordinates */
sprintf (temp, "<td>%6.1f</td><td>%6.1f</td>", pra, pdec);
strcat (headline, temp);
}
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
sprintf (temp,"<td>%5.1f</td><td>%5.1f</td><td>%2d</td><td>%2d</td>",
epmr, epmd, nim, nct);
strcat (headline, temp);
@@ -3483,7 +3490,7 @@ double eqout; /* Equinox for output coordinates */
numstr, rastr, decstr, gm[0][i], gm[1][i], gm[2][i], gm[3][i]);
else {
sprintf (headline, "%s %s %s", numstr, rastr, decstr);
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
sprintf (temp," %5.3f %5.3f", era, edec);
strcat (headline, temp);
}
@@ -3531,7 +3538,7 @@ double eqout; /* Equinox for output coordinates */
sprintf (temp, " %d ", gc[i]);
strcat (headline, temp);
}
- else if (refcat == UCAC2 || refcat == UCAC3) {
+ else if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
sprintf (temp, " %5.1f %5.1f %2d %2d",
epmr, epmd, nim, nct);
strcat (headline, temp);
@@ -3638,6 +3645,13 @@ double eqout; /* Equinox for output coordinates */
sprintf (headline,"%s %s %s %6.2f %6.2f %6.2f %6.2f",
numstr,rastr,decstr,gm[0][i],
gm[1][i], gm[2][i], gm[3][i]);
+ else if (refcat == UCAC3 || refcat == UCAC4) {
+ sprintf (headline,"%s %s %s", numstr,rastr,decstr);
+ for (imag = 0; imag < nmagr; imag++) {
+ sprintf (temp, " %.2f", gm[imag][i]);
+ strcat (headline, temp);
+ }
+ }
else if (refcat==SAO || refcat==PPM || refcat == BSC)
sprintf (headline," %s %s %s %6.2f",
numstr,rastr,decstr,gm[0][i]);
@@ -3681,7 +3695,7 @@ double eqout; /* Equinox for output coordinates */
sprintf (temp," %6.1f", ((double)gc[i])* 0.1);
strcat (headline, temp);
}
- else if (gcset && refcat != UCAC2 && refcat != UCAC3) {
+ else if (gcset && refcat != UCAC2 && refcat != UCAC3 && refcat != UCAC4) {
sprintf (temp," %7d",gc[i]);
strcat (headline, temp);
}
@@ -3704,7 +3718,7 @@ double eqout; /* Equinox for output coordinates */
strcat (headline, temp);
} */
- if (refcat == UCAC2 || refcat == UCAC3) {
+ if (refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4) {
sprintf (temp, " %2d %2d", nim, nct);
strcat (headline, temp);
}
@@ -4857,4 +4871,8 @@ PrintGSClass ()
* Apr 30 2010 Set GSC2 magnitudes to 99.99 if > 90
*
* Apr 21 2011 Fix tabs in TMPSCE output
+ *
+ * Feb 1 2013 Add -p option to Usage()
+ *
+ * Feb 15 2013 Add UCAC4 catalog
*/
diff --git a/sdssread.o b/sdssread.o
new file mode 100644
index 0000000..fa0a347
Binary files /dev/null and b/sdssread.o differ
diff --git a/sethead.c b/sethead.c
index 1bffcb4..adbc211 100644
--- a/sethead.c
+++ b/sethead.c
@@ -1,9 +1,9 @@
/* File sethead.c
- * September 1, 2011
+ * May 6, 2014
* By Jessica Mink Harvard-Smithsonian Center for Astrophysics)
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1996-2011
+ Copyright (C) 1996-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -66,7 +66,7 @@ static int addwcs = 0;
static int errflag = 0; /* Error return from program */
static char *rootdir=NULL; /* Root directory for input files */
-static char *RevMsg = "SETHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SETHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
@@ -223,7 +223,7 @@ char **av;
case 'x': /* FITS extension to read */
if (ac < 2)
usage();
- if (isnum (*(av+1)))
+ if (isnum (*(av+1)) || isrange (*(av+1)))
extensions = *++av;
else {
extensions = calloc (16, 1);
@@ -517,8 +517,8 @@ char **av;
namext = (char *) calloc (1, nch);
strcpy (namext, fn[ifile]);
strcat (namext, ",");
- strcat (namext, extension);
sprintf (extension, "%d", j);
+ strcat (namext, extension);
if (SetValues (namext, nkwd, kwd, comment))
break;
free (namext);
@@ -1471,4 +1471,6 @@ char *comment[]; /* Comments for those keywords (none if NULL) */
*
* Jan 3 2011 Exit with errflag value to indicate an error
* Sep 1 2011 Fix overflow bug by increasing size of history from 72 to 128
+ *
+ * May 6 2014 Fix bug so headers for multiple extensions can be changed
*/
diff --git a/setpix.c b/setpix.c
index f020fca..2397943 100644
--- a/setpix.c
+++ b/setpix.c
@@ -48,7 +48,7 @@ static int version = 0; /* If 1, print only program name and version */
static int logrange = 1; /* Log pixel change in image header */
static char *pform = NULL; /* Format in which to print pixels */
-static char *RevMsg = "SETPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SETPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/simpos.c b/simpos.c
index 5263811..36dbf1b 100644
--- a/simpos.c
+++ b/simpos.c
@@ -1,5 +1,5 @@
/*** simpos.c - search object by its name from command line arguments
- *** March 3, 2009
+ *** February 1, 2013
*** By Jessica Mink, sort of after IPAC byname.c for searching NED
*/
@@ -11,8 +11,10 @@
#include "libwcs/wcscat.h"
extern int ned_errno;
+static char *searchorder = NULL;
+static int printall = 0;
static void PrintUsage();
-static char *RevMsg = "SIMPOS 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "SIMPOS 3.9.0, 29 August 2014, Jessica Mink SAO";
int
main (ac, av)
@@ -24,6 +26,7 @@ char *av[];
int i;
int verbose = 0;
int printid = 0;
+ int printname = 0;
int printdeg = 0;
int nid = 0;
int nobj = 0;
@@ -32,16 +35,20 @@ char *av[];
int sysj = WCS_J2000;
int tabout = 0;
double ra, dec;
- char *str, *objname, *posdec, *posra;
+ char *str, *objname, *posdec, *posra, *iend, *ieq;
char *listfile;
char rastr[32], decstr[32];
char newobj[32];
- char *buff, *idline, *posline, *errline, *id, *errend;
+ char *buff, *buffid, *idline, *posline, *errline, *id, *errend;
char url[256];
int lbuff;
FILE *flist;
+ char cr, lf, eq;
listfile = NULL;
+ cr = (char) 13;
+ lf = (char) 10;
+ eq = '=';
str = *(av+1);
if (!str || !strcmp (str, "help") || !strcmp (str, "-help"))
@@ -59,6 +66,10 @@ char *av[];
while (c = *++str) {
switch (c) {
+ case 'a': /* Print all ID information */
+ printall = 1;
+ break;
+
case 'b': /* Print coordinates in B1950 */
outsys = WCS_B1950;
break;
@@ -79,6 +90,17 @@ char *av[];
printid++;
break;
+ case 'n': /* Print object name */
+ printname++;
+ break;
+
+ case 's': /* Database search order */
+ if (ac < 2)
+ PrintUsage(NULL);
+ searchorder = uppercase (*++av);
+ ac--;
+ break;
+
case 't': /* Print output in tab-separated table */
tabout++;
break;
@@ -100,15 +122,15 @@ char *av[];
if (isfile (listfile)) {
nfobj = getfilelines (listfile);
if (verbose)
- fprintf (stderr,"NEDPOS: %d objects from file %s\n",
+ fprintf (stderr,"SIMPOS: %d objects from file %s\n",
nfobj, listfile);
if ((flist = fopen (listfile, "r")) == NULL) {
- fprintf (stderr,"NEDPOS: List file %s cannot be read\n",
+ fprintf (stderr,"SIMPOS: List file %s cannot be read\n",
listfile);
}
}
else {
- printf ("NEDPOS: List file %s does not exist\n", listfile);
+ printf ("SIMPOS: List file %s does not exist\n", listfile);
listfile = NULL;
}
@@ -146,7 +168,15 @@ char *av[];
if (verbose)
printf ("%s -> ", objname);
- strcpy (url, "http://vizier.u-strasbg.fr/cgi-bin/nph-sesame?");
+ /* strcpy (url, "http://vizier.u-strasbg.fr/cgi-bin/nph-sesame?"); */
+ strcpy (url, "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oI/~");
+ if (searchorder)
+ strcat (url, searchorder);
+ else
+ strcat (url, "NSV");
+ if (printid || printall)
+ strcat (url, "A");
+ strcat (url, "?");
strcat (url, objname);
buff = webbuff (url, verbose, &lbuff);
@@ -157,6 +187,10 @@ char *av[];
fprintf (stderr,"*** No return from SIMBAD for %s\n",objname);
continue;
}
+ else if (printall) {
+ (void) printf ("%s\n", buff);
+ continue;
+ }
/* Read number of objects identified */
if ((idline = strsrch (buff, "#=")) != NULL) {
@@ -166,7 +200,7 @@ char *av[];
else
nid = 0;
- /* Get position */
+ /* Get position */
if ((posline = strsrch (buff, "%J ")) != NULL) {
posra = posline + 3;
while (*posra == ' ')
@@ -229,12 +263,16 @@ char *av[];
printf ("epoch 2000.0\n");
}
printf ("program %s\n",RevMsg);
- printf ("id ra dec ");
+ if (printname)
+ printf ("id ");
+ printf ("ra dec ");
printf ("\n");
- printf ("-- ------------ ------------");
+ if (printname)
+ printf ("------ ");
+ printf ("------------ ------------");
printf ("\n");
}
- if (printid) {
+ if (printname) {
printf ("%s", objname);
if (tabout)
printf (" ");
@@ -293,6 +331,31 @@ char *av[];
}
fprintf (stdout, "\n");
}
+ if (printid) {
+ buffid = buff;
+ while ((buffid = strsrch (buffid, "%I ")) != NULL) {
+ buffid = buffid + 3;
+ if ((iend = strchr (buffid, lf))) {
+ *iend = (char) 0;
+ if ((ieq = strchr (buffid, eq)))
+ *ieq = (char) 0;
+ printf ("%s\n", buffid);
+ if (ieq)
+ *ieq = eq;
+ *iend = lf;
+ }
+ else if ((iend = strchr (buffid,cr))) {
+ *iend = (char) 0;
+ if ((ieq = strchr (buffid, eq)))
+ *ieq = (char) 0;
+ printf ("%s\n", buffid);
+ if (ieq)
+ *ieq = eq;
+ *iend = cr;
+ }
+
+ }
+ }
}
free (buff);
}
@@ -311,11 +374,13 @@ char *command; /* Command where error occurred or NULL */
fprintf (stderr," simpos [-idtv][b|e|g] @namelist ...\n");
fprintf (stderr,"name(n): Objects for which to search (space -> _)\n");
fprintf (stderr,"namelist: File with one object name per line\n");
+ fprintf (stderr,"-a: Print all information returned\n");
fprintf (stderr,"-b: Print coordinates in B1950 instead of J2000\n");
fprintf (stderr,"-d: Print coordinates in degrees instead of sexigesimal\n");
fprintf (stderr,"-e: Print coordinates in ecliptic instead of J2000\n");
fprintf (stderr,"-g: Print coordinates in galactic instead of J2000\n");
- fprintf (stderr,"-i: Print ID returned from SIMBAD\n");
+ fprintf (stderr,"-i: Print ID(s) returned from SIMBAD\n");
+ fprintf (stderr,"-s [N][S][V]: Search order NED SIMBAD Vizier\n");
fprintf (stderr,"-t: Print output as tab-separated table\n");
fprintf (stderr,"-v: Print extra descriptive info\n");
exit (1);
@@ -334,4 +399,9 @@ char *command; /* Command where error occurred or NULL */
* Apr 16 2008 Fix @ mode for processing lists of objects
*
* Mar 3 2009 Put -i option back in; print name only if requested
+ *
+ * Jan 28 2013 Update Vizier URL
+ * Feb 1 2013 Add -s NSV option to allow users to change search order
+ * Feb 1 2013 Add -a option to print everything which is returned
+ * Feb 1 2013 Fix -i option to print list of catalog IDs returned
*/
diff --git a/simposx.c b/simposx.c
index a8d8df9..6100e86 100644
--- a/simposx.c
+++ b/simposx.c
@@ -12,7 +12,7 @@
extern int ned_errno;
static void PrintUsage();
-static char *RevMsg = "SIMPOS 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "SIMPOS 3.9.0, 29 August 2014, Jessica Mink SAO";
int
main (ac, av)
@@ -145,7 +145,8 @@ char *av[];
if (verbose)
printf ("%s -> ", objname);
- strcpy (url, "http://vizier.u-strasbg.fr/cgi-bin/nph-sesame?");
+ /* strcpy (url, "http://vizier.u-strasbg.fr/cgi-bin/nph-sesame?"); */
+ strcpy (url, "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-ol?");
strcat (url, objname);
buff = webbuff (url, verbose, &lbuff);
diff --git a/sky2xy.c b/sky2xy.c
index 0b2347d..f1b5f67 100644
--- a/sky2xy.c
+++ b/sky2xy.c
@@ -1,5 +1,5 @@
/* File sky2xy.c
- * September 25, 2009
+ * September 24, 2013
* By Jessica Mink, Harvard-Smithsonian Center for Astrophysics
* Send bug reports to jmink at cfa.harvard.edu
@@ -28,18 +28,15 @@
#include <errno.h>
#include <unistd.h>
#include <math.h>
-#include "libwcs/wcs.h"
-#include "libwcs/fitsfile.h"
+#include "libwcs/fitswcs.h"
static void PrintUsage();
extern void setrot(),setsys(),setcenter(),setsecpix(),setrefpix(),setdateobs();
extern void setnpix();
extern struct WorldCoor *GetFITSWCS (); /* Read WCS from FITS or IRAF header */
-extern struct WorldCoor *GetWCSFITS (); /* Read WCS from FITS or IRAF file */
-extern char *GetFITShead();
static int version = 0; /* If 1, print only program name and version */
-static char *RevMsg = "SKY2XY WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SKY2XY WCSTools 3.9.0, 16 September 2013, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
@@ -552,4 +549,6 @@ char *command;
* Jul 5 2007 Use command line argument if no system with coordinates
*
* Sep 25 2009 Declare setnpix()
+ *
+ * Sep 24 2013 Use fitswcs.h
*/
diff --git a/skybotread.o b/skybotread.o
new file mode 100644
index 0000000..aebd56c
Binary files /dev/null and b/skybotread.o differ
diff --git a/skycoor.c b/skycoor.c
index c397300..2e200ac 100644
--- a/skycoor.c
+++ b/skycoor.c
@@ -51,7 +51,7 @@ static double decpm = 0.0; /* Declination proper motion in mas/year */
static int epset = 0;
static int inhours = 0;
-static char *RevMsg = "SKYCOOR WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SKYCOOR WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/sortstar.o b/sortstar.o
new file mode 100644
index 0000000..ac14c13
Binary files /dev/null and b/sortstar.o differ
diff --git a/sp2char.c b/sp2char.c
index bd2c94f..695be6f 100644
--- a/sp2char.c
+++ b/sp2char.c
@@ -40,7 +40,7 @@ static int verbose = 0; /* verbose/debugging flag */
static int version = 0; /* If 1, print only program name and version */
static char spchar = '_';
-static char *RevMsg = "SP2CHAR WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SP2CHAR WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/sph.o b/sph.o
new file mode 100644
index 0000000..7c6bb1c
Binary files /dev/null and b/sph.o differ
diff --git a/str2dcpp.o b/str2dcpp.o
new file mode 100644
index 0000000..0ee920a
Binary files /dev/null and b/str2dcpp.o differ
diff --git a/subpix.c b/subpix.c
index 4536c85..7ddcf08 100644
--- a/subpix.c
+++ b/subpix.c
@@ -38,7 +38,7 @@ static int newimage = 0;
static int verbose = 0; /* verbose flag */
static int version = 0; /* If 1, print only program name and version */
-static char *RevMsg = "SUBPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "SUBPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/sumpix.c b/sumpix.c
index 7ce0432..6771e5a 100644
--- a/sumpix.c
+++ b/sumpix.c
@@ -1,9 +1,9 @@
/* File sumpix.c
- * May 16, 2012
+ * January 10, 2014
* By Jessica Mink Harvard-Smithsonian Center for Astrophysics)
* Send bug reports to jmink at cfa.harvard.edu
- Copyright (C) 1999-2012
+ Copyright (C) 1999-2014
Smithsonian Astrophysical Observatory, Cambridge, MA USA
This program is free software; you can redistribute it and/or
@@ -32,11 +32,14 @@
#include "libwcs/fitsfile.h"
#include "libwcs/wcscat.h"
+#define MAXFILES 2000
+static int maxnfile = MAXFILES;
+
static void usage();
static void SumPix();
extern double PhotPix();
-static char *RevMsg = "SUMPIX WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "SUMPIX WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
static int verbose = 0; /* verbose/debugging flag */
static int version = 0; /* If 1, print only program name and version */
@@ -62,9 +65,17 @@ int ac;
char **av;
{
char *str;
- char *fn;
+ char *listfile = NULL;
+ char **fn;
+ char filename[256];
+ int ifile, nbytes;
+ FILE *flist;
+
char *rrange; /* Row range string */
char *crange; /* Column range string */
+ char *zrange;
+
+ int nfile = 0;
/* Check for help or version command first */
str = *(av+1);
@@ -77,7 +88,9 @@ char **av;
crange = NULL;
rrange = NULL;
- fn = NULL;
+ zrange = (char *)calloc (4, sizeof(char));
+ strcpy (zrange, "0");
+ fn = (char **)calloc (maxnfile, sizeof(char *));
/* crack arguments */
for (av++; --ac > 0; av++) {
@@ -161,37 +174,56 @@ char **av;
else if (isnum (*av) || isrange (*av)) {
if (crange == NULL)
crange = *av;
- else {
+ else
rrange = *av;
- if (fn != NULL) {
- SumPix (fn, crange, rrange);
- }
- }
}
- /* read filename */
- else {
- fn = *av;
-
- if (!compmean && !compvar && !compstd)
- compsum++;
- if (crange && rrange)
- SumPix (fn, crange, rrange);
- else if (crange)
- SumPix (fn, crange, "0");
- else if (rrange)
- SumPix (fn, "0", rrange);
- else {
- if (ac > 0) {
- if (!isnum (*(av+1)) && !isrange (*(av+1)))
- SumPix (fn, "0", "0");
- }
- else
- SumPix (fn, "0", "0");
+ /* File with list of image files */
+ else if (*av[0] == '@') {
+ listfile = *av + 1;
+ }
+
+ /* Image file */
+ else if (isfits (*av) || isiraf (*av)) {
+ if (nfile >= maxnfile) {
+ maxnfile = maxnfile * 2;
+ nbytes = maxnfile * sizeof (char *);
+ fn = (char **) realloc ((void *)fn, nbytes);
}
+ fn[nfile] = *av;
+ nfile++;
}
}
+ if (crange == NULL)
+ crange = zrange;
+ if (rrange == NULL)
+ rrange = zrange;
+ if (!compmean && !compvar && !compstd)
+ compsum++;
+
+ /* Process files from listfile one at a time */
+ if (listfile && isimlist (listfile)) {
+ nfile = getfilelines (listfile);
+ if ((flist = fopen (listfile, "r")) == NULL) {
+ fprintf (stderr,"SUMPIX: Image list file %s cannot be read\n",
+ listfile);
+ usage ();
+ }
+ for (ifile = 0; ifile < nfile; ifile++) {
+ first_token (flist, 254, filename);
+ SumPix (filename, crange, rrange);
+ }
+ fclose (flist);
+ }
+
+ /* Process files already read from the command line */
+ else if (fn) {
+ for (ifile = 0; ifile < nfile; ifile++) {
+ SumPix (fn[ifile], crange, rrange);
+ }
+ }
+
return (0);
}
@@ -803,4 +835,6 @@ char *rrange; /* Row range string */
* May 16 2012 Add options i to print index and e to compute medians
* May 16 2012 Add option t to separate values by tabs
* May 16 2012 Add option h to print headings
+ *
+ * Jan 10 2014 Add list file with @ as command line option
*/
diff --git a/tabread.o b/tabread.o
new file mode 100644
index 0000000..fcf28e3
Binary files /dev/null and b/tabread.o differ
diff --git a/temp b/temp
new file mode 100644
index 0000000..e69de29
diff --git a/test.list b/test.list
new file mode 100644
index 0000000..2876a74
--- /dev/null
+++ b/test.list
@@ -0,0 +1,4 @@
+../wcstools.test/xx.fits
+../wcstools.test/xxa.fits
+../wcstools.test/xxaa.fits
+../wcstools.test/xxab.fits
diff --git a/testrot.c b/testrot.c
index 58b6f24..fcf9d4d 100644
--- a/testrot.c
+++ b/testrot.c
@@ -24,7 +24,7 @@ static int hms = 0; /* 1 for output in hh:mm:ss dd:mm:ss */
static int nf = 0;
static int version = 0; /* If 1, print only program name and version */
-static char *RevMsg = "TESTROT WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "TESTROT WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
main (ac, av)
int ac;
diff --git a/tmcread.o b/tmcread.o
new file mode 100644
index 0000000..443fb9a
Binary files /dev/null and b/tmcread.o differ
diff --git a/tnxpos.o b/tnxpos.o
new file mode 100644
index 0000000..eb8e107
Binary files /dev/null and b/tnxpos.o differ
diff --git a/ty2read.o b/ty2read.o
new file mode 100644
index 0000000..dd583b6
Binary files /dev/null and b/ty2read.o differ
diff --git a/uacread.o b/uacread.o
new file mode 100644
index 0000000..9d2539f
Binary files /dev/null and b/uacread.o differ
diff --git a/ubcread.o b/ubcread.o
new file mode 100644
index 0000000..4be66bb
Binary files /dev/null and b/ubcread.o differ
diff --git a/ucacread.o b/ucacread.o
new file mode 100644
index 0000000..2cba14d
Binary files /dev/null and b/ucacread.o differ
diff --git a/ucacread0.o b/ucacread0.o
new file mode 100644
index 0000000..256a9d4
Binary files /dev/null and b/ucacread0.o differ
diff --git a/ujcread.o b/ujcread.o
new file mode 100644
index 0000000..8bda362
Binary files /dev/null and b/ujcread.o differ
diff --git a/wcs.o b/wcs.o
new file mode 100644
index 0000000..34f8a48
Binary files /dev/null and b/wcs.o differ
diff --git a/wcscon.o b/wcscon.o
new file mode 100644
index 0000000..ce15188
Binary files /dev/null and b/wcscon.o differ
diff --git a/wcscon1.o b/wcscon1.o
new file mode 100644
index 0000000..118cd99
Binary files /dev/null and b/wcscon1.o differ
diff --git a/wcshead.c b/wcshead.c
index a70c1d3..ee5e3a5 100644
--- a/wcshead.c
+++ b/wcshead.c
@@ -47,7 +47,7 @@ static int restwave = 0; /* If 1, print first dimension limits */
static int printhead = 1; /* 1 until header has been printed */
static char *rootdir=NULL; /* Root directory for input files */
-static char *RevMsg = "WCSHEAD WCSTools 3.8.7, 19 October 2012, Jessica Mink SAO";
+static char *RevMsg = "WCSHEAD WCSTools 3.9.0, 29 August 2014, Jessica Mink SAO";
int
main (ac, av)
diff --git a/wcsinit.o b/wcsinit.o
new file mode 100644
index 0000000..08537e3
Binary files /dev/null and b/wcsinit.o differ
diff --git a/wcslib.o b/wcslib.o
new file mode 100644
index 0000000..fd0e94e
Binary files /dev/null and b/wcslib.o differ
diff --git a/wcstrig.o b/wcstrig.o
new file mode 100644
index 0000000..e7c5dfa
Binary files /dev/null and b/wcstrig.o differ
diff --git a/webread.o b/webread.o
new file mode 100644
index 0000000..edbd791
Binary files /dev/null and b/webread.o differ
diff --git a/worldpos.o b/worldpos.o
new file mode 100644
index 0000000..f0157f6
Binary files /dev/null and b/worldpos.o differ
diff --git a/xy2sky.c b/xy2sky.c
index 97dbb2b..931d55d 100644
--- a/xy2sky.c
+++ b/xy2sky.c
@@ -49,7 +49,7 @@ static int printhead = 0;
static char printonly = 'n';
static int version = 0; /* If 1, print only program name and version */
-static char *RevMsg = "XY2SKY WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "XY2SKY WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
@@ -419,6 +419,7 @@ char **av;
ln = listname;
while (*ln++)
*(ln-1) = *ln;
+ *ln = (char) 0;
if (strcmp (listname,"STDIN")==0 || strcmp (listname,"stdin")==0) {
fd = stdin;
nlines = 10000;
diff --git a/xy2sky1.c b/xy2sky1.c
index 1e149e8..1296aab 100644
--- a/xy2sky1.c
+++ b/xy2sky1.c
@@ -51,7 +51,7 @@ static int sizeset = 0;
static int scaleset = 0;
static int version = 0; /* If 1, print only program name and version */
-static char *RevMsg = "XY2SKY WCSTools 3.8.7, 19 October 2012, Jessica Mink (jmink at cfa.harvard.edu)";
+static char *RevMsg = "XY2SKY WCSTools 3.9.0, 29 August 2014, Jessica Mink (jmink at cfa.harvard.edu)";
int
main (ac, av)
diff --git a/zpxpos.o b/zpxpos.o
new file mode 100644
index 0000000..ee0b47f
Binary files /dev/null and b/zpxpos.o differ
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/wcstools.git
More information about the debian-science-commits
mailing list