1
C @(#)precess.for 19.1 (ES0-DMD) 02/25/03 14:27:54
2
C===========================================================================
3
C Copyright (C) 1995 European Southern Observatory (ESO)
5
C This program is free software; you can redistribute it and/or
6
C modify it under the terms of the GNU General Public License as
7
C published by the Free Software Foundation; either version 2 of
8
C the License, or (at your option) any later version.
10
C This program is distributed in the hope that it will be useful,
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
C GNU General Public License for more details.
15
C You should have received a copy of the GNU General Public
16
C License along with this program; if not, write to the Free
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
21
C Internet e-mail: midas@eso.org
22
C Postal address: European Southern Observatory
23
C Data Management Division
24
C Karl-Schwarzschild-Strasse 2
25
C D 85748 Garching bei Muenchen
27
C===========================================================================
29
C @(#)precess.for 19.1 (ESO-IPG) 14:27:54 02/25/03
31
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
C.IDENTIFICATION: PRECESS.FOR
33
C.PURPOSE: Precess RA and DEC coordinates in table created by CREATE/OPTABLE
35
C.AUTHOR: Alessandra Gemmo Padova Department of Astronomy
36
C.VERSION: 910826 AG Creation
37
C------------------------------------------------------------------------------
53
INTEGER NACINP,NARINP,NSINP
54
INTEGER OUTTYP,OUTCOL(2),COLNUM(2)
60
DOUBLE PRECISION RARAD,DECRAD
61
DOUBLE PRECISION PRA,PDEC,EQUI0,EQUI1
62
DOUBLE PRECISION PRARAD,PDECRA
63
DOUBLE PRECISION RA,DEC,PI
67
CHARACTER*80 STRING(10)
69
CHARACTER*16 LABEL1(NCPAR1),OUTLAB
70
CHARACTER*16 UNIT1(NCPAR1),OUTUNI
72
CHARACTER*16 FORMR8(2)
80
INCLUDE 'MID_INCLUDE:ST_DEF.INC'
82
INCLUDE 'MID_INCLUDE:ST_DAT.INC'
84
DATA LABEL1/'PRA ','PDEC '/
85
DATA UNIT1 /'HOURS ','DEGREES '/
89
DATA FORMR8/'F12.9','F12.9'/
90
DATA PI/3.14159265358979D0/
96
C *** get the input table
98
CALL STKRDC('INPUTFI',1,1,60,IAC,INPFIL,KUN,KNUL,ISTAT)
100
C *** open input table
102
CALL TBTOPN(INPFIL,F_IO_MODE,TIDINP,ISTAT)
104
C *** get information about the input table
106
CALL TBIGET(TIDINP,NCINP,NRINP,NSINP,NACINP,NARINP,ISTAT)
107
IF(NRINP.EQ.0)THEN !no rows in table
108
STRING(1) = '*** FATAL: There are no data in input table'
109
CALL STETER(9,STRING(1))
112
C *** initialize PRA and PDEC columns
119
CALL TBCINI(TIDINP,OUTTYP,1,OUTFOR,OUTUNI,
120
2 OUTLAB,OUTCOL(I1),ISTAT)
123
C *** fill in PRA and PDEC columns
125
CALL STKRDD('EQUINOX',1,1,IAC,EQUI0,KUN,KNUL,ISTAT)
126
CALL STKRDD('EQUINOX',2,1,IAC,EQUI1,KUN,KNUL,ISTAT)
128
C *** read in RA and DEC columns
131
CALL TBLSER(TIDINP,'RA',COLNUM(1),ISTAT)
132
CALL TBERDD(TIDINP,I2,COLNUM(1),RA,NULL,ISTAT)
134
CALL TBLSER(TIDINP,'DEC',COLNUM(2),ISTAT)
135
CALL TBERDD(TIDINP,I2,COLNUM(2),DEC,NULL,ISTAT)
137
RARAD = RA*1.5D1*(PI/1.8D2)
138
DECRAD = DEC*(PI/1.8D2)
140
C *** compute precession
142
CALL PRE(RARAD,DECRAD,PRARAD,PDECRA,EQUI0,EQUI1)
144
PRA = PRARAD*(1.8D2/PI)/15.
145
PDEC = PDECRA*(1.8D2/PI)
147
CALL TBEWRD(TIDINP,I2,OUTCOL(1),PRA,ISTAT)
148
CALL TBEWRD(TIDINP,I2,OUTCOL(2),PDEC,ISTAT)
151
C *** close the table
153
CALL TBTCLO(TIDINP,ISTAT)
159
C------------------------------------------------------------------------------
160
SUBROUTINE PRE(A0,D0,A1,D1,EQX0,EQX1)
162
C ... calculate general precession for two given epochs
164
C ... References: STUMPFF P.,ASTRON. ASTROPHYS. SUPPL. 41, P. 1 (1980)
165
C ... EXPLAN. SUPPL. ASTRON. EPHEREMERIS, P. 28 (1961)
167
IMPLICIT NONE !REAL*8 (A-H,O-Z)
169
DOUBLE PRECISION A0,D0,D1,EQX0,EQX1
170
DOUBLE PRECISION DT0,DT,DTS,DTC,DC1900,DC1M2
171
DOUBLE PRECISION DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9
172
DOUBLE PRECISION DZED,DZETA,DCSAR,DTHETA
173
DOUBLE PRECISION PI,SINR,COSR,A1,R
175
DATA DCSAR/4.848136812D-6/,DC1900/1900.0D0/,DC1M2/0.01D0/,
176
* DC1/2304.25D0/,DC2/1.396D0/,DC3/0.302D0/,DC4/0.018D0/,
177
* DC5/0.791D0/,DC6/2004.683D0/,DC7/-0.853D0/,DC8/-0.426D0/,
180
PI = 3.1415926535897928
182
C ... first determine the precession angles zeta, z and theta
184
DT0=(EQX0-DC1900)*DC1M2
188
DZETA=((DC1+DC2*DT0)*DT+DC3*DTS+DC4*DTC)*DCSAR
189
DZED=DZETA + DC5*DTS*DCSAR
190
DTHETA=((DC6+DC7*DT0)*DT+DC8*DTS+DC9*DTC)*DCSAR
192
C ... with these and A0,D0 compute the precessed coordinates A1,D1
194
D1 = ASIN(DCOS(DTHETA)*DSIN(D0)+DSIN(DTHETA)*DCOS(D0)*
196
SINR = (DCOS(D0)*DSIN(A0+DZETA))/DCOS(D1)
197
COSR = (DCOS(DTHETA)*DCOS(D0)*DCOS(A0+DZETA)-
198
1 DSIN(DTHETA)*DSIN(D0))/DCOS(D1)
200
IF (COSR.LT.0) R=PI-R ! determine quadrant of R
201
A1 = R+DZED ! this is the precessed R.A.
202
IF (A1.GT.2.0D0*PI) A1=A1-2.0D0*PI
203
IF (A1.LT.0.0D0) A1=A1+2.0D0*PI