pro printstar,unit,star,starname,vmag=vmag,kmag=kmag,comment=comment,decimal=decimal,tbl=tbl,raonly=raonly,deconly=deconly ;+ ; ; PRINTSTAR ; A procedure to print a single line of the following format: ; STARNAME HH MM SS.S +DD MM SS EQ. vmag=x.x kmag=x.x comment ; ; Call Sequence: ; PRINTSTAR, UNIT, STAR, STARNAME, [, VMAG=float] [, KMAG=float] ; [, /DECIMAL] [, /TBL] [, /RAONLY] [, /DECONLY] ; ; Input: ; UNIT - Where to print the output. (Usually file unit number, 0 for ; term.) Must be an integer. ; STAR - A single element of the Hipparcos structure. Specifically, ; it includes the fields: ; .RA - Decimal RA. Float. ; .DEC - Decimal dec. Float. ; .V - V-magnitude. Float. ; STARNAME - Optional. Name of star to be printed on list. No spaces ; allowed. String. Name can also be specified in .NAME ; field of STAR structure. ; ; Output: ; A line of text printed to UNIT specified. ; ; Keywords: ; VMAG - Set equal to V-magnitude to include 'VMAG=xx.x' at end ; of line. Default omits Vmag (line ends with equinox). ; KMAG - Set equal to K-magnitude to include 'KMAG=xxx' on list. ; COMMENT - Set equal to a string of additional comments to add ; to end of line. ; DECIMAL - Set /DECIMAL to output in decimal ra and dec. ; TBL - ? ; RAONLY - Set these keywords to print only RA or only DEC to current ; DECONLY - device, rather than whole line. ; ; ; N.B. ; Created to be of proper format for Shane/Keck observations. ; Doesn't contain all the possible keywords, just vmag. ; ; Katie Peek / Oct 2006 ; Jan 2007: Modified to have object name occupy 16 spaces in ; accordance with Keck starlist requirements. Also added RA decimal. ; Sep 2007: Take vmag value from keyword itself rather than .v field. ; (Presence of .v field now obsolete.) ; Oct 2007: Added COMMENT keyword. ; ;- ; Check that UNIT is an integer. if (size(unit,/type) ne 2) then message,' PRINTSTAR: Integer UNIT required.' ; Check that STARNAME is a string that contains no spaces. case 1 of (n_elements(starname) eq 0): starname = star.name (size(starname,/type) ne 7): message, 'STARNAME must be string.' (strhas(starname,' ')): message,'STARNAME must not contain spaces.' else: ;nothin' endcase ; RA ra = sixty(star.ra) ra_h = round(ra[0]) ra_m = round(ra[1]) ra_s = round(ra[2]*10) if (ra_h lt 10.) then ra_h='0'+str(ra_h) else ra_h = str(ra_h) if (ra_m lt 10.) then ra_m='0'+str(ra_m) else ra_m = str(ra_m) if (ra_s lt 100.) then ra_s = strmid('0'+str(ra_s/10.),0,4) $ else ra_s = strmid(str(ra_s/10.),0,4) if (keyword_set(decimal) or keyword_set(tbl)) then begin ra_deg = str(round(star.ra*360./24.*1e6)/1e6) ra_dcml = strmid(ra_deg,0,strpos(ra_deg,'.')+5) endif ; DEC if (star.dec ge 0.) then begin dec = sixty(star.dec) de_d = floor(dec[0]) de_m = floor(dec[1]) de_s = round(dec[2]) if (de_d lt 10.) then de_d='+0'+str(de_d) else de_d='+'+str(de_d) if (de_m lt 10.) then de_m='0'+str(de_m) else de_m = str(de_m) if (de_s lt 10.) then de_s='0'+str(de_s) else de_s = str(de_s) endif if (star.dec lt 0.) then begin dec = sixty(abs(star.dec)) de_d = floor(dec[0]) de_m = floor(dec[1]) de_s = round(dec[2]) if (de_d lt 10.) then de_d='-0'+str(de_d) else de_d = '-'+str(de_d) if (de_m lt 10.) then de_m='0'+str(de_m) else de_m = str(de_m) if (de_s lt 10.) then de_s='0'+str(de_s) else de_s = str(de_s) endif if (keyword_set(decimal) or keyword_set(tbl)) then begin destr = str(round((star.dec mod 1)*1e5)/1e5) depos = strpos(destr,'.') de_dcml = de_d + strmid(destr,depos,6) endif ; Equinox eqx = '2000.0' ; Vmag if keyword_set(vmag) then begin ; vmag = star.v ; star.vmag vmg = vmag ; Prevent changing the input accidentally. vmg = str(round(vmg*10)/10.) vmg = 'vmag='+strmid(vmg,0,strpos(vmg,'.')+2) ; Include tenths place endif if keyword_set(kmag) then begin kmag = str(round(kmag*10)/10.) kmag = 'kmag='+strmid(kmag,0,strpos(kmag,'.')+2) ; Include tenths place endif ; Do RAONLY or DECONLY cases, if keyword set, exiting afterward to ; avoid the real printing mess below. if keyword_set(raonly) then begin fmt='(a5,a3,a5)' printf,unit,ra_h,ra_m,ra_s,format=fmt return endif if keyword_set(deconly) then begin fmt='(a6,a3,a3)' printf,unit,de_d,de_m,de_s,format=fmt return endif ; Print the printing. code = 0 if keyword_set(decimal) then code = code + 2^0 if keyword_set(vmag) then code = code + 2^1 if keyword_set(kmag) then code = code + 2^2 if keyword_set(comment) then code = code + 2^3 if keyword_set(tbl) then code = 16 if (unit ne 0) then u=1 else u=0 case code of 00: begin f = '(a16,a5,a3,a5,a6,a3,a3,a11)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,format=f end 01: begin f = '(a16,a10,a11,a11)' if ~u then print,starname,ra_dcml,de_dcml,eqx,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,format=f end 02: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a11)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,format=f end 03: begin f = '(a16,a10,a11,a9,a11)' if ~u then print,starname,ra_dcml,de_dcml,eqx,vmg,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,vmg,format=f end 04: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a11)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,kmag,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,kmag,format=f end 05: begin f = '(a16,a10,a11,a9,a11)' if ~u then print,starname,ra_dcml,de_dcml,eqx,kmag,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,kmag,format=f end 06: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a9,a11)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,kmag,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,kmag,format=f end 07: begin f = '(a16,a10,a11,a9,a9,a11)' if ~u then print,starname,ra_dcml,de_dcml,eqx,vmg,kmag,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,vmg,kmag,format=f end 08: begin f = '(a16,a5,a3,a5,a6,a3,a3,a11,a)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,' '+comment,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,' '+comment,format=f end 09: begin f = '(a16,a10,a11,a11,a)' if ~u then print,starname,ra_dcml,de_dcml,eqx,' '+comment,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,' '+comment,format=f end 10: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a11,a)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,' '+comment,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,' '+comment,format=f end 11: begin f = '(a16,a10,a11,a9,a11,a)' if ~u then print,starname,ra_dcml,de_dcml,eqx,vmg,' '+comment,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,vmg,' '+comment,format=f end 12: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a11,a)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,kmag,' '+comment,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,kmag,' '+comment,format=f end 13: begin f = '(a16,a10,a11,a9,a11,a)' if ~u then print,starname,ra_dcml,de_dcml,eqx,kmag,' '+comment,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,kmag,' '+comment,format=f end 14: begin f = '(a16,a5,a3,a5,a6,a3,a3,a9,a9,a11,a)' if ~u then print,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,kmag,' '+comment,format=f $ else printf,unit,starname,ra_h,ra_m,ra_s,de_d,de_m,de_s,eqx,vmg,kmag,' '+comment,format=f end 15: begin f = '(a16,a10,a11,a9,a9,a11,a)' if ~u then print,starname,ra_dcml,de_dcml,eqx,vmg,kmag,' '+comment,format=f $ else printf,unit,starname,ra_dcml,de_dcml,eqx,vmg,kmag,' '+comment,format=f end 16: begin f = '(a15,a12,a9)' printf,unit,ra_dcml,de_dcml,eqx,format=f end else: message,"Yikes. This is getting out of hand." endcase end