Home > lukes_code > readArcCompare > read_arcSouthLL.m

read_arcSouthLL

PURPOSE ^

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

SYNOPSIS ^

function d = read_arcSouth(start, finish, regs, arcdir, calfile)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  function d = read_arc(start, finish, regs, arcdir, calfile)

 start/finish=start finish times as strings with format e.g.:
 01-Jan-2005:00:00:00
 optional regs=regs to extract if other than the standard set
 optional arcdir=directory containing archive files
 optional calfile=cal file

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function d = read_arcSouth(start, finish, regs, arcdir, calfile)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %  function d = read_arc(start, finish, regs, arcdir, calfile)
0005 %
0006 % start/finish=start finish times as strings with format e.g.:
0007 % 01-Jan-2005:00:00:00
0008 % optional regs=regs to extract if other than the standard set
0009 % optional arcdir=directory containing archive files
0010 % optional calfile=cal file
0011 %
0012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0013 
0014 if(~exist('regs'))
0015     regs=[];
0016 end
0017 if(~exist('arcdir'))
0018   arcdir=[];
0019 end
0020 if(~exist('calfile'))
0021   calfile=[];
0022 end
0023 
0024 if(isempty(regs))
0025   regs={'array.frame.received'...
0026       'array.frame.utc double',...
0027       'array.frame.features',...
0028       'antenna0.roach1.LLfreq double',...
0029       'antenna0.roach1.RR double',...
0030       'antenna0.roach1.RRfreq double',...
0031       'antenna0.roach1.U double',...
0032       'antenna0.roach1.Ufreq double',...
0033        'antenna0.roach1.Utime double',...
0034       'antenna0.roach1.Q double',...
0035       'antenna0.roach1.Qfreq double',...
0036       'antenna0.roach1.Qtime double',...
0037       'antenna0.roach1.load1 double',...
0038       'antenna0.roach1.load1freq double',...
0039       'antenna0.roach1.load2 double',...
0040       'antenna0.roach1.load2freq double',...
0041       'antenna0.roach1.utc double',...
0042       'antenna0.roach1.intCount double',...
0043       'antenna0.roach1.ntpSeconds double',...
0044       'antenna0.roach1.ntpUSeconds double',...
0045       'antenna0.roach1.fpgaClockStamp double',...
0046       'antenna0.roach2.fpgaClockStamp double',...
0047       'antenna0.roach2.LL double',...
0048       'antenna0.roach2.LLfreq double',...
0049       'antenna0.roach2.RR double',...
0050       'antenna0.roach2.RRfreq double',...
0051       'antenna0.roach2.U double',...
0052       'antenna0.roach2.Ufreq double',...
0053       'antenna0.roach2.Utime double',...
0054       'antenna0.roach2.Q double',...
0055       'antenna0.roach2.Qfreq double',...
0056       'antenna0.roach2.Qtime double',...
0057       'antenna0.roach2.load1 double',...
0058       'antenna0.roach2.load1freq double',...
0059       'antenna0.roach2.load2 double',...
0060       'antenna0.roach2.load2freq double',...
0061       'antenna0.roach2.utc double',...
0062       'antenna0.roach2.intCount double',...
0063       'antenna0.roach1.switchstatus double',...
0064       'antenna0.roach2.switchstatus double',...
0065       'antenna0.roach2.ntpSeconds double',...
0066       'antenna0.roach2.ntpUSeconds double',...
0067       'antenna0.thermal.ccTemperatureLoad double',...
0068       'antenna0.thermal.ccHeaterCurrent double',...
0069       'antenna0.thermal.lsTemperatureSensors double',...
0070       'antenna0.thermal.utc double',...
0071       'antenna0.roach1.version double',...
0072       'antenna0.servo.fast_az_pos double',...
0073       'antenna0.servo.fast_el_pos double',...
0074       'antenna0.servo.fast_az_err double',...
0075       'antenna0.servo.fast_el_err double',...
0076       'antenna0.servo.utc double',...
0077     'antenna0.servo.ntpSecond double',...
0078     'antenna0.servo.ntpUSecond double',...
0079       'antenna0.tracker.lst double',...
0080     'antenna0.tracker.lacking double',...
0081     'antenna0.tracker.equat_geoc double',...
0082     'antenna0.tracker.horiz_topo double',...
0083     'antenna0.tracker.horiz_mount double',...
0084     'antenna0.tracker.flexure double',...
0085     'antenna0.tracker.horiz_off double',...
0086     'antenna0.tracker.tilts double',...
0087     'antenna0.tracker.fixedCollimation double',...
0088     'antenna0.tracker.encoder_off double',...
0089     'antenna0.tracker.sky_xy_off double',...
0090     'antenna0.tracker.source string',...
0091     'antenna0.tracker.scan_off double',...
0092     'antenna0.tracker.refraction double',...
0093     'antenna0.tracker.ut1utc double',...
0094     'antenna0.tracker.eqneqx double',...
0095     'antenna0.tracker.utc double',...
0096     'antenna0.tracker.time_diff double',...
0097     'antenna0.tracker.offSource double',...
0098     'antenna0.tracker.siteActual double',...
0099     'antenna0.tracker.siteFiducial double',...
0100     'array.weather.airTemperature double',...
0101     'array.weather.pressure double',...
0102     'array.weather.relativeHumidity double',...
0103     
0104   };
0105 end
0106 
0107 % Ensure regs unique
0108   if(any(size(unique(regs))~=size(regs)))
0109     error('regs should be unique');
0110 end
0111 
0112 % Here we want to have the function know which directory to look for the
0113 % data depending on the machine name.
0114 [defaultDataDir defaultCalFile defaultReaderPath] = whichHostSa();
0115 
0116 if(isempty(arcdir))
0117 
0118   arcdir = defaultDataDir;
0119 end
0120 if(isempty(calfile))
0121   calfile = defaultCalFile;
0122 end
0123 
0124 eval(sprintf('addpath %s', defaultReaderPath));
0125 
0126 % let's get the previous 5 seconds and post 5 seconds, and then cut it down
0127 % to the right size.
0128 mjdstartorig = tstr2mjd(start);
0129 mjdstart = mjdstartorig - 5/60/60/24;
0130 mjdstoporig  = tstr2mjd(finish);
0131 mjdstop  = mjdstoporig  + 5/60/60/24;
0132 
0133 %display('cbassMatReadArcOpt')
0134 d = cbassMatReadArcOpt(regs, mjd2string(mjdstart), mjd2string(mjdstop), arcdir, calfile);
0135 
0136 
0137 %display('MassageData')
0138 d = massageDataSa(d);
0139 %display('reshapeResgister');
0140 % reshape the registers
0141 d = reshapeRegisters(d);
0142 %display('interpRegisters');
0143 d = ntpTimeAdjustSouth(d);
0144 % interpolate as needed.
0145 d = interpRegistersSa(d,1); %second flag==1 means use NTP time
0146 %display('cut Desired Date');
0147 % cut to the desired data
0148 d = apparentAzElSouth(d);
0149 
0150 d = determineIndicesSouth(d);
0151 %d = cutDesiredData(d, mjdstartorig, mjdstoporig);
0152 %display('here')
0153 return;
0154 
0155 % update the separate functions
0156 %function [defaultDataDir defaultCalfile defaultReader] = whichHost()
0157 %
0158 %% Here we want to have the function know which directory to look for the
0159 %% data depending on the machine name.
0160 %% For simplicity, we assign numbers to each hostname as follows:
0161 %% 0 - cbasscontrol  (OVRO)
0162 %% 1 - haggis  (CALTECH)
0163 %% 2 - falcon  (MANCHESTER)
0164 %% 3 - aslx10  (OXFORD)
0165 %% 4 - asosx48 (OXFORD)
0166 %% 5 - asosx39 (OXFORD)
0167 %% 6  - aslx2   (OXFORD)
0168 %% 7  - pravda  (Oliver)
0169 %
0170 %[s w] = unix('hostname');
0171 %
0172 %hostNum = nan;
0173 %
0174 %% check for cbasscontrol
0175 %host = strfind(w, 'cbasscontrol');
0176 %if(~isempty(host))
0177 %  hostNum = 0;
0178 %  defaultDataDir = '/mnt/data/cbass/arc';
0179 %  defaultCalfile = '/home/cbass/gcpCbass/control/conf/cbass/cal';
0180 %  defaultReader  = '/home/cbass/gcpCbass/matlab/common/';
0181 %end
0182 %
0183 %% check for haggis
0184 %host = strfind(w, 'haggis');
0185 %if(~isempty(host))
0186 %  hostNum = 1;
0187 %  defaultDataDir = '/scr/cbassarc/data/arc';
0188 %  defaultCalfile = '/home/cbassuser/cbass/gcpCbass/control/conf/cbass/cal';
0189 %  defaultReader  = '/home/cbassuser/cbass/gcpCbass/matlab/common/';
0190 %end
0191 %
0192 %% check for falcon
0193 %host = strfind(w, 'falcon');
0194 %if(~isempty(host))
0195 %  hostNum = 2;
0196 %  defaultDataDir = '/scratch/falcon_4/cdickins/cbass/cbassarc/data/arc';
0197 %  defaultCalfile = '/home/muchovej/cbass/gcpCbass/control/conf/cbass/cal';
0198 %  defaultReader  = '/home/muchovej/cbass/gcpCbass/matlab/common/';
0199 %end
0200 %
0201 %% check for aslx
0202 %host = strfind(w, 'aslx10');
0203 %if(~isempty(host))
0204 %  hostNum = 3;
0205 %  defaultDataDir = '/data/cbassuser/data/arc';
0206 %  defaultCalfile = '/home/Muchovej/cbass/gcpCbass/control/conf/cbass/cal';
0207 %  defaultReader  = '/home/Muchovej/cbass/gcpCbass/matlab/common/';
0208 %end
0209 %
0210 %% check for asosx48
0211 %host = strfind(w, 'asosx48');
0212 %if(~isempty(host))
0213 %  hostNum = 4;
0214 %defaultDataDir = '/Volumes/Data2/CBASS_ARC';
0215 %%defaultDataDir = '/Volumes/C-BASS-1';
0216 %%defaultDataDir = '/Volumes/C-BASS/data';
0217 %
0218 %defaultCalfile = '/Users/taylorA/CBASS/cbass/gcpCbass/control/conf/cbass/cal';
0219 %defaultReader  = '/Users/taylorA/CBASS/cbass/gcpCbass/matlab/common/';
0220 %end
0221 %
0222 %% check for pravda
0223 %host = strfind(w, 'pravda');
0224 %if(~isempty(host))
0225 %  hostNum = 7;
0226 %  defaultDataDir = '/Volumes/DATA/cbass/arc';
0227 %  defaultCalfile = '/Users/oliver/C-BASS/software/cbass/gcpCbass/control/conf/cbass/cal';
0228 %  defaultReader  = '/Users/oliver/C-BASS/software/cbass/gcpCbass/matlab/common/';
0229 %end
0230 %
0231 %host = strfind(w, 'asosx39');
0232 %if(~isempty(host))
0233 %  hostNum = 5;
0234 %defaultDataDir = '/Volumes/My Book/zuntz/cbass/arc';
0235 %defaultCalfile = '/Users/zuntz/src/cbass/cbass/gcpCbass/control/conf/cbass/cal';
0236 %defaultReader  = '/Users/zuntz/src/cbass/cbass/gcpCbass/matlab/common/';
0237 %end
0238 %
0239 %host = strfind(w, 'aslx2');
0240 %if(~isempty(host))
0241 %  hostNum = 6;
0242 %defaultDataDir = '/home/jxl/cbass_data/arc';
0243 %defaultCalfile = '/home/jxl/cbass/gcpCbass/control/conf/cbass/cal';
0244 %defaultReader  = '/home/jxl/cbass/gcpCbass/matlab/common/';
0245 %end
0246 %
0247 host = strfind(w, 'aslx5');                                                     
0248 if(~isempty(host))
0249  hostNum = 7; 
0250 defaultDataDir = '/home/cbassuser/cbass_data/arc';
0251 defaultCalfile = '/home/cbassuser/cbass/gcpCbass/control/conf/cbass/cal';
0252 defaultReader  = '/home/cbassuser/cbass/gcpCbass/matlab/common/';
0253 end                                                                                                                                                    
0254 %
0255 %
0256 %
0257 %if(isnan(hostNum))
0258 %  error('Can not match your host name to a recognized one');
0259 %  error('Update read_arc.m to reflect your host');
0260 %end
0261 %
0262 %return;
0263 
0264 
0265 
0266 
0267 % cut to the desired data
0268 function d = cutDesiredData(d, mjdstartorig, mjdstoporig)
0269 
0270 if(~isfield(d, 'array'))
0271   return;
0272 end
0273 
0274 if(~isfield(d, 'antenna0'))
0275   return;
0276 end
0277 
0278 if(issubfield(d.antenna0, 'receiver', 'utc'))
0279   indFast = d.antenna0.receiver.utc>=mjdstartorig & ...
0280       d.antenna0.receiver.utc<mjdstoporig;
0281   noRx = 0;
0282 else
0283   indFast = ones(length(d.array.frame.utc)*100,1);
0284   indFast = logical(indFast);
0285   noRx = 1;
0286 end
0287 
0288 if(isfield(d.antenna0, 'servo'))
0289   indMed  = d.antenna0.servo.utc>=mjdstartorig & ...
0290       d.antenna0.servo.utc<mjdstoporig;
0291   noServo = 0;
0292 else
0293   indMed = ones(length(d.array.frame.utc)*5,1);
0294   indMed = logical(indMed);
0295   noServo = 1;
0296 end
0297 
0298 indSlow = d.array.frame.utc>=mjdstartorig & d.array.frame.utc<mjdstoporig;
0299 
0300 
0301 indF = reshape(indFast, [5 20 length(indSlow)]);
0302 indF = permute(indF, [3 1 2]);
0303 indFs = mean(mean(indF,3),2)==1;
0304 
0305 indM = reshape(indMed, [5 length(indSlow)]);
0306 indM = permute(indM, [2 1]);
0307 indMs = mean(indM,2)==1;
0308 
0309 ind  = indMs & indFs & indSlow;
0310 
0311 % these are the real ind on the slow scale.  now we up it to the longer
0312 % scales -- already done in framecut.
0313 
0314 d = framecut(d, ind, 'regular');
0315 
0316 return;
0317

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