Home > scans > generate > makeSourceScan.m

makeSourceScan

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function makeSourceScan(azrange, elrange, scanParams, outfile)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  function makeScan(azrange, elval, scanParams, outFile)

    azrange is range of full scan in degrees ([minaz, maxaz]);
    elval is the fixed elevation value
    scanParams = [azVelocity, maxAccel, elStep];
       where azVelocity is the velocity during the scan
             maxAccel is the maximum allowed acceleration

    outFile is scan file name.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function makeSourceScan(azrange, elrange, scanParams, outfile)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function makeScan(azrange, elval, scanParams, outFile)
0006 %
0007 %    azrange is range of full scan in degrees ([minaz, maxaz]);
0008 %    elval is the fixed elevation value
0009 %    scanParams = [azVelocity, maxAccel, elStep];
0010 %       where azVelocity is the velocity during the scan
0011 %             maxAccel is the maximum allowed acceleration
0012 %
0013 %    outFile is scan file name.
0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0015 
0016 % define some things:
0017 azVel = scanParams(1);
0018 azAcc = scanParams(2);
0019 elStep= scanParams(3);
0020 
0021 % first let's figure out how long it takes for each turnaround.
0022 turnTime = abs(azVel/azAcc);
0023 % just to be safe, let's multiply it by 50%
0024 turnTime = ceil(turnTime*1.5);
0025 
0026 azVals = [];
0027 
0028 % first the startup:
0029 azStart(1) = 0;
0030 azVels(1) = 0;
0031 for m=1:turnTime
0032   prevAz = azStart(m);
0033   newVel = azVels(m) + azAcc;
0034   if(newVel> azVel)
0035     newVel = azVel;
0036   end
0037   newAz = prevAz + newVel;  % since we get a loc every second, this is easy
0038   
0039   azStart = [azStart; newAz];
0040   azVels = [azVels; newVel];
0041 end
0042 azStart = azStart - max(azStart) + azrange(1);
0043 % allow at least 10 seconds to get there.
0044 toGetThere = ones(10,1)*azStart(1);
0045 
0046 % now we apply the body to the scan.
0047 azBody = azrange(1):azVel:azrange(2);
0048 % first entry is repeated in last entry of start:
0049 % last entry repeated in first of stop
0050 azBody(1) = [];
0051 azBody(length(azBody)) = [];
0052 azBody = azBody';
0053 
0054 % now we stop.
0055 azStop(1) = azrange(2);
0056 for m=1:turnTime
0057   prevAz = azStop(m);
0058   newAz = prevAz + azVels(length(azVels)-m+1);
0059   
0060   azStop = [azStop; newAz];
0061 end
0062 
0063 stopTime = length(azStop)-1;
0064 
0065 
0066 % now we combine them all:
0067 azVals = [azStart; azBody; azStop];
0068 
0069 % add the going back.
0070 azVals = [azVals; reverseVector(azStop); reverseVector(azBody); reverseVector(azStart)];
0071 
0072 % now we have to repeat this for a every single value of the elevation.
0073 elRows = elrange(1):elStep:elrange(2);
0074 
0075 elVals = ones(size(azVals))*elRows(1);
0076 
0077 azValsFin = [];
0078 elValsFin = [];
0079 for m=1:length(elRows)
0080   if(m==1)
0081     azValsFin = [toGetThere; azVals];
0082     elValsFin = [ones(size(toGetThere))*elRows(m); ones(size(azVals))*elRows(m)];
0083   else 
0084     azValsFin = [azValsFin; azVals];
0085     elValsFin = [elValsFin; ones(size(azVals))*elRows(m)];
0086   end
0087   
0088   if(m ~= length(elRows))
0089     elValsFin(length(elValsFin)-stopTime+1:length(elValsFin)) = elRows(m+1);
0090   end
0091 end
0092 
0093 daVals = zeros(size(elValsFin));
0094 
0095 index = 0:1:(length(azValsFin)-1);
0096 
0097 % now we make the file:
0098 fid = fopen(outfile, 'w');
0099 fprintf(fid, 'MSPERSAMPLE 1000\n');
0100 for m=1:length(index)
0101   fprintf(fid, '%d \t %3.8f \t %3.3f \t 0\n', index(m), azValsFin(m), elValsFin(m));
0102 end
0103 fclose(fid);
0104 
0105 
0106 return;
0107 
0108 
0109 
0110 function revVec = reverseVector(vec)
0111 
0112 revVec = zeros(size(vec));
0113 
0114 for m=1:length(vec)
0115   revVec(m) = vec(length(vec)-m+1);
0116 end
0117 
0118 return;

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