Home > ctdcal > load_btl.m

load_btl

PURPOSE ^

load_btl: Read and save the SeaBird ASCII .BTL file format

SYNOPSIS ^

function varargout = load_btl(cruiseid)

DESCRIPTION ^

 load_btl: Read  and save the SeaBird ASCII .BTL file format

 CTD Calibration toolbox.

 INPUT: cruiseid: Cruise identification name. 

 USAGE: 
 load_btl(cruiseid): read the SeaBird ASCII .BTL files and save in
                     the database file of the cruise.This file will
                     be named "cruiseid"_db.mat 
                     
 btl=load_btl(cruiseid) : Additionally, it will save the  .BTL files 
                          in the workspace

 AUTHORS:Carlos Fonseca 
         UM/CIMAS
         Derrick Snowden
         NOAA/AOML/PhOD
         Tue May 11 11:23:37 EDT 2004

 CHANGELOG: 
   23-Jul-2004, Version 1.0
        * Initial version.
   01-Oct-2004  Derrick Snowden 
        * load_btl (load_btl): Removed dependence on directory structure in favor of 
             register_cruise

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout  = load_btl(cruiseid)
0002 % load_btl: Read  and save the SeaBird ASCII .BTL file format
0003 %
0004 % CTD Calibration toolbox.
0005 %
0006 % INPUT: cruiseid: Cruise identification name.
0007 %
0008 % USAGE:
0009 % load_btl(cruiseid): read the SeaBird ASCII .BTL files and save in
0010 %                     the database file of the cruise.This file will
0011 %                     be named "cruiseid"_db.mat
0012 %
0013 % btl=load_btl(cruiseid) : Additionally, it will save the  .BTL files
0014 %                          in the workspace
0015 %
0016 % AUTHORS:Carlos Fonseca
0017 %         UM/CIMAS
0018 %         Derrick Snowden
0019 %         NOAA/AOML/PhOD
0020 %         Tue May 11 11:23:37 EDT 2004
0021 %
0022 % CHANGELOG:
0023 %   23-Jul-2004, Version 1.0
0024 %        * Initial version.
0025 %   01-Oct-2004  Derrick Snowden
0026 %        * load_btl (load_btl): Removed dependence on directory structure in favor of
0027 %             register_cruise
0028 
0029 % Check for correct number of inputs.
0030 error(nargchk(1,1,nargin))
0031 
0032 % Retrieve the necessary preferences for this cruise
0033 group = group_name(cruiseid);
0034 
0035 % btl_dir is the calibration data directory
0036 if ispref(group,'cal_btl_dir')
0037     btl_dir=getpref(group,'cal_btl_dir');
0038 else
0039     error(['The cal_btl_dir preference was not set for cruise: ' cruiseid '.  Run register_cruise.m']);
0040 end
0041 
0042 % cruise_dir is the calibration data directory
0043 if ispref(group,'cal_data_dir')
0044     cruise_dir=getpref(group,'cal_data_dir');
0045 else
0046     error(['The cal_data_dir preference was not set for cruise: ' cruiseid '.  Run register_cruise.m']);
0047 end
0048 
0049 % Check that the btl files are in the given directory.
0050 % TODO: Make use of the upper case/lower case preference.
0051 lc_btl = dir(fullfile(btl_dir,'*.btl')); 
0052 uc_btl = dir(fullfile(btl_dir,'*.BTL'));
0053 if size(lc_btl)==size(uc_btl)
0054     btl_names = lc_btl;
0055 else
0056     if ~isempty(lc_btl) & ~isempty(uc_btl)
0057         error(['The *.btl files in ', btl_dir...
0058         ,' are named in both upper and lower case.  Pick one and rename before running ',mfilename]);
0059     elseif isempty(lc_btl) & ~isempty(uc_btl)
0060         btl_names = uc_btl;
0061     elseif ~isempty(lc_btl) & isempty(uc_btl)
0062         btl_names = lc_btl;
0063     else
0064         error(['No *.btl files were found in ', btl_dir]);
0065     end
0066 end
0067 
0068 % The files are there, retrieve the data.
0069 for i=1:length(btl_names)
0070     btl(i)=read_sbebtl(fullfile(btl_dir,btl_names(i).name));
0071 end
0072 
0073 % Open the output file
0074 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0075 if exist(db_file)==2
0076     save(db_file,'btl','-append');
0077 else
0078     save(db_file,'btl');
0079 end
0080 if nargout==0
0081     assignin('caller','ans',btl);
0082     return
0083 else
0084     varargout{1}=btl;
0085     return
0086 end
0087 %
0088

Generated on Fri 08-Oct-2004 11:57:17 by m2html © 2003