Home > reduc > support > webpipe.m

webpipe

PURPOSE ^

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

SYNOPSIS ^

function webpipe(d, field, rn,sched_name,thedate_day_portion)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  function webpipe(d, field, rn)

   d is the reduced data set
   field is the fieldname you used in reducing the data
   rn is the reduction number (ignored)
   sched_name is an optional name for the scedule, which will get printed in the index.html 
  
   sjcm
   jl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function webpipe(d, field, rn,sched_name,thedate_day_portion)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function webpipe(d, field, rn)
0006 %
0007 %   d is the reduced data set
0008 %   field is the fieldname you used in reducing the data
0009 %   rn is the reduction number (ignored)
0010 %   sched_name is an optional name for the scedule, which will get printed in the index.html
0011 %
0012 %   sjcm
0013 %   jl
0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0015 rn=1;
0016 
0017 if(nargin<4)
0018   sched_name = [];
0019 end
0020 
0021 
0022 
0023 %subdir={'intro', 'flags', 'intent', 'pointing', 'deglitch', 'positional', 'rfi', 'mains', 'alpha', 'stokes', 'load', ...
0024 %  'tau', 'tsys','noise', 'astro', 'power', 'overf', 'rms', ...
0025 %    'map','fits', 'noiseInterp', 'tauInterp'};
0026 
0027 month = getmonth;
0028 start = mjd2date_v2(d.array.frame.utc(1));
0029 
0030 mon=num2str(start.month);
0031 if (start.month<10)
0032   mon=num2str(start.month);
0033   mon=strcat('0',mon);
0034 end
0035 
0036 day=num2str(start.day);
0037 if (start.day<10)
0038   day=num2str(start.day);
0039   day=strcat('0',day);
0040 end
0041 
0042 [r,home]=unix('printenv HOME');
0043 usr=home(7:end-1);
0044 
0045 [maindir subdir] = getMainDir(d, field);
0046 fn=strcat(maindir,'/','index.html');
0047 
0048 fid=fopen(fn,'w');
0049 header(fid);
0050 
0051 info=skim(d,[],0,thedate_day_portion);
0052 start=info.track.start;
0053 stop=info.track.stop;
0054 
0055 fprintf(fid,'<a href="../">Home</a>\n\n');
0056 
0057 fprintf(fid,sprintf('<p>reduceData Version %s<p>\n\n',d.rev));
0058 fprintf(fid,'<pre>\n');
0059 fprintf(fid,'                         Track Summary\n');
0060 fprintf(fid,'================================================================\n');
0061 fprintf(fid,'Observation schedule\n');
0062 if(~isempty(sched_name))
0063   fprintf(fid,'  Schedule Name: %s \n',sched_name);
0064 end
0065 fprintf(fid,sprintf('  Start: %2u-%s-%4u:%2u:%2u:%2u\n',start.day,month{start.month},...
0066     start.year, start.hour, start.minute, round(start.second)));
0067 fprintf(fid,sprintf('  Stop:  %2u-%s-%4u:%2u:%2u:%2u\n',stop.day,month{stop.month},...
0068     stop.year, stop.hour, stop.minute, round(stop.second)));
0069 fprintf(fid,'  Number of Scans: %d\n', info.track.numScans);
0070 fprintf(fid,'  Total time of Track: %2.2f\n', info.track.intTime);
0071 fprintf(fid,'  Percent of total Data Flagged: %2.2f\n', info.track.perFlag);
0072 
0073 
0074 fprintf(fid, '\n');
0075 fprintf(fid, '\n');
0076 
0077 
0078 fprintf(fid, 'Order in which Routines were called\n');
0079 fprintf(fid, '\n');
0080 for m=1:length(d.par.routines.order)
0081   fprintf(fid, '%d: \t %s\n', m, d.par.routines.order{m});
0082 end
0083 
0084 fprintf(fid, '\n');
0085 fprintf(fid, '\n');
0086 
0087 
0088 fprintf(fid,'</pre>\n');
0089 
0090 fprintf(fid,'<table border="1">\n');
0091  
0092 fprintf(fid,'<tr>\n');
0093 fprintf(fid,'<td> <b> Routine </b> </td> <td> <b> Integration [min] </b> </td> <td>  <b> Percent Flagged </b> </td>\n');
0094 
0095 fprintf(fid,'</tr>\n');
0096 
0097 names = fieldnames(info);
0098 
0099 for m=1:length(names)
0100   thisName = names{m};
0101   eval(sprintf('thisData = info.%s;', thisName));
0102 
0103   if (~strcmp(thisName,'flag'))
0104    % N.B. This block should be executed in all cases
0105    % **except** when thisName is equal to 'flag'
0106    fprintf(fid,'<tr>\n');
0107    fprintf(fid,'<td> %s </td>',thisName);
0108    fprintf(fid,'<td> %8.2f </td>',thisData.intTime);
0109    fprintf(fid,'<td> %8.2f </td>\n',thisData.perFlag);
0110    fprintf(fid,'</tr>\n');
0111   end
0112 
0113 end
0114 
0115 fprintf(fid,'</table>\n');
0116 
0117 
0118 
0119 
0120 fprintf(fid, '\n');
0121 fprintf(fid, '\n');
0122 fprintf(fid,'<table border="1">\n');
0123  
0124 fprintf(fid,'<tr>\n');
0125 
0126 fprintf(fid,'<td> <b> Routine  </b> </td>  <td> <b>  Flag \% I1 </b> </td>  <td> <b>  Flag \% Pol </b> </td> <td> <b>  Flag \% I2 </b> </td> \n');
0127 fprintf(fid,'</tr>\n');
0128 
0129 names = fieldnames(info.flag);
0130 for m=1:length(names)
0131   if(strmatch(names{m}, 'tsys', 'exact'))
0132     if(isfield(d.correction, 'tsys'))
0133       if(~isempty(d.correction.tsys.val))
0134     txt = sprintf('<tr> <td> tsys </td> <td> %d of %d measurements </td> <td>  </td> <td>  </td> </tr>\n', ...
0135         length(find(d.correction.tsys.flag)), ...
0136         length(find(d.correction.tsys.val)));
0137     fprintf(fid, txt);
0138       end
0139     end
0140   elseif(strmatch(names{m}, 'noise', 'exact'))
0141     if(isfield(d.correction, 'tnoise'));
0142       if(d.correction.survey==0)
0143     txt = sprintf('<tr> <td> Noise diode </td> <td> %d of %d measurements </td> <td>  </td> <td>  </td> </tr>\n', ...
0144         length(find(d.correction.tnoise.flags)), length(find(d.correction.tnoise.Tnd)));
0145     fprintf(fid, txt);      
0146       end
0147     end
0148 %  elseif(strmatch(names{m}, 'gain', 'exact'))
0149 %    if(isfield(d.correction, 'gain'))
0150 %      txt = sprintf('<tr> <td> Gain </td> <td> %d of %d measurements </td> <td>  </td> <td>  </td> </tr>\n', ...
0151 %      length(find(d.correction.gain.flag)), ...
0152 %      length(find(d.correction.gain.val)));
0153 %      fprintf(fid, txt);
0154 %    end
0155    elseif(strmatch(names{m}, 'tau', 'exact') & isfield(d.correction,'tau'))
0156    % JL -possible for tau reduction stage to have been applied,
0157    % but no tau field added if e.g. there are no sky dips in the data
0158     txt = sprintf('<tr> <td> Tau </td> <td> %d of %d measurements </td> <td>  </td> <td>  </td> </tr> \n', ...
0159     length(find(d.correction.tau.flag)), ...
0160     length(find(d.correction.tau.values)));
0161     fprintf(fid, txt);
0162   else
0163     eval(sprintf('thisData = info.flag.%s; ', names{m}));
0164    
0165  
0166     if(m==1 | m==4 | m==6 | m==7 | m==10 | m==17)
0167       
0168       txt = sprintf('<tr> <td> %s  </td> <td>  %4.2f </td>  <td>  %4.2f  </td> <td> %4.2f </td> </tr> \n', names{m}, thisData(1), thisData(2), thisData(3));
0169       else
0170       
0171       txt = sprintf('<tr> <td> %s  </td> <td>  %4.2f </td>  <td>  %4.2f  </td> <td> %4.2f </td> </tr>\n', names{m}, thisData(1), thisData(2), thisData(3) );
0172     end
0173     fprintf(fid,txt);
0174   end
0175 end
0176 
0177 fprintf(fid,'<pre>\n');
0178 
0179 fprintf(fid,'</pre>\n');
0180 
0181 % create links to plots
0182 
0183 fprintf(fid,'<p>\n');
0184 for m=1:length(subdir)
0185   if(m==1)
0186     fprintf(fid,sprintf('<a href="flags.txt">flags</a><br>\n'));
0187   end
0188   fprintf(fid,sprintf('<a href="%s/fig1.html#fig1">%s</a><br>\n',subdir{m},subdir{m}));
0189   subpages(subdir,maindir,m);
0190 end
0191 fprintf(fid,'</p>\n');
0192 
0193 
0194 printpar(fid,d, subdir);
0195 
0196 tail(fid);
0197 
0198 % scp over to parker
0199 haggisdir=strcat('~cbassuser/web/observations/reduced_',field,'/',sprintf('r%u/',rn));
0200 %unix(sprintf('scp -r %s %s@haggis.caltech.edu:%s',maindir,usr,haggisdir));
0201 
0202 % now delete directory
0203 %unix(sprintf('rm -rf %s', maindir));
0204 
0205 
0206 fclose(fid);
0207 return;
0208 
0209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0210 function printpar(fid,d, subdir)
0211 
0212 if(~isempty(subdir))
0213   fields = {'bitmask', 'plotflag', 'autorun', 'rev'};
0214   lf = length(fields);
0215   for m=1:length(subdir)
0216     switch subdir{m}
0217       case 'rfi'
0218     fields{lf+1} = 'rfi';
0219     fields{lf+2} = 'coord';
0220     
0221       case 'mains'
0222     fields{lf+1} = 'mains';
0223     
0224       case 'noise'
0225     fields{lf+1} = 'noise';      
0226     
0227       case 'tsys'
0228     fields{lf+1} = 'tsys';      
0229     
0230       case 'stokes'
0231     fields{lf+1} = 'stokes';      
0232     
0233       case 'stokes'
0234     fields{lf+1} = 'stokes';      
0235     
0236       case 'load'
0237     fields{lf+1} = 'load';      
0238     
0239       case 'tau'
0240     fields{lf+1} = 'tau';      
0241     
0242       case 'astro'
0243     fields{lf+1} = 'astro';      
0244     
0245       case 'fits'
0246     fields{lf+1} = 'fits';      
0247     end
0248     lf = length(fields);
0249   end
0250 else
0251   fields = {'bitmask', 'deglitch', 'rfi', 'coord', 'mains', 'alpha', 'noise', 'tsys', 'stokes', 'load', ...
0252       'tau', 'astro', 'plotflag', 'autorun', 'rev','fits'};
0253 end
0254 
0255   
0256 fprintf(fid,'<p>\n');    
0257 fprintf(fid,'<h3>Parameters</h3>\n\n');
0258 fprintf(fid,'<p>\n');
0259 for m=1:length(fields)
0260   switch fields{m}
0261     case 'bitmask'
0262       if (isfield(d.par,'bitmask'))
0263     fprintf(fid,'<h3>Bitmask</h3>\n');
0264     fprintf(fid,'<pre>\n');
0265     fprintf(fid,sprintf('   Bits Flagged: %u \n',d.par.deglitch.chan1));
0266     fprintf(fid,'</pre>\n');
0267       end    
0268       
0269     case 'deglitch'
0270       if (isfield(d.par,'deglitch'))
0271     fprintf(fid,'<h3>Deglitch</h3>\n');
0272     fprintf(fid,'<pre>\n');
0273     fprintf(fid,sprintf('   Chan 1 Slope Jump: %u BU\n',d.par.deglitch.chan1));
0274     fprintf(fid,sprintf('   Chan 2 Slope Jump: %u BU\n',d.par.deglitch.chan2));
0275     fprintf(fid,'</pre>\n');
0276       end
0277       
0278    case 'rfi'
0279       if (isfield(d.par,'rfi'))
0280     fprintf(fid,'<h3>RFI flagging</h3>\n');
0281     fprintf(fid,'<pre>\n');
0282     fprintf(fid,sprintf('Fast Flag Significance: %3.3f\n',d.par.rfi.fast));
0283     fprintf(fid,sprintf('Polarization Flag Significance: %3.3f\n',d.par.rfi.polarization));
0284     fprintf(fid,sprintf('Intensity Flag Significance: %3.3f\n',d.par.rfi.intensity));
0285     fprintf(fid,'</pre>\n');
0286       end      
0287       
0288     case 'coord'
0289       if (isfield(d.par,'coord'))
0290     fprintf(fid,'<h3>Positional flagging</h3>\n');
0291     fprintf(fid,'<pre>\n');
0292     fprintf(fid,sprintf('hemisphere: %u\n',d.par.coord.hemisphere));
0293     fprintf(fid,'</pre>\n');
0294       end      
0295 
0296     case 'mains'
0297       if (isfield(d.par,'mains'))
0298     fprintf(fid,'<h3>Mains Filtering</h3>\n');
0299     fprintf(fid,'<pre>\n');
0300     fprintf(fid,sprintf('   tukey filter params: %3.3f\n',d.par.mains.tukey));
0301     fprintf(fid,'</pre>\n');
0302       end      
0303 
0304     case 'alpha'
0305        if (isfield(d.par,'alpha'))
0306     fprintf(fid,'<h3>Alpha Correction</h3>\n');
0307     fprintf(fid,'<pre>\n');
0308     fprintf(fid,sprintf('   jump tolerance: %5.5f [BU]\n',d.par.alpha.jump));
0309     fprintf(fid,sprintf('   flat tolerance: %5.5f [BU]\n', d.par.alpha.flat));
0310     fprintf(fid,'</pre>\n');
0311       end           
0312       
0313     case 'stokes'
0314        if (isfield(d.par,'stokes'))
0315     fprintf(fid,'<h3>R-factor correction</h3>\n');
0316     fprintf(fid,'<pre>\n');
0317     fprintf(fid,sprintf('     maximum value: %1.2f\n', d.par.stokes.maxVal));
0318     fprintf(fid,sprintf(' slope improvement: %1.2f\n', d.par.stokes.slope));
0319     fprintf(fid,sprintf('     smooth length: %1.2f\n', d.par.stokes.smooth));
0320     fprintf(fid,'</pre>\n');
0321       end                 
0322 
0323     case 'load'
0324        if (isfield(d.par,'load'))
0325     fprintf(fid,'<h3>Cold Load Correction</h3>\n');
0326     fprintf(fid,'<pre>\n');
0327     fprintf(fid,sprintf('   scale Type: %u \n',d.par.load.scaleType));
0328     fprintf(fid,'</pre>\n');
0329       end                 
0330 
0331     case 'tau'
0332        if (isfield(d.par,'tau'))
0333     fprintf(fid,'<h3>Opacity Flagging</h3>\n');
0334     fprintf(fid,'<pre>\n');
0335     fprintf(fid,sprintf('   outlier sigma: %u \n', d.par.tau.sigma));
0336     fprintf(fid,'</pre>\n');
0337       end           
0338       
0339     case 'tsys'
0340       if (isfield(d.par,'tsys'))
0341     fprintf(fid,'<h3>Tsys Flagging</h3>\n');
0342     fprintf(fid,'<pre>\n');
0343     fprintf(fid,sprintf('    max tsys temp: %u \n', d.par.tsys.valuehi));
0344     fprintf(fid,sprintf('    min tsys temp: %u \n', d.par.tsys.valuelo));
0345     fprintf(fid,'</pre>\n');
0346       end           
0347 
0348     case 'noise'
0349       if (isfield(d.par,'noise'))
0350     fprintf(fid,'<h3>Noise Flagging</h3>\n');
0351     fprintf(fid,'<pre>\n');
0352     fprintf(fid,sprintf('   max noise temp: %u \n', d.par.noise.valuehi));
0353     fprintf(fid,sprintf('   min noise temp: %u \n', d.par.noise.valuelo));
0354     fprintf(fid,'</pre>\n');
0355       end           
0356       
0357       
0358     case 'astro'
0359        if (isfield(d.par,'astro'))
0360     fprintf(fid,'<h3>Astronomical Flagging</h3>\n');
0361     fprintf(fid,'<pre>\n');
0362     fprintf(fid, sprintf(' NONE YET'));
0363     fprintf(fid,'</pre>\n');
0364       end 
0365 
0366     case 'fits'
0367        if (isfield(d.par,'fits'))
0368     fprintf(fid,'<h3>FITS writing</h3>\n');
0369     fprintf(fid,'<pre>\n');
0370         fprintf(fid, sprintf('Was run with map flag %s \n',d.par.fits.domapflag));
0371         fprintf(fid, sprintf('Frame = %s \n',d.par.fits.frame));
0372         fprintf(fid, sprintf('Projection = %s \n',d.par.fits.projection));   
0373     fprintf(fid,'</pre>\n');
0374       end  
0375       
0376   end
0377 end
0378 
0379 return;
0380            
0381       
0382 
0383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0384 function subpages(dir,maindir,num)
0385 
0386 % first we need to find out how many plots there are:
0387 
0388 eval(sprintf('[s w] = unix(''ls -l %s/%s'');', maindir, dir{num}));
0389 
0390 f = strfind(w, '.png');
0391 numPlots = length(f);
0392 
0393 if (numPlots==0)
0394   disp(['No plots found for ',dir{num}]);
0395   return;  
0396 end;
0397 
0398 % An overide to get the number of figures right in the fits dir
0399 if(strcmp(dir{num},'fits'))
0400   numPlots=3;
0401 end
0402 
0403 fn=strcat(maindir,'/',dir{num},'/fig1.html');
0404 
0405 for i=1:numPlots
0406     if(i==1)
0407         fid=fopen(fn,'w');
0408         header(fid);
0409         fprintf(fid, '<p> <a name="fig1">');
0410     else
0411     %    fid=fopen(fn,'a');
0412     %    if(fid == -1)
0413     %        message = ferror(fid)
0414     %        keyboard;
0415     %    end
0416         fprintf(fid,sprintf('<p> <a name="fig%u">', i));
0417     end
0418     fprintf(fid,'<a href="../index.html">Overview</a>\n\n');
0419     navfig(fid,numPlots);
0420     fprintf(fid,'<pre>\n');
0421     if (i==1)
0422         fig=i;
0423     else
0424         fig=i-1;
0425     end
0426     fprintf(fid,sprintf('<a href="#fig%u">Back</a>    ',fig));
0427     if (i==numPlots)
0428         fig=i;
0429     else
0430         fig=i+1;
0431     end
0432     fprintf(fid,sprintf('    <a href="#fig%u">Forward</a>\n',fig));
0433     fprintf(fid,'</pre>\n\n');
0434     fprintf(fid,sprintf('<img src="fig%u.png">\n\n',i));
0435     fprintf(fid,'<hr>');
0436 
0437 end
0438 
0439 
0440 
0441 if(strcmp(dir{num},'fits'))
0442  % Put links to the fits files in
0443 
0444   % JL here is some madness to get the name of both fits files in the directory
0445   eval(sprintf('[s w] = unix(''ls -l %s/%s/*.fits'');', maindir, dir{num}));
0446   s2 = regexp(w, '/', 'split');
0447   wanted_arr=regexp( char(s2(ceil(length(s2)/2))) , '\n', 'split');
0448   first=char(wanted_arr(1));
0449   second = char(s2(length(s2)));
0450 
0451 
0452   fprintf(fid,'<h3> Raw fits file and map fits file</h3>\n');
0453   %sprintf('<a href="%s">%s</a>\n\n',first,first)
0454   %sprintf('<a href="%s">%s</a>\n\n',second,second)
0455  
0456   fprintf(fid,'<p> <a href="%s">%s</a> </p>\n\n',first,first);
0457   fprintf(fid,'<p> <a href="%s">%s</a> </p>\n\n',second,second);  
0458 
0459   % JL here is some more madness to get the name of both fits files in the directory
0460   %
0461   eval(sprintf('[s w] = unix(''ls -l %s/%s/*_raw_plot.png'');', maindir, dir{num}));
0462   s2 = regexp(w, '/', 'split');
0463   wanted_arr=regexp( char(s2(ceil(length(s2)/2))) , '\n', 'split');
0464   first=char(wanted_arr(1));
0465   second = char(s2(length(s2)));
0466   disp(['raw png file is ',first,' --- ',second]);
0467  
0468   fprintf(fid,'<hr>\n');
0469   fprintf(fid,'<h3> Raw channel data</h3>\n');
0470 
0471   regexprep(second,'\r\n|\n|\r','');
0472   %fprintf(fid,'<p> <img src="%s"> </p>\n\n',first);
0473   fprintf(fid,'<p> <img src="%s"> </p>\n\n',second);  
0474 
0475 end
0476 
0477 %keyboard;
0478 %keyboard;
0479 %fclose(fid);
0480 
0481 %fid = fopen(fn, 'a');
0482 tail(fid);
0483 
0484 fclose(fid);
0485 
0486 return;
0487 
0488 
0489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0490 function navfig(fid,num)
0491 
0492 fprintf(fid,'\n<p>\n');
0493 
0494 for i=1:num
0495   fprintf(fid,sprintf(' [<a href="#fig%u">%u</a>] ',i,i));
0496 end
0497 
0498 fprintf(fid,'\n<p>\n');
0499 return;
0500 
0501 
0502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0503 function header(fid)
0504 
0505 fprintf(fid,'<html><body>\n\n'); 
0506 fprintf(fid,'<p>\n\n');
0507 
0508 return;
0509 
0510 
0511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0512 function tail(fid)
0513 
0514 fprintf(fid,'</table></body></html>');
0515 return;

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