Home > ctdcal > demos > load_salts_stc02.m

load_salts_stc02

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,'stc02_salinity_summary.txt');
0051 
0052 % EDIT
0053 year = 2002;
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.999; % 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     disp(['Working on autosal file ' dat_files(idx_file).name])
0069     [pathstr,namestr,ext,vers] = fileparts(dat_files(idx_file).name);
0070     % EDIT  The file naming convention I have encountered is MMDDHH or 2 dgit monthe
0071     % two digit day and two digit gmt hour at which the autosal analysis was performed.
0072     [mnth,day,gmthr] = strread(namestr,'%02d%02d%02d');
0073     this_dat = fullfile(cal_autosal_dir,dat_files(idx_file).name);
0074     this_raw = fullfile(cal_autosal_dir,raw_files(idx_file).name);
0075     % EDIT The raw files are pretty standard and should not need to be edited often.
0076     raw = read_autosal_raw(this_raw);
0077     % EDIT The dat files are likely different on each cruise.
0078     % Take an example read_autosal_dat_*.m and edit it according to your current configuration
0079     % then include it in the line below.  NOTE it MUST have the same input/output syntax as
0080     % examples.
0081     salts = read_autosal_dat_stc02(this_dat); % specialized for your cruise
0082     % If you've done the read_autosal_dat correctly, the followind two lines will work.
0083     autosal=match_autosal_raw_dat(salts,raw,sumfile,[year mnth day]);
0084     cond(idx_file) = correct_autosal_drift(nominal_std_conductivity,autosal,sumfile);
0085     %keyboard
0086     % Everything works to here for stc02.
0087     % 1. Concatentate the samples together so that they don't overwrite each other when
0088     %     saved to the db_file.
0089     % 2. Verify that the autosal struct above is what carlos needs for the make_cond_sumfile.
0090     %
0091 end
0092 
0093 
0094 % Open the output file
0095 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0096 if exist(db_file)==2
0097     save(db_file,'cond','-append');
0098 else
0099     save(db_file,'cond');
0100 end
0101 if nargout==0
0102     assignin('caller','ans',cond);
0103     return
0104 else
0105     varargout{1}=cond;
0106     return
0107 end
0108

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