1
! @(#)precess.prg 19.1 (ES0-DMD) 02/25/03 13:20:17
2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
! MIDAS command procedure precess.prg 860201
5
! D. Baade ST-ECF, Garching
6
! KB 870831,890519,900703,901008,910429
8
! precess equatorial coordinates from one epoch to another
10
! the following keywords are used:
12
! a) if all input is from keywords
13
! P1 original right ascension: hour,min,sec
14
! P2 original declination: degree,min,sec
15
! P3 original epoch: year,month,day
16
! P4 new epoch: year,month,day
17
! OUTPUTR/R/1/3 precessed right ascension: hour,min,sec
18
! OUTPUTR/R/4/3 precessed declination: degree,min,sec
19
! OUTPUTR/R/7/1 new epoch: real years
21
! b) if input is mainly from table
24
! P2 original epoch: year,month,day
25
! P3 new equinox: year,month,day
27
!------------------------------------------------------------------------------
29
crossref ALPHA0 DELTA0 EQUINOX0 EQUINOX1
32
define/local rneg/r/1/1 1.0
33
define/local sign/c/1/1 &
35
define/param p1 ? ? "Enter original R.A. (hour,min,sec) or table name: "
37
inputi(20) = m$index(p1,".tbl")
38
if inputi(20) .le. 1 then
40
! input only from keywords
41
! ------------------------
43
define/param p2 ? N "Enter original declination (degree,min,sec): "
44
define/param p3 ? N "Enter original epoch (year,month,day): "
45
define/param p4 ? N "Enter new epoch (year,month,day): "
48
write/keyw inputr/r/1/3 {p3},0,0
49
write/keyw inputr/r/4/3 {p4},0,0
50
write/keyw inputr/r/7/3 {p1},0,0
51
write/keyw inputr/r/10/3 {p2},0,0
52
inputc(1:1) = p2(1:1) !catch eventual minus sign
53
rneg = (inputr(10)*3600.)+(inputr(11)*60.)+inputr(12)
54
if rneg .lt. 0.0 inputc(1:1) = "-"
59
outputi(1) = outputr(1)
60
outputi(2) = outputr(2)
61
outputi(3) = outputr(4)
62
outputi(4) = outputr(5)
63
set/format i2 f10.3,g20.10 !f10.3 was g10.3 and ugly...
64
write/out "Coordinates precessed to {outputd(2)} are:"
66
define/local absout/i/1/2 0,0
67
absout(1) = m$abs(outputi(3))
68
absout(2) = m$abs(outputi(4))
69
define/local absr/r/1/1 0.0
70
absr(1) = m$abs(outputr(6))
71
write/out "R.A.: {outputi(1)} hrs {outputi(2)} min {outputr(3)} sec" -
72
" Decl.: - {absout(1)} deg {absout(2)} arcmin {absr(1)} arcsec"
74
write/out "R.A.: {outputi(1)} hrs {outputi(2)} min {outputr(3)} sec" -
75
" Decl.: {outputi(3)} deg {outputi(4)} arcmin {outputr(6)} arcsec"
80
! input mainly from table
81
! -----------------------
83
define/param p2 TAB ? "Enter original epoch (year,month,day): "
84
define/param p3 ? N "Enter new epoch (year,month,day): "
87
define/local lp/i/1/1 0 ! loop variable
88
define/local nline/i/1/1 0 ! number of lines in table
89
define/local table/c/1/20 ! name of table
91
inputi(20) = inputi(20)-1
92
table = "{p1(1:{inputi(20)})} "
94
if p2(1:3) .ne. "TAB" write/keyw inputr/r/1/3 {p2},0,0
95
write/keyw inputr/r/4/3 {p3},0,0
97
! create columns which shall accept the results
98
set/midas output=logonly !no error messages if columns exist already
99
create/column {table} :PAHR
100
create/column {table} :PAMIN
101
create/column {table} :PASEC
102
create/column {table} :PDDEG
103
create/column {table} :PDMIN
104
create/column {table} :PDSEC
105
set/midas output=yes ! default
107
nline = m$value({table}.tbl,tblcontr(4)) ! get number of lines in table
108
do lp = 1 nline ! loop over all lines in table
110
! get all missing input from table
111
copy/tk {table} :AHR :AMIN :ASEC @{lp} inputr/r/7/3
112
copy/tk {table} :DDEG :DMIN :DSEC @{lp} inputr/r/10/3
113
if p2(1:3) .eq. "TAB" then
114
copy/tk {table} :EYEAR :EMONTH :EDAY @{lp} inputr/r/1/3
116
write/keyw outputc/c/1/80 " " all
117
outputc = "{inputr(10)},{inputr(11)},{inputr(12)}"
122
! write all output to table
123
copy/kt outputr/r/1/3 {p1} :PAHR :PAMIN :PASEC @{lp}
124
copy/kt outputr/r/4/3 {p1} :PDDEG :PDMIN :PDSEC @{lp}
125
enddo ! these coordinates precessed
133
write/out {nline} {outputc} of table {table}.tbl processed
135
! update descriptor HISTORY
136
write/desc {p1} new_epoch/d/1/1 {outputd(2)}
137
if p2(1:3) .eq. "TAB" then
138
write/desc {p1} history/c/-1/80 "Coords precessed to {outputd(2)}"
140
write/desc {p1} old_epoch/d/1/1 {outputd(1)}
141
write/desc {p1} history/c/-1/80 -
142
"Coords precessed from {outputd(1)} to {outputd(2)}"