function [ra, dec]=gethex(racenter, deccenter, lside, nx, ny) Return RA, DEC coordinates for the hex grid centered on racenter, deccenter. Inputs: racenter -- The center pointing RA, in radians (use htor() if you want to pass RA as a hh:mm:ss.s string) deccenter -- The center pointing DEC, in radians (use dtor() if you want to pass DEC as a dd:mm:ss.s string) lside -- The pointing separation, in arcminutes nx -- The half-width of the hex grid. An integral number of pointings, spaced along a great circle tangential to the center DEC ring. ny -- The half-width of the hex grid. An integral number of pointings, spaced along a great circle passing through the center RA and the poles Example: [ra, dec] = gethex(htor('03:00:00'), dtor('45:00:00'), 600, 1, 1); would return the seven ra, dec pointing ceters for a simple hex, centered on 3h, 45d, spaced by 10 degrees.
0001 function [ra, dec]=gethex(racenter, deccenter, lside, nx, ny) 0002 0003 % function [ra, dec]=gethex(racenter, deccenter, lside, nx, ny) 0004 % 0005 % Return RA, DEC coordinates for the hex grid centered on racenter, deccenter. 0006 % 0007 % Inputs: 0008 % 0009 % racenter -- The center pointing RA, in radians (use htor() if you 0010 % want to pass RA as a hh:mm:ss.s string) 0011 % 0012 % deccenter -- The center pointing DEC, in radians (use dtor() if you 0013 % want to pass DEC as a dd:mm:ss.s string) 0014 % 0015 % lside -- The pointing separation, in arcminutes 0016 % 0017 % nx -- The half-width of the hex grid. An integral number of 0018 % pointings, spaced along a great circle tangential to the 0019 % center DEC ring. 0020 % 0021 % ny -- The half-width of the hex grid. An integral number of 0022 % pointings, spaced along a great circle passing through the 0023 % center RA and the poles 0024 % 0025 % Example: 0026 % 0027 % [ra, dec] = gethex(htor('03:00:00'), dtor('45:00:00'), 600, 1, 1); 0028 % 0029 % would return the seven ra, dec pointing ceters for a simple hex, 0030 % centered on 3h, 45d, spaced by 10 degrees. 0031 0032 0033 % Convert the spacing from arcminutes to radians 0034 0035 lside = lside*60.0/206265; 0036 0037 % Draw a globe 0038 0039 globe; 0040 0041 % Get the hexgrid in a coordinate system centered on the pointing position 0042 0043 xyz = hexgrid(lside, nx, ny); 0044 res = zeros(size(xyz)); 0045 0046 % Calculate the rotation matrices needed to rotate into the coordinate 0047 % system aligned with the celestial pole 0048 0049 rotMat = rot(racenter, deccenter); 0050 0051 for it=1:size(xyz,2) 0052 res(:,it) = rotMat * xyz(:, it); 0053 end 0054 0055 % Plot 'em 0056 0057 plot3(res(1,:),res(2,:),res(3,:), 'c.') 0058 0059 % Now we have xyz coordinates for the pointing centers. Convert back 0060 % to RA and DEC in radians 0061 0062 dec = asin(res(3,:)); 0063 ra = atan2(res(2,:), res(1,:)); 0064 0065 for iRa=1:size(ra,2) 0066 while(ra(iRa) < 0) 0067 ra(iRa) = ra(iRa) + 2*pi; 0068 end 0069 end