📄 tvlaser.pro
字号:
endelse device, xsize=inx, ysize=iny, xoffset=XOff, yoffset=YOff, /inches, $ bits=NBits, filename=fname, /helvetica, encapsulated=Encap, color=ColorPS if keyword_set(Magnify) then device, scale=Magnify else device, scale=1;-----------------------;; SECTION: TV OUTPUT ;;-----------------------; tv, ImageOut,true=TrueValue; If the BarPos keyword has four or five elements, then show the color bar. if (not(TrueValue)) then begin if (N_elements(BarPos) eq 0) then BarPos = [-0.25, 0.0, 0.2, 2.0] NumEls = N_elements(BarPos) if ( (NumEls eq 4) or (NumEls eq 5) ) then begin ColorBar = byte(round(congrid(findgen(nc)+BottomDW, 256))) $ # make_array(20,val=1b) if not(ColorPS) then $ ColorBar = 0.299 * sv_rr[ColorBar] + 0.587 * sv_gg[ColorBar] $ + 0.114 * sv_bb[ColorBar] ColorBar[0:*,[0,19]] = 0 ColorBar[[0,255],0:*] = 0 if (NumEls eq 4) then ColorBar = transpose(ColorBar) tv, ColorBar, BarPos[0],BarPos[1], xsize=BarPos[2],ysize=BarPos[3], /INCHES endif endif;;;; Now that the image has been displayed with the desired color table, we will ; play with the color table a bit to get the appropriate colors for the text,; arrows, and scale bar. The three RGB values for each one will be loaded into; vectors called things like 'CArrowsRGBN', 'CSizeRGBN', etc. The last value; in this vector will be the location of that color in the color table.; "Colors" is a string array of the keyword names, then via the EXECUTE; function, we determine what the content of each variable is: a string to be; used inthe pixcolor procedure, a single number indicating the location in the; current color table, or a 3-element vector with RGB values. One reason for; doing it this way, is that if more objects to be colored are added to the; keywords, only the variable COLORS need be changed here by adding those; keyword names.; "Val" is where we will be temporarily putting the new colors (usually in; the bottom bin).; Colors = ['CArrows','CSize','CTitle','CLabels'] r_new = bytarr(n_elements(Colors)) g_new = r_new b_new = r_new for N=0,(n_elements(Colors) -1) do begin tvlct, sv_rr, sv_gg, sv_bb Val = 0 dummy = execute( 'NumEls = n_elements(' + Colors[N] + ')' ) if (NumEls eq 0) then begin dummy = execute( Colors[N] + ' = "D"' ) NumEls = 1 endif dummy = execute( 'C = ' + Colors[N] ) if (NumEls eq 1) then begin ; string or color value if ((size(C))[1] eq 7) then pixcolor, Val, C else Val = C endif else begin if (NumEls eq 3) then tvlct,transpose(C) else pixcolor, Val, 'D' endelse tvlct, r, g, b, /get if (Val[0] ne -1) then begin r_new[N] = r[Val] g_new[N] = g[Val] b_new[N] = b[Val] dummy = execute(Colors[N]+'RGBN = [r[Val],g[Val],b[Val],N]') endifendfor tvlct, r_new, g_new, b_new;-------------------------------;; SECTION: HEADER and LABELS ;;-------------------------------;;;;; If a FITS header was given then include whatever of the following FITS; keywords that are present as annotation: OBJECT (becomes the title if none; given), TELESCOP, IMAGE, EXPTIME, EQUINOX, CRVAL1 (Right Ascension), CRVAL2; (Declination), NAXIS1, NAXIS2, CD (Rotation angle and pixel size), PDSDATIM; (Date of Microdensitometry). Also will include the name of the user and the; current date. Some blocks can be suppressed...see description of keywords; above. Also prints directional arrows and scale.; if (N_elements(Hdr) NE 0) then begin ;;;; Does the header have astrometry?; extast, hdr, astr, NoAstrom if NoAstrom GT 0 then begin ast_type = strmid( strupcase( strtrim(astr.ctype[0],2) ), 0 ,4) if ((ast_type NE 'RA--') and (ast_type NE 'GLON') and $ ;Valid projection? (ast_type NE 'ELAT') ) then NoAstrom = -1 endif if (NoAstrom LT 0) then begin rga = 'N/A' decl = 'N/A' equi = '' ROTATE = 'N/A' CDELT = [0.0,0.0] CDELTAS = 'N/A' endif else begin xcen = (XDim-XStart-1)/2. ycen = (YDim-YStart-1)/2. if FromTV then zoom_xy,xcen,ycen ;In case TV image has non-zero zoom or roam xyad,hdr, xcen, ycen, ra_cen, dec_cen str = adstring(ra_cen,dec_cen,1) rga = strmid( str, 1, 11) decl = strmid( str, 14, 11) equi = sxpar( hdr, 'EQUINOX', Count = N_equi) if N_equi EQ 0 then equi = '' else $ equi = '(' + strmid(strtrim(equi,2),0,7) + ')' getrot, hdr ,ROTATE, CDELT ROTATE = strtrim(string(ROTATE, format='(f7.2)'),2) + ' degrees' CDELT = abs(CDELT*60.*60.) if CDELT[0] LT 0.1 then fmt = '(f7.3)' else fmt = '(f7.2)' CDELTAS = strtrim(string(CDELT[0],format=fmt ),2) if (abs(CDELT[0] - CDELT[1]) GT 0.05*CDELT[0]) THEN $ CDELTAS = CDELTAS + ' by ' + strtrim(string(CDELT[1],format=fmt),2) CDELTAS = CDELTAS + ' arcsec/pixel' endelse;;;; Printout the image information? YSpace is used to scale the spacing of the; linformation lines in NORMAL units. dY is one line height. LabXs and LabYs; are arrays that define the placement of Label/Value pairs in the NORMAL; coordinates. So to increment to the next line, simply use:; LabYs = LabYs + dY;if (strtrim(CLabels[0],2) ne '-1') then begin dY = -0.025 * YSpace LabYs = [-0.05, -0.05] * YSpace LabX1s = [ 0.01, 0.21] * XSpace LabX2s = [ 0.64, 0.74] * XSpace;;;; Set the label color and print out each label/value.; !P.Color = CLabelsRGBN[3];OBJECT OBJ = strtrim( sxpar(hdr,'OBJECT', Count = N_Obj),2 ) if N_Obj EQ 0 then begin OBJ = strtrim( sxpar( hdr,'TARGNAME', Count = N_Obj),2) if N_Obj EQ 0 then OBJ = 'N/A' endif XYOUTS, LabX1s, LabYs, ['OBJECT:',OBJ],/ NORMAL LabYs = LabYs + dY;TITLE (set here, but print out later in case no header was given) if NOT keyword_set(TITLE) then begin if (N_Obj NE 0) then TITLE=OBJ else TITLE = '' endif ;IMAGE ID imname = 'N/A' imname = sxpar(hdr,'IMAGE', Count = N_image) if N_image EQ 0 then imname = sxpar(hdr,'EXPNAME', Count = N_image) if N_image EQ 0 then imname = sxpar(hdr,'OBS_ID', Count = N_image) if N_image EQ 0 then imname = sxpar(hdr,'ROOTNAME', Count = N_image) imname = strtrim(imname,2) XYOUTS,LabX1s,LabYs,['IMAGE:',IMNAME],/NORMAL LabYs = LabYs + dY LabYs = LabYs + dY;TELESCOPE scop = sxpar( hdr,'INSTRUME', Count = N_Scop) if N_Scop EQ 0 then scop = sxpar( hdr,'TELESCOP', Count = N_Scop) if N_Scop EQ 0 then scop = sxpar( hdr,'OBSERVAT', Count = N_Scop) if N_Scop EQ 0 then scop = '' else scop = strtrim(scop,2) detector = sxpar( hdr,'DETECTOR', Count = N_det) if N_det EQ 0 then detector = '' else detector = strtrim(detector,2) if scop EQ '' then scop = detector else $ if detector NE '' then scop = scop + '/' + detector XYOUTS,LabX1s,LabYs,['INSTRUMENT:',scop],/NORMAL;SIZE SIZ = strtrim(XDim,2) +' by ' + strtrim(YDim,2) + ' pixels' XYOUTS,LabX2s,LabYs,['SIZE:',SIZ],/NORMAL LabYs = LabYs + dY;FILTER filter = sxpar(hdr, 'FILTER', Count= N_filter) if N_filter EQ 0 then filter = sxpar(hdr, 'FILTNAM1', Count= N_filter) if N_filter EQ 0 then filter = sxpar(hdr, 'FILTER1', Count= N_filter) if N_filter EQ 0 then FILTER = 'N/A' else filter = strtrim(filter,2) XYOUTS,LabX1s,LabYs,['CAMERA/FILTER:',FILTER],/NORMAL;SCALE if NoAstrom GE 0 then XYOUTS,LabX2s,LabYs,['SCALE:',CDELTAS],/NORMAL LabYs = LabYs + dY;EXPOSURE TIME First try 'EXPTIME' then 'EXPOSURE' then 'INTEG' exptime = sxpar(hdr, 'EXPTIME', Count = N_time) if N_time EQ 0 then exptime = sxpar(hdr, 'EXPOSURE', Count = N_time) if N_time EQ 0 then exptime = sxpar(hdr, 'INTEG', Count = N_time) if N_time EQ 0 then exptime = 'N/A' else $ exptime = strmid( strtrim(exptime,2),0,6) + ' seconds' XYOUTS,LabX1s,LabYs,['EXPOSURE TIME:',EXPTIME],/NORMAL LabYs = LabYs + dY LabYs = LabYs + dY if noastrom GE 0 then begin;CENTER COORDINATES XYOUTS, LabX1s, LabYs,['CENTER '+ equi + ':', $ 'RA = ' + RGA + ' DEC = ' + DECL], /NORMAL LabYs = LabYs + dY;ROTATION XYOUTS,LabX1s,LabYs,['ROTATION:',strtrim(ROTATE,2)],/NORMAL LabYs = LabYs + dY endif;COMMENTS if keyword_set(Comments) then begin XYOUTS,LabX1s[0],LabYs[0],'COMMENTS:',/NORMAL for N=0,(n_elements(Comments)-1) do $ XYOUTS,LabX1s[1],(LabYs[1] + (dY * N)),Comments[N],/NORMAL endif LabYs = LabYs + dY;USER and DATE/TIME if not keyword_set(No_pers_info) then begin XYOUTS, LabX2s[0],LabYs[0], GetEnv('USER') + ' (' + $ STRMID(systime(),4,20) + ')' ,SIZE=0.9, /NORMAL endif endif;ARROWS; The calculations AX and XY allow the smallest use of space for the arrows; for all possible rotation angles. To test the extent of the circle, add; code like the following in before the "R = float(..." line:; hextract,ImageOut,h,i1,h1,0,5,0,5 & for N=0,18 do begin; hrot,i1,h1,i2,h2,N*20,-1,-1,0 & getrot, h2 ,Rotate; if ((strtrim(CArrows[0],2) ne '-1') and (NoAstrom ne -1)) then begin R = float(rotate) * !pi / 180 AX = ( 0.50 + (0.05 * (cos(R) + sin(R)))) * XSpace AY = (-0.10 - (0.05 * (cos(R) - sin(R)))) * YSpace !P.Font = -1 !P.Color = CArrowsRGBN[3] arrows, hdr, AX, AY, /NORMAL, FONT=13, COLOR=!P.Color, arrowlen=3, charsize=2 !P.Font = 0 endif ;SIZE SCALE BAR; This is probably more complicated than necessary, but the idea is to find; the best size scale bar for any image, where the scale may be a few arcsec; or a few degrees.; "BarLength" is the length of a 1 arcsecond bar in normal coordinates; "BarScale" is the list of standard sizes for the bar in arcsec or arcmin.; "BarLength" is the length in normal coordiates of the "best" scale bar.; if ((strtrim(CSize[0],2) ne '-1') and (NoAstrom ne -1)) then begin BarLength = 1.0 / (CDelt[0] * XDim) BarScale = [1,2,3,5,10,15,20,25,30,40] MinBar = 0.1 * XSpace BS = where((BarLength * BarScale) gt MinBar) ; bar scale in arcsec? if (BS[0] ne -1) then begin BarLength = BarLength * BarScale[BS[0]] BarLabel = strtrim(BarScale[BS[0]], 2) + '"' endif else begin BS = where((BarLength * BarScale * 60) gt MinBar) ; bar scale in arcmin? if (BS[0] ne -1) then begin BarLength = BarLength * BarScale[BS[0]] * 60 BarLabel = strtrim(BarScale[BS[0]], 2) + "'" endif else begin BarLength = BarLength * 3600 BarLabel = '1 degree' endelse endelse; Barlength = BarLength * XSpace BarX = 0.7 * XSpace ; left end of bar BarY = -0.03 * YSpace ; Y position of bar BarDY = 0.01 * [-1,1] * YSpace ; height of bar's endpoints LabY = BarY - (0.025 * YSpace) ; position of label !P.Color = CSizeRGBN[3] plots, BarX+[0,BarLength], [BarY,BarY], /NORMAL plots, [BarX,BarX], BarY+BarDY, /NORMAL plots, BarLength+[BarX,BarX], BarY+BarDY,/NORMAL xyouts, ((BarX + (BarX + BarLength)) / 2.0), LabY, /NORMAL, ALIGN=0.5, $ '!6'+BarLabel+'!X', FONT=-1 endifendif ;;;; TITLE (handle here in case no header was given but TITLE keyword was used.); if (keyword_set(TITLE) and (strtrim(CTitle[0],2) ne '-1')) then begin !P.Color = CTitleRGBN[3] XYOUTS, 0.50*XSpace, 1+(0.01*YSpace), TITLE,SIZE=2.0, /NORMAL, ALIGN=0.5 endif if keyword_set(NoClose) then begin plot,[0,xdim-1],[0,ydim-1],/noerase,xsty=5,ysty=5,/nodata, $ pos = [0,0,1,1] return endif Device,/close;-------------------------------;; SECTION: PRINTING THE FILE ;;-------------------------------; if not(NoPrint or Encap) then begin ;Should the file be printed out? if not keyword_set(PRINTER) then begin case !VERSION.OS_FAMILY of 'unix': printer = 'lpr' else: printer = 'print' endcase endif spawn,printer + ' ' + fname message,/INFO,'Now printing image: $' + printer + ' ' + fname endif; Reset output direction to X-windows, and restore some variables. tvlct,sv_rr,sv_gg,sv_bb set_plot, sv_device !P.font = sv_font !P.Color = sv_color return end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -