LOAD_OXY - Load a *.oxy files from the AOML Winkler titration system. CTD Calibration toolbox. USAGE: >> load_oxy(cruiseid) Read the *.oxy files and save the results in the cruise database file. >> oxy=load_oxy(cruiseid) Return the data from the *.oxy files as a structure to the workspace INPUT: cruiseid: Cruise identification name. OUTPUT: oxy: struct with fields date: time and data of titration (usually wrong on AOML computer) station: string indicating station/cast depth: depth field in the titration computer, frequently Niskin bottle Rosette position sample_bottle: label of the sample bottle in which the titration was done. thio_vol: solume of Thiosulphate in the titration. oxygen: oxygen in units of micromoles per liter. See ox_units for conversion to other more standard units for analysis. units: 'mmmperl'
0001 function varargout = load_oxy(cruiseid) 0002 % LOAD_OXY - Load a *.oxy files from the AOML Winkler titration system. 0003 % 0004 % CTD Calibration toolbox. 0005 % 0006 % USAGE: 0007 % >> load_oxy(cruiseid) 0008 % Read the *.oxy files and save the results in the cruise database file. 0009 % 0010 % >> oxy=load_oxy(cruiseid) 0011 % Return the data from the *.oxy files as a structure to the workspace 0012 % 0013 % INPUT: 0014 % cruiseid: Cruise identification name. 0015 % 0016 % OUTPUT: 0017 % oxy: struct with fields 0018 % date: time and data of titration (usually wrong on AOML computer) 0019 % station: string indicating station/cast 0020 % depth: depth field in the titration computer, frequently Niskin bottle Rosette position 0021 % sample_bottle: label of the sample bottle in which the titration was done. 0022 % thio_vol: solume of Thiosulphate in the titration. 0023 % oxygen: oxygen in units of micromoles per liter. See ox_units for conversion to other 0024 % more standard units for analysis. 0025 % units: 'mmmperl' 0026 % 0027 0028 % AUTHORS:Carlos Fonseca 0029 % UM/CIMAS 0030 % Derrick Snowden 0031 % NOAA/AOML/PhOD 0032 % Tue May 11 11:23:37 EDT 2004 0033 % 0034 % CHANGELOG: 0035 % 23-Jul-2004, Version 1.0 0036 % * Initial version. 0037 % 0038 % 01-Oct-2004 Derrick Snowden 0039 % * load_oxy (load_oxy): Removed dependence on directory structure in favor of 0040 % register_cruise 0041 0042 0043 % Check for correct number of inputs. 0044 error(nargchk(1,1,nargin)) 0045 0046 % Retrieve the necessary preferences for this cruise 0047 group = group_name(cruiseid); 0048 0049 % oxy_dir is the calibration data directory 0050 if ispref(group,'cal_oxy_dir') 0051 oxy_dir=getpref(group,'cal_oxy_dir'); 0052 else 0053 error(['The cal_oxy_dir preference was not set for cruise: ' cruiseid '. Run register_cruise.m']); 0054 end 0055 0056 % cruise_dir is the calibration data directory 0057 if ispref(group,'cal_data_dir') 0058 cruise_dir=getpref(group,'cal_data_dir'); 0059 else 0060 error(['The cal_data_dir preference was not set for cruise: ' cruiseid '. Run register_cruise.m']); 0061 end 0062 0063 % Check that the oxy files are in the given directory. 0064 % TODO: Make use of the upper case/lower case preference. 0065 lc_oxy = dir(fullfile(oxy_dir,'*.oxy')); 0066 uc_oxy = dir(fullfile(oxy_dir,'*.OXY')); 0067 if size(lc_oxy)==size(uc_oxy) 0068 oxy_names = lc_oxy; 0069 else 0070 if ~isempty(lc_oxy) & ~isempty(uc_oxy) 0071 error(['The *.oxy files in ', oxy_dir... 0072 ,' are named in both upper and lower case. Pick one and rename before running ',mfilename]); 0073 elseif isempty(lc_oxy) & ~isempty(uc_oxy) 0074 oxy_names = uc_oxy; 0075 elseif ~isempty(lc_oxy) & isempty(uc_oxy) 0076 oxy_names = lc_oxy; 0077 else 0078 error(['No *.oxy files were found in ', oxy_dir]); 0079 end 0080 end 0081 0082 % The files are there, retrieve the data. 0083 for i=1:length(oxy_names) 0084 oxy(i)=read_oxy(fullfile(oxy_dir,oxy_names(i).name)); 0085 end 0086 0087 % Open the output file 0088 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']); 0089 if exist(db_file)==2 0090 save(db_file,'oxy','-append'); 0091 else 0092 save(db_file,'oxy'); 0093 end 0094 if nargout==0 0095 assignin('caller','ans',oxy); 0096 return 0097 else 0098 varargout{1}=oxy; 0099 return 0100 end 0101