Home > RPSstuff > mergescal.m

mergescal

PURPOSE ^

MERGESCAL Merges scalar data from multiple EPIC time series files

SYNOPSIS ^

function [wi,jd]=mergescal(cdflist,uname,start,stop,dt);

DESCRIPTION ^

 MERGESCAL   Merges scalar data from multiple EPIC time series files
             onto a uniform time base (perhaps with gaps)
 

 Usage: [u,jd]=mergescal(cdflist,uname,start,stop,dt);

      Inputs:  cdflist = array of netcdf file names, one name per row 
               uname = character string containing the variable name 
                       that you want to contatenate
                       (must be found in all files in CDFLIST)
               start =  gregorian start time
               stop  =  gregorian stop time
               dt    =  time interval (seconds) for concatenated time series

      Outputs: u = new scalar time series with uniform time base
              jd = corresponding julian day time base 

      Example:  [u,jd]=mergescal(['file_1.nc '
                                   'file_2.nc '
                                   'file_10.nc'],...
                   'T_20',[1997 4 1 8 0 0],[1998 8 2 0 0 0],3600);

       This merges temperature from three different deployments onto
       a uniform hourly time base beginning at April 1, 1998, 0800 UTC
       and ending August 2, 0000 UTC.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [wi,jd]=mergescal(cdflist,uname,start,stop,dt);
0002 % MERGESCAL   Merges scalar data from multiple EPIC time series files
0003 %             onto a uniform time base (perhaps with gaps)
0004 %
0005 %
0006 % Usage: [u,jd]=mergescal(cdflist,uname,start,stop,dt);
0007 %
0008 %      Inputs:  cdflist = array of netcdf file names, one name per row
0009 %               uname = character string containing the variable name
0010 %                       that you want to contatenate
0011 %                       (must be found in all files in CDFLIST)
0012 %               start =  gregorian start time
0013 %               stop  =  gregorian stop time
0014 %               dt    =  time interval (seconds) for concatenated time series
0015 %
0016 %      Outputs: u = new scalar time series with uniform time base
0017 %              jd = corresponding julian day time base
0018 %
0019 %      Example:  [u,jd]=mergescal(['file_1.nc '
0020 %                                   'file_2.nc '
0021 %                                   'file_10.nc'],...
0022 %                   'T_20',[1997 4 1 8 0 0],[1998 8 2 0 0 0],3600);
0023 %
0024 %       This merges temperature from three different deployments onto
0025 %       a uniform hourly time base beginning at April 1, 1998, 0800 UTC
0026 %       and ending August 2, 0000 UTC.
0027 
0028 %   Rich Signell, USGS  rsignell@usgs.gov  (August 7, 1998)
0029 
0030 jd0=julian(start);
0031 jd1=julian(stop);
0032 % number of points
0033 npts=((jd1-jd0)/(dt/3600/24))+1;
0034 jdi=0:npts-1;
0035 jdi=jdi*dt;     %time in seconds from start
0036 wi=jdi*NaN;
0037 
0038 [m,n]=size(cdflist);
0039 for icdf=1:m,
0040   cdf=cdflist(icdf,:);
0041   ind=min(find(cdf==' '));
0042   if(length(ind)>0),
0043     cdf=cdf(1:ind-1);
0044   end
0045 %  [w,jd]=getts(cdf,uname,start,stop);
0046   cdf
0047   [w,jd]=getts(cdf,uname);
0048   if(isempty(w)==0),
0049 % convert to seconds from start
0050     jd=(jd-jd0)*24*3600;
0051     w=interp1(jd,w,jdi);
0052     ind=find(~isnan(w));
0053     wi(ind)=w(ind);
0054   end
0055 end
0056 wi=wi(:);
0057 jd=jd0+jdi/3600/24;

Generated on Wed 30-Nov-2005 14:45:02 by m2html © 2003