Home > pointing > rad_set.m

rad_set

PURPOSE ^

function rad_set(lststart,lstspace, lstfinish)

SYNOPSIS ^

function rad_set(lststart, lstspace, lstfinish, fluxLim, filename)

DESCRIPTION ^

 function rad_set(lststart,lstspace, lstfinish)

 Plot the range of elevations and az of a list of sources in rad_sources.cat
 visible starting at lststart and spaced at lstspace intervals (the
 time it takes to do one cross)

 Use lst>24 here-program will take care of it

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function rad_set(lststart, lstspace, lstfinish, fluxLim, filename)
0002 % function rad_set(lststart,lstspace, lstfinish)
0003 %
0004 % Plot the range of elevations and az of a list of sources in rad_sources.cat
0005 % visible starting at lststart and spaced at lstspace intervals (the
0006 % time it takes to do one cross)
0007 %
0008 % Use lst>24 here-program will take care of it
0009 
0010 clf
0011 lat=37;       % Latitude of the site
0012 d2r=pi/180; r2d=180/pi;
0013 ellim=25;   % elevation limit below which we don't look
0014   
0015 % Initialize plot
0016 figure(2)
0017 clf
0018 polar(10,91)
0019 hold on
0020 view(-90,90)
0021 
0022 % Default lststart is 0
0023 if (~exist('lststart'))
0024   lststart=0;
0025 end
0026 
0027 % default is to run for 12 hours
0028 if (~exist('lstfinish'))
0029   lstfinish=lststart+12;
0030 end
0031 
0032 % Default lstspace is half hour
0033 if (~exist('lstspace'))
0034   lstspace=0.25;
0035 end
0036 
0037 % Read sources in-num is how many sources are in catalog
0038 [names,flux, ra ,dec]=textread(filename,'%s %f %s %s %*s\n','commentstyle','matlab');
0039 
0040 % add a + for positive declination
0041 for i=1:size(ra,1)
0042   if ~strcmp( dec{i}(1),'-')
0043     if ~strcmp( dec{i}(1), '+')
0044       dec{i}=['+',dec{i}];
0045     end
0046   end
0047 end
0048 
0049 ind = flux>fluxLim;
0050 names = names(ind);
0051 flux = flux(ind);
0052 ra = ra(ind);
0053 dec = dec(ind);
0054 
0055 
0056     
0057 num=length(ra);
0058 disp(sprintf('%1f sources read',num))
0059 
0060 
0061 % Convert to fractional degrees
0062 [ra,dec]=ast2fracdeg(ra,dec);
0063 % Convert input params in degrees and hours to radians
0064 lat=lat*d2r;
0065 dec=dec*d2r;
0066 
0067 % Loop through lst range
0068 for lstp=lststart:lstspace:lstfinish
0069 % keep lstp in normal range
0070   if lstp>24
0071     lst=lstp-24;
0072   else 
0073     lst=lstp;
0074   end
0075   
0076   % Hour angle is defined as lst minus ra, here given in degrees
0077   ha=lst*ones(num,1)-ra/15;
0078   ha=15*ha*d2r; 
0079 
0080   % Generate az, el for sources at this lst
0081   cat.name=names;
0082   cat.flux=flux;
0083   [cat.az,cat.el]=hdl2ae(ha,dec,lat);
0084   cat.az=cat.az*r2d; cat.el=cat.el*r2d;
0085   
0086   % Only interested in sources higher than 15 degrees
0087   ind=cat.el>ellim;
0088   cat=structcut(cat,ind);
0089   ind=cat.flux>fluxLim;
0090   cat=structcut(cat,ind);
0091   
0092   % If it's the first source, take the first object
0093   % Otherwise look for the object furthest from the already observed
0094   % sources
0095   if (lst==lststart)
0096     nextsource=1;
0097     obs.az=cat.az(1);
0098     obs.el=cat.el(1);
0099   else
0100     % Method=2 means next source is the one with the furthest nearest
0101     % neighbor (think about it)
0102     nextsource=neighbor(obs,cat);
0103     
0104     % Extend obs to hold the new point
0105     obs.az=[obs.az;cat.az(nextsource)];
0106     obs.el=[obs.el;cat.el(nextsource)];
0107   end
0108   
0109   %    disp(sprintf('%8s,',cat.name{nextsource}))
0110   disp(sprintf('{%8s, %2.2f, %2.2f},',cat.name{nextsource},lst, cat.flux(nextsource)))
0111   polar(d2r*cat.az(nextsource),90-cat.el(nextsource),'ob')
0112   
0113 end
0114 
0115 return
0116 
0117 
0118 function [nextsource]=furthest(obs,cat)
0119 % function [nextsource]=furthest(obs,cat)
0120 %
0121 % nextsource is the index of the source in cat(az,el) that maximizes the
0122 % sum of space angles to already observed sources in obs(az,el)
0123 
0124 % sumsa is the sum of the space angles to all observed sources
0125 sumsa=zeros(length(cat.az),1);
0126 for k=1:length(obs.az)
0127   % Space ANgle between kth already observed source and all cat
0128   % sources
0129   ob.az=obs.az(k)*ones(length(cat.az),1);
0130   ob.el=obs.el(k)*ones(length(cat.az),1);
0131   sa=spaceangle(ob.az,ob.el,cat.az,cat.el);
0132   sumsa=sumsa+sa;
0133 end
0134 
0135 [mx,nextsource]=max(sumsa);
0136 return
0137 
0138 function [nextsource]=neighbor(obs,cat)
0139 % function [nextsource]=neighbor(obs,cat)
0140 %
0141 % nextsource is the index of the source that has the largest value of
0142 % the distance to its nearest neighbor among points already observed
0143 nearest=zeros(length(cat.az),1);
0144 
0145 for k=1:length(cat.az)
0146   % Find space angle between every observed source and this option for
0147   % the next source and take nearest neighbor
0148   el=cat.el(k)*ones(length(obs.el),1);
0149   az=cat.az(k)*ones(length(obs.az),1);
0150   sa=spaceangle(az,el,obs.az,obs.el);
0151   nearest(k,1)=min(sa);
0152 end
0153 
0154 % Choose the source with the largest nearest neighbor distance
0155 [mx,nextsource]=max(nearest);
0156 
0157 return

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005