-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRTMLEphemerisTargetTrackNode.java
More file actions
370 lines (344 loc) · 10.2 KB
/
RTMLEphemerisTargetTrackNode.java
File metadata and controls
370 lines (344 loc) · 10.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
package org.estar.rtml;
import java.io.*;
import java.text.*;
import java.util.*;
import org.estar.astrometry.*;
/**
* This class is a data container for information contained in an ephemeris target line
* of an ephemeris target in an RTML document. e.g. a line of the form:
* 2018-Sep-26 00:10 00 43 56.61 +11 08 37.2 -78.155203 65.006315
* where
* Columns desciption:
* <ul>
* <li>1 = UTC Date (YYYY-MMM-DD)
* <li>2 = UTC time (HH:MM)
* <li>3,4,5 = RA ( HH MM SS.SS) (J2000, topocentric)
* <li>6,7,8 = DEC (sDD mm ss.s ) (J2000, topocentric)
* <li>9 = RA rate (arcsec/hour)
* <li>10 = DEC rate (arcsec/hour)
* </ul>
* @author Chris Mottram
* @version $Revision$
* @see org.estar.rtml.RTMLAttributes
*/
public class RTMLEphemerisTargetTrackNode extends RTMLAttributes implements Serializable
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* The date format used to parse and print the timestamp in an ephemeris target line.
* This is currently "yyyy-MMM-dd HH:mm".
*/
public final static String EPHEMERIS_DATE_FORMAT = new String("yyyy-MMM-dd HH:mm");
/**
* Serial version ID. Fixed as these documents can be used as parameters in RMI calls across JVMs.
*/
// static final long serialVersionUID = ;
/**
* The timestamp for this node.
*/
private Date timestamp = null;
/**
* The right ascension of the target.
* For ephemeris targets these should be J2000, topocentric, astrometric.
*/
private RA ra = null;
/**
* The declination of the target.
* For ephemeris targets these should be J2000, topocentric, astrometric.
*/
private Dec dec = null;
/**
* The non-sidereal tracking rate in RA of the ephemeris at this point in time,in arcsec/hour.
*/
private double trackRateRA = 0.0;
/**
* The non-sidereal tracking rate in Dec of the ephemeris at this point in time,in arcsec/hour.
*/
private double trackRateDec = 0.0;
/**
* Default constructor.
*/
public RTMLEphemerisTargetTrackNode()
{
super();
}
/**
* Set the timestamp of this track node.
* @param d A date.
* @see #timestamp
*/
public void setTimestamp(Date d)
{
timestamp = d;
}
/**
* Parse a string of the form:"2018-Sep-26 00:10", with a SimpleDateFormat using format "yyyy-MMM-dd HH:mm".
* @param dateString The date string to parse, in the format "yyyy-MMM-dd", e.g. "2018-Sep-26".
* @param timeString The time string to parse, in the format "HH:mm", e.g. "00:10".
* @see #EPHEMERIS_DATE_FORMAT
* @see #timestamp
*/
public void parseTimestamp(String dateString,String timeString) throws ParseException
{
SimpleDateFormat dateFormat = null;
String parseString = null;
parseString = new String(dateString+" "+timeString);
dateFormat = new SimpleDateFormat(EPHEMERIS_DATE_FORMAT);
timestamp = dateFormat.parse(parseString);
}
/**
* Get the timestamp of this track node.
* @return A date.
* @see #timestamp
*/
public Date getTimestamp()
{
return timestamp;
}
/**
* Set the target right ascension. For ephemeris targets these should be J2000, topocentric, astrometric.
* @param r The right ascension.
* @see #ra
*/
public void setRA(RA r)
{
ra = r;
}
/**
* Set the target right ascension. For ephemeris targets these should be J2000, topocentric, astrometric.
* @param s A string representing the right ascension, in space separated format.
* @see #ra
* @exception IllegalArgumentException Thrown if there is a problem with the parsing.
*/
public void parseRA(String s) throws IllegalArgumentException
{
ra = new RA();
ra.parseSpace(s);
}
/**
* Get the target right ascension.
* @return The right ascension.
* @see #ra
*/
public RA getRA()
{
return ra;
}
/**
* Set the target declination. For ephemeris targets these should be J2000, topocentric, astrometric.
* @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.
* For ephemeris targets these should be J2000, topocentric, astrometric.
* @param s A string representing the declination, in space 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 parseDec(String s) throws IllegalArgumentException
{
dec = new Dec();
dec.parseSpace(s);
}
/**
* Get the target declination.
* @return The declination.
* @see #dec
*/
public Dec getDec()
{
return dec;
}
/**
* Set the non-sidereal tracking rate in RA of the ephemeris at this point in time,in arcsec/hour.
* @param d The non-sidereal tracking rate in RA, in decimal arcsec/hour.
* @see #trackRateRA
*/
public void setTrackRateRA(double d)
{
trackRateRA = d;
}
/**
* Return the non-sidereal tracking rate in RA of the ephemeris at this point in time.
* @return The non-sidereal tracking rate in RA, in arcsec/hour.
* @see #trackRateRA
*/
public double getTrackRateRA()
{
return trackRateRA;
}
/**
* Set the non-sidereal tracking rate in Declination of the ephemeris at this point in time,in arcsec/hour.
* @param d The non-sidereal tracking rate in Declination, in decimal arcsec/hour.
* @see #trackRateDec
*/
public void setTrackRateDec(double d)
{
trackRateDec = d;
}
/**
* Return the non-sidereal tracking rate in Declination of the ephemeris at this point in time.
* @return The non-sidereal tracking rate in Declination, in arcsec/hour.
* @see #trackRateDec
*/
public double getTrackRateDec()
{
return trackRateDec;
}
/**
* Parse an ephemeris target line of the form:
* "2018-Sep-26 00:10 00 43 56.61 +11 08 37.2 -78.155203 65.006315"
* and fill out the fields of this instance of RTMLEphemerisTargetTrackNode accordingly.
* @param lineString One line of an ephemeris.
* @exception IllegalArgumentException Throwen if the parsing of the string fails.
* @see #timestamp
* @see #ra
* @see #dec
* @see #trackRateRA
* @see #trackRateDec
* @see #parseTimestamp
* @see #parseRA
* @see #parseDec
*/
public void parse(String lineString) throws IllegalArgumentException, ParseException
{
StringTokenizer stringTokenizer = new StringTokenizer(lineString," ");
double dRA,dDec;
if(stringTokenizer.countTokens() < 8)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
" only has "+stringTokenizer.countTokens()+" tokens.");
}
try
{
String dateString = (String) stringTokenizer.nextElement();
String timeString = (String) stringTokenizer.nextElement();
try
{
parseTimestamp(dateString,timeString);
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
":Failed to parse timestamp:"+dateString+" "+
timeString+":",e);
}
String raHString = (String) stringTokenizer.nextElement();
String raMString = (String) stringTokenizer.nextElement();
String raSString = (String) stringTokenizer.nextElement();
try
{
parseRA(raHString+" "+raMString+" "+raSString);
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
":Failed to parse RA:"+raHString+" "+raMString+" "+raSString+
":",e);
}
String decDString = (String) stringTokenizer.nextElement();
String decMString = (String) stringTokenizer.nextElement();
String decSString = (String) stringTokenizer.nextElement();
try
{
parseDec(decDString+" "+decMString+" "+decSString);
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
":Failed to parse Dec:"+decDString+" "+decMString+" "+decSString+
":",e);
}
// track rates are apparently optional
if(stringTokenizer.countTokens() >= 10)
{
String trackRateRAString = (String) stringTokenizer.nextElement();
try
{
dRA = Double.parseDouble(trackRateRAString);
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
":Failed to parse RA track rate:"+trackRateRAString+":",e);
}
setTrackRateRA(dRA);
String trackRateDecString = (String) stringTokenizer.nextElement();
try
{
dDec = Double.parseDouble(trackRateDecString);
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+
":Failed to parse Dec track rate:"+trackRateDecString+":",e);
}
setTrackRateDec(dDec);
}
else
{
setTrackRateRA(0.0);
setTrackRateDec(0.0);
}
}
catch (Exception e)
{
throw new IllegalArgumentException(this.getClass().getName()+
":parse:Illegal Ephemeris target line "+lineString+":",e);
}
}
/**
* Print out the data contained in this instance of RTMLEphemerisTargetTrackNode as a
* formatted ephemeris target line as follows:
* "2018-Sep-26 00:10 00 43 56.61 +11 08 37.2 -78.155203 65.006315"
* @see #EPHEMERIS_DATE_FORMAT
* @see #timestamp
* @see #ra
* @see #dec
* @see #trackRateRA
* @see #trackRateDec
*/
public String toString()
{
StringBuffer sb = null;
SimpleDateFormat sdf = null;
DecimalFormat df = null;
// initialise string buffer and decimal format
sb = new StringBuffer();
df = new DecimalFormat("0.000000");
// timestamp
sdf = new SimpleDateFormat(EPHEMERIS_DATE_FORMAT);
sb.append(sdf.format(timestamp));
sb.append(" ");
// ra
sb.append(ra.toString(' '));
sb.append(" ");
// dec
sb.append(dec.toString(' '));
sb.append(" ");
// trackRateRA
sb.append(df.format(trackRateRA));
sb.append(" ");
// trackRateDec
sb.append(df.format(trackRateDec));
return sb.toString();
}
}
/*
** $Log: not supported by cvs2svn $
*/