Home > constants > getTauVal.m

getTauVal

PURPOSE ^

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

SYNOPSIS ^

function [tauVals] = getTauVal(d)

DESCRIPTION ^

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

  function [tauVals] = getTauVal(d)


   function that reads an ASCII text file, re-orders everything in that
   file, flags on tau, and calculates the values to be used in yoru sched.%   

   sjcm

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tauVals] = getTauVal(d)
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 %  function [tauVals] = getTauVal(d)
0005 %
0006 %
0007 %   function that reads an ASCII text file, re-orders everything in that
0008 %   file, flags on tau, and calculates the values to be used in yoru sched.%
0009 %
0010 %   sjcm
0011 %
0012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0013 
0014 filename = 'constants/tau_values_ptcross.txt';
0015 
0016 % file is in form:
0017 %[time source az elev tau1 tau2 tau1err tau2err tau1flag tau2flag]
0018 % only want to use method 1!
0019 
0020 tau = load(filename);
0021 
0022 % next let us re-order everything
0023 tDate  = tau(:,1);
0024 % first put things in chronological order
0025 [tDateChron, sortOrder] = sort(tDate);
0026 tChron     = tau(sortOrder,:);
0027 
0028 % redefine the variables in chronologiacl order
0029 tDate     = tDateChron;
0030 tau       = tChron;
0031 
0032 % let us get rid of the repeats - always trust the lastest one
0033 reps   = find(diff(tDate)==0);
0034 tDate(reps,:) = [];
0035 tau(reps,:) = [];
0036 
0037 % find the ones that are completely flagged
0038 flags     = tau(:,9:10);
0039 indbad = sum(flags,2) == 2;
0040 
0041 % redefine variables for ease to work with
0042 times     = tDate(~indbad);
0043 sources   = tau(~indbad,2);
0044 az        = tau(~indbad,3);
0045 elev      = tau(~indbad,4);
0046 tauVals   = tau(~indbad,5:10);  % tau1 tau2 tau1err tau2err flag1 flag2
0047 tau       = tauVals(:,1:2);
0048 tauErr    = tauVals(:,3:4);
0049 flags     = tauVals(:,5:6);
0050 
0051 % next...we find values which are near our data set:
0052 ind = times > d.array.frame.utc(1) - 2/24  & times < ...
0053     last(d.array.frame.utc) + 2/24;
0054 finc= find(ind);
0055 % if nothing within a few hours, keep getting more!
0056 hr = 3;
0057 while(isempty(finc))
0058   %display('getTauVal:: WARNING WARNING WARNING');
0059   %eval(sprintf('display(''getTauVal:: No skydips within %d hours of track'')', (hr-1)));
0060   ind =  times > d.array.frame.utc(1) - hr/24  & times < ...
0061       last(d.array.frame.utc) + hr/24;
0062   finc = find(ind);
0063   hr   = hr+1;
0064 end
0065 eval(sprintf('display(''getTauVal:: Nearest skydip is within %d hours of track'')', (hr-1)));
0066 
0067 if(~isempty(finc))
0068   tauVals.time   = times(finc);
0069   tauVals.source = sources(finc);
0070   tauVals.elev   = elev(finc);
0071   tauVals.az     = az(finc);
0072   tauVals.error  = tauErr(finc,:);
0073   tauVals.flag   = flags(finc,:);
0074   tauVals.values = tau(finc,:);
0075 else
0076   error('getTauVal:: You have no opacity info in your archive');
0077 end
0078 
0079 return;
0080 
0081 
0082 % plot if we want to.
0083 
0084 
0085 %marks = {'r.', 'g.', 'k.', 'b.', 'c.', 'y.', 'm.'};
0086 %full_flux(full_flags>0) = nan;
0087 
0088 % let us make a plot
0089 %unCals = unique(sources);
0090 %for m=1:length(unCals)
0091 %  f = find(sources == unCals(m));
0092 %  plot(times(f), full_flux(f,1), marks{m});
0093 %  hold on
0094 %  thisName = getSourceName(unCals(m));
0095 %  fullname{m} = thisName;
0096 %end
0097 %legend(fullname);
0098 
0099 
0100

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