close all;clear all; % ECO_CAL_DATA1 uses IAG's GetOriginalDataServlet to extract the raw data via the web. % The data are then averaged and calibrations are applied. % Calibrated data files are created for inclusion into the SSDS catalog. % A log file of the results is written to the CIMT directory. % Process both ECO devices and creates two data files: fluorescence % and backscatter % 09 June 2004 rpm %------------------------------------------------------------------------- % Requires: % readProperties.m % getProperty.m % getprops.m % urlread.m % extract_ecodata.m % avg_ecodata.m % ecofl_calibrate.m % ecobb_calibrate.m % plot_eco.m %------------------------------------------------------------------------- % :::::::::::::::::::::::::::::: Begin Processing ::::::::::::::::::::::::::::::::::::::::::: try, %ecotype='ecofl'; % **Process the ECOFL Fluorometer newpath=MBARI_path('/hosts/tornado/vol/vol0/ssdsdata/ecocimt/src'); cd(newpath); cdir = ['../configuration/ecofl2.properties']; prop = readProperties(cdir); otype='data'; p=getprops(prop,otype); days=1; line_ct=0; % Check start and end dates to see if the data has already been processed. status=1; t=datestr(now-1,30); startD=[t(1:8),'.000000']; t=datestr(now,30); endD=[t(1:8),'.000000']; fid=fopen([p.pdir,'/',p.datefile],'rt+'); % date file of processed data fseek(fid,0,-1); while ~feof(fid) tline = fgetl(fid); line=strtok(tline,'.'); line_ct = line_ct + 1; % for debug if strcmp(line,strtok(startD,'.')), status=0; break, end if strcmp(line,strtok(endD,'.')), status=0; break, end end %while 1 if status, %response=input(['Enter the number of days to process (default=',num2str(days),'):']); %if ~isempty(response) % days=response; %end % Write to log file fid=fopen([p.ldir,'/',p.log],'at+'); fprintf(fid,'%s\n',['ECO CAL DATA',p.ecotype,' ',p.project,', ',p.mooring, ', device number: ', p.dev, ', serial number ', p.serial]); fprintf(fid,'%s\n',[' 1. ECO_PROCESS: ' DATESTR(NOW), ' days=',num2str(days)]); fclose(fid); % **Process the ECOFL Fluorometer % Get data from IAG's API [ecofl_out_array2,dev_num]=extract_ecodata(p,days); % average the records ecofl_out_array=avg_ecodata(ecofl_out_array2,p); % calibrate the fluorometer data ecofl_output_array=calibrate_ecofl(ecofl_out_array,p,prop); netcdf_eco(p); % **Process the ECOBB Scattering Meter devfl=dev_num; %ecotype='ecobb'; cdir=['../configuration/ecobb.properties']; prop = readProperties(cdir); otype='data'; p=getprops(prop,otype); % Write to log file fid=fopen([p.ldir,'/',p.log],'at+'); fprintf(fid,'%s\n',['ECO CAL DATA', p.ecotype,' device number: ', p.dev, ', serial number ', p.serial]); fprintf(fid,'%s\n',[' 1. ECO_PROCESS: ' DATESTR(NOW), ' days=',num2str(days)]); fclose(fid); % Get data from IAG's API [ecobb_out_array2,dev_num]=extract_ecodata(p,days); % dev_num is device number of ECOBB assigned by SSDS % average the records ecobb_out_array=avg_ecodata(ecobb_out_array2,p); % calibrate the backscatterometer data ecobb_output_array=ecobb_calibrate(ecobb_out_array,p,prop); netcdf_eco(p); % write dates to datefile fid=fopen([p.pdir,'/',p.datefile],'at+'); fprintf(fid,'%s\n',startD); fclose(fid); fid=fopen([p.ldir,'/',p.log],'at+'); fprintf(fid,'%s\n',':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); fclose(fid); disp('Processing complete'); else %status=0, data already exists fid=fopen([p.ldir,'/',p.log],'at+'); fprintf(fid,'%s\n',['ECO CAL DATA', p.ecotype,' device number: ', p.dev, ', serial number ', p.serial]); fprintf(fid,'%s\n',[' 1. ECO_PROCESS: ' DATESTR(NOW), ' Processing halted. Data already exists for ',line]); fprintf(fid,'%s\n',':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); fclose(fid); disp(['The calibrated data already exists for ',line(5:6),'/',line(7:8),'/',line(1:4),'. Processing halted.']); end %if status, % write to output file and plot values %plot_eco(ecofl_output_array,ecobb_output_array,dev_num,devfl,cdir,days); %exit; % :::::::::::::::::::::::::::::::: End Processing ::::::::::::::::::::::::::::::::::::::::: catch, % Something went wrong, capture error message and write to log file [LASTMSG, LASTID] = lasterr; disp(['** PROCESSING HALTED** Error: ',LASTMSG]); disp([' Last ID: ', LASTID]); fid=fopen([p.ldir,'/',p.log],'at+'); fprintf(fid,'%s\n',['ECO CAL DATA']); fprintf(fid,'%s\n',[' **PROCESSING HALTED** Error: ', LASTMSG ]); fprintf(fid,'%s\n',[' Last ID: ', LASTID ]); fprintf(fid,'%s\n',':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); fprintf(fid,'\n'); fclose(fid); %exit; end