ds9 - EranOfek/AstroPack GitHub Wiki
ds9 is a static class for basic ds9 control and communication. The class requires the user to install ds9 and xpa. A reference list of XPA commands is available here.
DS9analaysis is a class for advanced analysis of AstroImage objects via ds9. DS9analysis allows the user to load AstroImage objects including their metadata (e.g., Mask image, Catalog data), and to interact with the data in the AstroImage object (e.g., get sources from the catalog, get mask image values).
To see the ds9 methods, click ds9..
ds9.open
ds9.disp('FileName.fits');
% or you can open the file directly using:
ds9 FileName.fits
% or
ds9('FileName.fits')
You can load to ds9, FITS files, matrices or AstroImage objects
ds9(rand(100,100))
AI = AstroImage('FileName.fits');
ds9(AI)
You can load a sequence of images to multiple frames:
ds9('*.fits');
%or
AI = AstroImage('*.fits');
ds9(AI)
% you can load an image to a specific frame
ds9(AI, 2)
and you can switch frame using:
ds9.frame(2)
% and delete the content of a frame
ds9.delete_frame;
You can zoom, rotate, pan, and scale an image. For example:
% zoom in by factor of 2
ds9.zoom('in')
% absolute zoom
ds9.zoom(4)
% or relative zoom
ds9.zoom('4')
To rotate an image:
ds9.rotate(30)
Scaling the image:
ds9.scale('linear')
ds9.scale('log',100)
ds9.scale('log 100');
ds9.scale('limits',1520,1900)
You can use the ds9 engines to convert RA/Dec coordinates to X/Y coordinates and vice versa. The following functions work on the image in the current frame, and they require the image header will contain the WCS information.
[CooX,CooY]=ds9.coo2xy(RA,Dec);
% or
[CooX,CooY]=ds9.coo2xy(RA,Dec,'image');
% where the 3rd optional argument can be image/physical
% and from X/Y to RA/Dec:
[RA,Dec]=ds9.xy2coo(X,Y)
% and you cam also choose the output coordinate system: 'icrs'|'fk5'|'fk4'
[RA,Dec]=ds9.xy2coo(X, Y, 'fk4')
The following functions are availble:
- ds9.ginput - Interactively get the coordinates (X/Y or WCS)
- ds9.getpos - Get X,Y position and pixel value (like ds9.ginput, but for X/Y positions)
- ds9.getcoo - Interactively get the coordinates (WCS). (like ds9.ginput but for RA/Dec positions).
- ds9.getbox - Get the pixel values in a specified box region.
[CooX,CooY,Val,Key]=ds9.ginput('icrs','q','key'); % stop after user clicked 'q'
[CooX,CooY,Val,Key]=ds9.ginput('icrs',2,'mouse'); % return after two mouse clicks
% Get a matrix of pixel values within a box:
[MatVal,MatX,MatY]=getbox([1 10 21 30], 'section', 'image')
The DS9analysis class contains AstroImage objects and display each image in its own frame. The Images property in the DS9analysis is an array of AstroImage objects.
The following examples show how to load (and display) some AstroImage objects.
% create a DS9analysis object
D9 = DS9analysis;
% Load an AstroImage object AI(1) into the first frame:
D9.load(AI(1), 1)
% load an AstroImage object AI(2) into the second frame:
D9.load(AI(2), 2)
There are several functions that allow you to inspect the value of some pixels, plot the pixels values, check bit mask values, search for the nearest star in the associated catalog, forced photometry and more.
Most of these functions can work either using mouse click, or specified positions, and the functions can work either in pixels positions or sky positions.
For example, the getXY method returns the position of a point specified by the user:
% To specify the point position using a mouse click:
[X,Y, Val,~,Key,Coo] = D9.getXY()
% specify the point positions by X/Y pix position:
[X,Y, Val,~,Key,Coo] = D9.getXY([155 189],'CooSys','pix')
% specify by RA/Dec:
[X,Y, Val,~,Key,Coo] = D9.getXY([192.1123, -10.234])
The following examples uses mouse specified positions:
% Measure the pixel and angular distance between two points on the image:
R=D9.dist
% using 1st moment to find the star center, and plot a radial plot around the position:
R=D9.radial;
% Calculate the moments and aperture photometry:
[M1, M2, Aper, RADec, AI] = D9.moments;
% Calculate forced PSF fitted photometry (requires the PSFData property in the AstroImage to contain the PSF):
R=D9.forcedPhot
% Get bit mask names at the clicked position:
D9.getMask
% Get background value:
D9.getBack
% Get the nearest source from the associated CatData property in the AstroImage:
[R,Dist]=D9.near
% Plot the position of known asteroids on the image:
[KA] = D9.plotKnownAst;