;+ ; NAME: ; oc_getstar_hd ; ; PURPOSE: (one line) ; Returns HD star structures given their ID's. ; ; DESCRIPTION: ; Returns a fully-populated HD star structure for each ID supplied. ; The ID's must be in the HD format. The star structure is returned in ; the standard format, and includes the raw HD catalog line as well as ; standard-format RA, DEC, magnitudes, etc. ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; stars = oc_getstar_hd(ids [, NSTARS=nstars] [, /VERBOSE]) ; ; INPUTS: ; ids -- HD id's in string format. Can be either scalar or vector. ; Either SCAT-format SCAT-format ('221.00434') or standard UCAC2 ; format ('00534450'), but all ids must be in the same format. ; ; OPTIONAL INPUT PARAMETERS: ; None ; ; KEYWORD INPUT PARAMETERS: ; VERBOSE -- Print messages about incorrect/missing ID's to screen if set. ; ; KEYWORD OUTPUT PARAMETERS: ; NSTARS -- Returns the number of successfully-retrieved stars ; ; OUTPUTS: ; Structures of type 'star' with fields filled in. ; Returns either a vector or a scalar depending on input value 'ids'. ; Length of returned value is the same as that of input 'ids.' ; ; The field star.hd.record is the HD text catalog entry. ; The fields in star.hd.* are exactly as described in the ; HD Vizier ReadMe file. ; If a star is not found, that entry is blank. ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; HD catalog must be available at $WCS_CATDIR/hd/catalog.dat . ; ; EXAMPLE: ; print, (oc_getstar_hd(['0', '1000', '10000'])).id ; [Prints "none 1000 10000"] ; ; MODIFICATION HISTORY: ; Written 18-Oct-2005 by Henry Throop, SwRI ; Modified 30-Oct-2005 by HBT. Fixed to read magnitudes properly. ; Modified 7-Dec-2005 by HBT. Fixed to handle invalid ID's properly. ; Changed SILENT->VERBOSE. ; Modified 27-Feb-2006 by HBT. Improved documentation and formatting. ; Modified 05-Mar-2006 by LAY. Change nstars to count (consistent ; with oc_getline_ucac2) ; Modified 14-Mar-2006 by HBT. Undid LAY's nstars change (hah!) ; (It was already consistent.) ; Fixed handling of undefined mag's ; for HD=37020-37026. ; Modified 24-Mar-2006 by HBT. Added fields for ETPM, RA_ETPM, etc. ; ;- function oc_getstar_hd, ids, NSTARS=nstars, VERBOSE=verbose ; ** HD catalog file format, from Vizier's ReadMe file. ** ; ; -------------------------------------------------------------------------------- ; Bytes Format Units Label Explanations ; -------------------------------------------------------------------------------- ; 1- 6 I6 --- HD [1/272150]+ Henry Draper Catalog (HD) number ; 7- 18 A12 --- DM Durchmusterung identification (1) ; 19- 20 I2 h RAh Hours RA, equinox B1900, epoch 1900.0 ; 21- 23 I3 0.1min RAdm Deci-Minutes RA, equinox B1900, epoch 1900.0 ; 24 A1 --- DE- Sign Dec, equinox B1900, epoch 1900.0 ; 25- 26 I2 deg DEd Degrees Dec, equinox B1900, epoch 1900.0 ; 27- 28 I2 arcmin DEm Minutes Dec, equinox B1900, epoch 1900.0 ; 29 I1 --- q_Ptm [0/1]? Code for Ptm: 0 = measured, 1 = value ; inferred from Ptg and spectral type ; 30- 34 F5.2 mag Ptm ? Photovisual magnitude (2) ; 35 A1 --- n_Ptm [C] 'C' if Ptm is combined value with Ptg ; 36 I1 --- q_Ptg [0/1]? Code for Ptg: 0 = measured, 1 = value ; inferred from Ptm and spectral type ; 37- 41 F5.2 mag Ptg ? Photographic magnitude (2) ; 42 A1 --- n_Ptg [C] 'C' if Ptg is combined value for this ; entry and the following or preceding entry ; 43- 45 A3 --- SpType Spectral type ; 46- 47 A2 --- Intensity [ 0-9B] Photographic intensity of spectrum (3) ; 48 A1 --- Remarks [DEGMR*] Remarks, see note (4) yr2sec = 31557600d ; Year -> seconds. ; 31557600. from cspice_jyear. ; Initialize all of the proper *STAR* variables ; Ideally we would call oc_struct_star to set this up, but this does not work ; here because it is not possible to add new fields (e.g., .hd) to an existing ; structure. idcat = '' id = '' poscat = '' et = 0d ra = 0d dec = 0d raerr = 0d decerr = 0d radot = 0d decdot = 0d radoterr = 0d decdoterr = 0d etpm = [0d, 0d] ra_etpm = 0d ; RA at PM=0 dec_etpm = 0d ; DEC at PM=0 raerr_etpm = 0d ; RA err at PM=0 decerr_etpm = 0d ; Dec err at PM=0 magcat = ['', ''] magname = ['', ''] mag = [0d, 0d] magerr = [0d, 0d] SpTcat = '' SpT = '' notecat = [''] note = [''] ; Initialize all of the proper *HD* variables. All values are kept as their ; original format, even if this is a little unusual (e.g., RA is integer, in ; tenths of a minute). ; This is 'hd' in HD catalog. This causes IDL confusion between variable and ; structure names. hd_ = 0L dm = '' rah = 0 radm = 0 ; This is 'DE-' in HD catalog, which is not a legal IDL variable name. ; Changed to DE. de = '' ded = 0 dem = 0 q_ptm = 0 ptm = 0d ; String to hold ptm before processing it ptm_str = '' n_ptm = '' q_ptg = 0 ptg = 0d ; String to hold ptg before processing it ptg_str = '' n_ptg = '' sptype = '' intensity = '' remarks = '' ; Not an HD field. This field stores the entire HD catalog line entry. record = '' hd = {hd:hd_, dm:dm, rah:rah, radm:radm, de:de, ded:ded, $ dem:dem, q_ptm:q_ptm, ptm:ptm, n_ptm:n_ptm, q_ptg:q_ptg, $ ptg:ptg, n_ptg:n_ptg, sptype:sptype, intensity:intensity, $ remarks:remarks, record:record} star = {idcat:idcat, id:id, poscat:poscat, et:et, ra:ra, dec:dec,$ raerr:raerr, decerr:decerr, radot:radot, $ decdot:decdot, radoterr:radoterr, decdoterr:decdoterr, $ etpm:etpm, ra_etpm:ra_etpm, dec_etpm:dec_etpm, $ raerr_etpm:raerr_etpm, decerr_etpm:decerr_etpm, $ magcat:magcat, magname:magname, mag:mag, $ magerr:magerr, sptcat:sptcat, spt:spt, notecat:notecat, $ note:note, $ hd:hd} hd_init = hd star_init = star num_ids = sizex(ids) stars = make_array(num_ids, value=star) ; Get the raw catalog lines from the HD catalog lines = oc_getline_hd(ids, NSTARS=nstars, VERBOSE=verbose) ; Now process each line for i = 0L, num_ids-1 do begin id = ids[i] line = lines[i] id = ids[i] ; Check to make sure it's valid if (line eq '') then begin star = oc_star_set_empty(star_init) goto, parse_end end ; Set the string from the Vizier ReadMe catalog description file string_hd = '(I6, A12, I2, I3, A1, I2, I2, I1, A5, A1, I1,' + $ 'A5, A1, A3, A2, A1)' ; string_hd = '(I6, A12, I2, I3, A1, I2, I2, I1, F5.2, A1, I1,' + $ ; 'A5, A1, A3, A2, A1)' ; Parse the raw catalog line into a bunch of variables line = str_replace(line, ' .$', ' ', /REGEX) reads, line, format=string_hd, hd_, dm, rah, radm, de, ded, dem, $ q_ptm, ptm_str, $ n_ptm, q_ptg, ptg_str, n_ptg, sptype, intensity, remarks ; Clear the star structure, then stick each variable into its proper *HD* ; structure location ; We handle as special cases a few stars (HD 37020, 37026, etc.) ; which have missing fields for ptm and ptg, and we want to set these to -999, ; *not* 0.0. hd = hd_init star = star_init hd.record = line hd.hd = hd_ ; illegal line if (strcompress(dm,/REM)) eq '' then dm = 'none' hd.dm = dm hd.rah = rah hd.radm = radm hd.de = de hd.ded = ded hd.dem = dem hd.q_ptm = q_ptm if (strcompress(ptm_str,/REM)) eq '' then ptm = -999d else ptm = double(ptm_str) hd.ptm = ptm hd.n_ptm = n_ptm hd.q_ptg = q_ptg if (strcompress(ptg_str,/REM)) eq '' then ptg = -999d else ptg = double(ptg_str) hd.ptg = ptg hd.n_ptg = n_ptg hd.sptype = sptype hd.intensity = intensity hd.remarks = remarks ; Process the variables, precess the coords, and stick them all into the ; proper *STAR* structure location. ; ; Precess to J2000. Note that the HD catalog is limited intrinsically in its ; precision, and better coordinates for HD stars can be taken from the ; HD->Tycho star cross-reference catalog. ; RA, B1900, radians ra_1900 = (hd.rah + (hd.radm * 0.1)/60d ) * (2d*!dpi/24d) ; Dec, B1900, radians dec_1900 = (hd.de eq '-' ? -1d : 1d) * $ ( hd.ded + (hd.dem/60d)) * (2d*!dpi/360d) ra = ra_1900 dec = dec_1900 ; Call astrolib precession routine precess, ra, dec, 1900, 2000, /RADIAN star.ra = ra star.dec = dec star.ra_etpm = ra star.dec_etpm = dec star.idcat = 'hd' star.id = strcompress(string(hd.hd), /REMOVE) star.poscat = 'hd' ; Fill in the proper motion fields. We mostly keep these blank, since ; HD has no proper motion. However, we do set ETPM to be the year 1920, ; since original obs were taken 1918-1925. star.et = 0d ; Default to 2000 for ET star.etpm = [1,1]*(1920-2000) * yr2sec star.raerr_etpm = -999d star.decerr_etpm = -999d star.raerr = -999d star.decerr = -999d star.radot = -999d star.decdot = -999d star.radoterr = -999d star.decdoterr = -999d star.mag = [hd.ptm, hd.ptg] star.magcat = ['hd', 'hd'] star.magname = ['Ptm', 'Ptg'] ; Photovisual, photographic mags star.magerr = [-999d, -999d] star.SpTcat = ['hd'] star.SpT = hd.sptype star.notecat = 'hd' note = strcompress(hd.remarks + ' ' + $ hd_mag_to_flag(hd.ptm) + ' ' + hd_mag_to_flag(hd.ptg), /REMOVE) star.note = [note] star.hd = hd parse_end: ; Store the structure in an array stars[i] = star end ; Based on whether a scalar or an array was passed in, return the same. (In ; reality, it appears to always return a one-element array of structures, but ; this makes no difference to the user.) if is_scalar(ids) then return, stars[0] if is_array(ids) then return, stars end