File: fortcat.c

package info (click to toggle)
wcstools 3.9.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,684 kB
  • sloc: ansic: 113,336; sh: 553; makefile: 245; lisp: 86; sed: 1
file content (161 lines) | stat: -rw-r--r-- 6,347 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*** File libwcs/fortcat.c
 *** April 3, 2003
 *** By Jessica Mink, jmink@cfa.harvard.edu
 *** Harvard-Smithsonian Center for Astrophysics
 *** Copyright (C) 2001-2003
 *** 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@cfa.harvard.edu
           Postal address: Jessica Mink
                           Smithsonian Astrophysical Observatory
                           60 Garden St.
                           Cambridge, MA 02138 USA
 */

/* Fortran wrappers for subroutines which read astronomical catalogs
 *
 * Catalogs supported include: USNO-A2.0, USNO_SA2.0, ACT, Tycho 2, SAO
 * TDC binary format (SAO, PPM, Yale Bright Star, IRAS Point Source Catalogs)
 * SAO TDC ASCII format, and Starbase tab-delimited format
 *
 * For shell-level searches, use WCSTools scat, documented at
 * http://tdc-www.harvard.edu/software/wcstools/scat/
 *
 * int catread_()	Read catalog stars in specified region of the sky
 * int catrnum_()	Read catalog stars with specified numbers
 */

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include "wcs.h"
#include "wcscat.h"

/* default pathname for catalog, used if catalog file not found in current
   working directory, but overridden by WCS_CATDIR environment variable */
char catdir[64]="/data/catalogs";

static struct StarCat **starcat; /* Catalog data structure */

/* CATREAD -- Read ASCII stars in specified region using ctgread() */

void
catread_ (catfile, distsort, cra, cdec, dra, ddec, drad,
	  csysout, eqout, epout, mag1, mag2, nsmax, nlog, nstars,
	  xnum, xra, xdec, xpra, xpdec, xmag, xmagb)

char	*catfile;	/* Name of reference star catalog file */
int	distsort;	/* 1 to sort stars by distance from center */
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) */
char	*csysout;	/* 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     nsmax;		/* Maximum number of stars to be returned */
int     nlog;		/* Logging frequency */
int	*nstars;		/* Number of catalog stars found (returned) */
double	*xnum;		/* Array of ID numbers (returned) */
double	*xra;		/* Array of right ascensions (returned) */
double	*xdec;		/* Array of declinations (returned) */
double	*xpra;		/* Array of right ascension proper motions (returned) */
double	*xpdec;		/* Array of declination proper motions (returned) */
double	*xmag;		/* Array of magnitudes (returned) */
double	*xmagb;		/* Array of second magnitudes (returned) */

{
int     refcat;         /* Catalog code from wcscat.h */
char    **tobj;         /* Array of object names (ignored) */
int     *tc;            /* Array of fluxes (ignored) */
int	nread;		/* Number of stars read from catalog */
int     sysout;         /* Search coordinate system */

    tc = NULL;
    tobj = NULL;

    refcat = CatCode (catfile);
    sysout = wcscsys (csysout);

    nread = ctgread (catfile, refcat, distsort, cra, cdec, dra, ddec, drad,
         sysout, eqout, epout, mag1, mag2, nsmax, starcat,
         xnum, xra, xdec, xpra, xpdec, xmag, xmagb, tc, tobj, nlog);

    /* Return number of stars read or maximum, which ever is lower */
    if (nread < nsmax)
	*nstars = nread;
    else
	*nstars = nsmax;

    return;
}


/* CATRNUM -- Read ASCII stars with specified numbers using ctgrnum() */

void
catrnum_ (catfile, nnum, csysout, eqout, epout, match, nlog, nstars,
          xnum, xra, xdec, xpra, xpdec, xmag, xmagb)

char    *catfile;       /* Name of reference star catalog file */
int     nnum;           /* Number of stars to look for */
char	*csysout;	/* Search coordinate system */
double  eqout;          /* Search coordinate equinox */
double  epout;          /* Proper motion epoch (0.0 for no proper motion) */
int     match;          /* 1 to match star number exactly, else sequence num.*/
int     nlog;		/* Logging frequency */
int	*nstars;	/* Number of catalog stars found (returned) */
double  *xnum;          /* Array of star numbers to look for */
double  *xra;           /* Array of right ascensions (returned) */
double  *xdec;          /* Array of declinations (returned) */
double  *xpra;          /* Array of right ascension proper motions (returned) */
double  *xpdec;         /* Array of declination proper motions (returned) */
double  *xmag;          /* Array of magnitudes (returned) */
double  *xmagb;         /* Array of second magnitudes (returned) */

{
int     refcat;         /* Catalog code from wcscat.h */
int     *tc;            /* Array of fluxes (ignore) */
char    **tobj;         /* Array of object names (ignored) */
int     sysout;         /* Search coordinate system */
int	nread;		/* Number of stars read from catalog */

    tc = NULL;
    tobj = NULL;

    sysout = wcscsys (csysout);

    refcat = CatCode (catfile);

    nread = ctgrnum (catfile,refcat, nnum,sysout,eqout,epout,match,starcat,
		     xnum,xra,xdec,xpra,xpdec,xmag,xmagb,tc,tobj,nlog);
    *nstars = nread;

    return;
}
/*
 * Feb 16 2001	New subroutines
 * Sep 19 2001	Drop fitshead.h; it is in wcs.h
 *
 * Apr  3 2003	Use CatCode() instead of RefCat(); add nstars to catrnum_()
 */