function [pser,Jhour_start]=cts_read(CTS,Jhour_start,nT_int)
%
% Call [pser,Jhour_start]=cts_read(CTS,Jhour_start,nT_int);
%
% CTS		    = output structure from cts_open;
% Jhour_start	= Hour of day to start reading;
% nT_int		= Number of samples to read;
%
% OUTPUTS:
% pser			= nT_int by nrec complex time series in uPa;
% Jhour_start	= Actual hour of day of first sample;

% Obtain input structure CTS from: CTS=cts_open(cts_root);
%
% See:  cts_details, cts_open, cts_read, cts_write, cts_write_open, cts_combine, cts2fft, cts2spec, 
%       cts_from_real, cts_shot, cts_wf_make, fft2cts, mcs_gui.
%
dt=1/CTS.fs;
%
% Position file to starting point Jhour_start:
Jhour_start=max(Jhour_start,CTS.Jhour1);			% Can't start before first time in file;
nT_t1=round(3600*(Jhour_start-CTS.Jhour1)/dt);	% Number of time samples into data to start;
Jhour_start=CTS.Jhour1 + nT_t1*dt/3600;			% Compute exact start time;
fmt='real*4';
nbyte_sample=8*CTS.nrec;										% Number of bytes per (complex) sample of all receivers;
offset=4*CTS.header(1) + nbyte_sample*nT_t1;	% Offset from beginning of file
fseek(CTS.fid_cts,offset,-1);							% Seek to desired position in .cts file;
%
% Read in nT_int samples of complex data for nrec receivers:
[pser,count]=fread(CTS.fid_cts,[2*CTS.nrec,nT_int],fmt);
pser=pser(1:2:2*CTS.nrec,:)' + i*pser(2:2:2*CTS.nrec,:)';		% pser is nT_int by nrec complex;
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
