A lot of the SAO-RD online documentation for xpa has become fairly unreadable. I am now just using examples in old scripts to document how things can be done (for as long as they work!). See this link to see how to use xpa commands and also see overall discussion of ds9 with this. One other useful thing I have found is to go to my bash scripts directory (using the mob alias) and then grep on xpaget or xpaset. These are two of the most generic xpa tools, and doing this will list command examples I have used in the past along with the scripts they are used in:
% mob (i.e. cd /home/sco/sco/codes/bash) % grep -n 'xpaget' -R * ds9_multi_view:58: xpaget ds9 frame # ds9_open:25:xpaget xpans % grep -n 'xpaset' -R * A huge list, ending with: usno_look:105:cat stars.reg | xpaset ds9 regions -format ds9 usno_look:106:cat gals.reg | xpaset ds9 regions -format ds9 usno_look:115: xpaset -p ds9 saveimage jpeg a.jpeg 75 wcs_getA:57:xpaset -p ds9 frame frameno 1 wcs_getA:58:xpaset -p ds9 file A.fits wcs_getA:59:cat STARS.cdfp.reg | xpaset ds9 regions -format ds9 wcs_getB:59:xpaset -p ds9 frame frameno 1 wcs_getB:60:xpaset -p ds9 file B.fits wcs_getB:61:cat STARS.cdfp.reg | xpaset ds9 regions -format ds9From the lists above I can see examples of how to display or read regions, view multiple frames, etc....
The web docs that descibe xpa nd ds9 sometimes change significantly of the URL disapears. I keep a PDF version of the xpa command page at $scohtm/scocodes/xpa+ds9/xpa_command.pdf. You might be able to view this file directly with your browser HERE.
I have collected a few scripts and image sets in my Tdata directories. I store this work in the T_runs/ds9+xpa directory. I have some running notes there in:
T_runs/ds9+xpa/ex3_ngc3379/S/README.ds9+xpaThese notes are by no means exhaustive, but they cover a lot of the more useful things I can do with xpa. Return to top of page.
# Zoom to fit an (already displayed) image then plot regions in ifu.reg % xpaset -p ds9 zoom to fit % cat ifu.reg | xpaset ds9 regions -format ds9 # display image 1 and overplot regions file just created % xpaset -p ds9 frame frameno 1 % xpaset -p ds9 file $1 % xpaset -p ds9 scale limits $2 $3 # Save marked regions to a file % xpaset -p ds9 regions save ds9_save2.reg # Delet all markers % xpaset -p ds9 regions delete all # Be sure you save physical coordinates % xpaset -p ds9 regions system physical % xpaset -p ds9 regions save Saved_Coordinates.physical.reg # Lay out the 2 image viewing frames % xpaset -p ds9 tile grid layout 2 1 % xpaset -p ds9 tile yes =========================================================== Here I show a useful example from a script. The closing of the window part is really hansdled simply by the "xpaset -p ds9 exit" command string. # close the ds9 window printf "\nClose the ds9 window? (Y/n):" read Final_Answer if [ "$Final_Answer" = "Y" ] then printf "Deleting the ds9 window. Goodbye.\n" xpaset -p ds9 exit else printf "Goodbye.\n" fi =========================================================== # Adjust images to the WCS of frame1 (assumed image # in frame 1 has valid WCS, test with wcs_ask) wcs_ask $1 > wcs.present read WCS_There < wcs.present printf "WCS is present = $WCS_There \n" if [ $WCS_There = "Y" ] then xpaset -p ds9 frame frameno 1 xpaset -p ds9 frame match wcs fiReturn to top of page.
In Apr2016 I began working on my some ways to view multiple images. I want to put different images into different ds9 frames. I also modified the ds9_view script so that I could use a variety of ways to automatically set the image grey scale level. Here is an example of doing this:
% ds9_open 1000 700 % xpaset -p ds9 tile grid layout 2 1 % xpaset -p ds9 tile yes % xpaset -p ds9 frame frameno 1 % xpaset -p ds9 frame frameno 2 % ds9_view Rsco2040.fits zscale n 1 % ds9_view Rsco2040.fits minmax n 2
![]() |
Here is an example of opening a window with two frames. I
display the same image using two different scalings. The
following set of command lines were used for this:
% ds9_open 1000 700 % xpaset -p ds9 tile grid layout 2 1 % xpaset -p ds9 tile yes % xpaset -p ds9 frame frameno 1 % xpaset -p ds9 frame frameno 2 % ds9_view Rsco2040.fits zscale n 1 % ds9_view Rsco2040.fits minmax n 2Recall that ds9_open is my own little script for opening a ds9 window of a user-specified size and ds9_view is another script I wrote that handles the display of a given image. |
I often want to view a portion of a big image. I want to specify the image location, usually by specifying a location in physical coordinates.
Places a crosshair marker on the position X,Y=870,551 % xpaset -p ds9 crosshair 870 551 The pan command is very useful: $xpaget ds9 pan # get current image coords $xpaset -p ds9 pan to 400 400 physical # pan to physical coords What I really need! $xpaset -p ds9 pan to 13:29:55 47:11:50 wcs fk5 # pan to wcs coordsReturn to top of page.
Still have not figured thsi one out!
These change as I change the part of the image viewed: % xpaget ds9 pan 734.6942 576.35785 # tells me cnetr of viewed image % xpaget ds9 zoom 26.623333 # tells me the zoom factorHow I get the corners of the viewed image area (in pixel units) remains a mystery to me. First, I don't know how to get the relative size in X and Y of the image viewing area. Second, I don't know how to use the zoom factor to tell me the size in pixels of the viewed area. Return to top of page.
Sometimes the DATASEC keyword can obscure what we want to see.
Being sure you see ALL of the pixels. ===================================== What is the "size" of the image: % gethead 20161221T041713.7_066LL_sci.fits NAXIS1 NAXIS2 DATASEC BIASSEC 2128 1032 [1:2064,1:1032] [2065:2128,1:1032] I simple way to see the image: ds9 20161221T041713.7_066LL_sci.fits An easy SCO wayto see the image on mcs: ds9_open 800 800 ds9_view 20161221T041713.7_066LL_sci.fits zscale n 1 When I zoom into the top-right corner and measure the X,Y position of the corner pixel ====> X,Y = 2064 1032 Hence, ds9 does NOT show me the bias region! Hoow do I see it? I do the following: ANSWER: Select from the menu bar at top: Scale > DATASEC >>> I see the image change size. The bias area is now visible on the right side of the display.
Soemtimes it is easier to bypass xpa and just run ds9 from the command line. Her are examples:
% ds9 -geometry -scale zscale -match scale *.fits *** I could use the "zoom to fit" command, but it is easier to show all of the images, zoom in obe of them, then use the Frame>Match>Image option to re-zoom all of the displayed images.Return to top of page.
The point region types are useful for plotting regions with sizes that are smaller than an image pixel.
% cat ds9.reg # Region file format: DS9 version 4.1 global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1 physical point(425.89899,351.05168) # point=circle point(428.26533,354.09412) # point=box point(429.57997,351.23948) # point=crossReturn to top of page.
One thing I have wanted to know for a long time: waht is the name of the image (the FITS image name) read into a given frame. This seems so obvious, duh.....
% xpaget ds9 frame has OBJECT XPA$ERROR parse error, expecting: IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS, WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI, WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR, WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, CONTOUR, DATAMIN, DATASEC, FITS, GRID, IIS, IRAFMIN, MARKER, SMOOTH, SYSTEM, found OBJECT (DS9:ds9 7f000001:36357) % xpaget ds9 frame has IMAGE yes HERE IT IS!!!! % xpaget ds9 iis filename dss.fits % xpaget ds9 frame # tells me current frame 1 % xpaget ds9 iis filename # tells me name of image in the frame acam_dss.fits % xpaset -p ds9 frame frameno 2 # switched current frame to frameno=2 % xpaget ds9 iis filename dss.fits
Back to SCO CODES page