Home > reduc > support > tauCalWrapper.m

tauCalWrapper

PURPOSE ^

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

SYNOPSIS ^

function d = tauCalWrapper(d, plotparams, parm, field,thedate_day_portion)

DESCRIPTION ^

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

  function d = tauCalWrapper(d, plotparams, parm, field);

    reduceData function that calculates the opacity and removes the effect
    of the sky

    sjcm

    3/30/2011 sjcm:  saving plots without displaying
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d = tauCalWrapper(d, plotparams, parm, field,thedate_day_portion)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function d = tauCalWrapper(d, plotparams, parm, field);
0006 %
0007 %    reduceData function that calculates the opacity and removes the effect
0008 %    of the sky
0009 %
0010 %    sjcm
0011 %
0012 %    3/30/2011 sjcm:  saving plots without displaying
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 [d,q] = logcal(d, 'tau');
0016 if (q)
0017   disp('Tau values have already been calculated');
0018   disp(' ')
0019   return
0020 end
0021 
0022 [d, q] = logcal(d, 'noise');
0023 if (~q)
0024   disp('Noise correction must be calculated before tau');
0025   disp('');
0026   return;
0027 end
0028 
0029 tau_values_offint_filename = ['tau_values_offint_',thedate_day_portion,'.txt'];
0030 tau2_values_offint_filename = ['tau2_values_offint_',thedate_day_portion,'.txt'];
0031 tau_values_ptcross_filename = ['tau_values_ptcross_',thedate_day_portion,'.txt'];
0032 tau2_values_ptcross_filename = ['tau2_values_ptcross_',thedate_day_portion,'.txt'];
0033 
0034 display('in tau');
0035 tau1_ptcross = [];
0036 
0037 %if this is a calibration observation, we should have tau already calculated
0038 if(d.correction.survey==0 & d.correction.tnoise.method==1)
0039   % already calculated
0040   tau1 = [d.correction.tnoise.time, d.correction.tnoise.source ...
0041     d.correction.tnoise.az d.correction.tnoise.elev d.correction.tnoise.calcTau, ...
0042     d.correction.tnoise.calcTauErr, d.correction.tnoise.flags];
0043   tau2 = [d.correction.tnoise.tauSrcDip];
0044   tau1_ptcross = [d.correction.tnoise.time, d.correction.tnoise.source ...
0045     d.correction.tnoise.az d.correction.tnoise.elev d.correction.tnoise.calcTau2, ...
0046     d.correction.tnoise.calcTauErr, d.correction.tnoise.flags];
0047   tau2_ptcross = [d.correction.tnoise.tauSrcDip2];
0048   tauVals.time   = d.correction.tnoise.time;
0049   tauVals.source = d.correction.tnoise.source;
0050   tauVals.az     = d.correction.tnoise.az;
0051   tauVals.elev   = d.correction.tnoise.elev;
0052   tauVals.values = d.correction.tnoise.calcTau;
0053   tauVals.error  = d.correction.tnoise.calcTauErr;
0054   tauVals.flag   = d.correction.tnoise.flags;
0055   if(all(isnan(tauVals.values(:))))
0056     tauVals = calculateTau(d);
0057     tau2 = [];
0058   end
0059 else
0060   % we need to calculate tau, using the noise diode temperature
0061   tauVals = calculateTau(d);
0062   tau2 = [];
0063 end
0064 
0065 if(isempty(tauVals))
0066   tauVals = getTauVal(d);
0067   doNotSave = 1;
0068 else
0069   doNotSave = 0;
0070 end  
0071 
0072 
0073 
0074 % next we flag on these values, before applying them to the data.
0075 d.correction.tau = tauVals;
0076 setPlotDisplay(plotparams.plot);
0077 tauflags = tauVals.flag;
0078 
0079 [d tauflags]  = packd(d, tauflags, 'none', 'tau', plotparams, 'Opacity Plots', field);
0080 tauVals.flag = tauVals.flag | tauflags;
0081 
0082 tauVector = [tauVals.time tauVals.source tauVals.az tauVals.elev ...
0083       tauVals.values, tauVals.error, tauVals.flag];
0084 
0085 % check again that user flagging hasn't made all the data bad.
0086 if(all(d.correction.tau.flag(:)))
0087   display('ATTENTION --- ATTENTION --- ATTENTION');
0088   display('No good tsys values in your data');
0089   display('This data set will not be used for calibration');
0090   d.correction.tau.allbad = 1;
0091 else
0092   d.correction.tau.allbad = 0;
0093 end
0094 
0095 [home,installeddir]=where_am_i();
0096 
0097 % last we save the tau values we calculate
0098 parFlag = checkpar(parm, 'autosave');
0099 if(parFlag)
0100   if(parm.autosave.flag & d.correction.tau.allbad==0 & doNotSave==0)
0101     thisTau = tauVector;
0102 
0103     % make sure file is up-to-date
0104     %system('cvs update constants/tau_values.txt');
0105     %allTau  = load([home,'/',installeddir,'/constants/tau_values_offint.txt']);
0106     %allTau  = [allTau; thisTau];
0107     save([home,'/',installeddir,'/constants/tau_values_offint.txt'],'thisTau', '-ascii','-single','-append');
0108     save([home,'/',installeddir,'/constants/',tau_values_offint_filename],'thisTau', '-ascii','-single','-append');
0109  
0110 %    system('cvs commit -m "update" constants/tau_values.txt');
0111   
0112     if(~isempty(tau2))
0113       %allTau2 = load([home,'/',installeddir,'/constants/tau2_values_offint.txt']);
0114       %allTau2 = [allTau2; tau2];
0115       save([home,'/',installeddir,'/constants/tau2_values_offint.txt'],'tau2','-ascii','-single','-append');
0116       save([home,'/',installeddir,'/constants/',tau2_values_offint_filename],'tau2', '-ascii','-single','-append');      
0117     end
0118     
0119     if(~isempty(tau1_ptcross))
0120       %allTau  = load([home,'/',installeddir,'/constants/tau_values_ptcross.txt']);
0121       %allTau  = [allTau; tau1_ptcross];
0122       save([home,'/',installeddir,'/constants/',tau_values_ptcross_filename],'tau1_ptcross', '-ascii','-single','-append');
0123       save([home,'/',installeddir,'/constants/tau_values_ptcross.txt'],'tau1_ptcross','-ascii','-single','-append');      
0124   
0125       %allTau2 = load([home,'/',installeddir,'/constants/tau2_values_ptcross.txt']);
0126       %allTau2 = [allTau2; tau2_ptcross];
0127       save([home,'/',installeddir,'/constants/tau2_values_ptcross.txt'],'tau2_ptcross','-ascii','-single','-append');
0128       save([home,'/',installeddir,'/constants/',tau2_values_ptcross_filename],'tau2_ptcross', '-ascii','-single','-append');
0129     end
0130 
0131     
0132   end
0133 end
0134 % and now, we interpolate the tau values based on what's in the archive
0135 %d = interpolateTau(d, '/home/sjcm/cbass_analysis/constants/tau_values_offint.txt');
0136 d = interpolateTau(d);
0137 
0138 % log that it has been applied
0139 d = logcal(d, 'tau');
0140 
0141 
0142 return;
0143

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