Home > reduc > read_arc.m

read_arc

PURPOSE ^

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

SYNOPSIS ^

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

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_arc(start, finish, regs, arcdir, calfile, noswitch)
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(~exist('noswitch'))
0025   if(isempty(regs))
0026     regs={'array.frame.received'...
0027     'array.frame.utc double',...
0028     'array.frame.features',...
0029     'array.weather.utc double',...
0030     'array.weather.pressure double',...
0031     'array.weather.airTemperature double',...
0032     'array.weather.windSpeed[0] double',...
0033     'array.weather.windDirection[0] double',...
0034     'array.weather.status double',...
0035     'array.weather.relativeHumidity double',...
0036     'antenna0.thermal.ccHeaterCurrent double',...
0037     'antenna0.thermal.lsTemperatureSensors double',...
0038     'antenna0.thermal.ccTemperatureLoad double',...
0039     'antenna0.thermal.ccColdPlate double',...
0040     'antenna0.thermal.utc double',...
0041     'antenna0.thermal.dlpTemperatureSensors double',...
0042     'antenna0.tracker.lst double',...
0043     'antenna0.tracker.lacking double',...
0044     'antenna0.tracker.equat_geoc double',...
0045     'antenna0.tracker.horiz_topo double',...
0046     'antenna0.tracker.horiz_mount double',...
0047     'antenna0.tracker.flexure double',...
0048     'antenna0.tracker.horiz_off double',...
0049     'antenna0.tracker.tilts double',...
0050     'antenna0.tracker.fixedCollimation double',...
0051     'antenna0.tracker.encoder_off double',...
0052     'antenna0.tracker.sky_xy_off double',...
0053     'antenna0.tracker.source string',...
0054     'antenna0.tracker.scan_off double',...
0055     'antenna0.tracker.refraction double',...
0056     'antenna0.tracker.ut1utc double',...
0057     'antenna0.tracker.eqneqx double',...
0058     'antenna0.tracker.utc double',...
0059     'antenna0.tracker.time_diff double',...
0060     'antenna0.tracker.offSource double',...
0061     'antenna0.tracker.siteActual double',...
0062     'antenna0.tracker.siteFiducial double',...
0063     'antenna0.servo.utc double',...
0064     'antenna0.servo.slow_az_pos double',...
0065     'antenna0.servo.slow_el_pos double',...
0066     'antenna0.servo.az_ccw_soft_limit[0] double',...
0067     'antenna0.servo.fast_az_pos double',...
0068     'antenna0.servo.fast_el_pos double',...
0069     'antenna0.servo.fast_az_err double',...
0070     'antenna0.servo.fast_el_err double',...
0071     'antenna0.servo.command_current_az1[0] double',...
0072     'antenna0.servo.command_current_az2[0] double',...
0073     'antenna0.servo.command_current_el1[0] double',...
0074     'antenna0.servo.actual_current_az1[0] double',...
0075     'antenna0.servo.actual_current_az2[0] double',...
0076     'antenna0.servo.actual_current_el1[0] double',...
0077     'antenna0.servo.enable_status_az1',...
0078     'antenna0.servo.enable_status_az2',...
0079     'antenna0.servo.enable_status_el1',...
0080     'antenna0.frame.utc double',...
0081     'antenna0.frame.received double',...
0082     'antenna0.receiver.flags double',...
0083     'antenna0.receiver.utc double',...
0084     'antenna0.receiver.data double',...
0085     'antenna0.receiver.switchData double',...
0086     'antenna0.receiver.diagnostics double',...
0087     'antenna0.receiver.drainCurrent double',...
0088     'antenna0.receiver.drainVoltage double',...
0089     'antenna0.receiver.gateVoltage double',...
0090     'antenna0.receiver.avgSecond double',...
0091     };
0092   end
0093 else
0094   if(isempty(regs))
0095     regs={'array.frame.received'...
0096     'array.frame.utc double',...
0097     'array.frame.features',...
0098     'array.weather.utc double',...
0099     'array.weather.pressure double',...
0100     'array.weather.airTemperature double',...
0101     'array.weather.windSpeed[0] double',...
0102     'array.weather.windDirection[0] double',...
0103     'array.weather.status double',...
0104     'array.weather.relativeHumidity double',...
0105     'antenna0.thermal.ccHeaterCurrent double',...
0106     'antenna0.thermal.lsTemperatureSensors double',...
0107     'antenna0.thermal.ccTemperatureLoad double',...
0108     'antenna0.thermal.ccColdPlate double',...
0109     'antenna0.thermal.utc double',...
0110     'antenna0.thermal.dlpTemperatureSensors double',...
0111     'antenna0.tracker.lst double',...
0112     'antenna0.tracker.lacking double',...
0113     'antenna0.tracker.equat_geoc double',...
0114     'antenna0.tracker.horiz_topo double',...
0115     'antenna0.tracker.horiz_mount double',...
0116     'antenna0.tracker.flexure double',...
0117     'antenna0.tracker.horiz_off double',...
0118     'antenna0.tracker.tilts double',...
0119     'antenna0.tracker.fixedCollimation double',...
0120     'antenna0.tracker.encoder_off double',...
0121     'antenna0.tracker.sky_xy_off double',...
0122     'antenna0.tracker.source string',...
0123     'antenna0.tracker.scan_off double',...
0124     'antenna0.tracker.refraction double',...
0125     'antenna0.tracker.ut1utc double',...
0126     'antenna0.tracker.eqneqx double',...
0127     'antenna0.tracker.utc double',...
0128     'antenna0.tracker.time_diff double',...
0129     'antenna0.tracker.offSource double',...
0130     'antenna0.tracker.siteActual double',...
0131     'antenna0.tracker.siteFiducial double',...
0132     'antenna0.servo.utc double',...
0133     'antenna0.servo.slow_az_pos double',...
0134     'antenna0.servo.slow_el_pos double',...
0135     'antenna0.servo.fast_az_pos double',...
0136     'antenna0.servo.fast_el_pos double',...
0137     'antenna0.servo.fast_az_err double',...
0138     'antenna0.servo.fast_el_err double',...
0139     'antenna0.servo.command_current_az1[0] double',...
0140     'antenna0.servo.command_current_az2[0] double',...
0141     'antenna0.servo.command_current_el1[0] double',...
0142     'antenna0.servo.actual_current_az1[0] double',...
0143     'antenna0.servo.actual_current_az2[0] double',...
0144     'antenna0.servo.actual_current_el1[0] double',...
0145     'antenna0.servo.enable_status_az1',...
0146     'antenna0.servo.enable_status_az2',...
0147     'antenna0.servo.enable_status_el1',...
0148     'antenna0.frame.utc double',...
0149     'antenna0.frame.received double',...
0150     'antenna0.receiver.flags double',...
0151     'antenna0.receiver.utc double',...
0152     'antenna0.receiver.data double',...
0153     'antenna0.receiver.diagnostics double',...
0154     'antenna0.receiver.drainCurrent double',...
0155     'antenna0.receiver.drainVoltage double',...
0156     'antenna0.receiver.gateVoltage double',...
0157     'antenna0.receiver.avgSecond double',...
0158     };
0159   end
0160 end
0161 
0162 % Ensure regs unique
0163   if(any(size(unique(regs))~=size(regs)))
0164     error('regs should be unique');
0165 end
0166 
0167 % Here we want to have the function know which directory to look for the
0168 % data depending on the machine name.
0169 [defaultDataDir defaultCalFile defaultReaderPath] = whichHost();
0170 
0171 if(isempty(arcdir))
0172 
0173   arcdir = defaultDataDir;
0174 end
0175 if(isempty(calfile))
0176   calfile = defaultCalFile;
0177 end
0178 
0179 eval(sprintf('addpath %s', defaultReaderPath));
0180 
0181 % let's get the previous 5 seconds and post 5 seconds, and then cut it down
0182 % to the right size.
0183 mjdstartorig = tstr2mjd(start);
0184 mjdstart = mjdstartorig - 5/60/60/24;
0185 mjdstoporig  = tstr2mjd(finish);
0186 mjdstop  = mjdstoporig  + 5/60/60/24;
0187 
0188 %display('read_arc:: cbassMatReadArcOpt')
0189 d = cbassMatReadArcOpt(regs, mjd2string(mjdstart), mjd2string(mjdstop), arcdir, calfile);
0190 
0191 if(isempty(d.array.frame.utc))
0192   % no data
0193   return;
0194 end
0195 
0196 %display('read_arc::MassageData')
0197 d = massageData(d);
0198 %display('read_arc::reshapeResgister');
0199 % reshape the registers
0200 d = reshapeRegisters(d);
0201 %display('read_arc::interpRegisters');
0202 % interpolate as needed.
0203 d = interpRegisters(d);
0204 %display('read_arc::cut Desired Date');
0205 %return;
0206 % cut to the desired data
0207 d = cutDesiredData(d, mjdstartorig, mjdstoporig);
0208 %display('read_arc:: here')
0209 
0210 
0211 return;
0212 
0213 
0214 
0215 
0216 % cut to the desired data
0217 function d = cutDesiredData(d, mjdstartorig, mjdstoporig)
0218 
0219 if(~isfield(d, 'array'))
0220   return;
0221 end
0222 
0223 if(~isfield(d, 'antenna0'))
0224   return;
0225 end
0226 
0227 if(issubfield(d.antenna0, 'receiver', 'utc'))
0228   indFast = d.antenna0.receiver.utc>=mjdstartorig & ...
0229       d.antenna0.receiver.utc<mjdstoporig;
0230   noRx = 0;
0231 else
0232   indFast = ones(length(d.array.frame.utc)*100,1);
0233   indFast = logical(indFast);
0234   noRx = 1;
0235 end
0236 
0237 if(isfield(d.antenna0, 'servo'))
0238   indMed  = d.antenna0.servo.utc>=mjdstartorig & ...
0239       d.antenna0.servo.utc<mjdstoporig;
0240   noServo = 0;
0241 else
0242   indMed = ones(length(d.array.frame.utc)*5,1);
0243   indMed = logical(indMed);
0244   noServo = 1;
0245 end
0246 
0247 indSlow = d.array.frame.utc>=mjdstartorig & d.array.frame.utc<mjdstoporig;
0248 
0249 
0250 indF = reshape(indFast, [5 20 length(indSlow)]);
0251 indF = permute(indF, [3 1 2]);
0252 indFs = mean(mean(indF,3),2)==1;
0253 
0254 indM = reshape(indMed, [5 length(indSlow)]);
0255 indM = permute(indM, [2 1]);
0256 indMs = mean(indM,2)==1;
0257 
0258 ind  = indMs & indFs & indSlow;
0259 
0260 % these are the real ind on the slow scale.  now we up it to the longer
0261 % scales -- already done in framecut.
0262 
0263 d = framecut(d, ind, 'regular');
0264 
0265 return;
0266

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