;+ ; NAME: ; oc_mkstar ; ; PURPOSE: ; Returns an array of star structures. ; ; DESCRIPTION: ; Construct an array of star structures from argumant lists ; ; CALLING SEQUENCE: ; star = oc_mkstar(et, ra, dec, nstar) ; ; INPUTS: ; et - ephemeris time (TDB seconds path J2000) of positions ; ra - J2000 right ascension in radians (scalar or array) ; dec - J2000 declination in radians (scalar or array) ; ra and dec are the same length (nstar) ; KEYWORDS ; idcat - catalog for id. String or array of length ncat. Default 'none' ; idval - id. String or array of length [ncat,nstar]. Default 'none' ; (using idval for star.id to avoid keyword name conflicts) ; poscat - catalog for ra, dec, raerr, decerr, radot, decdot, ; radoterr, decdoterr. String or array of length nstar. ; Default 'none' ; raerr - error in ra * cos(dec). Radians. Scalar or array of ; length nstar. Default -999 ; decerr - error in dec. Radians. Scalar or array of ; length nstar. Default -999 ; radotval - proper motion in ra*cos(dec), radian/s. Scalar or array ; of length nstar. Default -999 ; decdotval - proper motion in dec, radian/s. Scalar or array ; of length nstar. Default -999 ; radoterr - error in radot. Radian/s. Scalar or array of length ; nstar. Default -999. ; decdoterr - error in decdot. Radian/s. Scalar or array of length ; nstar. Default -999. ; etpm - time of proper motion pivot point (where pm err ; doesn't contribute to raerr and decerr) ; Default et ; ra_etpm - RA at etpm (default ra) ; dec_etpm - Dec at etpm (default dec) ; raerr_etpm - error in cos(dec)*RA at etpm (default raerr) ; decerr_etpm - error in dec at etpm (default decerr) ; magcat - catalog for magname, mag, magerr. String. Scalar or array ; of length nmag. Default 'none' ; magname - name (eg filter) for mag, magerr. String. Array ; of length nmag. Default 'none' ; magval - magnitudes. Array of size [nmag, nstar]. Default -999. ; (using magval for star.mag to avoid keyword name conflicts) ; magerr - error in mag. Array of size [nmag, nstar]. Default -999. ; SpTcat - catalog for SpT. String or array of length ; nstar. Default 'none' ; SpT - spectral type. String or array of length nstar. Default '' ; notecat - catalogs for notes. Array of length nnote. Default 'none' ; note - Notes. Array of size [nnote, nstar] ; structname - fieldname for optional structure (default 'mkstar') ; structval - Array of structures of length nstar with ; user-defined information ; OUTPUTS: ; nstar - number of stars in array ; star - returns an array of star structures, optionally ; with star.mkstar structures ; ; ; REVISON HISTORY: ; 2005 Dec 29 Leslie A Young, SwRI ; 2006 Mar 12 LAY Added etpm, ra_etpm, dec_etpm, raerr_etpm, decerr_etpm ; Actually do the assignment of structval into the star ; structure array ; 2009 Sep 6 LAY ; change keyword_set(_raerr_etpm) to keyword_set(raerr_etpm) ; (and the same for _decerr_etpm) ;- function oc_mkstar, et, ra, dec, nstar, $ verbose=verbose, $ idcat=idcat, idval=idval, $ poscat=poscat, raerr=raerr, decerr=decerr, $ radotval=radotval, decdotval=decdotval, $ 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,magval=magval,magerr=magerr,$ SpTcat=SpTcat, SpTval=SpTval, $ notecat=notecat, noteval=noteval,$ structtag = structtag, structval = structval nstar = 0 ; set it now to the value of return on error nstar = n_elements(ra) if n_elements(dec) ne nstar then begin if keyword_set(verbose) then begin print, 'oc_mkstar: ra and dec must be the same length' endif return, -1 end star1 = oc_star_new() if keyword_set(idval) then begin nid = n_elements(idval)/nstar star1 = struct_assignfield(star1, 'idcat', $ replicate('none',nid)) star1 = struct_assignfield(star1, 'id', $ replicate('none',nid)) endif if keyword_set(magname) then begin nmag = n_elements(magname) star1 = struct_assignfield(star1, 'magcat', $ replicate('none',nmag)) star1 = struct_assignfield(star1, 'magname', $ replicate('none',nmag)) star1 = struct_assignfield(star1, 'mag', $ replicate(-999.d,nmag)) star1 = struct_assignfield(star1, 'magerr', $ replicate(-999.d,nmag)) endif if keyword_set(notecat) then begin nnote = n_elements(notecat) star1 = struct_assignfield(star1, 'notecat', $ replicate('none',nnote)) star1 = struct_assignfield(star1, 'note', $ replicate('none',nnote)) endif if keyword_set (structval) then begin if not keyword_set(structtag) then structtag = 'mkstar' star1 = struct_addfield(star1, structtag, structval[0]) tagnum = (where(tag_names(star1) eq strupcase(structtag)))[0] endif star = replicate(star1, nstar) star.et = et star.ra = ra star.dec = dec if keyword_set(idcat) then star.idcat = idcat if keyword_set(idval) then star.id = idval if keyword_set(poscat) then star.poscat = poscat if keyword_set(raerr) then star.raerr = raerr if keyword_set(decerr) then star.decerr = decerr if keyword_set(radotval) then star.radot = radotval if keyword_set(decdotval) then star.decdot = decdotval if keyword_set(radoterr) then star.radoterr = radoterr if keyword_set(decdoterr) then star.decdoterr = decdoterr if keyword_set(etpm) then $ star.etpm = etpm else begin star.etpm[0,*] = reform(star.et,1,nstar) star.etpm[1,*] = reform(star.et,1,nstar) end if keyword_set(ra_etpm) then $ star.ra_etpm = ra_etpm else $ star.ra_etpm = star.ra if keyword_set(dec_etpm) then $ star.dec_etpm = dec_etpm else $ star.dec_etpm = star.dec if keyword_set(raerr_etpm) then $ star.raerr_etpm = raerr_etpm else $ star.raerr_etpm = star.raerr if keyword_set(decerr_etpm) then $ star.decerr_etpm = decerr_etpm else $ star.decerr_etpm = star.decerr if keyword_set(magcat) then star.magcat = magcat if keyword_set(magname) then star.magname = magname if keyword_set(magval) then star.mag = reform(magval,nmag,nstar) if keyword_set(magerr) then star.magerr = reform(magerr,nmag,nstar) if keyword_set(SpTcat) then star.SpTcat = SpTcat if keyword_set(SpTval) then star.SpT = SpTval if keyword_set(notecat) then star.notecat = notecat if keyword_set(noteval) then star.note = noteval if keyword_set(structval) then star.(tagnum) = structval return, star end