-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpose.java
More file actions
473 lines (448 loc) · 12.4 KB
/
Expose.java
File metadata and controls
473 lines (448 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*
Copyright 2006, Astrophysics Research Institute, Liverpool John Moores University.
This file is part of org.estar.toop.
org.estar.toop is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
org.estar.toop is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with org.estar.toop; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Expose.java
// $Header: /space/home/eng/cjm/cvs/org_estar_toop/Expose.java,v 1.5 2007-01-30 18:35:22 cjm Exp $
package org.estar.toop;
import java.io.*;
import java.util.*;
import java.text.*;
import ngat.util.*;
import ngat.util.logging.*;
/**
* Expose command implementation.
* @author Steve Fraser, Chris Mottram
* @version $Revision$
*/
public class Expose extends TOCCommand implements Logging, Runnable
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* Classname for logging.
*/
public static final String CLASS = "Expose";
/**
* The command name.
*/
public static final String COMMAND_NAME = "EXPOSE";
/**
* The exposure length in milliseconds.
*/
protected int exposureLength = 0;
/**
* The number of exposures to do. This is specified only if runatDate is <b>NOT</b> specified.
* @see #runatDate
*/
protected int exposureCount = 0;
/**
* Whether to call the data pipeline or not.
*/
protected boolean dataPipelineFlag = false;
/**
* The time to start the exposure. This is an alternative to exposureCount.
* @see #exposureCount
*/
protected Date runatDate = null;
/**
* Return value from the EXPOSE command.
* A list of returned exposure image filenames.
*/
protected List filenameList = null;
/**
* Return value from the EXPOSE command.
* The seeing in arcseconds.
*/
protected double seeing = 0.0;
/**
* Return value from the EXPOSE command.
* The integrated counts from the brightest object in the field, in ADU.
*/
protected int counts = 0;
/**
* Return value from the EXPOSE command.
* Photometricity from the DpRt, in magnitudes of extinction (standard fields only).
*/
protected double photometric = 0.0;
/**
* Return value from the EXPOSE command.
* Sky brightness from the DpRt, in magnitudes per square arcsecond.
*/
protected double skyBrightness = 0.0;
/**
* Return value from the EXPOSE command.
* The x pixel of the brightest object in the field, in pixels.
*/
protected double xPix = 0.0;
/**
* Return value from the EXPOSE command.
* The y pixel of the brightest object in the field, in pixels.
*/
protected double yPix = 0.0;
/**
* Default constructor.
*/
public Expose()
{
super();
}
/**
* Set the exposure length.
* @param i The exposure length in milliseconds.
* @see #exposureLength
*/
public void setExposureLength(int i)
{
exposureLength = i;
}
/**
* Set the number of exposures to do of the specified length (MULTRUN count).
* Set <b>either</b> this or the runat date.
* @param i The number of exposures.
* @see #exposureLength
*/
public void setExposureCount(int i)
{
exposureCount = i;
}
/**
* Set whether to call the data pipeline for these exposures.
* @param b A boolean, if true call the data pipeline, else don't.
* @see #dataPipelineFlag
*/
public void setDataPipelineFlag(boolean b)
{
dataPipelineFlag = b;
}
/**
* Set the exposure start date.
* Set <b>either</b> this or the exposure count - RUNATs can only have 1 exposure.
* @param d A date, the time the shutter should open.
* @see #runatDate
*/
public void setRunatDate(Date d)
{
runatDate = d;
}
/**
* Run method.
* Setup commandString.
* Call TOCCommand.run.
* If successful, look at the reply keyword/value pairs and extract the relevant data, updating the
* sessionData as necessary.
* @see #COMMAND_NAME
* @see #commandString
* @see #sessionData
* @see #exposureLength
* @see #exposureCount
* @see #dataPipelineFlag
* @see #runatDate
* @see #filenameList
* @see #seeing
* @see #counts
* @see #photometric
* @see #skyBrightness
* @see #xPix
* @see #yPix
* @see #logger
* @see #successful
* @see #errorString
*/
public void run()
{
DateFormat df = null;
String filename = null;
boolean done;
int index;
if(runatDate == null)
{
commandString = new String(COMMAND_NAME+" "+sessionData.getSessionId()+
" "+exposureLength+
" "+exposureCount);
}
else
{
df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
commandString = new String(COMMAND_NAME+" "+sessionData.getSessionId()+
" "+exposureLength+
" "+df.format(runatDate));
}
// postpend data pipeline flag
if(dataPipelineFlag)
commandString = new String(commandString+" T");
else
commandString = new String(commandString+" F");
super.run();
// results
if(getSuccessful())
{
try
{
// file<n> from n=1. Usually exposureCount results - but not always! (RUNAT)
filenameList = new Vector();
index = 1;// file<n> starts from n=1
done = false;
while(done == false)
{
filename = getReplyValue("file"+index);
if(filename != null)
{
filenameList.add(filename);
index++;
}
else
{
done = true;
}
}
// The next set of data is only returned if the data pipeline flag is set
if(dataPipelineFlag)
{
// seeing
seeing = getReplyValueDouble("seeing");
sessionData.setProperty(".expose.seeing",""+seeing);
// counts
counts = getReplyValueInt("counts");
sessionData.setProperty(".expose.counts",""+counts);
// photometric
photometric = getReplyValueDouble("photom");
sessionData.setProperty(".expose.photometric",""+photometric);
// skyBrightness
skyBrightness = getReplyValueDouble("skybright");
sessionData.setProperty(".expose.sky_brightness",""+skyBrightness);
// xPix
xPix = getReplyValueDouble("xpix");
sessionData.setProperty(".expose.xpix",""+xPix);
// yPix
yPix = getReplyValueDouble("ypix");
sessionData.setProperty(".expose.ypix",""+yPix);
// logging
logger.log(INFO, 1, CLASS, RCSID,"run","Expose successful with seeing : "+seeing+
", counts : "+counts+", photometric : "+photometric+
", xpix : "+xPix+", ypix : "+yPix+".");
}
else
{
// logging
logger.log(INFO, 1, CLASS, RCSID,"run","Expose successful.");
}
}
catch(NGATPropertyException e)
{
successful = false;
errorString = new String(this.getClass().getName()+
":run:Parsing EXPOSE results failed:"+e);
logger.log(INFO, 1, CLASS, RCSID,"run",errorString);
logger.dumpStack(1,e);
return;
}
}
else
{
logger.log(INFO, 1, CLASS, RCSID,"run","Expose failed with error : "+getErrorString()+".");
}
}
/**
* Return the number of FITS image filenames returned from the EXPOSE command.
* @return The number of filenames. If filenameList is null, 0 is returned.
* @see #filenameList
*/
public int getFilenameCount()
{
if(filenameList == null)
return 0;
return filenameList.size();
}
/**
* Return one of the FITS image filenames returned from the EXPOSE command.
* NB It is possible for an IndexOutOfBoundsException or ClassCastException to occur.
* @param i The index in the list of the filename to return.
* @return A FITS image filename. This filename exists on the <b>occ</b> machine, not the proxy machine.
* @see #filenameList
*/
public String getFilename(int i)
{
return (String)(filenameList.get(i));
}
/**
* Return the DpRt calculated seeing from the frames taken.
* @return The seeing in arcseconds.
* @see #seeing
*/
public double getSeeing()
{
return seeing;
}
/**
* Return the DpRt calculated integrated counts from the brightest object in the frame.
* @return The integrated counts of the brightest object in ADU.
* @see #counts
*/
public int getCounts()
{
return counts;
}
/**
* Return the DpRt calculated photometric flag, the number of magnitudes of extinction for this field.
* This normally returns -999.0, it only returns the magnitudes of extinction for standard fields.
* @return A number of magnitudes of extinction (for standard fields), or -999.0.
* @see #photometric
*/
public double getPhotometric()
{
return photometric;
}
/**
* Return the DpRt calculated sky brightness, the number of magnitudes per square arcsecond for this field.
* This normally returns 99.0.
* @return A number of magnitudes per square arcsecond, or 99.0.
* @see #skyBrightness
*/
public double getSkyBrightness()
{
return skyBrightness;
}
/**
* Return the DpRt calculated x pixel location of the brightest object in the field.
* @return The x pixel position in pixels.
* @see #xPix
*/
public double getXPix()
{
return xPix;
}
/**
* Return the DpRt calculated y pixel location of the brightest object in the field.
* @return The y pixel position in pixels.
* @see #yPix
*/
public double getYPix()
{
return yPix;
}
/**
* Test main program.
* @param args The argument list.
*/
public static void main(String args[])
{
TOCSessionData sessionData = null;
Expose expose = null;
File inputPropertiesFile = null;
Logger l = null;
DateFormat df = null;
Boolean b = null;
Date runatDate = null;
int exposureLength = 0;
int exposureCount = 0;
boolean dataPipelineFlag;
if(args.length != 4)
{
System.out.println("java org.estar.toop.Expose <input properties filename> <exposure length ms> <<exposure count>|<runat date>> <data pipeline flag>");
System.exit(1);
}
inputPropertiesFile = new File(args[0]);
exposureLength = Integer.parseInt(args[1]);
if(args[2].indexOf("T") > -1)
{
try
{
df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
runatDate = df.parse(args[2]);
}
catch(Exception e)
{
System.err.println("Parsing runat date "+args[2]+" failed:"+e);
e.printStackTrace();
System.exit(1);
}
}
else
{
exposureCount = Integer.parseInt(args[2]);
}
b = Boolean.valueOf(args[3]);
dataPipelineFlag = b.booleanValue();
// setup logger
ConsoleLogHandler console = new ConsoleLogHandler(new BasicLogFormatter(150));
console.setLogLevel(ALL);
l = LogManager.getLogger("org.estar.toop.TOCAClient");
l.setLogLevel(ALL);
l.addHandler(console);
l = LogManager.getLogger("org.estar.toop.TOCCommand");
l.setLogLevel(ALL);
l.addHandler(console);
l = LogManager.getLogger("org.estar.toop.Expose");
l.setLogLevel(ALL);
l.addHandler(console);
l = LogManager.getLogger("org.estar.toop.TOCSessionData");
l.setLogLevel(ALL);
l.addHandler(console);
// load session data
sessionData = new TOCSessionData();
try
{
sessionData.load(inputPropertiesFile);
}
catch(Exception e)
{
System.err.println("Loading session data failed:"+e);
e.printStackTrace();
System.exit(1);
}
expose = new Expose();
expose.setSessionData(sessionData);
expose.setExposureLength(exposureLength);
expose.setExposureCount(exposureCount);
expose.setRunatDate(runatDate);
expose.setDataPipelineFlag(dataPipelineFlag);
expose.run();
if(expose.getSuccessful())
{
for(int i = 0; i < expose.getFilenameCount(); i++)
{
System.out.println("Filename "+i+":"+expose.getFilename(i)+".");
}
System.out.println("Seeing:"+expose.getSeeing()+" arc-seconds.");
System.out.println("Counts:"+expose.getCounts()+" ADU.");
System.out.println("Position:"+expose.getXPix()+","+expose.getYPix()+".");
System.out.println("Photometricity:"+expose.getPhotometric()+" magnitudes.");
System.out.println("Sky Brightness:"+expose.getSkyBrightness()+" magnitudes per square arc-second.");
}
else
{
System.out.println("Expose failed:"+expose.getErrorString()+".");
}
System.out.println("Expose finished.");
System.exit(0);
}
}
/*
** $Log: not supported by cvs2svn $
** Revision 1.4 2005/06/15 16:56:18 cjm
** Made expose public so return filenames can be retrieved.
**
** Revision 1.3 2005/06/07 13:27:58 cjm
** Comment fix.
**
** Revision 1.2 2005/06/06 17:46:56 cjm
** Comment fix.
**
** Revision 1.1 2005/06/06 16:01:13 cjm
** Initial revision
**
*/