Home > reduc > read_arcSouth.m

read_arcSouth

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

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