%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function d = read_arcSouthColdLoad(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 'antenna0.roach1.LL double',... 0028 'antenna0.roach1.RR double',... 0029 'antenna0.roach1.load1 double',... 0030 'antenna0.roach1.load2 double',... 0031 'antenna0.roach1.utc double',... 0032 'antenna0.roach1.ntpSeconds double',... 0033 'antenna0.roach1.ntpUSeconds double',... 0034 'antenna0.roach1.fpgaClockStamp double',... 0035 'antenna0.roach2.fpgaClockStamp double',... 0036 'antenna0.roach2.LL double',... 0037 'antenna0.roach2.RR double',... 0038 'antenna0.roach2.load1 double',... 0039 'antenna0.roach2.load2 double',... 0040 'antenna0.roach2.utc double',... 0041 'antenna0.roach2.ntpSeconds double',... 0042 'antenna0.roach2.ntpUSeconds double',... 0043 'antenna0.thermal.ccTemperatureLoad double',... 0044 'antenna0.thermal.utc double',... 0045 'antenna0.servo.utc double',... 0046 'antenna0.servo.ntpSecond double',... 0047 'antenna0.servo.ntpUSecond double',... 0048 'antenna0.servo.fast_az_pos double',... 0049 'antenna0.servo.fast_el_pos double',... 0050 'antenna0.servo.fast_az_err double',... 0051 'antenna0.servo.fast_el_err double',... 0052 }; 0053 end 0054 0055 % Ensure regs unique 0056 if(any(size(unique(regs))~=size(regs))) 0057 error('regs should be unique'); 0058 end 0059 0060 % Here we want to have the function know which directory to look for the 0061 % data depending on the machine name. 0062 [defaultDataDir defaultCalFile defaultReaderPath] = whichHostSa(); 0063 0064 if(isempty(arcdir)) 0065 0066 arcdir = defaultDataDir; 0067 end 0068 if(isempty(calfile)) 0069 calfile = defaultCalFile; 0070 end 0071 0072 eval(sprintf('addpath %s', defaultReaderPath)); 0073 0074 % let's get the previous 5 seconds and post 5 seconds, and then cut it down 0075 % to the right size. 0076 mjdstartorig = tstr2mjd(start); 0077 mjdstart = mjdstartorig - 5/60/60/24; 0078 mjdstoporig = tstr2mjd(finish); 0079 mjdstop = mjdstoporig + 5/60/60/24; 0080 0081 %display('cbassMatReadArcOpt') 0082 d = cbassMatReadArcOpt(regs, mjd2string(mjdstart), mjd2string(mjdstop), arcdir, calfile); 0083 0084 0085 %display('MassageData') 0086 %d = massageDataSa(d); 0087 %display('reshapeResgister'); 0088 % reshape the registers 0089 d = reshapeRegisters(d); 0090 %display('interpRegisters'); 0091 %%%%%d = ntpTimeAdjustSouth(d); 0092 % interpolate as needed. 0093 %%%%%d = interpRegistersSa(d,1); %second flag==1 means use NTP time 0094 %display('cut Desired Date'); 0095 % cut to the desired data 0096 %d = apparentAzElSouth(d); 0097 0098 %d = determineIndicesSouth(d); 0099 %d = cutDesiredData(d, mjdstartorig, mjdstoporig); 0100 %display('here') 0101 return; 0102 0103 % update the separate functions 0104 %function [defaultDataDir defaultCalfile defaultReader] = whichHost() 0105 % 0106 %% Here we want to have the function know which directory to look for the 0107 %% data depending on the machine name. 0108 %% For simplicity, we assign numbers to each hostname as follows: 0109 %% 0 - cbasscontrol (OVRO) 0110 %% 1 - haggis (CALTECH) 0111 %% 2 - falcon (MANCHESTER) 0112 %% 3 - aslx10 (OXFORD) 0113 %% 4 - asosx48 (OXFORD) 0114 %% 5 - asosx39 (OXFORD) 0115 %% 6 - aslx2 (OXFORD) 0116 %% 7 - pravda (Oliver) 0117 % 0118 %[s w] = unix('hostname'); 0119 % 0120 %hostNum = nan; 0121 % 0122 %% check for cbasscontrol 0123 %host = strfind(w, 'cbasscontrol'); 0124 %if(~isempty(host)) 0125 % hostNum = 0; 0126 % defaultDataDir = '/mnt/data/cbass/arc'; 0127 % defaultCalfile = '/home/cbass/gcpCbass/control/conf/cbass/cal'; 0128 % defaultReader = '/home/cbass/gcpCbass/matlab/common/'; 0129 %end 0130 % 0131 %% check for haggis 0132 %host = strfind(w, 'haggis'); 0133 %if(~isempty(host)) 0134 % hostNum = 1; 0135 % defaultDataDir = '/scr/cbassarc/data/arc'; 0136 % defaultCalfile = '/home/cbassuser/cbass/gcpCbass/control/conf/cbass/cal'; 0137 % defaultReader = '/home/cbassuser/cbass/gcpCbass/matlab/common/'; 0138 %end 0139 % 0140 %% check for falcon 0141 %host = strfind(w, 'falcon'); 0142 %if(~isempty(host)) 0143 % hostNum = 2; 0144 % defaultDataDir = '/scratch/falcon_4/cdickins/cbass/cbassarc/data/arc'; 0145 % defaultCalfile = '/home/muchovej/cbass/gcpCbass/control/conf/cbass/cal'; 0146 % defaultReader = '/home/muchovej/cbass/gcpCbass/matlab/common/'; 0147 %end 0148 % 0149 %% check for aslx 0150 %host = strfind(w, 'aslx10'); 0151 %if(~isempty(host)) 0152 % hostNum = 3; 0153 % defaultDataDir = '/data/cbassuser/data/arc'; 0154 % defaultCalfile = '/home/Muchovej/cbass/gcpCbass/control/conf/cbass/cal'; 0155 % defaultReader = '/home/Muchovej/cbass/gcpCbass/matlab/common/'; 0156 %end 0157 % 0158 %% check for asosx48 0159 %host = strfind(w, 'asosx48'); 0160 %if(~isempty(host)) 0161 % hostNum = 4; 0162 %defaultDataDir = '/Volumes/Data2/CBASS_ARC'; 0163 %%defaultDataDir = '/Volumes/C-BASS-1'; 0164 %%defaultDataDir = '/Volumes/C-BASS/data'; 0165 % 0166 %defaultCalfile = '/Users/taylorA/CBASS/cbass/gcpCbass/control/conf/cbass/cal'; 0167 %defaultReader = '/Users/taylorA/CBASS/cbass/gcpCbass/matlab/common/'; 0168 %end 0169 % 0170 %% check for pravda 0171 %host = strfind(w, 'pravda'); 0172 %if(~isempty(host)) 0173 % hostNum = 7; 0174 % defaultDataDir = '/Volumes/DATA/cbass/arc'; 0175 % defaultCalfile = '/Users/oliver/C-BASS/software/cbass/gcpCbass/control/conf/cbass/cal'; 0176 % defaultReader = '/Users/oliver/C-BASS/software/cbass/gcpCbass/matlab/common/'; 0177 %end 0178 % 0179 %host = strfind(w, 'asosx39'); 0180 %if(~isempty(host)) 0181 % hostNum = 5; 0182 %defaultDataDir = '/Volumes/My Book/zuntz/cbass/arc'; 0183 %defaultCalfile = '/Users/zuntz/src/cbass/cbass/gcpCbass/control/conf/cbass/cal'; 0184 %defaultReader = '/Users/zuntz/src/cbass/cbass/gcpCbass/matlab/common/'; 0185 %end 0186 % 0187 %host = strfind(w, 'aslx2'); 0188 %if(~isempty(host)) 0189 % hostNum = 6; 0190 %defaultDataDir = '/home/jxl/cbass_data/arc'; 0191 %defaultCalfile = '/home/jxl/cbass/gcpCbass/control/conf/cbass/cal'; 0192 %defaultReader = '/home/jxl/cbass/gcpCbass/matlab/common/'; 0193 %end 0194 % 0195 host = strfind(w, 'aslx5'); 0196 if(~isempty(host)) 0197 hostNum = 7; 0198 defaultDataDir = '/home/cbassuser/cbass_data/arc'; 0199 defaultCalfile = '/home/cbassuser/cbass/gcpCbass/control/conf/cbass/cal'; 0200 defaultReader = '/home/cbassuser/cbass/gcpCbass/matlab/common/'; 0201 end 0202 % 0203 % 0204 % 0205 %if(isnan(hostNum)) 0206 % error('Can not match your host name to a recognized one'); 0207 % error('Update read_arc.m to reflect your host'); 0208 %end 0209 % 0210 %return; 0211 0212 0213 0214 0215 % cut to the desired data 0216 function d = cutDesiredData(d, mjdstartorig, mjdstoporig) 0217 0218 if(~isfield(d, 'array')) 0219 return; 0220 end 0221 0222 if(~isfield(d, 'antenna0')) 0223 return; 0224 end 0225 0226 if(issubfield(d.antenna0, 'receiver', 'utc')) 0227 indFast = d.antenna0.receiver.utc>=mjdstartorig & ... 0228 d.antenna0.receiver.utc<mjdstoporig; 0229 noRx = 0; 0230 else 0231 indFast = ones(length(d.array.frame.utc)*100,1); 0232 indFast = logical(indFast); 0233 noRx = 1; 0234 end 0235 0236 if(isfield(d.antenna0, 'servo')) 0237 indMed = d.antenna0.servo.utc>=mjdstartorig & ... 0238 d.antenna0.servo.utc<mjdstoporig; 0239 noServo = 0; 0240 else 0241 indMed = ones(length(d.array.frame.utc)*5,1); 0242 indMed = logical(indMed); 0243 noServo = 1; 0244 end 0245 0246 indSlow = d.array.frame.utc>=mjdstartorig & d.array.frame.utc<mjdstoporig; 0247 0248 0249 indF = reshape(indFast, [5 20 length(indSlow)]); 0250 indF = permute(indF, [3 1 2]); 0251 indFs = mean(mean(indF,3),2)==1; 0252 0253 indM = reshape(indMed, [5 length(indSlow)]); 0254 indM = permute(indM, [2 1]); 0255 indMs = mean(indM,2)==1; 0256 0257 ind = indMs & indFs & indSlow; 0258 0259 % these are the real ind on the slow scale. now we up it to the longer 0260 % scales -- already done in framecut. 0261 0262 d = framecut(d, ind, 'regular'); 0263 0264 return; 0265