1
C===========================================================================
2
C Copyright (C) 1995-2010 European Southern Observatory (ESO)
4
C This program is free software; you can redistribute it and/or
5
C modify it under the terms of the GNU General Public License as
6
C published by the Free Software Foundation; either version 2 of
7
C the License, or (at your option) any later version.
9
C This program is distributed in the hope that it will be useful,
10
C but WITHOUT ANY WARRANTY; without even the implied warranty of
11
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
C GNU General Public License for more details.
14
C You should have received a copy of the GNU General Public
15
C License along with this program; if not, write to the Free
16
C Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
C Correspondence concerning ESO-MIDAS should be addressed as follows:
20
C Internet e-mail: midas@eso.org
21
C Postal address: European Southern Observatory
22
C Data Management Division
23
C Karl-Schwarzschild-Strasse 2
24
C D 85748 Garching bei Muenchen
26
C===========================================================================
29
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
C.AUTHOR Andrew T. Young
35
C.PURPOSE collapse star table with multiple positions to means.
42
C-----------------------------------------------------------------------------
43
C*****************************************************************************
46
C Reads a sorted star table with duplicate positions, and tries to
47
C estimate a "best" position for each star. Complains if the spread
48
C in either coordinate exceeds a minute of arc.
50
C This is done in the command CONVERT/PHOT.
52
C This program is modified from the "esodcon" program, and may contain
56
C*****************************************************************************
65
INTEGER NCOLS,NROWS,NSORTC,NWPRAL,NROWSAL, ISTAT
68
CHARACTER CARD*78, TBLFIL*80
69
CHARACTER*32 OBJECT,OLDOBJ,CTEST
72
INTEGER KOBJ,KRA,KDEC,KEQ,NROW
73
INTEGER JOBJ,JRA,JDEC,JEQ,NROUT
76
PARAMETER (MXITEM=900)
78
REAL RAS(MXITEM),DECS(MXITEM),EQUINOXS(MXITEM)
82
C Types for external fcns.:
85
C Set up MIDAS declarations:
91
INCLUDE 'MID_INCLUDE:ST_DEF.INC'
99
C BEGIN DATA statements:
101
INCLUDE 'MID_INCLUDE:ST_DAT.INC'
104
C END DATA statements.
107
C ******************** PROLOGUE ********************
109
CALL STSPRO ('MEANSTAR')
115
C Set up INPUT table file:
117
CALL TV('Opening sdata.tbl')
118
CALL TBTOPN('sdata.tbl', 1, ITBL, ISTAT)
119
IF (ISTAT.NE.0) CALL TERROR (ITBL,1,'Could not open "sdata.tbl".')
121
CALL TBIGET(ITBL, NCOLS,NROWS,NSORTC,NWPRAL,NROWSAL, ISTAT)
122
IF (ISTAT.NE.0) CALL TERROR
123
1 (ITBL,1,'Could not get basic table data.')
125
C Get column pointers...
127
CALL TBLSER (ITBL, 'OBJECT', KOBJ,ISTAT)
128
IF (ISTAT.NE.0 .OR. KOBJ.EQ.-1)
129
1 CALL TERROR(ITBL,2,'Could not find column OBJECT')
130
CALL TBLSER (ITBL, 'RA', KRA,ISTAT)
131
IF (ISTAT.NE.0 .OR. KRA.EQ.-1)
132
1 CALL TERROR(ITBL,3,'Could not find column RA')
133
CALL TBLSER (ITBL, 'DEC', KDEC,ISTAT)
134
IF (ISTAT.NE.0 .OR. KDEC.EQ.-1)
135
1 CALL TERROR(ITBL,4,'Could not find column DEC')
136
CALL TBLSER (ITBL, 'EQUINOX', KEQ,ISTAT)
137
IF (ISTAT.NE.0 .OR. KEQ.EQ.-1)
138
1 CALL TERROR(ITBL,5,'Could not find column EQUINOX')
140
C Make sure table is sorted on OBJECT column:
142
CALL TBCSRT (ITBL, 1, KOBJ, 1, ISTAT)
144
1 CALL TERROR(ITBL,8,'Could not sort OBJECT column')
147
C Set up OUTPUT table file:
149
C First, get name from tblfil local keyword:
150
CALL STKRDC ('TBLFIL', 1, 1, 80, NACTEL,TBLFIL,IUNIT,NULLS,ISTAT)
152
CARD='Creating '//TBLFIL(:71)
154
CALL TBTINI (TBLFIL, 0, 0, 1, 1, NEWTBL, ISTAT)
156
C create column pointers...
158
CALL TBCINI(NEWTBL, D_C_FORMAT,32,'A32',' ','OBJECT',JOBJ,ISTAT)
159
CALL TBCINI(NEWTBL, D_R4_FORMAT, 1,'R10.5',' ','RA',JRA,ISTAT)
160
CALL TBCINI(NEWTBL, D_R4_FORMAT, 1,'s9.4',' ','DEC',JDEC,ISTAT)
162
1 (NEWTBL, D_R4_FORMAT, 1,'F10.3',' ','EQUINOX',JEQ,ISTAT)
172
CALL TBERDC (ITBL, NROW, KOBJ, CTEST, NULL, ISTAT)
173
CALL FT_EOS (CTEST,32, OBJECT, ISTAT)
175
IF (OBJECT.EQ.OLDOBJ .OR.OLDOBJ.EQ.' ') THEN
176
C continue collecting data for this star.
179
IF (ITEM.GT.MXITEM) THEN
180
CALL TV('Too many data for this star.')
181
CALL STETER(21,'Increase parameter MXITEM and recompile.')
184
C Summarize this star.
188
CALL TBERDR(ITBL, NROW, KRA, RAS(ITEM),NULL, ISTAT)
189
CALL TBERDR(ITBL, NROW, KDEC, DECS(ITEM),NULL, ISTAT)
190
CALL TBERDR(ITBL, NROW, KEQ, EQUINOXS(ITEM),NULL, ISTAT)
192
IF (NROW.EQ.NROWS) GO TO 30
196
C Summarize this star:
205
CARD='Only one observation of '//OLDOBJ
209
C extract robust estimates.
210
CARD='Processing '//OLDOBJ
214
C (here is where we should display scatter.)
216
CALL SORT1(RAS,ITEMS)
217
CALL SORT1(DECS,ITEMS)
219
RA=0.5*(RAS((ITEMS+1)/2) + RAS(ITEMS/2+1))
220
DEC=0.5*(DECS((ITEMS+1)/2) + DECS(ITEMS/2+1))
225
80 CALL TBEWRC (NEWTBL, NROUT, JOBJ, OLDOBJ, ISTAT)
226
CALL TBEWRR (NEWTBL, NROUT, JRA, RA, ISTAT)
227
CALL TBEWRR (NEWTBL, NROUT, JDEC, DEC, ISTAT)
228
CALL TBEWRR (NEWTBL, NROUT, JEQ, EQUINOX, ISTAT)
230
IF (NROW.EQ.NROWS) GO TO 90
232
C Prepare for next star:
238
90 CALL TBTCLO(ITBL, ISTAT)
239
CALL TV(' sdata.tbl closed.')
241
CALL TBTCLO(NEWTBL, ISTAT)
242
CARD='File '//TBLFIL(1:60)//' closed' ! RHW 4/10/93