process_cast.m
changeset 22 624b1ed6e9c9
parent 20 61b92f8fb463
equal deleted inserted replaced
21:bce791a17f4e 22:624b1ed6e9c9
    38 % 17: SAVE OUTPUT
    38 % 17: SAVE OUTPUT
    39 
    39 
    40 %======================================================================
    40 %======================================================================
    41 %                    P R O C E S S _ C A S T . M 
    41 %                    P R O C E S S _ C A S T . M 
    42 %                    doc: Thu Jun 24 16:54:23 2004
    42 %                    doc: Thu Jun 24 16:54:23 2004
    43 %                    dlm: Wed Mar 29 12:57:24 2017
    43 %                    dlm: Wed Sep  4 17:59:11 2019
    44 %                    (c) 2004 A.M. Thurnherr
    44 %                    (c) 2004 A.M. Thurnherr
    45 %                    uE-Info: 90 39 NIL 0 0 72 0 2 8 NIL ofnI
    45 %                    uE-Info: 467 12 NIL 0 0 72 0 2 8 NIL ofnI
    46 %======================================================================
    46 %======================================================================
    47 
    47 
    48 % NOTES:
    48 % NOTES:
    49 %  - changing this function should not be required, except to fix bugs
    49 %  - changing this function should not be required, except to fix bugs
    50 %  - in order to preserve state variables across load/save calls in matlab,
    50 %  - in order to preserve state variables across load/save calls in matlab,
    86 %  Oct 14, 2016: - BUG: ctd_t, ctd_s were set after first pass, sometimes
    86 %  Oct 14, 2016: - BUG: ctd_t, ctd_s were set after first pass, sometimes
    87 %			causing inconsistent vector lengths
    87 %			causing inconsistent vector lengths
    88 %  Mar 29, 2017: - added att and da to saveres
    88 %  Mar 29, 2017: - added att and da to saveres
    89 %	 	 - added saveplot_pdf
    89 %	 	 - added saveplot_pdf
    90 %		 - made fignums 2-digit
    90 %		 - made fignums 2-digit
       
    91 %  Sep 15, 2018: - disabled serial-number code
       
    92 %  Feb  8, 2019: - added pause before saving figures (TheThinMint requires this)
       
    93 %  Feb 16, 2019: - move cast post-processing to step 17 so that post-processing
       
    94 %		   is done before results are saved
       
    95 %  Aug 30, 2019: - changed error message about p.getdepth
       
    96 %  Sep  4, 2019: - replaced [getshear2.m] by GK's new [calc_shear3.m]
    91 
    97 
    92 %----------------------------------------------------------------------
    98 %----------------------------------------------------------------------
    93 % STEP 0: EXECUTE ALWAYS
    99 % STEP 0: EXECUTE ALWAYS
    94 %----------------------------------------------------------------------
   100 %----------------------------------------------------------------------
    95 
   101 
   171   %  2) merge down-up data
   177   %  2) merge down-up data
   172   %  3) do some fist order error checks
   178   %  3) do some fist order error checks
   173   [d,p]=loadrdi(f,p); 
   179   [d,p]=loadrdi(f,p); 
   174 
   180 
   175   % get instrument serial number
   181   % get instrument serial number
   176   p=getserial(f,p);
   182   %  p=getserial(f,p);
   177 
   183 
   178   end_processing_step;
   184   end_processing_step;
   179 end % OF STEP 1: LOAD DATA
   185 end % OF STEP 1: LOAD DATA
   180 
   186 
   181 %----------------------------------------------------------------------
   187 %----------------------------------------------------------------------
   289 
   295 
   290   %  Find depth and bottom and surface using ADCP data 
   296   %  Find depth and bottom and surface using ADCP data 
   291   if p.getdepth==2
   297   if p.getdepth==2
   292    [d,p]=getdpthi(d,p);
   298    [d,p]=getdpthi(d,p);
   293    if length(find(~isfinite(d.izm(1,:))))
   299    if length(find(~isfinite(d.izm(1,:))))
   294      error('Non-finite values in d.izm --- try processing with p.getdepth == 1');
   300      error('Missing values in d.izm --- likely missing values in CTD file (processing with p.getdepth = 1; might work');
   295    end
   301    end
   296   else
   302   else
   297    [d,p]=getdpth(d,p);
   303    [d,p]=getdpth(d,p);
   298   end
   304   end
   299 
   305 
   454   %  second use super ensemble data
   460   %  second use super ensemble data
   455   ps=setdefv(ps,'shear',1);
   461   ps=setdefv(ps,'shear',1);
   456   
   462   
   457   if ps.shear>0
   463   if ps.shear>0
   458    if ps.shear==1
   464    if ps.shear==1
   459     [ds,dr,ps,p]=getshear2(d,p,ps,dr);
   465     [ds,p,dr]=calc_shear3(d,p,ps,dr);		% use all data (d)
   460    else
   466    else
   461     [ds,dr,ps,p]=getshear2(di,p,ps,dr);
   467     [ds,p,dr]=calc_shear3(di,p,ps,dr);		% use superensemble data (di)
   462    end
   468    end
   463   end
   469   end
   464 
   470 
   465   end_processing_step;
   471   end_processing_step;
   466 end % OF STEP 15: CALCULATE SHEAR SOLUTION
   472 end % OF STEP 15: CALCULATE SHEAR SOLUTION
   529   end
   535   end
   530   if existf(d,'ctdprof_ss')
   536   if existf(d,'ctdprof_ss')
   531     dr.ctd_ss=interp1q(d.ctdprof_z,d.ctdprof_ss,dr.z);
   537     dr.ctd_ss=interp1q(d.ctdprof_z,d.ctdprof_ss,dr.z);
   532   end
   538   end
   533 
   539 
       
   540   if exist('post_process_cast','file')	% cruise-specific post-processing
       
   541     post_process_cast;
       
   542   end
       
   543 
   534   if length(f.res)>1
   544   if length(f.res)>1
   535   
   545   
   536     %
   546     %
   537     % save results to ASCII, MATLAB and NETCD files
   547     % save results to ASCII, MATLAB and NETCD files
   538     %
   548     %
   548        j = p.saveplot(i);
   558        j = p.saveplot(i);
   549        if any(ismember(j,pcs.update_figures))
   559        if any(ismember(j,pcs.update_figures))
   550          disp(sprintf('  figure %d...',j));
   560          disp(sprintf('  figure %d...',j));
   551          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   561          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   552          if ok
   562          if ok
   553            figure(j);
   563            figure(j); pause(1);
   554            eval(sprintf('print -dpsc %s_%02d.ps',f.res,j))
   564            eval(sprintf('print -dpsc %s_%02d.ps',f.res,j))
   555          end
   565          end
   556        end
   566        end
   557     end
   567     end
   558     for i = 1:length(p.saveplot_png)
   568     for i = 1:length(p.saveplot_png)
   559        j = p.saveplot_png(i);
   569        j = p.saveplot_png(i);
   560        if any(ismember(j,pcs.update_figures))
   570        if any(ismember(j,pcs.update_figures))
   561          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   571          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   562          if ok
   572          if ok
   563            figure(j)
   573            figure(j); pause(1);
   564            eval(sprintf('print -dpng %s_%02d.png',f.res,j))
   574            eval(sprintf('print -dpng %s_%02d.png',f.res,j))
   565          end
   575          end
   566        end
   576        end
   567     end
   577     end
   568     for i = 1:length(p.saveplot_pdf)
   578     for i = 1:length(p.saveplot_pdf)
   569        j = p.saveplot_pdf(i);
   579        j = p.saveplot_pdf(i);
   570        if any(ismember(j,pcs.update_figures))
   580        if any(ismember(j,pcs.update_figures))
   571          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   581          ok = 1; eval(sprintf('h = get(%d);',j),'ok = 0;');
   572          if ok
   582          if ok
   573            figure(j)
   583            figure(j); pause(1);
   574            eval(sprintf('print -dpdf %s_%02d.pdf',f.res,j))
   584            eval(sprintf('print -dpdf %s_%02d.pdf',f.res,j))
   575          end
   585          end
   576        end
   586        end
   577     end
   587     end
   578 
   588 
   590 
   600 
   591 %----------------------------------------------------------------------
   601 %----------------------------------------------------------------------
   592 % FINAL STEP: CLEAN UP
   602 % FINAL STEP: CLEAN UP
   593 %----------------------------------------------------------------------
   603 %----------------------------------------------------------------------
   594 
   604 
   595 if exist('post_process_cast','file')	% cruise-specific post-processing
       
   596   post_process_cast;
       
   597 end
       
   598 
       
   599 fclose('all');				%  close all files just to make sure
   605 fclose('all');				%  close all files just to make sure
   600 
   606 
   601 disp(' ')				% final message
   607 disp(' ')				% final message
   602 disp(['==> The whole task took ',int2str(toc),' seconds'])
   608 disp(['==> The whole task took ',int2str(toc),' seconds'])
   603 
   609