rms-starcat 1.0.2__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.
starcat/ybsc.py ADDED
@@ -0,0 +1,638 @@
1
+ ################################################################################
2
+ # starcat/ybsc.py
3
+ ################################################################################
4
+
5
+ # The Bright Star Catalogue, 5th Revised Ed. (Preliminary Version)
6
+ # Hoffleit D., Warren Jr W.H.
7
+ # <Astronomical Data Center, NSSDC/ADC (1991)>
8
+ # =1964BS....C......0H
9
+ # From ftp://cdsarc.u-strasbg.fr/cats/V/50/1
10
+ # http://tdc-www.harvard.edu/catalogs/bsc5.html
11
+
12
+ from __future__ import annotations
13
+
14
+ import numpy as np
15
+ import os
16
+ from pathlib import Path
17
+ from typing import Any, Iterator, Optional, cast
18
+
19
+ from filecache import FCPath
20
+
21
+ from .starcatalog import (AS_TO_RAD,
22
+ YEAR_TO_SEC,
23
+ Star,
24
+ StarCatalog
25
+ )
26
+
27
+
28
+ class YBSCStar(Star):
29
+ """A holder for star attributes.
30
+
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']
39
+
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:
53
+ # Initialize the standard fields
54
+ super().__init__()
55
+
56
+ # Initialize the YBSC-specific fields
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}'
188
+ ret += '\n'
189
+
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} '
197
+ ret += str(self.ads_components)
198
+ ret += f' | Variable "{self.variable_star_id}"'
199
+ ret += '\n'
200
+
201
+ ret += f'SCLASS Code {self.spectral_class_code}'
202
+
203
+ ret += ' | Galactic LON '
204
+ if self.galactic_longitude is None:
205
+ ret += 'N/A'
206
+ else:
207
+ ret += str(np.degrees(self.galactic_longitude))
208
+ ret += ' LAT '
209
+ if self.galactic_latitude is None:
210
+ ret += 'N/A'
211
+ else:
212
+ ret += str(np.degrees(self.galactic_latitude))
213
+ ret += '\n'
214
+
215
+ ret += f'B-V {self.b_v}'
216
+ ret += f' | U-B {self.u_b}'
217
+ ret += f' | R-I {self.r_i}'
218
+ ret += '\n'
219
+
220
+ ret += 'Parallax '
221
+ if self.parallax_type == 'D':
222
+ ret += 'DYN'
223
+ else:
224
+ ret += 'TRIG'
225
+
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}'
241
+ ret += '\n'
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
+
257
+ return ret
258
+
259
+ # TODO
260
+ # star.cat_match = None
261
+ # star.num_img_total = None
262
+ # star.num_img_used = None
263
+ # star.num_cat_pm = None
264
+ # star.ra_mean_epoch = None
265
+ # star.dec_mean_epoch = None
266
+ # star.id_str = None
267
+ # star.id_str_ucac2 = None
268
+
269
+
270
+ # --------------------------------------------------------------------------------
271
+ # Bytes Format Units Label Explanations
272
+ # --------------------------------------------------------------------------------
273
+ # 1- 4 I4 --- HR [1/9110]+ Harvard Revised Number
274
+ # = Bright Star Number
275
+ # 5- 14 A10 --- Name Name, generally Bayer and/or Flamsteed name
276
+ # 15- 25 A11 --- DM Durchmusterung Identification (zone in
277
+ # bytes 17-19)
278
+ # 26- 31 I6 --- HD [1/225300]? Henry Draper Catalog Number
279
+ # 32- 37 I6 --- SAO [1/258997]? SAO Catalog Number
280
+ # 38- 41 I4 --- FK5 ? FK5 star Number
281
+ # 42 A1 --- IRflag [I] I if infrared source
282
+ # 43 A1 --- r_IRflag *[ ':] Coded reference for infrared source
283
+ # 44 A1 --- Multiple *[AWDIRS] Double or multiple-star code
284
+ # 45- 49 A5 --- ADS Aitken's Double Star Catalog (ADS) designation
285
+ # 50- 51 A2 --- ADScomp ADS number components
286
+ # 52- 60 A9 --- VarID Variable star identification
287
+ # 61- 62 I2 h RAh1900 ?Hours RA, equinox B1900, epoch 1900.0 (1)
288
+ # 63- 64 I2 min RAm1900 ?Minutes RA, equinox B1900, epoch 1900.0 (1)
289
+ # 65- 68 F4.1 s RAs1900 ?Seconds RA, equinox B1900, epoch 1900.0 (1)
290
+ # 69 A1 --- DE-1900 ?Sign Dec, equinox B1900, epoch 1900.0 (1)
291
+ # 70- 71 I2 deg DEd1900 ?Degrees Dec, equinox B1900, epoch 1900.0 (1)
292
+ # 72- 73 I2 arcmin DEm1900 ?Minutes Dec, equinox B1900, epoch 1900.0 (1)
293
+ # 74- 75 I2 arcsec DEs1900 ?Seconds Dec, equinox B1900, epoch 1900.0 (1)
294
+ # 76- 77 I2 h RAh ?Hours RA, equinox J2000, epoch 2000.0 (1)
295
+ # 78- 79 I2 min RAm ?Minutes RA, equinox J2000, epoch 2000.0 (1)
296
+ # 80- 83 F4.1 s RAs ?Seconds RA, equinox J2000, epoch 2000.0 (1)
297
+ # 84 A1 --- DE- ?Sign Dec, equinox J2000, epoch 2000.0 (1)
298
+ # 85- 86 I2 deg DEd ?Degrees Dec, equinox J2000, epoch 2000.0 (1)
299
+ # 87- 88 I2 arcmin DEm ?Minutes Dec, equinox J2000, epoch 2000.0 (1)
300
+ # 89- 90 I2 arcsec DEs ?Seconds Dec, equinox J2000, epoch 2000.0 (1)
301
+ # 91- 96 F6.2 deg GLON ?Galactic longitude (1)
302
+ # 97-102 F6.2 deg GLAT ?Galactic latitude (1)
303
+ # 103-107 F5.2 mag Vmag ?Visual magnitude (1)
304
+ # 108 A1 --- n_Vmag *[ HR] Visual magnitude code
305
+ # 109 A1 --- u_Vmag [ :?] Uncertainty flag on V
306
+ # 110-114 F5.2 mag B-V ? B-V color in the UBV system
307
+ # 115 A1 --- u_B-V [ :?] Uncertainty flag on B-V
308
+ # 116-120 F5.2 mag U-B ? U-B color in the UBV system
309
+ # 121 A1 --- u_U-B [ :?] Uncertainty flag on U-B
310
+ # 122-126 F5.2 mag R-I ? R-I in system specified by n_R-I
311
+ # 127 A1 --- n_R-I [CE:?D] Code for R-I system (Cousin, Eggen)
312
+ # 128-147 A20 --- SpType Spectral type
313
+ # 148 A1 --- n_SpType [evt] Spectral type code
314
+ # 149-154 F6.3 arcsec/yr pmRA *?Annual proper motion in RA J2000, FK5 system
315
+ # 155-160 F6.3 arcsec/yr pmDE ?Annual proper motion in Dec J2000, FK5 system
316
+ # 161 A1 --- n_Parallax [D] D indicates a dynamical parallax,
317
+ # otherwise a trigonometric parallax
318
+ # 162-166 F5.3 arcsec Parallax ? Trigonometric parallax (unless n_Parallax)
319
+ # 167-170 I4 km/s RadVel ? Heliocentric Radial Velocity
320
+ # 171-174 A4 --- n_RadVel *[V?SB123O ] Radial velocity comments
321
+ # 175-176 A2 --- l_RotVel [<=> ] Rotational velocity limit characters
322
+ # 177-179 I3 km/s RotVel ? Rotational velocity, v sin i
323
+ # 180 A1 --- u_RotVel [ :v] uncertainty and variability flag on
324
+ # RotVel
325
+ # 181-184 F4.1 mag Dmag ? Magnitude difference of double,
326
+ # or brightest multiple
327
+ # 185-190 F6.1 arcsec Sep ? Separation of components in Dmag
328
+ # if occultation binary.
329
+ # 191-194 A4 --- MultID Identifications of components in Dmag
330
+ # 195-196 I2 --- MultCnt ? Number of components assigned to a multiple
331
+ # 197 A1 --- NoteFlag [*] a star indicates that there is a note
332
+ # (see file notes)
333
+ # --------------------------------------------------------------------------------
334
+ # Note (1): These fields are all blanks for stars removed from
335
+ # the Bright Star Catalogue (see notes).
336
+ # Note on r_IRflag:
337
+ # Blank if from NASA merged Infrared Catalogue, Schmitz et al., 1978;
338
+ # ' if from Engles et al. 1982
339
+ # : if uncertain identification
340
+ # Note on Multiple:
341
+ # A = Astrometric binary
342
+ # D = Duplicity discovered by occultation;
343
+ # I = Innes, Southern Double Star Catalogue (1927)
344
+ # R = Rossiter, Michigan Publ. 9, 1955
345
+ # S = Duplicity discovered by speckle interferometry.
346
+ # W = Worley (1978) update of the IDS;
347
+ # Note on n_Vmag:
348
+ # blank = V on UBV Johnson system;
349
+ # R = HR magnitudes reduced to the UBV system;
350
+ # H = original HR magnitude.
351
+ # Note on pmRA:
352
+ # As usually assumed, the proper motion in RA is the projected
353
+ # motion (cos(DE).d(RA)/dt), i.e. the total proper motion is
354
+ # sqrt(pmRA^2^+pmDE^2^)
355
+ # Note on n_RadVel:
356
+ # V = variable radial velocity;
357
+ # V? = suspected variable radial velocity;
358
+ # SB, SB1, SB2, SB3 = spectroscopic binaries,
359
+ # single, double or triple lined spectra;
360
+ # O = orbital data available.
361
+ # --------------------------------------------------------------------------------
362
+
363
+ class YBSCStarCatalog(StarCatalog):
364
+ def __init__(self,
365
+ dir: Optional[str | Path | FCPath] = None) -> None:
366
+ """Create a YBSCStarCatalog.
367
+
368
+ Parameters:
369
+ dir: The path to the star catalog directory (may be a URL). Within
370
+ this directory should be the file ``catalog``.
371
+ """
372
+
373
+ super().__init__()
374
+
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
410
+ if not ra_min <= star.ra <= ra_max:
411
+ continue
412
+ if not dec_min <= star.dec <= dec_max:
413
+ continue
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 != ' ':
420
+ continue
421
+
422
+ if self.debug_level:
423
+ print(star)
424
+ print('-' * 80)
425
+
426
+ yield star
427
+
428
+ @staticmethod
429
+ def _record_to_star(record: str) -> YBSCStar:
430
+
431
+ star = YBSCStar()
432
+
433
+ ###################
434
+ # CATALOG NUMBERS #
435
+ ###################
436
+
437
+ # 1- 4 I4 --- HR [1/9110]+ Harvard Revised Number
438
+ # = Bright Star Number
439
+ # 5- 14 A10 --- Name Name, generally Bayer and/or Flamsteed name
440
+ # 15- 25 A11 --- DM Durchmusterung Identification (zone in
441
+ # bytes 17-19)
442
+ # 26- 31 I6 --- HD [1/225300]? Henry Draper Catalog Number
443
+ # 32- 37 I6 --- SAO [1/258997]? SAO Catalog Number
444
+ # 38- 41 I4 --- FK5 ? FK5 star Number
445
+
446
+ star.unique_number = int(record[0:4].strip())
447
+ star.name = record[4:14].strip()
448
+ star.durchmusterung_id = record[14:25].strip()
449
+ if record[25:31].strip() != '':
450
+ star.draper_number = int(record[25:31].strip())
451
+ if record[31:37].strip() != '':
452
+ star.sao_number = int(record[31:37].strip())
453
+ if record[37:41].strip() != '':
454
+ star.fk5_number = int(record[37:41].strip())
455
+
456
+ ################
457
+ # SOURCE FLAGS #
458
+ ################
459
+
460
+ # 42 A1 --- IRflag [I] I if infrared source
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
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;
474
+ # 45- 49 A5 --- ADS Aitken's Double Star Catalog (ADS) designation
475
+ # 50- 51 A2 --- ADScomp ADS number components
476
+ # 52- 60 A9 --- VarID Variable star identification
477
+
478
+ star.ir_source = (record[41] == 'I')
479
+ if record[42] == ' ':
480
+ star.ir_source_ref = YBSCStar.YBSC_IR_NASA
481
+ elif record[42] == '\'':
482
+ star.ir_source_ref = YBSCStar.YBSC_IR_ENGLES
483
+ elif record[42] == ':':
484
+ star.ir_source_ref = YBSCStar.YBSC_IR_UNCERTAIN
485
+
486
+ star.multiple_star_code = record[43]
487
+ if record[44:49].strip() != '':
488
+ star.aitken_designation = record[44:49].strip()
489
+ if record[49:51].strip() != '':
490
+ star.ads_components = record[49:51].strip()
491
+ if record[51:60].strip() != '':
492
+ star.variable_star_id = record[51:60].strip()
493
+
494
+ ###########
495
+ # RA, DEC #
496
+ ###########
497
+
498
+ # 76- 77 I2 h RAh ?Hours RA, equinox J2000, epoch 2000.0 (1)
499
+ # 78- 79 I2 min RAm ?Minutes RA, equinox J2000, epoch 2000.0 (1)
500
+ # 80- 83 F4.1 s RAs ?Seconds RA, equinox J2000, epoch 2000.0 (1)
501
+ # 84 A1 --- DE- ?Sign Dec, equinox J2000, epoch 2000.0 (1)
502
+ # 85- 86 I2 deg DEd ?Degrees Dec, equinox J2000, epoch 2000.0 (1)
503
+ # 87- 88 I2 arcmin DEm ?Minutes Dec, equinox J2000, epoch 2000.0 (1)
504
+ # 89- 90 I2 arcsec DEs ?Seconds Dec, equinox J2000, epoch 2000.0 (1)
505
+
506
+ ra_hr = float(record[75:77])
507
+ ra_min = float(record[77:79])
508
+ ra_sec = float(record[79:83])
509
+ dec_deg = float(record[83:86])
510
+ dec_min = float(record[86:88])
511
+ dec_sec = float(record[88:90])
512
+
513
+ sign = 1
514
+ if dec_deg < 0:
515
+ dec_deg = -dec_deg
516
+ sign = -1
517
+
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.))
520
+
521
+ ########################
522
+ # GALACTIC COORDINATES #
523
+ ########################
524
+
525
+ # 91- 96 F6.2 deg GLON ?Galactic longitude (1)
526
+ # 97-102 F6.2 deg GLAT ?Galactic latitude (1)
527
+
528
+ star.galactic_longitude = np.radians(float(record[90:96]))
529
+ star.galactic_latitude = np.radians(float(record[96:102]))
530
+
531
+ ##############
532
+ # MAGNITUDES #
533
+ ##############
534
+
535
+ # 103-107 F5.2 mag Vmag ?Visual magnitude (1)
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.
541
+ # 109 A1 --- u_Vmag [ :?] Uncertainty flag on V
542
+ # 110-114 F5.2 mag B-V ? B-V color in the UBV system
543
+ # 115 A1 --- u_B-V [ :?] Uncertainty flag on B-V
544
+ # 116-120 F5.2 mag U-B ? U-B color in the UBV system
545
+ # 121 A1 --- u_U-B [ :?] Uncertainty flag on U-B
546
+ # 122-126 F5.2 mag R-I ? R-I in system specified by n_R-I
547
+ # 127 A1 --- n_R-I [CE:?D] Code for R-I system (Cousin, Eggen)
548
+
549
+ star.vmag = float(record[102:107])
550
+ star.vmag_code = record[107]
551
+ star.vmag_uncertainty_flag = record[108]
552
+ if record[109:114].strip() != '':
553
+ star.b_v = float(record[109:114])
554
+ if record[115:120].strip() != '':
555
+ star.u_b = float(record[115:120])
556
+ if record[121:126].strip() != '':
557
+ star.r_i = float(record[121:126])
558
+ star.r_i_code = record[126]
559
+
560
+ ##################
561
+ # SPECTRAL CLASS #
562
+ ##################
563
+
564
+ # 128-147 A20 --- SpType Spectral type
565
+ # 148 A1 --- n_SpType [evt] Spectral type code
566
+
567
+ star.spectral_class = record[127:147].strip()
568
+ star.spectral_class_code = record[147]
569
+
570
+ #######################
571
+ # MOTION AND PARALLAX #
572
+ #######################
573
+
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^)
579
+ # 155-160 F6.3 arcsec/yr pmDE ?Annual proper motion in Dec J2000, FK5 system
580
+ # 161 A1 --- n_Parallax [D] D indicates a dynamical parallax,
581
+ # otherwise a trigonometric parallax
582
+ # 162-166 F5.3 arcsec Parallax ? Trigonometric parallax (unless n_Parallax)
583
+ # 167-170 I4 km/s RadVel ? Heliocentric Radial Velocity
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.
591
+ # 175-176 A2 --- l_RotVel [<=> ] Rotational velocity limit characters
592
+ # 177-179 I3 km/s RotVel ? Rotational velocity, v sin i
593
+ # 180 A1 --- u_RotVel [ :v] uncertainty and variability flag on
594
+ # RotVel
595
+
596
+ star.pm_rac = float(record[148:154]) * AS_TO_RAD * YEAR_TO_SEC
597
+ star.pm_ra = star.pm_rac / np.cos(cast(float, star.dec))
598
+ star.pm_dec = float(record[154:160]) * AS_TO_RAD * YEAR_TO_SEC
599
+
600
+ star.parallax_type = record[160]
601
+ if record[161:166].strip() != '':
602
+ star.parallax = float(record[161:166])
603
+ if record[166:170].strip() != '':
604
+ star.radial_velocity = float(record[166:170])
605
+ star.radial_velocity_comments = record[170:174].strip()
606
+ star.rotational_velocity_limit = record[174:176].strip()
607
+ if record[176:179].strip() != '':
608
+ star.rotational_velocity = float(record[176:179])
609
+ star.rotational_velocity_uncertainty_flag = record[179:180]
610
+
611
+ # 181-184 F4.1 mag Dmag ? Magnitude difference of double,
612
+ # or brightest multiple
613
+ # 185-190 F6.1 arcsec Sep ? Separation of components in Dmag
614
+ # if occultation binary.
615
+ # 191-194 A4 --- MultID Identifications of components in Dmag
616
+ # 195-196 I2 --- MultCnt ? Number of components assigned to a multiple
617
+ # 197 A1 --- NoteFlag [*] a star indicates that there is a note
618
+ # (see file notes)
619
+
620
+ if record[180:184].strip() != '':
621
+ star.double_mag_diff = float(record[180:184])
622
+ if record[184:190].strip() != '':
623
+ star.double_mag_sep = float(record[184:190]) * AS_TO_RAD
624
+ star.double_mag_components = record[190:194].strip()
625
+ if record[194:196].strip() != '':
626
+ star.multiple_num_components = int(record[194:196])
627
+
628
+ ##################################################
629
+ # COMPUTE SPECTRAL CLASS AND SURFACE TEMPERATURE #
630
+ ##################################################
631
+
632
+ sclass = star.spectral_class
633
+ if sclass[0] == 'g':
634
+ sclass = sclass[1:]
635
+ sclass = sclass[0:2].strip()
636
+ star.temperature = Star.temperature_from_sclass(sclass)
637
+
638
+ return star