Home > ctdcal > demos > load_salts_ab0409.m

load_salts_ab0409

PURPOSE ^

load_salts: Load the autosal samples into the cruise database.

SYNOPSIS ^

function theResult = load_salts(cruiseid)

DESCRIPTION ^

 load_salts: Load the autosal samples into the cruise database.
 
 CTD Calibration toolbox
 
 INPUT: 
   cruiseid: character array containing the cruise id.

 OUTPUT:
   theSalts: Combined salinity structure

 DESCRIPTION:    


 
 AUTHOR: 
            Derrick Snowden
            NOAA/AOML/PhOD
            Fri Oct 01 18:32:14 EDT 2004

 CHANGELOG: 
   08-Jul-2004, Version 1.0
        * Initial version.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function theResult  = load_salts(cruiseid)
0002 % load_salts: Load the autosal samples into the cruise database.
0003 %
0004 % CTD Calibration toolbox
0005 %
0006 % INPUT:
0007 %   cruiseid: character array containing the cruise id.
0008 %
0009 % OUTPUT:
0010 %   theSalts: Combined salinity structure
0011 %
0012 % DESCRIPTION:
0013 %
0014 %
0015 %
0016 % AUTHOR:
0017 %            Derrick Snowden
0018 %            NOAA/AOML/PhOD
0019 %            Fri Oct 01 18:32:14 EDT 2004
0020 %
0021 % CHANGELOG:
0022 %   08-Jul-2004, Version 1.0
0023 %        * Initial version.
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 % Check for correct number of inputs.
0028 error(nargchk(1,1,nargin))
0029 
0030 % Retrieve the necessary preferences for this cruise
0031 group = group_name(cruiseid);
0032 
0033 % btl_dir is the calibration data directory
0034 if ispref(group,'cal_autosal_dir')
0035     cal_autosal_dir=getpref(group,'cal_autosal_dir');
0036 else
0037     error(['The cal_autosal_dir preference was not set for cruise: ' cruiseid '.  Run register_cruise.m']);
0038 end
0039 
0040 % cruise_dir is the calibration data directory
0041 if ispref(group,'cal_data_dir')
0042     cruise_dir=getpref(group,'cal_data_dir');
0043 else
0044     error(['The cal_data_dir preference was not set for cruise: ' cruiseid '.  Run register_cruise.m']);
0045 end
0046 
0047 % This file will contain the summary information
0048 % It is currently buggy and may not work.  Nevertheless, it is intended
0049 % to be different for each cruise EDIT
0050 sumfile =  fullfile(cal_autosal_dir,'ab0409_salinity_summary.txt');
0051 
0052 % EDIT
0053 year = 2004;
0054 
0055 
0056 % EDIT  If you have more than one batch of standard water per cruise you may
0057 % need to include this in the loop below and change it for each autosal file.
0058 nominal_std_conductivity = 1.99987; % This is fake for testing only....
0059 
0060 % The cruise database.  Don't edit this line.
0061 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0062 
0063 % EDIT Maybe.  The following two lines should be pretty standard on the Brown.
0064 dat_files = dir(fullfile(cal_autosal_dir,'*.dat'));
0065 raw_files = dir(fullfile(cal_autosal_dir,'*.raw'));
0066 
0067 for idx_file = 1:length(dat_files)
0068     [pathstr,namestr,ext,vers] = fileparts(dat_files(idx_file).name);
0069     % EDIT  The file naming convention I have encountered is MMDDHH or 2 dgit monthe
0070     % two digit day and two digit gmt hour at which the autosal analysis was performed.
0071     [mnth,day,gmthr] = strread(namestr,'%02d%02d%02d');
0072     this_dat = fullfile(cal_autosal_dir,dat_files(idx_file).name);
0073     this_raw = fullfile(cal_autosal_dir,raw_files(idx_file).name);
0074     % EDIT The raw files are pretty standard and should not need to be edited often.
0075     raw = read_autosal_raw(this_raw);
0076     % EDIT The dat files are likely different on each cruise.
0077     % Take an example read_autosal_dat_*.m and edit it according to your current configuration
0078     % then include it in the line below.  NOTE it MUST have the same input/output syntax as
0079     % examples.
0080     salts = read_autosal_dat_wward3(this_dat); % specialized for your cruise
0081     % If you've done the read_autosal_dat correctly, the followind two lines will work.
0082     autosal=match_autosal_raw_dat(salts,raw,sumfile,[year mnth day])
0083     cond(idx_file) = correct_autosal_drift(nominal_std_conductivity,autosal,sumfile);
0084     %keyboard
0085     % Everything works to here for stc02.
0086     % 1. Concatentate the samples together so that they don't overwrite each other when
0087     %     saved to the db_file.
0088     % 2. Verify that the autosal struct above is what carlos needs for the make_cond_sumfile.
0089     %
0090 end
0091 
0092 
0093 % Open the output file
0094 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0095 if exist(db_file)==2
0096     save(db_file,'cond','-append');
0097 else
0098     save(db_file,'cond');
0099 end
0100 if nargout==0
0101     assignin('caller','ans',cond);
0102     return
0103 else
0104     varargout{1}=cond;
0105     return
0106 end
0107 %
0108

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