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