Home > reduc > read_arcSouthLNA.m

read_arcSouthLNA

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

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