0001 function oxy_cal = make_oxy_sumfile_shallow(cruiseid)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 flag_message1=0;
0046 flag_message2=0;
0047 flag_conv1=0;
0048 flag_conv2=0;
0049
0050 group = group_name(cruiseid);
0051
0052
0053 if ispref(group,'cal_data_dir')
0054 cruise_dir=getpref(group,'cal_data_dir');
0055 else
0056 error(['The cal_data_dir preference was not set for cruise: ' cruiseid '. Run register_cruise.m']);
0057 end
0058
0059
0060 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0061 if exist(db_file)==2
0062 load(db_file);
0063 else
0064 error(['The cruise data base file was not found on the path. ' db_file]);
0065 end
0066
0067
0068 n=who('btl');
0069 if isempty(n)==1
0070 error(['btl variable not found in the cruise database. Run load_btl.m ']);
0071 return;
0072 end
0073 n=who('bl');
0074 if isempty(n)==1
0075 error(['bl variable not found in the cruise database. Run load_bl.m ']);
0076 return;
0077 end
0078 n=who('oxy');
0079 if isempty(n)==1
0080 error(['oxy variable not found in the cruise database. Run load_oxy.m ']);
0081 return;
0082 end
0083
0084 oxy_cal.cruiseid=cruiseid;
0085
0086 stations= unique(vertcat(oxy.station));
0087 oxy_cal.stnnbr=vertcat(oxy.station);
0088 oxy_cal.castnbr=vertcat(oxy.station);
0089 oxy_cal.sampnbr=vertcat(oxy.sample_bottle);
0090 oxy_cal.btlnbr=vertcat(oxy.depth);
0091 oxy_cal.niskinbtlpos=vertcat(oxy.depth);
0092
0093 for i=1:1:length(oxy_cal.btlnbr)
0094 oxy_cal.stnnbr(i);
0095 if (oxy_cal.stnnbr(i)==0)
0096 oxy_cal.fireorder(i,1)=NaN;
0097 else
0098 fire_index=find(bl(oxy_cal.stnnbr(i)).niskinnumber==oxy_cal.btlnbr(i));
0099 oxy_cal.fireorder(i,1)=bl(oxy_cal.stnnbr(i)).fireorder(fire_index);
0100 end
0101 end
0102
0103 oxy_cal.btloxy=vertcat(oxy.oxygen)*0.02239;
0104
0105
0106 jj_nan=find(isnan(oxy_cal.fireorder)==0);
0107 oxy_cal.fireorder=oxy_cal.fireorder(jj_nan);
0108 oxy_cal.stnnbr=oxy_cal.stnnbr(jj_nan);
0109 oxy_cal.castnbr=oxy_cal.castnbr(jj_nan);
0110 oxy_cal.sampnbr=oxy_cal.sampnbr(jj_nan);
0111 oxy_cal.btlnbr=oxy_cal.btlnbr(jj_nan);
0112 oxy_cal.niskinbtlpos=oxy_cal.niskinbtlpos(jj_nan);
0113 oxy_cal.btloxy=oxy_cal.btloxy(jj_nan);
0114
0115
0116 disp('**************************************');
0117 disp('Extracting information from .btl files');
0118 disp('**************************************');
0119 for i=1:length(oxy_cal.btloxy)
0120 sta_idx=oxy_cal.stnnbr(i);
0121 fire_idx=oxy_cal.fireorder(i);
0122
0123 for j=1:length(btl(sta_idx).names);
0124 if strncmp(btl(sta_idx).names(j),'pressure',8);
0125 pr_idx=j;
0126 end
0127 if strncmp(btl(sta_idx).names(j),'con_pri',7);
0128 ctd_c1_idx=j;
0129 end
0130 if strncmp(btl(sta_idx).names(j),'con_sec',7);
0131 ctd_c2_idx=j;
0132 end
0133 if strncmp(btl(sta_idx).names(j),'sbedo2_mll_pri',14);
0134 ctd_oxy1_idx=j;
0135 end
0136 if strncmp(btl(sta_idx).names(j),'sbedo2_mll_sec',14);
0137 ctd_oxy2_idx=j;
0138 end
0139 if strncmp(btl(sta_idx).names(j),'sbeox_volt_pri',14);
0140 ctd_oxv1_idx=j;
0141 end
0142 if strncmp(btl(sta_idx).names(j),'sbeox_volt_sec',14);
0143 ctd_oxv2_idx=j;
0144 end
0145 if strncmp(btl(sta_idx).names(j),'sbeox_dOCdt_pri',15);
0146 ctd_dvdt1_idx=j;
0147 end
0148 if strncmp(btl(sta_idx).names(j),'sbeox_dOCdt_sec',15);
0149 ctd_dvdt2_idx=j;
0150 end
0151 if strncmp(btl(sta_idx).names(j),'t68_pri',7);
0152 ctd_t1_idx=j;
0153 end
0154 if strncmp(btl(sta_idx).names(j),'t68_sec',7);
0155 ctd_t2_idx=j;
0156 end
0157 if strncmp(btl(sta_idx).names(j),'t90_pri',7);
0158 ctd_t1_idx=j;
0159 flag_conv1=1;
0160 if flag_message1==0
0161 disp('Primary temperatures are given in T90.')
0162 disp('This program will convert to T68 to make the necessary calculations')
0163 flag_message1=1;
0164 end
0165 end
0166 if strncmp(btl(sta_idx).names(j),'t90_sec',7);
0167 ctd_t2_idx=j;
0168 flag_conv2=1;
0169 if flag_message2==0
0170 disp('Secondary temperatures are given in T90.')
0171 disp('This program will convert to T68 to make the necessary calculations')
0172 flag_message2=1;
0173 end
0174 end
0175 end
0176 oxy_cal.ctdprs(i,1)=btl(sta_idx).data(fire_idx,pr_idx);
0177 oxy_cal.ctdcon1(i,1)=10*btl(sta_idx).data(fire_idx,ctd_c1_idx);
0178 oxy_cal.ctdcon2(i,1)=10*btl(sta_idx).data(fire_idx,ctd_c2_idx);
0179 oxy_cal.ctdoxy1(i,1)=btl(sta_idx).data(fire_idx,ctd_oxy1_idx);
0180 oxy_cal.ctdoxy2(i,1)=btl(sta_idx).data(fire_idx,ctd_oxy2_idx);
0181 oxy_cal.ctdoxv1(i,1)=btl(sta_idx).data(fire_idx,ctd_oxv1_idx);
0182 oxy_cal.ctdoxv2(i,1)=btl(sta_idx).data(fire_idx,ctd_oxv2_idx);
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199 oxy_cal.ctdtmp1(i,1)=btl(sta_idx).data(fire_idx,ctd_t1_idx);
0200 if flag_conv1==1;
0201 oxy_cal.ctdtmp1(i,1)=t90tot68(oxy_cal.ctdtmp1(i,1));
0202 end
0203 oxy_cal.ctdtmp2(i,1)=btl(sta_idx).data(fire_idx,ctd_t2_idx);
0204 if flag_conv2==1;
0205 oxy_cal.ctdtmp2(i,1)=t90tot68(oxy_cal.ctdtmp2(i,1));
0206 end
0207 end
0208 disp('*****************************************');
0209 disp('Matching .btl information with .oxy files')
0210 disp('*****************************************');
0211 oxy_cal.ctdsal1=sw_salt(oxy_cal.ctdcon1/sw_c3515,oxy_cal.ctdtmp1,oxy_cal.ctdprs);
0212 oxy_cal.ctdsigflu1=sw_pden(oxy_cal.ctdsal1,oxy_cal.ctdtmp1,oxy_cal.ctdprs,oxy_cal.ctdprs)-1000;
0213 oxy_cal.ctdsal2=sw_salt(oxy_cal.ctdcon1/sw_c3515,oxy_cal.ctdtmp1,oxy_cal.ctdprs);
0214 oxy_cal.ctdsigflu2=sw_pden(oxy_cal.ctdsal2,oxy_cal.ctdtmp2,oxy_cal.ctdprs,oxy_cal.ctdprs)-1000;
0215
0216
0217 save(db_file,'oxy_cal','-append');
0218
0219 if nargout==0
0220 assignin('caller','ans',oxy_cal);
0221 return
0222 else
0223 varargout{1}=oxy_cal;
0224 return
0225 end
0226 return
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238