1
! @(#)dcon.prg 19.1 (ES0-DMD) 02/25/03 13:28:59
2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3
!.IDENTIFICATION: DCON.PRG
4
!.PURPOSE: Convert data from raw to MIDAS *.tbl form.
6
!.AUTHOR: Andrew T. Young
7
! ----------------------------------------------------------------------
9
! ********* DEFINE LOCAL KEYWORDS **********
11
DEFINE/LOCAL reply/C/1/12 "?" A
12
DEFINE/LOCAL type/C/1/6 "?" A
13
DEFINE/LOCAL rawdat/C/1/80 " " A
14
DEFINE/LOCAL tblfil/C/1/80 " " A
15
DEFINE/LOCAL datfil/C/1/80 "data.dat"
16
DEFINE/LOCAL fmtfil/C/1/80 "data.fmt"
17
DEFINE/LOCAL obstbl/C/1/80 "esotel.tbl"
18
DEFINE/LOCAL nrows/I/1/1 1
20
! ********* BEGIN EXECUTION **********
24
WRITE/OUT "The CONVERT/PHOT command will make a new data-table file for you."
26
WRITE/OUT "You should have a file of raw data from the telescope to convert."
29
WRITE/OUT " It will be useful to embed date information in file names."
35
INQUIRE/KEYW tblfil "What name do you want to give the new DATA-TABLE file?"
36
IF M$INDEX(tblfil,".tbl") .ne. 0 THEN
37
! name already has .tbl ext.
38
WRITE/OUT "(new file will be named" {tblfil} ")"
40
WRITE/OUT "(new file will be named" {tblfil}.tbl ")"
41
WRITE/KEYW tblfil {tblfil}.tbl
46
IF M$EXIST(tblfil) .eq. 0 THEN
50
WRITE/OUT {tblfil} "already exists!"
51
INQUIRE/KEYW reply "OK to write over it?"
53
IF reply(:1) .eq. "y" THEN
55
WRITE/OUT {tblfil} "will be re-written."
56
ELSEIF reply(:1) .eq. "n" THEN
58
WRITE/OUT "Here are the files in your current directory:"
60
IF AUX_MODE(1) .LE. 1 THEN ! VMS
66
WRITE/OUT "Please select a new name."
69
WRITE/OUT "Please reply YES or NO."
78
INQUIRE/KEYW rawdat "What is the name of the RAW data file?"
80
IF M$EXIST(rawdat) .eq. 0 THEN
81
WRITE/OUT "(Cannot find {rawdat})"
83
WRITE/OUT "Sorry, no such file exists. Be sure the name is right."
85
WRITE/OUT "Here are the files in your current directory:"
87
IF AUX_MODE(1) .LE. 1 THEN ! VMS
93
ELSEIF rawdat(:4) .eq. "quit" THEN
96
WRITE/OUT "OK," {rawdat} "is found."
100
! Make sure esotel.tbl is available...
101
IF M$EXIST("esotel.tbl") .eq. 0 THEN ! not available
102
IF AUX_MODE(1) .LE. 1 THEN ! VMS
103
define/local peplib/c/1/60 -
104
"MID_DISK:[&MID_PEPSYS] "
105
$ COPY {peplib}esotel.tbl []
106
$ SET PROT=(O:RWED) esotel.tbl
108
define/local peplib/c/1/60 "$MID_PEPSYS/"
109
$ cp {peplib}esotel.tbl `pwd`
110
$ chmod 644 esotel.tbl
113
WRITE/OUT "The standard Observatory file esotel.tbl"
114
WRITE/OUT "has been copied into your working directory."
121
WRITE/OUT "The following formats are supported and cna be converted:"
122
WRITE/OUT " DANISH (D)"
123
WRITE/OUT " ESO 50 cm (ESO50)"
124
WRITE/OUT " ESO standard (E)"
125
WRITE/OUT "and OTHER (O) format"
127
INQUIRE/KEYW reply "In which format is the raw data:"
128
IF reply(:1) .eq. "D" THEN ! Danish format
132
! Make sure it terminated normally:
134
IF APPLIC(1:1) .EQ. "X" THEN
138
WRITE/KEYW type "Danish"
140
ELSEIF reply(1:5) .eq. "ESO50" THEN ! ESO 50cm photometer format
142
WRITE/KEYW IN_A/C/1/60 {rawdat}
143
WRITE/KEYW OUT_A/C/1/60 {tblfil}
146
! Make sure it terminated normally:
148
IF APPLIC(1:1) .EQ. "X" THEN
152
WRITE/KEYW type "ESO50"
155
ELSEIF reply(:1) .eq. "E" THEN ! ESO format
159
! Make sure it terminated normally:
161
IF APPLIC(1:1) .EQ. "X" THEN
165
WRITE/KEYW type "ESO"
167
ELSEIF reply(:1) .eq. "O" THEN ! other format
169
WRITE/OUT "Sorry -- you have to convert those data yourself."
173
WRITE/OUT "Please answer DANISH, ESO50, ESO, or OTHER."
177
! *** Here check for the data and format file and create the table
178
! Only for the D and E format; the ESO50 table are created directly
181
! (*dcon programs create files "data.dat" and "data.fmt")
182
IF M$EXIST(datfil) .eq. 0 THEN
183
WRITE/OUT "ERROR -- Could not find " {datfil}
185
WRITE/OUT "Probably the data could not be converted."
186
WRITE/OUT "Please make sure your raw data are clean."
189
WRITE/OUT {datfil} "has been created."
192
IF M$EXIST(fmtfil) .eq. 0 THEN
194
WRITE/OUT "ERROR -- Could not find " {fmtfil}
196
WRITE/OUT "Probably the data could not be converted."
197
WRITE/OUT "Please make sure your raw data are clean."
200
WRITE/OUT {fmtfil} "has been created."
204
WRITE/OUT "Creating the table (may take a while) ..."
205
CREATE/TABLE {tblfil} 1 1 {datfil} {fmtfil}
207
WRITE/OUT "Observational-data table file" {tblfil} "has been created."
208
WRITE/OUT "Here are the first 5 lines:"
212
! *** Table created; read it
213
READ/TABLE {tblfil} @1..5
218
INQUIRE/KEYW reply "Do you have a star-table file for your program stars?"
221
IF reply(:1) .eq. "y" THEN
222
WRITE/OUT "Good. You can now reduce these data with REDUCE/PHOT."
224
ELSEIF reply(:1) .eq. "n" THEN
227
WRITE/OUT "If you can find accurate coordinates for them, create"
228
WRITE/OUT "an ASCII table of the coordinate data, and use the"
229
WRITE/OUT "MAKE/STARTABLE command to convert it to MIDAS *.tbl format."
231
WRITE/OUT "You should be able to get good coordinates from STARCAT."
234
WRITE/OUT "It is possible to extract rough coordinates from the" {type}
235
WRITE/OUT "data themselves. However, these values may be in error by an"
236
WRITE/OUT "unknown amount, and this procedure is NOT recommended."
238
WRITE/OUT "Do you want to try to extract coordinates from" {rawdat} "?"
239
INQUIRE/KEYW reply "?"
241
IF reply(:1) .eq. "y" THEN
245
WRITE/OUT " W A R N I N G"
248
WRITE/OUT "You are at the mercy of whoever last adjusted the coordinate"
249
WRITE/OUT "zero-points of the telescope control system! The results may"
250
WRITE/OUT "be in ERROR by an UNKNOWN amount. This is the last warning"
251
WRITE/OUT "you will have that there may be serious systematic errors."
254
INQUIRE/KEYW reply " Do you REALLY want to do this ???"
255
IF reply(:1) .eq. "y" THEN
259
WRITE/OUT " YOU HAVE BEEN WARNED."
263
WRITE/KEYW tblfil/C/1/80 " " ALL ! clear the damn keyword
264
INQUIRE/KEYW tblfil "What do you want to call the program-star table?"
266
IF M$EXIST(tblfil) .eq. 0 THEN
270
WRITE/OUT {tblfil} "already exists!"
271
INQUIRE/KEYW reply "OK to write over it?"
273
IF reply(:1) .eq. "y" THEN
274
WRITE/OUT {tblfil} "will be re-written."
275
ELSEIF reply(:1) .eq. "n" THEN
277
WRITE/OUT "Here are the files in your current directory:"
279
IF AUX_MODE(1) .LE. 1 THEN ! VMS
285
WRITE/OUT "Please select a new name."
288
WRITE/OUT "Please reply YES or NO."
293
WRITE/OUT "Extracting stars..."
295
IF type(:1) .eq. "D" THEN
300
! Make sure it terminated normally:
302
IF APPLIC(1:1) .EQ. "X" THEN
306
ELSEIF type(:1) .eq. "E" THEN
308
RUN CON_EXE:ESODSTARX
310
! Make sure it terminated normally:
312
IF APPLIC(1:1) .EQ. "X" THEN
318
WRITE/OUT "Creating sdata.tbl (may take some time)..."
319
CREATE/TABLE sdata.tbl 1 1 sdata.dat sdata.fmt
321
WRITE/OUT "Combining multiple positions..."
325
! Make sure it terminated normally:
327
IF APPLIC(1:1) .EQ. "X" THEN
332
WRITE/OUT "Program star positions are in " {tblfil}
334
WRITE/OUT "Here are the first 10 lines:"
336
READ/TABLE {tblfil} @1..10
340
WRITE/OUT "Please use Starcat and MAKE/STARTABLE before REDUCE/PHOT."
342
ELSEIF reply(:1) .eq. "n" THEN
344
WRITE/OUT "Please use Starcat and MAKE/STARTABLE before REDUCE/PHOT."