;+ ; NAME: ; smei_star_show ; PURPOSE: ; Plot star time series ; CATEGORY: ; camera/idl/star ; CALLING SEQUENCE: PRO smei_star_show, star_name, pnt_, $ source = source , $ xname = xname , $ xtype = xtype , $ yname = yname , $ ytype = ytype , $ ttrange = ttrange , $ cvrange = cvrange , $ fixgain = fixgain , $ magnitude=magnitude , $ pnt = pnt , $ camera = camera , $ track = track , $ yaxis = yaxis , $ newyaxis= newyaxis , $ dtsmooth= dtsmooth , $ tsmooth = tsmooth , $ xysize = xysize , $ zbuffer = zbuffer , $ imgfile = imgfile , $ logo = logo , $ silent = silent , $ _extra = _extra ; INPUTS: ; star_name scalar; type: string; default: Polaris ; name of star ; used only if 2nd argument (pnt_) is not specified ; star_name is run through href=smei_star_alias= ; and href=smei_star_info= to translate the specified ; name to a star_name on one of the SMEI star catalogues ; (set keyword cat='*' to scan all available catalogues). ; If no match is found then 'star_name' is used (after ; replacing spaces with underscores) to locate a time ; series file .txt or .txt.gz. ; If a match is found than the standard naming convention ; for naming pnt files is followed to locate a pnt file ; (see href=smei_star_filename=). ; pnt_ array; type: structure ; time series info read from pnt file. ; If this argument is specified (obtained from a previous ; call to smei_star_show) then 'star_name' is ignored ; and this argument is used instead of reading the ; time series from file. ; OPTIONAL INPUT PARAMETERS: ; source=source scalar; type: string; default: $SMEISKY0/star ; name of directory where pnt file for 'star_name' ; timeseries is located ; ; Any of the quantities in the time series ('pnt') file can be plotted. ; These are selected by specifying field names in the xname and yname ; keywords. Valid entries are: ; NAME ; RADEC 2-element vector ; MAPTYPE ; CAMERA ; TIME ; PSFANGLE ; FOVANGLE 2-element vector ; PSFSTRETCH 2-element vector ; GAIN ; NAME_CLOSE ; TOTAL_ADUS ; BRIGHT_RAW ; BRIGHT_MDL ; BRIGHT ; BACK_CONST ; BACK_SLOPE 2-element vector ; N_BKGND ; N_FITPSF ; STDEV_BKGND ; STDEV_PSF ; CVFIT ; DRADEC 2-element vector ; DPSFANGLE ; DPSFSTRETCH 2-element vector ; PSFWIDTH 2-element vector ; REMOVE ; DONE ; ; xname=xname scalar; type: string; default: 'TIME' ; selects the quantity on the horizontal axis ; yname=yname scalar or array; type: string; default: 'BRIGHT' ; selects one or more quantities for the vertical axis ; Note: if more than one quantity for the y-axis is ; specified then probably keywords newyaxis and yaxis ; will be needed to get a decent plot ; (see href=PlotCurve=). ; xtype=xtype scaler; type: integer; default: 0 ; ytype=ytype scalar; type: integer; default: replicate(0,n_elements(yname) ; either 0 or 1; selects the vector component if one of the ; vector fields is used for xname and/or yname ; Special cases: ; - If one of the vector fields is used for xname, then the second vector ; component is used for the y-axis, e.g. ; xname='RADEC' is the same as xname='RADEC, xtype=0, yname='RADEC', ytype=1 ; ; camera=camera scalar or array; type: integer; default: none ; list of cameras (value 1,2 or 3). If present, only ; data points for the indicated cameras are plotted. ; ttrange=ttrange array[2]; type: string or time structure; default: none ; limits time series to specied time range ; If only one time is specified than the time series ; from that time to the end of the time series is plotted. ; cvrange=cvrange scalar or array[2]; type: numeric; default: none ; only plots data points for which the correlation of the ; PSF fits was in the specified range. ; If a scalar is specified then [cvrange,1.0] is assumed, ; i.e. all points with fits better than the indicated ; threshold are used. ; /magnitude converts the brightness to a SMEI magnitude scale ; (Note: this is a very coarse conversion) ; /fixgain if set, then the gain information in the pnt file is used ; to correct the timeseries for camera gain. ; /track calls smei_sky_track instead of plotting time series info ; (Does this work? What does it do anyways?) ; ; _extra=_extra extra keywords passed to smei_star_info, smei_sky_track, ; PlotCurve and xyouts ; OUTPUTS: ; pnt_ array; type structure ; the content read from the pnt file. This can be used ; in subsequent calls to bypass reading the file ; again. In this case the 'star_name' argument is ignored. ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; PROCEDURE: ; MODIFICATION HISTORY: ; JAN-2008, Paul Hick (UCSD/CASS) ; FEB-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; ;- InitVar, silent, 0 IF IsType(pnt_, /undefined) THEN BEGIN InitVar, source, filepath(root=getenv('SMEISKY0'),'star') InitVar, star_name, 'Polaris' name = smei_star_alias(star_name) star_names = smei_star_info(/get_name,_extra=_extra);,/silent) tmp = (where(strpos(star_names,name) NE -1))[0] IF tmp EQ -1 THEN BEGIN message, /info, 'star name not found in SMEI catalogue, '+star_name ;RETURN name = star_name ENDIF ELSE $ name = star_names[tmp] file = filepath(root=source,smei_star_filename(name)+'.txt') IF smei_star_readpnt( file, pnt_ ) NE 1 THEN $ RETURN ENDIF InitVar, fixgain , /key InitVar, magnitude, /key InitVar, track , /key pnt = pnt_ usec = TimeUnit(/sec) IF IsType(ttrange,/defined) THEN BEGIN CASE 1 OF IsTime(ttrange) : ; nothing to do IsType(ttrange,/string) : ttrange = TimeSet(ttrange) ELSE: BEGIN message, /info, 'ttrange must be string or time structure' RETURN END ENDCASE IF n_elements(ttrange) EQ 1 THEN ttrange = [ttrange[0],TimeLimits(TimeSet(pnt.time),/max)] i = TimeGet(ttrange,/_ydoy,upto=usec) i = where(i[0] LE pnt.time AND pnt.time LE i[1]) IF i[0] EQ -1 THEN BEGIN message, /info, 'no points in ttrange' RETURN ENDIF pnt = pnt[i] ENDIF IF IsType(cvrange,/defined) THEN BEGIN InitVar, cvrange, count=1, [cvrange,1.0] i = where(cvrange[0] LE pnt.cvfit AND pnt.cvfit LE cvrange[1]) IF i[0] EQ -1 THEN BEGIN message, /info, 'no points in cvrange' RETURN ENDIF message, /info, 'cvrange=['+strjoin(cvrange,',')+']' pnt = pnt[i] ENDIF If IsType(camera,/defined) THEN BEGIN i = where_common(pnt.camera,camera) IF i[0] EQ -1 THEN BEGIN message, /info, 'no points for selected camera(s)' RETURN ENDIF message, /info, 'camera=['+strjoin(camera,',')+']' pnt = pnt[i] ENDIF CASE track OF 0: BEGIN tags = tag_names(pnt) star_loc = pnt[0].radec pnt.radec += pnt.dradec ; Add centroid fit pnt.psfstretch += pnt.dpsfstretch ; Add psf width fit pnt.psfangle += pnt.dpsfangle ; Add psf orientation fit InitVar, xname, 'TIME' InitVar, xtype, 0 vector_tags = ['RADEC','FOVANGLE','PSFSTRETCH','BACK_SLOPE','DRADEC','DPSFSTRETCH','PSFWIDTH'] CASE IsType(yname,/defined) OF 0: BEGIN CASE (where( strpos(vector_tags,strupcase(xname)) EQ 0 ))[0] NE -1 OF 0: BEGIN yname = 'BRIGHT' ytype = 0 END 1: BEGIN yname = xname ytype = 1-xtype END ENDCASE END 1: InitVar, ytype, replicate(0,n_elements(yname)) ENDCASE xtag = strupcase( [xname,yname] ) itag = [xtype,ytype] FOR i=0,n_elements(xtag)-1 DO BEGIN n = where(strpos(tags,xtag[i]) EQ 0, ntag) CASE ntag OF ; # of matching tags 0: BEGIN ; No matching tag message, /info, 'invalid tag: '+xtag[i]+'; choose from' message, /info, strjoin(tags,' ') RETURN END 1: n = n[0] ; Just one matching tag ELSE: BEGIN ; Multiple matching tags; use tag with shortest name tmp = min(strlen(tags[n]),j) message, /info, 'ambiguous tag: '+xtag[i]+ $ ' ('+strjoin(tags[n],',')+'), using '+tags[n[j]] n = n[j] END ENDCASE xtag[i] = tags[n] ; Set identified tag is_vector = (where(vector_tags EQ xtag[i]))[0] NE -1 IF itag[i] EQ 1 THEN $ IF NOT is_vector THEN $ itag[i] = 0 IF i GT 0 THEN $ IF xtag[i] EQ xtag[0] THEN $ itag[i] = 1-itag[0] ENDFOR IF fixgain THEN BEGIN message, /info, 'apply gain correction' ;whatis, pnt.gain pnt.bright /= pnt.gain pnt.bright_mdl /= pnt.gain pnt.bright_raw /= pnt.gain ENDIF nx = (where(tags EQ xtag[0]))[0] ny = (where(tags EQ xtag[1]))[0] ix = itag[0] iy = itag[1] xx = pnt.(nx)[ix] yy = pnt.(ny)[iy] xx = smei_star_showsmooth( pnt.time, xx, dtsmooth=dtsmooth, tsmooth=tsmooth ) yy = smei_star_showsmooth( pnt.time, yy, dtsmooth=dtsmooth, tsmooth=tsmooth ) CASE xtag[0] EQ 'TIME' OF 0: xtitle = smei_star_title(nx,ix) 1: destroyvar, xtitle ENDCASE ytitle = smei_star_title(ny,iy) IF magnitude THEN BEGIN IF strmid(xtag[0],0,6) EQ 'BRIGHT' THEN BEGIN xtitle = 'SMEI magnitude' xx = smei_i2m(from_bb=xx) ENDIF IF strmid(xtag[1],0,6) EQ 'BRIGHT' THEN BEGIN ytitle = 'SMEI magnitude' yy = smei_i2m(from_bb=yy) ENDIF ENDIF set_page, zbuffer=zbuffer, file=imgfile, xysize=xysize, /silent PlotCurve, xx, yy, $ title = pnt[0].name , $ xtitle = xtitle , $ ytitle = ytitle , $ yaxis = -1 , $ _extra = _extra IF (xtag[0] EQ 'RADEC' AND xtag[1] EQ 'RADEC' ) OR $ (xtag[0] EQ 'DRADEC' AND xtag[1] EQ 'DRADEC') THEN BEGIN stars = smei_star_info(/get_struct,catalogue='*',/silent) loc = smei_star_info(stars,/degrees) loc = where(!x.crange[0] LE loc[0,*] AND loc[0,*] LE !x.crange[1] AND $ !y.crange[0] LE loc[1,*] AND loc[1,*] LE !y.crange[1], n ) IF loc[0] EQ -1 THEN BEGIN message, /info, 'no stars inside plot; wrong xrange or yrange keyword set??' RETURN ENDIF stars = stars[loc] loc = smei_star_info(stars,/degrees) name = smei_star_info(stars,/get_name) FOR i=0,n-1 DO BEGIN IF xtag[0] EQ 'DRADEC' THEN loc[*,i] -= star_loc plots, loc[*,i], psym=1, symsize=5 xyouts, loc[0,i]+0.01*(!x.crange[1]-!x.crange[0]), $ loc[1,i]+0.01*(!y.crange[1]-!y.crange[0]), $ name[i], _extra=_extra ENDFOR ENDIF IF IsType(newyaxis,/undefined) THEN newyaxis = 1 FOR i=2,n_elements(xtag)-1 DO BEGIN ny = (where(tags EQ xtag[i]))[0] iy = itag[1] xx = pnt.(nx)[ix] yy = pnt.(ny)[iy] xx = smei_star_showsmooth( pnt.time, xx, dtsmooth=dtsmooth, tsmooth=tsmooth ) yy = smei_star_showsmooth( pnt.time, yy, dtsmooth=dtsmooth, tsmooth=tsmooth ) IF magnitude THEN BEGIN IF strmid(xtag[0],0,6) EQ 'BRIGHT' THEN $ xx = smei_i2m(from_bb=xx) IF strmid(xtag[i],0,6) EQ 'BRIGHT' THEN $ yy = smei_i2m(from_bb=yy) ENDIF InitVar, yaxis, set=yaxis_, i-2 PlotCurve, xx, yy, /oplot, yaxis=yaxis_, newyaxis=newyaxis, _extra=_extra ENDFOR get_page, logo=logo, /silent END 1: BEGIN pnt.radec += pnt.dradec ; Add centroid fit orbits = smei_orbit_get(TimeGet(pnt.time,/smei),/number) FOR i=0L,n_elements(pnt)-1 DO BEGIN smei_sky_track, orbits[i] , $ camera = pnt[i].camera , $ /exact , $ body = pnt[i].radec , $ /degrees , $ /equator , $ xysize = xysize , $ _extra = _extra ENDFOR END ENDCASE RETURN & END