Home > constants > getPointingModel.m

getPointingModel

PURPOSE ^

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

SYNOPSIS ^

function [fullmodel] = getPointingModel(d)

DESCRIPTION ^

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

  function [fullmodel] = getPointingModel(d)


   function that reads an ASCII text file on pointing models, and
   determines which pointing model to use for that data set.

   if a data set spans day/night, it checks which one is longest, and if
   it's not a clear majority (65% or more), it'll check hysterisis.  

   sjcm

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fullmodel] = getPointingModel(d)
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 %  function [fullmodel] = getPointingModel(d)
0005 %
0006 %
0007 %   function that reads an ASCII text file on pointing models, and
0008 %   determines which pointing model to use for that data set.
0009 %
0010 %   if a data set spans day/night, it checks which one is longest, and if
0011 %   it's not a clear majority (65% or more), it'll check hysterisis.
0012 %
0013 %   sjcm
0014 %
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 % default poiting model (online one)
0018 fullmodel = [d.antenna0.tracker.flexure(1,:), d.antenna0.tracker.tilts(1,:), ...
0019       d.antenna0.tracker.fixedCollimation(1,:), ...
0020       d.antenna0.tracker.encoder_off(1,:) 0 0];
0021 
0022 % if it's the southern system, just return the online model.
0023 if(d.antenna0.tracker.siteFiducial(1,2,1) < 0)
0024   return;
0025 end
0026 
0027 %filename = 'constants/ptmodel_9term.txt';
0028 display('getPointingModel:: loading 11 parameter pointing model');
0029 filename = 'constants/ptmodel_11term.txt';
0030 
0031 
0032 % file is in form:
0033 %[starttime stoptime day/nighflag model parameters]
0034 point = load(filename);
0035 
0036 % first let's find out if we should be using day/night.
0037 [elsun azsun] = calcSunLoc(d);
0038 bindata=fitsread('constants/ovro_horizon.fits','bintable');
0039 az=wrap360(d.antenna0.servo.az);
0040 raz=round(60*az);
0041 raz(raz>=21600) = 0;
0042 horizonInf = bindata{:,2};
0043 horizonEl = horizonInf(raz+1)';
0044 daynight = length(find(elsun>(horizonEl+1) | elsun < (horizonEl-1)));
0045 dayfract = length(find(elsun>(horizonEl+1)))./daynight;
0046 nightfract = length(elsun < (horizonEl-1))./daynight;
0047 trackstart = mean(horizonEl(1:1000));
0048 
0049 
0050 if(dayfract>=0.65)
0051   useday = 1;
0052 elseif(nightfract<0.65) 
0053   useday = 0;
0054 else
0055   if(trackstart>=1)
0056     % transition, use hysterisis
0057     % started as daytime
0058     useday = 1;
0059   else  
0060     useday = 0;
0061   end
0062 end
0063 
0064 % next we find the model entry to use
0065 f = find(d.array.frame.utc(1) >= point(:,1) & ...
0066     d.array.frame.utc(1)<=point(:,2) & point(:,3)==useday);
0067 
0068 if(isempty(f))
0069   warning('Could not find a suitable pointing model, using default from TOD');
0070   fullmodel = fullmodel;
0071 else
0072   fullmodel = point(f,:);
0073   fullmodel(1:3) = [];
0074 end
0075 
0076 return;

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