Home > reduc > alpha > readAlphaDatabase.m

readAlphaDatabase

PURPOSE ^

x = readAlphaDatabase(mjd_array)

SYNOPSIS ^

function x = readAlphaDatabase(varargin)

DESCRIPTION ^

 x = readAlphaDatabase(mjd_array)
 OR
 x = readAlphaDatabase('date')
 OR
 x = readAlphaDatabase(mjd_start, mjd_end)
 OR
 x = readAlphaDatabase('start date','end date')

 This function reads in the database of alpha values from the disk and
 returns a list with the following matrices in it:
   x{1} = t: Nx1 vector - MJD of alpha value measurement
   x{2} = alpha DD: Nx5 matrix - alpha values of classic data routines
   x{3} = gain DD: Nx5 matrix - gain values of classic data routines
   x{4} = variances of alpha DD values (x{2}) Nx5 matrix
   x{5} = variances of gain DD values (x{3}) Nx5 matrix
   x{6} = Nx2 matrix, total intensity gains of PolOnly data routines
   x{7} = Nx2 matrix, variances of x{6}
   x{8} = gain filtered, Nx5 matrix, gain values of filtered data routines
       (0 before October 2011)
   x{9} = alpha filtered, Nx3 matrix, phase angles of filtered data routines
       (0 before October 2011)
   x{10} = Nx5 matrix, variances of x{8}
   x{11} = Nx3 matrix, variances of x{9}
   x{12} = r: Nx2 matrix - r factor
   x{13} = T: Nx2 matrix - estimate of Tsys/TND
   x{14} = Nx4 matrix [az el ra dec] - telescope pointing direction (rad)
   x{15} = temps: Nx7 matrix - environmental temperature sensor data in degrees C
   x{16} = TYPE: Nx1 vector - vector detailing the way the alpha values were calculated.
         if == 0, then the values were calculated in interactive mode
         if == 1, then the values were calculated in non-interactive mode
   x{17} = FLAGGED: Nx1 matrix to which specifies if the selected time
       sample has been flagged as bad.
         if == 0: good value
         if == 1: bad value

 OGK, 13 March 2012

 Edited: OGK, 19 November 2012
         It now reads the data from the split alpha database files. Output
         format is exactly as before. User can specify input dates if
         desired, in both MJD float and date string formats.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x = readAlphaDatabase(varargin)
0002 % x = readAlphaDatabase(mjd_array)
0003 % OR
0004 % x = readAlphaDatabase('date')
0005 % OR
0006 % x = readAlphaDatabase(mjd_start, mjd_end)
0007 % OR
0008 % x = readAlphaDatabase('start date','end date')
0009 %
0010 % This function reads in the database of alpha values from the disk and
0011 % returns a list with the following matrices in it:
0012 %   x{1} = t: Nx1 vector - MJD of alpha value measurement
0013 %   x{2} = alpha DD: Nx5 matrix - alpha values of classic data routines
0014 %   x{3} = gain DD: Nx5 matrix - gain values of classic data routines
0015 %   x{4} = variances of alpha DD values (x{2}) Nx5 matrix
0016 %   x{5} = variances of gain DD values (x{3}) Nx5 matrix
0017 %   x{6} = Nx2 matrix, total intensity gains of PolOnly data routines
0018 %   x{7} = Nx2 matrix, variances of x{6}
0019 %   x{8} = gain filtered, Nx5 matrix, gain values of filtered data routines
0020 %       (0 before October 2011)
0021 %   x{9} = alpha filtered, Nx3 matrix, phase angles of filtered data routines
0022 %       (0 before October 2011)
0023 %   x{10} = Nx5 matrix, variances of x{8}
0024 %   x{11} = Nx3 matrix, variances of x{9}
0025 %   x{12} = r: Nx2 matrix - r factor
0026 %   x{13} = T: Nx2 matrix - estimate of Tsys/TND
0027 %   x{14} = Nx4 matrix [az el ra dec] - telescope pointing direction (rad)
0028 %   x{15} = temps: Nx7 matrix - environmental temperature sensor data in degrees C
0029 %   x{16} = TYPE: Nx1 vector - vector detailing the way the alpha values were calculated.
0030 %         if == 0, then the values were calculated in interactive mode
0031 %         if == 1, then the values were calculated in non-interactive mode
0032 %   x{17} = FLAGGED: Nx1 matrix to which specifies if the selected time
0033 %       sample has been flagged as bad.
0034 %         if == 0: good value
0035 %         if == 1: bad value
0036 %
0037 % OGK, 13 March 2012
0038 %
0039 % Edited: OGK, 19 November 2012
0040 %         It now reads the data from the split alpha database files. Output
0041 %         format is exactly as before. User can specify input dates if
0042 %         desired, in both MJD float and date string formats.
0043 %
0044 
0045 if nargin == 0
0046     % need to read in the entire database. This starts in May 2012 and
0047     % continues up until the present day.
0048     mjd_start = tstr2mjd('01-MAY-2010:00:00:00');
0049     c = clock();
0050     mjd_end = date2mjd(c(1),c(2),c(3),c(4),c(5),c(6));
0051     fnames = getAlphaDatabaseName(linspace(mjd_start,mjd_end,round((mjd_end-mjd_start)/10)));
0052 elseif nargin == 1
0053     % in this case an mjd array has been provided. might have provided a
0054     % single mjd.
0055     if isfloat(varargin{1})
0056         fnames = getAlphaDatabaseName(varargin{1});
0057     else
0058         fnames = getAlphaDatabaseName(tstr2mjd(varargin{1}));
0059     end
0060 elseif nargin == 2
0061     if isfloat(varargin{1})
0062         mjd_start = varargin{1};
0063     else
0064         mjd_start = tstr2mjd(varargin{1});
0065     end
0066     if isfloat(varargin{2})
0067         mjd_end = varargin{2};
0068     else
0069         mjd_end = tstr2mjd(varargin{2});
0070     end
0071     fnames = getAlphaDatabaseName(linspace(mjd_start,mjd_end,ceil((mjd_end-mjd_start)/10)));
0072 else
0073     disp('readAlphaDatabase:: Error in readAlphaDatabase!')
0074     disp('readAlphaDatabase:: Wrong number of input arguments specified!')
0075     disp('readAlphaDatabase:: Either provide no arguments, one MJD float array, or two datestrings.')
0076     return
0077 end
0078 
0079 % now, read in a data array for each file entry in fnames:
0080 x = cell(17,1); % we want 17 entries in the structure we return
0081 for k=1:size(fnames,1)
0082     if exist(fnames{k},'file') == 2
0083         d = importdata(fnames{k},' ',1);
0084         if isstruct(d)
0085             x{1} = [x{1}; d.data(:,1)]; % t
0086             x{2} = [x{2}; d.data(:,2:6)]; % aDD
0087             x{3} = [x{3}; d.data(:,7:11)]; % gDD
0088             x{4} = [x{4}; d.data(:,12:16)]; % VaDD
0089             x{5} = [x{5}; d.data(:,17:21)]; % VgDD
0090             x{6} = [x{6}; d.data(:,22:23)]; % gPO
0091             x{7} = [x{7}; d.data(:,24:25)]; % VgPO
0092             x{8} = [x{8}; d.data(:,26:30)]; % gFILT
0093             x{9} = [x{9}; d.data(:,31:33)]; % aFILT
0094             x{10} = [x{10}; d.data(:,34:38)]; % VgFILT
0095             x{11} = [x{11}; d.data(:,39:41)]; % VaFILT
0096             x{12} = [x{12}; d.data(:,42:43)]; % r
0097             x{13} = [x{13}; d.data(:,44:45)]; % T
0098             x{14} = [x{14}; d.data(:,46:49)]; % point
0099             x{15} = [x{15}; d.data(:,50:56)]; % temps
0100             x{16} = [x{16}; d.data(:,57)]; % TYPE
0101             x{17} = [x{17}; d.data(:,58)]; % FLAGGED
0102         end
0103     end
0104 end
0105 
0106 
0107 end

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