;+ ; NAME: ; oc_getstar_2mass ; ; PURPOSE: (one line) ; Returns 2MASS star structures given their ID's. ; ; DESCRIPTION: ; Returns a fully-populated 2MASS star structure for each ID supplied. ; The ID's must be in the 2MASS format. The star structure is returned in ; the standard format, and includes the raw 2MASS data as well as ; standard-format RA, DEC, magnitudes, etc. ; ; CATEGORY: ; Star catalogs. ; ; CALLING SEQUENCE: ; oc_getstar_2mass, ids [, NSTARS=nstars] [, /VERBOSE] ; ; INPUTS: ; ids -- 2MASS id's in string format. Can be either scalar or vector. ; ; 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.tmass.record is the 2MASS catalog entry line. ; The remaining fields in star.tmass.* are exactly as described in the ; 2Mass User's Guide, at ; http://www.ipac.caltech.edu/2mass/releases/allsky/doc/sec2_2a.html . ; ; If a star is not found, that entry is blank. ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; 2MASS catalog must be available at $TMC_PATH ; ; EXAMPLE: ; print, oc_getstar_2mass(['23590064-7916219'], nst=nst, /VERB) ; ; MODIFICATION HISTORY: ; Written 26-May-2006 by Henry Throop, SwRI ; ;- function oc_getstar_2mass, ids, NSTARS=nstars, VERBOSE=verbose ; -------------------------------------------------------------------------------- EMPTY = -999d EMPTY_FLT = ' -999d' d2r = 2*!dpi / 360d ; Degrees -> radians r2d = 1 / d2r as2d = 1/(60d * 60d) ; Arcsec -> degrees as2r = as2d * d2r mas2d = as2d / 1000d ; mArcsec -> degrees mas2r = mas2d*d2r ; mArcsec -> radians yr2sec = 31557600d ; Year -> seconds. day2sec = 86400d ; 31557600 from cspice_jyear(). ; Initialize all of the proper *STAR* variables idcat = '' id = '' poscat = '' et = 0d ra = 0d dec = 0d raerr = 0d decerr = 0d radot = 0d decdot = 0d radoterr = 0d decdoterr = 0d etpm = [0d, 0d] ; ET at which PM=0 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, 0d] magerr = [0d, 0d, 0d] SpTcat = '' SpT = '' notecat = [''] note = [''] ; Initialize all of the proper *2MASS* variables. All values are kept as their ; original format, even if this is a little unusual. ra = 0d dec = 0d err_maj = 0d err_min = 0d err_ang = 0 designation = '' j_m = 0d j_cmsig = 0d j_msigcom = 0d j_snr = 0d h_m = 0d h_cmsig = 0d h_msigcom = 0d h_snr = 0d k_m = 0d k_cmsig = 0d k_msigcom = 0d k_snr = 0d ph_qual = '' rd_flag = '' bl_flg = '' cc_flg = '' ndet = '' prox = 0d pxpa = 0 pxcntr = 0 gal_contam = 0 mp_flg = 0 pts_key = 0L hemis = '' date = '' scan = 0 glon = 0d glat = 0d x_scan = 0d jdate = 0d j_psfchi = 0d h_psfchi = 0d k_psfchi = 0d j_m_stdap = 0d j_msig_stdap = 0d h_m_stdap = 0d h_msig_stdap = 0d k_m_stdap = 0d k_msig_stdap = 0d dist_edge_ns = 0 dist_edge_ew = 0 dist_edge_flg = '' dup_src = 0 use_src = 0 a = '' dist_opt = 0d phi_opt = 0 b_m_opt = 0d vr_m_opt = 0d nopt_mchs = 0 ext_key = 0L scan_key = 0L coadd_key = 0L coadd = 0 ; Not a 2mass field. This field stores the raw catalog line entry. record = '' tmass = { $ ra : ra , $ dec : dec , $ err_maj : err_maj , $ err_min : err_min , $ err_ang : err_ang , $ designation : designation , $ j_m : j_m , $ j_cmsig : j_cmsig , $ j_msigcom : j_msigcom , $ j_snr : j_snr , $ h_m : h_m , $ h_cmsig : h_cmsig , $ h_msigcom : h_msigcom , $ h_snr : h_snr , $ k_m : k_m , $ k_cmsig : k_cmsig , $ k_msigcom : k_msigcom , $ k_snr : k_snr , $ ph_qual : ph_qual , $ rd_flag : rd_flag , $ bl_flg : bl_flg , $ cc_flg : cc_flg , $ ndet : ndet , $ prox : prox , $ pxpa : pxpa , $ pxcntr : pxcntr , $ gal_contam : gal_contam , $ mp_flg : mp_flg , $ pts_key : pts_key , $ hemis : hemis , $ date : date , $ scan : scan , $ glon : glon , $ glat : glat , $ x_scan : x_scan , $ jdate : jdate , $ j_psfchi : j_psfchi , $ h_psfchi : h_psfchi , $ k_psfchi : k_psfchi , $ j_m_stdap : j_m_stdap , $ j_msig_stdap : j_msig_stdap , $ h_m_stdap : h_m_stdap , $ h_msig_stdap : h_msig_stdap , $ k_m_stdap : k_m_stdap , $ k_msig_stdap : k_msig_stdap , $ dist_edge_ns : dist_edge_ns , $ dist_edge_ew : dist_edge_ew , $ dist_edge_flg : dist_edge_flg , $ dup_src : dup_src , $ use_src : use_src , $ a : a , $ dist_opt : dist_opt , $ phi_opt : phi_opt , $ b_m_opt : b_m_opt , $ vr_m_opt : vr_m_opt , $ nopt_mchs : nopt_mchs , $ ext_key : ext_key , $ scan_key : scan_key , $ coadd_key : coadd_key , $ coadd : coadd , $ 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, $ tmass:tmass} tmass_init = tmass star_init = star num_ids = sizex(ids) stars = make_array(num_ids, value=star) ; Get the catalog entry line for each star lines = oc_getline_2mass(ids, nstars=nstars, verbose=verbose) ; Loop over every star and fill in the fields for i = 0L, num_ids-1 do begin id = ids[i] line = lines[i] line_raw = line ; Parse the raw catalog line into a bunch of variables if (line eq '') then begin star = oc_star_set_empty(star_init) goto, parse_end end ; Replace Nulls ('\N') with spaces, and then split on |'s. line = str_replace(line, '\N', ' ', /all) ; arr_tmass = ht_str_split(line, char='|') arr_tmass = strsplit(line, '|', /extract) ; 2007 Apr 27 LAY ; Clear the star structure, then stick each variable into its proper 2mass ; structure location. The EMPTY_FLT values are set up s.t. they will ; be set to EMPTY iff they are actually empty. ; The field names and formats are taken exactly from this document: ; ; http://www.ipac.caltech.edu/2mass/releases/allsky/doc/sec2_2a.html ; tmass = tmass_init star = star_init tmass.ra = arr_tmass[0] tmass.dec = arr_tmass[1] tmass.err_maj = arr_tmass[2] tmass.err_min = arr_tmass[3] tmass.err_ang = arr_tmass[4] tmass.designation = arr_tmass[5] tmass.j_m = arr_tmass[6] + EMPTY_FLT tmass.j_cmsig = arr_tmass[7] + EMPTY_FLT tmass.j_msigcom = arr_tmass[8] + EMPTY_FLT tmass.j_snr = arr_tmass[9] + EMPTY_FLT tmass.h_m = arr_tmass[10] + EMPTY_FLT tmass.h_cmsig = arr_tmass[11] + EMPTY_FLT tmass.h_msigcom = arr_tmass[12] + EMPTY_FLT tmass.h_snr = arr_tmass[13] + EMPTY_FLT tmass.k_m = arr_tmass[14] + EMPTY_FLT tmass.k_cmsig = arr_tmass[15] + EMPTY_FLT tmass.k_msigcom = arr_tmass[16] + EMPTY_FLT tmass.k_snr = arr_tmass[17] + EMPTY_FLT tmass.ph_qual = arr_tmass[18] tmass.rd_flag = arr_tmass[19] tmass.bl_flg = arr_tmass[20] tmass.cc_flg = arr_tmass[21] tmass.ndet = arr_tmass[22] tmass.prox = arr_tmass[23] tmass.pxpa = arr_tmass[24] + EMPTY_FLT tmass.pxcntr = arr_tmass[25] tmass.gal_contam = arr_tmass[26] tmass.mp_flg = arr_tmass[27] tmass.pts_key = arr_tmass[28] tmass.hemis = arr_tmass[29] tmass.date = arr_tmass[30] tmass.scan = arr_tmass[31] tmass.glon = arr_tmass[32] tmass.glat = arr_tmass[33] tmass.x_scan = arr_tmass[34] tmass.jdate = arr_tmass[35] tmass.j_psfchi = arr_tmass[36] + EMPTY_FLT tmass.h_psfchi = arr_tmass[37] + EMPTY_FLT tmass.k_psfchi = arr_tmass[38] + EMPTY_FLT tmass.j_m_stdap = arr_tmass[39] + EMPTY_FLT tmass.j_msig_stdap = arr_tmass[40] + EMPTY_FLT tmass.h_m_stdap = arr_tmass[41] + EMPTY_FLT tmass.h_msig_stdap = arr_tmass[42] + EMPTY_FLT tmass.k_m_stdap = arr_tmass[43] + EMPTY_FLT tmass.k_msig_stdap = arr_tmass[44] + EMPTY_FLT tmass.dist_edge_ns = arr_tmass[45] tmass.dist_edge_ew = arr_tmass[46] tmass.dist_edge_flg = arr_tmass[47] tmass.dup_src = arr_tmass[48] tmass.use_src = arr_tmass[49] tmass.a = arr_tmass[50] tmass.dist_opt = arr_tmass[51] + EMPTY_FLT tmass.phi_opt = arr_tmass[52] + EMPTY_FLT tmass.b_m_opt = arr_tmass[53] + EMPTY_FLT tmass.vr_m_opt = arr_tmass[54] + EMPTY_FLT tmass.nopt_mchs = arr_tmass[55] tmass.ext_key = arr_tmass[56] + EMPTY_FLT tmass.scan_key = arr_tmass[57] tmass.coadd_key = arr_tmass[58] tmass.coadd = arr_tmass[59] tmass.record = line_raw ; Process the variables and stick them all into the proper *STAR* structure ; location. No precession or PM is necessary, since TYC2 is already in J2000. ; Convert RA to radians star.ra = tmass.ra*d2r star.dec = tmass.dec*d2r star.raerr = mean( (tmass.err_maj*sin(tmass.err_ang))^2 + $ (tmass.err_min*cos(tmass.err_ang))^2) * $ cos(star.dec)*as2r star.decerr = mean( (tmass.err_maj*cos(tmass.err_ang))^2 + $ (tmass.err_min*sin(tmass.err_ang))^2) * as2r star.idcat = '2mass' star.id = tmass.designation star.poscat = '2mass' star.magcat = ['2mass', '2mass', '2mass'] star.mag = [tmass.j_m, tmass.h_m, tmass.k_m] star.magerr = [tmass.j_msigcom, tmass.h_msigcom, tmass.k_msigcom] star.magname = ['J', 'H', 'K'] ; Epoch of original obs, for proper motion corrections. ; star.et is seconds before 2000. For 2MASS catalog, ; this can come from either 'date' or 'jdate' field, but latter ; is marginally more accurate. jdcnv, 2000, 1, 1, 0, julian_2000 ; 1-Jan-2000 in Julian star.et = (tmass.jdate - julian_2000)*day2sec ; Error of RA*cos(Dec). Convert to radians. ; TYC2 already includes cos(Dec). star.raerr_etpm = star.raerr star.decerr_etpm = star.decerr ; Proper motion, mas/yr. Not measured for 2MASS. star.radot = EMPTY star.decdot = EMPTY star.radoterr = EMPTY star.decdoterr = EMPTY ; ETPM -- default ET in (RA, Dec) at which PM to apply is zero star.etpm = ([star.et, star.et]) ; RA_ETPM -- RA at ETPM (ie, ~time at which obs was taken) ; We subtract out the PM, since catalog is *not* supplied ; with the actual RA at ETPM. star.ra_etpm = star.ra star.dec_etpm = star.dec ; 2MASS has no spectral types star.SpTcat = ['none'] star.SpT = [''] star.notecat = '2mass' star.note = '' star.tmass = tmass 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 return, stars end