~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to applic/proc/precess.prg

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
! @(#)precess.prg       19.1 (ES0-DMD) 02/25/03 13:20:17
 
2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
3
!
 
4
!  MIDAS command procedure  precess.prg  860201
 
5
!  D. Baade ST-ECF, Garching
 
6
!  KB   870831,890519,900703,901008,910429
 
7
!  MP   920807
 
8
!  precess equatorial coordinates from one epoch to another
 
9
!
 
10
!  the following keywords are used:
 
11
!
 
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
 
20
!
 
21
!  b) if input is mainly from table
 
22
!
 
23
!  P1                   table name
 
24
!  P2                   original epoch: year,month,day
 
25
!  P3                   new equinox: year,month,day
 
26
!
 
27
!------------------------------------------------------------------------------
 
28
!
 
29
crossref ALPHA0 DELTA0 EQUINOX0 EQUINOX1
 
30
!
 
31
inputc(1:2) = "++"
 
32
define/local rneg/r/1/1 1.0
 
33
define/local sign/c/1/1 &
 
34
!
 
35
define/param p1 ? ? "Enter original R.A. (hour,min,sec) or table name: "
 
36
!
 
37
inputi(20) = m$index(p1,".tbl") 
 
38
if inputi(20) .le. 1 then
 
39
!
 
40
! input only from keywords
 
41
! ------------------------
 
42
 
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):                 "
 
46
   define/maxpar 4
 
47
!
 
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) = "-"
 
55
!
 
56
   write/keyw action PR
 
57
   run MID_EXE:COMPXY
 
58
!
 
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:"
 
65
   if sign .eq. "-" then
 
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"
 
73
   else
 
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"
 
76
   endif
 
77
!
 
78
else
 
79
!
 
80
! input mainly from table
 
81
! -----------------------
 
82
 
83
   define/param p2 TAB ? "Enter original epoch (year,month,day):            "
 
84
   define/param p3 ? N "Enter new epoch (year,month,day):                 "
 
85
   define/maxpar 3
 
86
!
 
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
 
90
!
 
91
   inputi(20) = inputi(20)-1
 
92
   table = "{p1(1:{inputi(20)})}     "
 
93
!
 
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
 
96
!
 
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
 
106
!
 
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
 
109
!
 
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
 
115
     endif
 
116
     write/keyw outputc/c/1/80 " " all
 
117
     outputc = "{inputr(10)},{inputr(11)},{inputr(12)}"
 
118
!
 
119
     write/keyw action PR
 
120
     run MID_EXE:COMPXY
 
121
!
 
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
 
126
!
 
127
   set/format i1
 
128
   if nline .eq. 1 then
 
129
      outputc = "row "
 
130
   else
 
131
      outputc = "rows "
 
132
   endif
 
133
   write/out {nline} {outputc} of table {table}.tbl processed
 
134
!
 
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)}"
 
139
   else
 
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)}"
 
143
   endif
 
144
endif