-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRTMLTarget.java
More file actions
644 lines (599 loc) · 17.2 KB
/
RTMLTarget.java
File metadata and controls
644 lines (599 loc) · 17.2 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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
/*
Copyright 2006, Astrophysics Research Institute, Liverpool John Moores University.
This file is part of org.estar.rtml.
org.estar.rtml 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.rtml 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.rtml; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// RTMLTarget.java
// $Header: /space/home/eng/cjm/cvs/org_estar_rtml/RTMLTarget.java,v 1.11 2019-01-02 11:34:48 cjm Exp $
package org.estar.rtml;
import java.io.*;
import java.text.*;
import java.util.*;
//import java.util.Comparator;
//import java.util.SortedSet;
//import java.util.TreeSet;
import org.estar.astrometry.*;
/**
* This class is a data container for information contained in the target nodes/tags of an RTML document.
* @author Chris Mottram
* @version $Revision$
* @see org.estar.rtml.RTMLAttributes
*/
public class RTMLTarget extends RTMLAttributes implements Serializable
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* Serial version ID. Fixed as these documents can be used as parameters in RMI calls across JVMs.
*/
static final long serialVersionUID = -4226657892010129299L;
/**
* The type of the Target, the type attribute in the Target tag. Should be either "normal" or
* "toop".
*/
private String type = null;
/**
* The ident of the target, as specified in Target's ident attribute.
*/
private String ident = null;
/**
* The name of the target, as specified in the #PCDATA of the TargetName sub node.
*/
private String name = null;
/**
* The right ascension of the target. This will be null if the target is an ephemeris target.
*/
private RA ra = null;
/**
* The declination of the target. This will be null if the target is an ephemeris target.
*/
private Dec dec = null;
/**
* The equinox of the coordinates.
*/
private String equinox = null;
/**
* If the target is an ephemeris target rather than an extra solar target, this set will contain a
* sorted (in time) list of RTMLEphemerisTargetTrackNode s.
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
private SortedSet ephemerisTargetTrack = null;
/**
* An offset to be applied to the Right Ascension.
*/
private double raOffset = 0.0;
/**
* An offset to be applied to the Declination.
*/
private double decOffset = 0.0;
/**
* The magnitude of the target.
*/
private double magnitude = 0.0;
/**
* The filter type the magnitude of the target is quoted in (i.e. Mag 10 in R).
*/
private String magnitudeFilterType = null;
/**
* The error of the magnitude.
*/
private double magnitudeError = 0.0;
/**
* How to acquire this target onto the instrument focal plane. Usually only specifried for spectrographs.
*/
private RTMLAcquisition acquisition = null;
/**
* Default constructor.
*/
public RTMLTarget()
{
super();
type = new String("normal");
}
/**
* Set the target type.
* @param s The type of the target. Should be either "normal", or "toop". See DTD, %targetType;.
* @exception IllegalArgumentException Thrown if the type is nor legal.
* @see #type
*/
public void setType(String s) throws IllegalArgumentException
{
if((s.equals("normal") == false)&&(s.equals("toop") == false))
throw new IllegalArgumentException(this.getClass().getName()+":setType:Type "+s+" not legal.");
type = s;
}
/**
* Set the target type to a target of opportunity. The "type" string is set to "toop".
* @see #type
*/
public void setTypeTOOP()
{
type = new String("toop");
}
/**
* Get the target type.
* @return A string representing the target type, either "normal", or "toop".
* @see #type
*/
public String getType()
{
return type;
}
/**
* Return whether the target is normal, as opposed to a target of opportunity.
* @return Returns true if the target type is normal, otherwise false.
* @see #type
*/
public boolean isTypeNormal()
{
return type.equals("normal");
}
/**
* Return whether the target is a target of opportunity.
* @return Returns true if the target type is toop, otherwise false.
* @see #type
*/
public boolean isTypeTOOP()
{
return type.equals("toop");
}
/**
* Set the target name.
* @param s The name.
* @see #name
*/
public void setName(String s)
{
name = s;
}
/**
* Get the target name.
* @return The name.
* @see #name
*/
public String getName()
{
return name;
}
/**
* Set the target ident. This can be null, if no ident was specified.
* @param s The ident.
* @see #ident
*/
public void setIdent(String s)
{
ident = s;
}
/**
* Get the target ident. This can be null, if no ident was specified.
* @return The ident string.
* @see #ident
*/
public String getIdent()
{
return ident;
}
/**
* Set the target right ascension.
* @param r The right ascension.
* @see #ra
*/
public void setRA(RA r)
{
ra = r;
}
/**
* Set the target right ascension.
* @param s A string representing the right ascension, in colon separated format.
* @see #ra
* @exception IllegalArgumentException Thrown if there is a problem with the parsing.
*/
public void setRA(String s) throws IllegalArgumentException
{
ra = new RA();
ra.parseColon(s);
}
/**
* Get the target right ascension.
* @return The name.
* @see #ra
*/
public RA getRA()
{
return ra;
}
/**
* Set the target declination.
* @param d The declination.
* @see #dec
*/
public void setDec(Dec d)
{
dec = d;
}
/**
* Set the target declination. Now allows declinations with no sign character, assumes positive.
* @param s A string representing the declination, in colon separated format.
* @see #dec
* @see org.estar.astrometry.Dec#parseColon(java.lang.String,boolean)
* @exception IllegalArgumentException Thrown if there is a problem with the parsing.
*/
public void setDec(String s) throws IllegalArgumentException
{
dec = new Dec();
dec.parseColon(s,false);
}
/**
* Get the target declination.
* @return The declination.
* @see #dec
*/
public Dec getDec()
{
return dec;
}
/**
* Set the equinox.
* @param s The equinox.
* @see #equinox
*/
public void setEquinox(String s)
{
equinox = s;
}
/**
* Get the equinox.
* @return The equinox.
* @see #equinox
*/
public String getEquinox()
{
return equinox;
}
/**
* Set the ephemeris target track to the specified set of RTMLEphemerisTargetTrackNode s.
* @param track A SortedSet containing elements of RTMLEphemerisTargetTrackNode, sorted in timestamp order.
* @see #ephemerisTargetTrack
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public void setEphemerisTrack(SortedSet track)
{
ephemerisTargetTrack = track;
}
/**
* Get the ephemeris target track.
* @return The ephemeris target track, A SortedSet containing elements of RTMLEphemerisTargetTrackNode,
* sorted in timestamp order.
* @see #ephemerisTargetTrack
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public SortedSet getEphemerisTrack()
{
return ephemerisTargetTrack;
}
/**
* Add the specified ephemeris target track node to the list of ephemeris target track nodes.
* @param node An instance of RTMLEphemerisTargetTrackNode to add to the list.
* @see #ephemerisTargetTrack
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public void addEphemerisTrackNode(RTMLEphemerisTargetTrackNode node)
{
if(ephemerisTargetTrack == null)
ephemerisTargetTrack = new TreeSet(new NodeComparator());
if(ephemerisTargetTrack.contains(node) == false)
ephemerisTargetTrack.add(node);
}
/**
* Remove the list of ephemeris target track nodes.
* ephemerisTargetTrack is set to null, which effectively makes this target an extra solar target
* until an ephemeris target track node is added.
* @see #ephemerisTargetTrack
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public void clearEphemerisTrack()
{
ephemerisTargetTrack.clear();
ephemerisTargetTrack = null;
}
/**
* Remove the specified ephemeris target track node from the list of ephemeris target track nodes.
* @param node An instance of RTMLEphemerisTargetTrackNode to remove from the list.
* @see #ephemerisTargetTrack
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public void removeEphemerisTrackNode(RTMLEphemerisTargetTrackNode node)
{
if(ephemerisTargetTrack != null)
{
if(ephemerisTargetTrack.contains(node))
ephemerisTargetTrack.remove(node);
}
}
/**
* Set an offset from right ascension.
* @param d The offset, in decimal arcseconds.
* @see #raOffset
*/
public void setRAOffset(double d)
{
raOffset = d;
}
/**
* Return an offset to be applied from the target's position.
* @return The offset in RA, in arcseconds.
* @see #raOffset
*/
public double getRAOffset()
{
return raOffset;
}
/**
* Set an offset from declination.
* @param d The offset, in decimal arcseconds.
* @see #decOffset
*/
public void setDecOffset(double d)
{
decOffset = d;
}
/**
* Return an declination offset to be applied from the target's position.
* @return The offset in declination, in arcseconds.
* @see #decOffset
*/
public double getDecOffset()
{
return decOffset;
}
/**
* Set target magnitude.
* @param d The magnitude.
* @see #magnitude
*/
public void setMagnitude(double d)
{
magnitude = d;
}
/**
* Return an target magnitude.
* @return The magnitude.
* @see #magnitude
*/
public double getMagnitude()
{
return magnitude;
}
/**
* Set the magnitude filter type.
* @param s The magnitude filter type. See schema for valid values e.g.:
* U|B|V|R|I etc.
* @see #magnitudeFilterType
* @exception IllegalArgumentException Thrown if the filter type is illegal.
*/
public void setMagnitudeFilterType(String s) throws IllegalArgumentException
{
if((s != null)&&(s.equals("none")||s.equals("clear")||s.equals("neutral_density")||
s.equals("blue")||s.equals("green")||s.equals("red")||s.equals("U")||
s.equals("B")||s.equals("V")||s.equals("R")||s.equals("I")||s.equals("H")||
s.equals("J")||s.equals("K")||s.equals("L")||s.equals("M")||s.equals("N")||
s.equals("Johnson_U")||s.equals("Johnson_B")||s.equals("Johnson_V")||
s.equals("Johnson_R")||s.equals("Johnson_I")||s.equals("Johnson_J")||
s.equals("Johnson_H")||s.equals("Johnson_K")||s.equals("Johnson_L")||
s.equals("Johnson_M")||s.equals("Johnson_N")||
s.equals("Bessel_U")||s.equals("Bessel_B")||s.equals("Bessel_V")||
s.equals("Bessel_R")||s.equals("Bessel_I")||
s.equals("Cousins_R")||s.equals("Cousins_I")||
s.equals("Sloan_u")||s.equals("Sloan_g")||s.equals("Sloan_r")||
s.equals("Sloan_i")||s.equals("Sloan_z")||
s.equals("Stroemgren_u")||s.equals("Stroemgren_b")||s.equals("Stroemgren_v")||
s.equals("Stroemgren_beta")||s.equals("Stroemgren_y")||
s.equals("Gunn_g")||s.equals("Gunn_r")||s.equals("Gunn_i")||s.equals("Gunn_z")||
s.equals("narrowband")||s.equals("Halpha")||s.equals("Hbeta")||
s.equals("forbidden_OI")||s.equals("forbidden_OII")||s.equals("forbidden_OIII")||
s.equals("forbidden_NII")||s.equals("forbidden_SII")||s.equals("other")))
{
magnitudeFilterType = s;
}
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setMagnitudeFilterType:Illegal filter type:"+s);
}
}
/**
* Get the magnitude filter type.
* @return The magnitude filter type.
* @see #magnitudeFilterType
*/
public String getMagnitudeFilterType()
{
return magnitudeFilterType;
}
/**
* Set target magnitude error.
* @param d The magnitude error.
* @see #magnitudeError
*/
public void setMagnitudeError(double d)
{
magnitudeError = d;
}
/**
* Return the target magnitude error.
* @return The magnitude error.
* @see #magnitudeError
*/
public double getMagnitudeError()
{
return magnitudeError;
}
/**
* Set the RTML Acquisition data.
* @param a An RTMLAcquisition instance containing the acquisition mode for this target.
* @see #acquisition
*/
public void setAcquisition(RTMLAcquisition a)
{
acquisition = a;
}
/**
* Get the RTMLAcquisition instance containing the acquisition mode for this targ.
* @return An RTMLAcquisition instance containing the acquisition mode for this target.
* @see #acquisition
*/
public RTMLAcquisition getAcquisition()
{
return acquisition;
}
/**
* Method to print out a string representation of this node.
*/
public String toString()
{
return toString("");
}
/**
* Method to print out a string representation of this node, with a prefix.
* @param prefix A string to prefix to each line of data we print out.
* @see #type
* @see #name
* @see #ident
* @see #ra
* @see #dec
* @see #equinox
* @see #ephemerisTargetTrack
* @see #raOffset
* @see #decOffset
* @see #magnitude
* @see #magnitudeFilterType
* @see #magnitudeError
* @see #acquisition
* @see org.estar.rtml.RTMLAttributes#toString(java.lang.String)
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public String toString(String prefix)
{
StringBuffer sb = null;
DecimalFormat df = null;
df = new DecimalFormat("#0.0#");
sb = new StringBuffer();
sb.append(prefix+"Target: type = "+type+"\n");
sb.append(super.toString(prefix+"\t"));
if(name != null)
sb.append(prefix+"\tName:"+name+"\n");
if(ident != null)
sb.append(prefix+"\tIdent:"+ident+"\n");
if(ra != null)
sb.append(prefix+"\tRA:"+ra+"\n");
if(equinox != null)
sb.append(prefix+"\tEquinox:"+equinox+"\n");
if(ephemerisTargetTrack != null)
{
sb.append(prefix+"\tEphemeris Target Track:\n");
List<RTMLEphemerisTargetTrackNode> list = new ArrayList<RTMLEphemerisTargetTrackNode>(ephemerisTargetTrack);
for (RTMLEphemerisTargetTrackNode node : list)
{
//RTMLEphemerisTargetTrackNode node = (RTMLEphemerisTargetTrackNode)o;
sb.append(prefix+"\t\t"+node);
}
}
sb.append(prefix+"\tRA offset:"+df.format(raOffset)+"\n");
if(dec != null)
sb.append(prefix+"\tDec:"+dec+"\n");
sb.append(prefix+"\tDec offset:"+df.format(decOffset)+"\n");
if(magnitudeFilterType != null)
{
sb.append(prefix+"\tMagtitude:"+df.format(magnitude)+" in "+magnitudeFilterType+
" (+/- "+df.format(magnitudeError)+")\n");
}
if(acquisition != null)
sb.append(acquisition.toString(prefix+"\t")+"\n");
return sb.toString();
}
/**
* Internal Comparator class for testing order of track anchor points (track nodes).
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
*/
public static class NodeComparator implements Comparator, Serializable
{
/**
* Method to compare two objects in the set. These should both be instances of
* RTMLEphemerisTargetTrackNode. Any list using this comparator are ordered in timestamp order.
* @param o1 An object, should be an instance of RTMLEphemerisTargetTrackNode.
* @param o2 An object, should be an instance of RTMLEphemerisTargetTrackNode.
* @return Returns an integer, -1 if o1's timestamp is before o2, 1 if o1's timestamp is after o2,
* 0 if they have the same timestamp.
* @exception ClassCastException Thrown if o1 and o2 are not both instances of
* RTMLEphemerisTargetTrackNode
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode#timestamp
* @see org.estar.rtml.RTMLEphemerisTargetTrackNode#getTimestamp
*/
public int compare (Object o1, Object o2)
{
long time1,time2;
if (! (o1 instanceof RTMLEphemerisTargetTrackNode) ||
! (o2 instanceof RTMLEphemerisTargetTrackNode))
{
throw new ClassCastException("Compare:: Not both EphemerisTrackNodes: ("+
(o1 == null ? "NULL": o1.getClass().getName())+","+
(o2 == null ? "NULL": o2.getClass().getName())+")");
}
RTMLEphemerisTargetTrackNode node1 = (RTMLEphemerisTargetTrackNode)o1;
RTMLEphemerisTargetTrackNode node2 = (RTMLEphemerisTargetTrackNode)o2;
time1 = node1.getTimestamp().getTime();
time2 = node2.getTimestamp().getTime();
if (time1 < time2)
return -1;
else if(time1 > time2)
return 1;
return 0;
}
} // comparator
}
/*
** $Log: not supported by cvs2svn $
** Revision 1.10 2009/08/12 17:48:46 cjm
** Added target magnitude data.
**
** Revision 1.9 2008/08/11 13:54:54 cjm
** Added RA and Dec offsets.
**
** Revision 1.8 2008/05/27 15:01:06 cjm
** Added serialVersionUID.
**
** Revision 1.7 2008/05/23 17:09:42 cjm
** Now extends RTMLAttributes.
**
** Revision 1.6 2007/01/30 18:31:23 cjm
** gnuify: Added GNU General Public License.
**
** Revision 1.5 2005/06/08 11:38:41 cjm
** Fixed comments.
**
** Revision 1.4 2005/05/12 10:07:02 cjm
** Changed setDec to allow strings without a sign char, it assumes positive.
**
** Revision 1.3 2005/04/25 10:32:00 cjm
** Added ident attribute.
**
** Revision 1.2 2005/01/19 15:30:38 cjm
** Added Serializable.
**
** Revision 1.1 2003/02/24 13:19:56 cjm
** Initial revision
**
*/