rms-starcat 0.0.1__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rms-starcat might be problematic. Click here for more details.

starcat/ybsc.py CHANGED
@@ -7,135 +7,253 @@
7
7
  # <Astronomical Data Center, NSSDC/ADC (1991)>
8
8
  # =1964BS....C......0H
9
9
  # From ftp://cdsarc.u-strasbg.fr/cats/V/50/1
10
+ # http://tdc-www.harvard.edu/catalogs/bsc5.html
10
11
 
11
- from __future__ import print_function
12
+ from __future__ import annotations
12
13
 
13
- try:
14
- from starcatalog import *
15
- except:
16
- from .starcatalog import *
17
14
  import numpy as np
18
- import os.path
19
- import struct
15
+ import os
16
+ from pathlib import Path
17
+ from typing import Any, Iterator, Optional, cast
20
18
 
21
- YBSC_IR_NASA = 0
22
- YBSC_IR_ENGLES = 1
23
- YBSC_IR_UNCERTAIN = 2
19
+ from filecache import FCPath
24
20
 
25
- YBSC_MULTIPLE_NONE = ' '
26
- YBSC_MULTIPLE_ASTROMETRIC = 'A'
27
- YBSC_MULTIPLE_DUPLICITY_OCCULTATION = 'D'
28
- YBSC_MULTIPLE_INNES = 'I'
29
- YBSC_MULTIPLE_ROSSITER = 'R'
30
- YBSC_MULTIPLE_DUPLICITY_SPECKLE = 'S'
31
- YBSC_MULTIPLE_WORLEY = 'W'
32
-
33
- YBSC_VMAG_UNCERTAINTY_V = ' '
34
- YBSC_VMAG_UNCERTAINTY_HR_REDUCED = 'R'
35
- YBSC_VMAG_UNCERTAINTY_HR = 'H'
36
-
37
- # WE SHOULD ADD MORE DEFINITIONS HERE
21
+ from .starcatalog import (AS_TO_RAD,
22
+ YEAR_TO_SEC,
23
+ Star,
24
+ StarCatalog
25
+ )
38
26
 
39
27
 
40
28
  class YBSCStar(Star):
41
29
  """A holder for star attributes.
42
30
 
43
- This class includes attributes unique to the YBSC catalog."""
31
+ This class includes attributes unique to the YBSC catalog.
32
+ """
33
+
34
+ YBSC_IR_NASA = 0
35
+ YBSC_IR_ENGLES = 1
36
+ YBSC_IR_UNCERTAIN = 2
37
+
38
+ YBSC_IR_STRINGS = ['NASA', 'ENGLES', 'UNCERTAIN']
44
39
 
45
- def __init__(self):
40
+ YBSC_MULTIPLE_NONE = ' '
41
+ YBSC_MULTIPLE_ASTROMETRIC = 'A'
42
+ YBSC_MULTIPLE_DUPLICITY_OCCULTATION = 'D'
43
+ YBSC_MULTIPLE_INNES = 'I'
44
+ YBSC_MULTIPLE_ROSSITER = 'R'
45
+ YBSC_MULTIPLE_DUPLICITY_SPECKLE = 'S'
46
+ YBSC_MULTIPLE_WORLEY = 'W'
47
+
48
+ YBSC_VMAG_UNCERTAINTY_V = ' '
49
+ YBSC_VMAG_UNCERTAINTY_HR_REDUCED = 'R'
50
+ YBSC_VMAG_UNCERTAINTY_HR = 'H'
51
+
52
+ def __init__(self) -> None:
46
53
  # Initialize the standard fields
47
- Star.__init__(self)
54
+ super().__init__()
48
55
 
49
56
  # Initialize the YBSC-specific fields
50
- self.name = None
51
- self.durchmusterung_id = None
52
- self.draper_number = None
53
- self.sao_number = None
54
- self.fk5_number = None
55
- self.ir_source = None
56
- self.ir_source_ref = None
57
- self.double_star_code = None
58
- self.aitken_designation = None
59
- self.ads_components = None
60
- self.variable_star_id = None
61
- self.galactic_longitude = None
62
- self.galactic_latitude = None
63
- self.vmag_code = None
64
- self.vmag_uncertainty_flag = None
65
- self.b_v = None
66
- self.u_b = None
67
- self.r_i = None
68
- self.spectral_class = None
69
- self.spectral_class_code = None
70
- self.parallax_type = None
71
- self.parallax = None
72
- self.radial_velocity = None
73
- self.radial_velocity_comments = None
74
- self.rotational_velocity_limit = None
75
- self.rotational_velocity = None
76
- self.rotational_velocity_uncertainty_flag = None
77
- self.double_mag_diff = None
78
- self.double_mag_sep = None
79
- self.double_mag_components = None
80
- self.multiple_num_components = None
81
- self.temperature = None
82
-
83
- def __str__(self):
84
- ret = Star.__str__(self)
85
-
86
- ret += 'Name "' + str(self.name) + '"'
87
- ret += ' | Durch "' + str(self.durchmusterung_id) + '"'
88
- ret += ' | Draper ' + str(self.draper_number)
89
- ret += ' | SAO ' + str(self.sao_number)
90
- ret += ' | FK5 ' + str(self.fk5_number)
57
+ self.name: Optional[str] = None
58
+ """Bayer and/or Flamsteed name"""
59
+
60
+ self.durchmusterung_id: Optional[str] = None
61
+ """Durchmusterung identification"""
62
+
63
+ self.draper_number: Optional[int] = None
64
+ """Henry Draper Catalog number (out of 225300)"""
65
+
66
+ self.sao_number: Optional[int] = None
67
+ """SAO Catalog number (out of 258997)"""
68
+
69
+ self.fk5_number: Optional[int] = None
70
+ """FK5 star number"""
71
+
72
+ self.ir_source: Optional[bool] = None
73
+ """True if infrared source"""
74
+
75
+ self.ir_source_ref: Optional[int] = None
76
+ """Infrared source:
77
+ NASA, ENGLES, or UNCERTAIN"""
78
+
79
+ self.multiple_star_code: Optional[str] = None
80
+ """Double or multiple star code:
81
+ 'A' = Astrometric binary;
82
+ 'D' = Duplicity discovered by occultation;
83
+ 'I' = Innes, Southern Double Star Catalogue (1927);
84
+ 'R' = Rossiter, Michigan Publ. 9, 1955;
85
+ 'S' = Duplicity discovered by speckle interferometry;
86
+ 'W' = Worley (1978) update of the IDS"""
87
+
88
+ self.aitken_designation: Optional[str] = None
89
+ """Aitken's Double Star Catalog (ADS) designation"""
90
+
91
+ self.ads_components: Optional[str] = None
92
+ """ADS number components"""
93
+
94
+ self.variable_star_id: Optional[str] = None
95
+ """Variable star identification"""
96
+
97
+ self.galactic_longitude: Optional[float] = None
98
+ """Galactic longitude (radians)"""
99
+
100
+ self.galactic_latitude: Optional[float] = None
101
+ """Galactic latitude (radians)"""
102
+
103
+ self.vmag_code: Optional[str] = None
104
+ """Visual magnitude code:
105
+ ' ' = V on UBV Johnson system;
106
+ 'R' = HR magnitudes reduced to the UBV system;
107
+ 'H' = original HR magnitude"""
108
+
109
+ self.vmag_uncertainty_flag: Optional[str] = None
110
+ """Uncertainty flag on visual magnitude"""
111
+
112
+ self.b_v: Optional[float] = None
113
+ """B-V color in the UBV system"""
114
+
115
+ self.b_v_uncertainty_flag: Optional[str] = None
116
+ """Uncertainty flag on B-V color"""
117
+
118
+ self.u_b: Optional[float] = None
119
+ """U-B color in the UBV system"""
120
+
121
+ self.u_b_uncertainty_flag: Optional[str] = None
122
+ """Uncertainty flag on U-B color"""
123
+
124
+ self.r_i: Optional[float] = None
125
+ """R-I color in the system indicated by r_i_code"""
126
+
127
+ self.r_i_code: Optional[str] = None
128
+ """Code for R-I system:
129
+ 'C' = Cousin;
130
+ 'E' = 'Eggen';
131
+ ':' = Unknown;
132
+ '?' = Unknown;
133
+ 'D' = Unknown"""
134
+
135
+ self.spectral_class_code: Optional[str] = None
136
+ """Spectral class code:
137
+ 'e', 'v', or 't'"""
138
+
139
+ self.parallax_type: Optional[str] = None
140
+ """Parallax type:
141
+ 'D' = Dyanmical, otherwise Trigonometric"""
142
+
143
+ self.parallax: Optional[float] = None
144
+ """Parallax (arcsec); see parallax_type for measurement type"""
145
+
146
+ self.radial_velocity: Optional[float] = None
147
+ """Radial velocity (km/s)"""
148
+
149
+ self.radial_velocity_comments: Optional[str] = None
150
+ """Radial velocity comments (multiple possible):
151
+ 'V' = Variable radial velocity;
152
+ 'V?' = Suspected variable radial velocity;
153
+ 'SB', 'SB1', 'SB2', 'SB3' = Spectroscopic binaries,
154
+ single/double/triple-lined spectra;
155
+ 'O' = Orbital data available"""
156
+
157
+ self.rotational_velocity_limit: Optional[str] = None
158
+ """Rotational velocity limit:
159
+ '<', '=', or '>'"""
160
+
161
+ self.rotational_velocity: Optional[float] = None
162
+ """Rotational velocity [v sin i] (km/s)"""
163
+
164
+ self.rotational_velocity_uncertainty_flag: Optional[str] = None
165
+ """Rotational velocity uncertainty and variability flag:
166
+ ' ', ':', or 'v'"""
167
+
168
+ self.double_mag_diff: Optional[float] = None
169
+ """Magnitude difference of double, or brightest multiple"""
170
+
171
+ self.double_mag_sep: Optional[float] = None
172
+ """Separation of components in double_mag if occultation binary (radians)"""
173
+
174
+ self.double_mag_components: Optional[str] = None
175
+ """Indentification of components in double_mag"""
176
+
177
+ self.multiple_num_components: Optional[int] = None
178
+ """Number of components assigned to a multiple"""
179
+
180
+ def __str__(self) -> str:
181
+ ret = Star.__str__(self) + '\n'
182
+
183
+ ret += f'Name "{self.name}"'
184
+ ret += f' | Durch "{self.durchmusterung_id}"'
185
+ ret += f' | Draper {self.draper_number}'
186
+ ret += f' | SAO {self.sao_number}'
187
+ ret += f' | FK5 {self.fk5_number}'
91
188
  ret += '\n'
92
189
 
93
- ret += 'IR ' + str(self.ir_source) + ' Ref ' + str(self.ir_source_ref)
94
- ret += ' | Double "' + str(self.double_star_code) + '"'
95
- ret += ' | Aitken ' + str(self.aitken_designation) + ' '
190
+ if self.ir_source_ref is not None:
191
+ ir_ref = YBSCStar.YBSC_IR_STRINGS[self.ir_source_ref]
192
+ else:
193
+ ir_ref = 'N/A'
194
+ ret += f'IR {self.ir_source:d} Ref {ir_ref}'
195
+ ret += f' | Multiple "{self.multiple_star_code}"'
196
+ ret += f' | Aitken {self.aitken_designation} '
96
197
  ret += str(self.ads_components)
97
- ret += ' | Variable ' + str(self.variable_star_id)
198
+ ret += f' | Variable "{self.variable_star_id}"'
98
199
  ret += '\n'
99
200
 
100
- if self.temperature is None:
101
- ret += 'TEMP None'
102
- else:
103
- ret += 'TEMP %5d' % (self.temperature)
104
- ret += ' | SCLASS %2s' % (self.spectral_class)
105
- ret += ' ' + str(self.spectral_class_code)
201
+ ret += f'SCLASS Code {self.spectral_class_code}'
106
202
 
107
203
  ret += ' | Galactic LON '
108
204
  if self.galactic_longitude is None:
109
- ret += 'None'
205
+ ret += 'N/A'
110
206
  else:
111
- ret += str(self.galactic_longitude*DPR)
207
+ ret += str(np.degrees(self.galactic_longitude))
112
208
  ret += ' LAT '
113
209
  if self.galactic_latitude is None:
114
- ret += 'None'
210
+ ret += 'N/A'
115
211
  else:
116
- ret += str(self.galactic_latitude*DPR)
212
+ ret += str(np.degrees(self.galactic_latitude))
117
213
  ret += '\n'
118
214
 
119
- ret += 'B-V ' + str(self.b_v)
120
- ret += ' | U-B ' + str(self.u_b)
121
- ret += ' | R-I ' + str(self.r_i)
215
+ ret += f'B-V {self.b_v}'
216
+ ret += f' | U-B {self.u_b}'
217
+ ret += f' | R-I {self.r_i}'
122
218
  ret += '\n'
123
219
 
124
- ret += 'Parallax "' + str(self.parallax_type) + '"'
125
- ret += ' ' + str(self.parallax)
126
- ret += ' | RadVel ' + str(self.radial_velocity)
127
- ret += ' ' + str(self.radial_velocity_comments)
128
- ret += ' ' + str(self.rotational_velocity_limit)
129
- ret += ' | RotVel ' +str(self.rotational_velocity)
130
- ret += ' ' + str(self.rotational_velocity_uncertainty_flag)
131
- ret += '\n'
220
+ ret += 'Parallax '
221
+ if self.parallax_type == 'D':
222
+ ret += 'DYN'
223
+ else:
224
+ ret += 'TRIG'
132
225
 
133
- ret += 'Double mag diff ' + str(self.double_mag_diff)
134
- ret += ' Sep ' + str(self.double_mag_sep)
135
- ret += ' Components ' + str(self.double_mag_components)
136
- ret += ' Num components ' + str(self.multiple_num_components)
226
+ if self.parallax is None:
227
+ ret += ' N/A'
228
+ else:
229
+ ret += f' {self.parallax:.7f} arcsec'
230
+ if self.radial_velocity is None:
231
+ ret += ' | RadVel N/A'
232
+ else:
233
+ ret += f' | RadVel {self.radial_velocity} km/s'
234
+ ret += f' {self.radial_velocity_comments}'
235
+ ret += f' {self.rotational_velocity_limit}'
236
+ if self.rotational_velocity is None:
237
+ ret += ' | RotVel (v sin i) N/A'
238
+ else:
239
+ ret += f' | RotVel (v sin i) {self.rotational_velocity} km/s'
240
+ ret += f' {self.rotational_velocity_uncertainty_flag}'
137
241
  ret += '\n'
138
242
 
243
+ if self.double_mag_diff is None:
244
+ ret += 'Double mag diff N/A'
245
+ else:
246
+ ret += f'Double mag diff {self.double_mag_diff:.2f}'
247
+ if self.double_mag_sep is None:
248
+ ret += ' Sep N/A'
249
+ else:
250
+ ret += f' Sep {self.double_mag_sep / AS_TO_RAD:.2f} arcsec'
251
+ ret += f' Components {self.double_mag_components}'
252
+ if self.multiple_num_components is None:
253
+ ret += ' # N/A'
254
+ else:
255
+ ret += f' # {self.multiple_num_components:d}'
256
+
139
257
  return ret
140
258
 
141
259
  # TODO
@@ -243,61 +361,78 @@ class YBSCStar(Star):
243
361
  # --------------------------------------------------------------------------------
244
362
 
245
363
  class YBSCStarCatalog(StarCatalog):
246
- def __init__(self, dir=None):
247
- if dir is None:
248
- self.dirname = os.environ["YBSC_DIR"]
249
- else:
250
- self.dirname = dir
251
-
252
- self.stars = []
253
-
254
- fp = open(os.path.join(self.dirname, 'catalog'), 'r')
255
- while True:
256
- record = fp.readline().rstrip()
257
- if record == '':
258
- break
259
- if record[102:107].strip() == '': # No VMAG
260
- continue
261
- star = self._record_to_star(record)
262
- self.stars.append(star)
263
- fp.close()
264
-
265
-
266
- def _find_stars(self, ra_min, ra_max, dec_min, dec_max, **kwargs):
267
- """Yield the results for all stars.
364
+ def __init__(self,
365
+ dir: Optional[str | Path | FCPath] = None) -> None:
366
+ """Create a YBSCStarCatalog.
268
367
 
269
- Optional arguments: DEFAULT
270
- ra_min, ra_max 0, 2PI RA range in radians
271
- dec_min, dec_max -PI, PI DEC range in radians
272
- vmag_min, vmag_max ALL Magnitude range
273
- allow_double False Allow double stars
368
+ Parameters:
369
+ dir: The path to the star catalog directory (may be a URL). Within
370
+ this directory should be the file ``catalog``.
274
371
  """
275
372
 
276
- vmag_min = kwargs.get('vmag_min', None)
277
- vmag_max = kwargs.get('vmag_max', None)
278
- allow_double = kwargs.get('allow_double', False)
373
+ super().__init__()
279
374
 
280
- for star in self.stars:
375
+ if dir is None:
376
+ self._dirname = FCPath(os.environ['YBSC_PATH'])
377
+ else:
378
+ self._dirname = FCPath(dir)
379
+
380
+ self._stars = []
381
+
382
+ with (self._dirname / 'catalog').open(mode='r') as fp:
383
+ while True:
384
+ record = fp.readline().rstrip()
385
+ if record == '':
386
+ break
387
+ record = record.ljust(197, ' ')
388
+ if record[102:107].strip() == '': # No VMAG
389
+ continue
390
+ star = self._record_to_star(record)
391
+ self._stars.append(star)
392
+
393
+ def _find_stars(self,
394
+ ra_min: float,
395
+ ra_max: float,
396
+ dec_min: float,
397
+ dec_max: float,
398
+ vmag_min: Optional[float] = None,
399
+ vmag_max: Optional[float] = None,
400
+ full_result: bool = True,
401
+ **kwargs: Any) -> Iterator[YBSCStar]:
402
+
403
+ # We do this here instead of as specific arguments because it works better
404
+ # with mypy
405
+ allow_double: bool = kwargs.pop('allow_double', False)
406
+
407
+ for star in self._stars:
408
+ if star.ra is None or star.dec is None:
409
+ continue
281
410
  if not ra_min <= star.ra <= ra_max:
282
411
  continue
283
412
  if not dec_min <= star.dec <= dec_max:
284
413
  continue
285
- if vmag_min and star.vmag < vmag_min:
286
- continue
287
- if vmag_max and star.vmag > vmag_max:
288
- continue
289
- if not allow_double and star.double_star_code != ' ':
414
+ if star.vmag is not None:
415
+ if vmag_min and star.vmag < vmag_min:
416
+ continue
417
+ if vmag_max and star.vmag > vmag_max:
418
+ continue
419
+ if not allow_double and star.multiple_star_code != ' ':
290
420
  continue
291
421
 
422
+ if self.debug_level:
423
+ print(star)
424
+ print('-' * 80)
425
+
292
426
  yield star
293
427
 
294
428
  @staticmethod
295
- def _record_to_star(record):
429
+ def _record_to_star(record: str) -> YBSCStar:
430
+
296
431
  star = YBSCStar()
297
432
 
298
- ###################
299
- # CATALOG NUMBERS #
300
- ###################
433
+ ###################
434
+ # CATALOG NUMBERS #
435
+ ###################
301
436
 
302
437
  # 1- 4 I4 --- HR [1/9110]+ Harvard Revised Number
303
438
  # = Bright Star Number
@@ -324,22 +459,33 @@ class YBSCStarCatalog(StarCatalog):
324
459
 
325
460
  # 42 A1 --- IRflag [I] I if infrared source
326
461
  # 43 A1 --- r_IRflag *[ ':] Coded reference for infrared source
462
+ # Note on r_IRflag:
463
+ # Blank if from NASA merged Infrared Catalogue, Schmitz et al., 1978;
464
+ # ' if from Engles et al. 1982
465
+ # : if uncertain identification
327
466
  # 44 A1 --- Multiple *[AWDIRS] Double or multiple-star code
467
+ # Note on Multiple:
468
+ # A = Astrometric binary
469
+ # D = Duplicity discovered by occultation;
470
+ # I = Innes, Southern Double Star Catalogue (1927)
471
+ # R = Rossiter, Michigan Publ. 9, 1955
472
+ # S = Duplicity discovered by speckle interferometry.
473
+ # W = Worley (1978) update of the IDS;
328
474
  # 45- 49 A5 --- ADS Aitken's Double Star Catalog (ADS) designation
329
475
  # 50- 51 A2 --- ADScomp ADS number components
330
476
  # 52- 60 A9 --- VarID Variable star identification
331
477
 
332
478
  star.ir_source = (record[41] == 'I')
333
479
  if record[42] == ' ':
334
- star.ir_source_ref = YBSC_IR_NASA
480
+ star.ir_source_ref = YBSCStar.YBSC_IR_NASA
335
481
  elif record[42] == '\'':
336
- star.ir_source_ref = YBSC_IR_ENGLES
482
+ star.ir_source_ref = YBSCStar.YBSC_IR_ENGLES
337
483
  elif record[42] == ':':
338
- star.ir_source_ref = YBSC_IR_UNCERTAIN
484
+ star.ir_source_ref = YBSCStar.YBSC_IR_UNCERTAIN
339
485
 
340
- star.double_star_code = record[43]
486
+ star.multiple_star_code = record[43]
341
487
  if record[44:49].strip() != '':
342
- star.aitken_designation = record[44:49]
488
+ star.aitken_designation = record[44:49].strip()
343
489
  if record[49:51].strip() != '':
344
490
  star.ads_components = record[49:51].strip()
345
491
  if record[51:60].strip() != '':
@@ -369,8 +515,8 @@ class YBSCStarCatalog(StarCatalog):
369
515
  dec_deg = -dec_deg
370
516
  sign = -1
371
517
 
372
- star.ra = (ra_hr/24. + ra_min/24./60 + ra_sec/24./60/60)*360 * RPD
373
- star.dec = sign*(dec_deg + dec_min/60. + dec_sec/3600.) * RPD
518
+ star.ra = np.radians((ra_hr/24. + ra_min/24./60 + ra_sec/24./60/60)*360)
519
+ star.dec = np.radians(sign*(dec_deg + dec_min/60. + dec_sec/3600.))
374
520
 
375
521
  ########################
376
522
  # GALACTIC COORDINATES #
@@ -379,8 +525,8 @@ class YBSCStarCatalog(StarCatalog):
379
525
  # 91- 96 F6.2 deg GLON ?Galactic longitude (1)
380
526
  # 97-102 F6.2 deg GLAT ?Galactic latitude (1)
381
527
 
382
- star.galactic_longitude = float(record[90:96]) * RPD
383
- star.galactic_latitude = float(record[96:102]) * RPD
528
+ star.galactic_longitude = np.radians(float(record[90:96]))
529
+ star.galactic_latitude = np.radians(float(record[96:102]))
384
530
 
385
531
  ##############
386
532
  # MAGNITUDES #
@@ -388,6 +534,10 @@ class YBSCStarCatalog(StarCatalog):
388
534
 
389
535
  # 103-107 F5.2 mag Vmag ?Visual magnitude (1)
390
536
  # 108 A1 --- n_Vmag *[ HR] Visual magnitude code
537
+ # Note on n_Vmag:
538
+ # blank = V on UBV Johnson system;
539
+ # R = HR magnitudes reduced to the UBV system;
540
+ # H = original HR magnitude.
391
541
  # 109 A1 --- u_Vmag [ :?] Uncertainty flag on V
392
542
  # 110-114 F5.2 mag B-V ? B-V color in the UBV system
393
543
  # 115 A1 --- u_B-V [ :?] Uncertainty flag on B-V
@@ -405,6 +555,7 @@ class YBSCStarCatalog(StarCatalog):
405
555
  star.u_b = float(record[115:120])
406
556
  if record[121:126].strip() != '':
407
557
  star.r_i = float(record[121:126])
558
+ star.r_i_code = record[126]
408
559
 
409
560
  ##################
410
561
  # SPECTRAL CLASS #
@@ -421,28 +572,38 @@ class YBSCStarCatalog(StarCatalog):
421
572
  #######################
422
573
 
423
574
  # 149-154 F6.3 arcsec/yr pmRA *?Annual proper motion in RA J2000, FK5 system
575
+ # Note on pmRA:
576
+ # As usually assumed, the proper motion in RA is the projected
577
+ # motion (cos(DE).d(RA)/dt), i.e. the total proper motion is
578
+ # sqrt(pmRA^2^+pmDE^2^)
424
579
  # 155-160 F6.3 arcsec/yr pmDE ?Annual proper motion in Dec J2000, FK5 system
425
580
  # 161 A1 --- n_Parallax [D] D indicates a dynamical parallax,
426
581
  # otherwise a trigonometric parallax
427
582
  # 162-166 F5.3 arcsec Parallax ? Trigonometric parallax (unless n_Parallax)
428
583
  # 167-170 I4 km/s RadVel ? Heliocentric Radial Velocity
429
584
  # 171-174 A4 --- n_RadVel *[V?SB123O ] Radial velocity comments
585
+ # Note on n_RadVel:
586
+ # V = variable radial velocity;
587
+ # V? = suspected variable radial velocity;
588
+ # SB, SB1, SB2, SB3 = spectroscopic binaries,
589
+ # single, double or triple lined spectra;
590
+ # O = orbital data available.
430
591
  # 175-176 A2 --- l_RotVel [<=> ] Rotational velocity limit characters
431
592
  # 177-179 I3 km/s RotVel ? Rotational velocity, v sin i
432
593
  # 180 A1 --- u_RotVel [ :v] uncertainty and variability flag on
433
594
  # RotVel
434
595
 
435
596
  star.pm_rac = float(record[148:154]) * AS_TO_RAD * YEAR_TO_SEC
436
- star.pm_ra = star.pm_rac / np.cos(star.dec)
597
+ star.pm_ra = star.pm_rac / np.cos(cast(float, star.dec))
437
598
  star.pm_dec = float(record[154:160]) * AS_TO_RAD * YEAR_TO_SEC
438
599
 
439
- star.parallax_type = record[160:161]
600
+ star.parallax_type = record[160]
440
601
  if record[161:166].strip() != '':
441
- star.parallax = float(record[161:166]) * AS_TO_RAD
602
+ star.parallax = float(record[161:166])
442
603
  if record[166:170].strip() != '':
443
604
  star.radial_velocity = float(record[166:170])
444
605
  star.radial_velocity_comments = record[170:174].strip()
445
- star.rotational_velocity_limit = record[174:176]
606
+ star.rotational_velocity_limit = record[174:176].strip()
446
607
  if record[176:179].strip() != '':
447
608
  star.rotational_velocity = float(record[176:179])
448
609
  star.rotational_velocity_uncertainty_flag = record[179:180]
@@ -460,7 +621,7 @@ class YBSCStarCatalog(StarCatalog):
460
621
  star.double_mag_diff = float(record[180:184])
461
622
  if record[184:190].strip() != '':
462
623
  star.double_mag_sep = float(record[184:190]) * AS_TO_RAD
463
- star.double_mag_components = record[190:194]
624
+ star.double_mag_components = record[190:194].strip()
464
625
  if record[194:196].strip() != '':
465
626
  star.multiple_num_components = int(record[194:196])
466
627
 
@@ -471,40 +632,7 @@ class YBSCStarCatalog(StarCatalog):
471
632
  sclass = star.spectral_class
472
633
  if sclass[0] == 'g':
473
634
  sclass = sclass[1:]
474
- sclass = sclass[0:2]
475
- star.temperature = StarCatalog.temperature_from_sclass(sclass)
635
+ sclass = sclass[0:2].strip()
636
+ star.temperature = Star.temperature_from_sclass(sclass)
476
637
 
477
638
  return star
478
-
479
-
480
- #===============================================================================
481
- # UNIT TESTS
482
- #===============================================================================
483
-
484
- import unittest
485
-
486
- class Test_YBSCStarCatalog(unittest.TestCase):
487
-
488
- def runTest(self):
489
- cat = YBSCStarCatalog('/seti/external/YBSC')
490
-
491
- self.assertEqual(len(cat.stars), 9096)
492
- self.assertEqual(cat.count_stars(), 7519)
493
- self.assertEqual(cat.count_stars(allow_double=True), 9096)
494
-
495
- # Look up Vega
496
- ra_vega = 279.2333 * RPD
497
- dec_vega = 38.7836 * RPD
498
-
499
- vega_list = list(cat.find_stars(ra_min=ra_vega-0.1*RPD,
500
- ra_max=ra_vega+0.1*RPD,
501
- dec_min=dec_vega-0.1*RPD,
502
- dec_max=dec_vega+0.1*RPD))
503
- self.assertEqual(len(vega_list), 1)
504
-
505
- vega = vega_list[0]
506
- self.assertEqual(vega.vmag, 0.03)
507
-
508
-
509
- if __name__ == '__main__':
510
- unittest.main(verbosity=2)