% do100X process LISST 100X data using Sequoia's mfile % % function do100X(inFile, zscFile, ringFile, settings, [samplerange]); % inFile = binary or ascii LISST data file % zscFile = background file to use (this from your calibration) % ringFile = ring area (detector calibration) file (this from the factory) % settings = a structure with metadata % settings.expYear = 2006; %the year the experiment started % settings.LISSTtype = 'A'; %type A (5-500 micrions), % B (1.2-250 microns), % C (2.5-500 microns), % F % settings.volconv = 45733; % for LISST 1172 % settings.navg = 1; % number of samples to average together % settings.pscale = 0.01; % pscale is the pressure scale from the INI file, HK4Scale % settings.poffset = 0; %poffset is the pressure offset from the INI file, HK4Off % settings.raux % raux converts counts to volts for aux channel (from the INI file) % samplerange = [1 Inf]; % for all or a set range % % this uses mfile from Sequoia, set up as a function rather than in % interactive script % Assumptions % Header size is 80 bytes in settling experiments % written by Marinna Martini 22 July 2008 % TODO need to differentiate between settling experiments and time series % at the moment, treat all data as simple time series % could use a utility to extract part of an experiment as the background % calibration function [lisst, settings] = do100X(inFile, zscFile, ringFile, settings, samplerange) % get the current SVN version- the value is automatically obtained in svn % is the file's svn.keywords which is set to "Revision" rev_info = 'SVN $Revision$'; disp(sprintf('%s %s running',mfilename,rev_info)) Settling = 0; % get the data file if exist('inFile','var') ~=1, FilterSpec(1,:) = {'*.DAT','*.DAT binary LISST data file'}; [fname, pathname] = uigetfile(FilterSpec, 'Pick a LISST data file'); if isequal(fname,0) || isequal(pathname,0) disp('User pressed cancel') return end inFile = fullfile(pathname, fname); disp(['User selected data file ', inFile]) if fname(1) == 'S', disp('This is a settling experiment') Settling = 1; end end settings.inFile = inFile; settings.Settling = Settling; % get the background scatter calibration file if exist('zscFile','var') ~=1, FilterSpec(1,:) = {'*.asc','*.asc ASCII LISST background file'}; FilterSpec(2,:) = {'*.DAT','*.DAT binary LISST background file'}; [fname, pathname] = uigetfile(FilterSpec, 'Pick a LISST background scatter file'); if isequal(fname,0) || isequal(pathname,0) disp('User pressed cancel') return end zscFile = fullfile(pathname, fname); disp(['User selected background file ', zscFile]) end % is it Binary or ASCII? [inPath, inName, inExt] = fileparts(zscFile); if strcmp(inExt,'.asc') % ASCII cal files have only 32 data points zsclab = load(zscFile); else zsclab = tt2mat(zscFile,nVariables); % a binary file could be anything, including part of an experiment zsclab = mean(zsclab); end settings.zscFile = zscFile; settings.zsclab = zsclab; % get the ring area file if exist('ringFile','var') ~=1, [fname, pathname] = uigetfile('*.asc', 'Pick a ring area (detector calibration) file'); if isequal(fname,0) || isequal(pathname,0) disp('User pressed cancel') return end ringFile = fullfile(pathname, fname); disp(['User selected ring area file ', ringFile]) end settings.ringFile = ringFile; % make sure all the metadata is here if exist('settings','var') ~=1, settings = []; end if isfield(settings, 'expYear'), expYear = settings.expYear; else d = gregoria(julian(datevec(now))); expYear = inputdlg('Is this the year of the start of the time series?',... 'Input the year',1,{sprintf('%d',d(1))}); expYear = str2double(char(expYear)); settings.expYear = expYear; end disp(sprintf('The year of the experiment is %d',expYear)) % what LISST is it? LISSTtypes = {'A','B','C','F'}; LISSTtype = []; if isfield(settings, 'LISSTtype'), settings.LISSTtype = lower(settings.LISSTtype); else [n,v] = listdlg('PromptString','Select type of instrument:',... 'SelectionMode','single','ListString',LISSTtypes); if ~v, disp('LISST type is required information') return end LISSTtype = lower(LISSTtypes{n}); settings.LISSTtype = LISSTtype; end disp(sprintf('The LISST type is %s',settings.LISSTtype)) % now convert to a number for itype = 1:length(LISSTtypes), if strcmpi(settings.LISSTtype, LISSTtypes{itype}), LISSTtype = itype; end end if isempty(LISSTtype), disp([settings.LISSTtype ' not found']) return; end if isfield(settings, 'navg'), navg = settings.navg; else navg = 1; settings.navg = navg; end disp(sprintf('%d samples will be averaged',navg)) if isfield(settings, 'pscale'), pscale = settings.pscale; else pscale = 0.01; disp('Pscale not given') end disp(sprintf('Pscale is %f',pscale)) if isfield(settings, 'poffset'), poffset = settings.poffset; else poffset = 0; disp('Poffset not given') end disp(sprintf('Poffset is %f',poffset)) if isfield(settings, 'raux'), raux = settings.raux; else raux = 5/4095; disp('Aux. input conversion not given') end disp(sprintf('Aux. input conversion is %f',raux)) if isfield(settings, 'volconv'), volconv = settings.volconv; else volconv = 1; disp('volconv input conversion not given') end disp(sprintf('volconv conversion is %f',volconv)) % samplerange = [1 Inf]; % for all or a set range if ~exist('samplerange','var'), samplerange = [1 Inf]; end if isinf(samplerange(2)), samplerange(2) = -1; end fid = fopen(fullfile(pwd,'nliafunc.log'),'w'); disp(['Writing error messages to ',fullfile(pwd,'nliafunc.log')]) disp('Sequoia''s nlia function will take some time to process without update messages') disp('please be patient') [vd,tau,dias32,scat,mzsc, press,temp,aux,bvolt, Lref, beam_c, vdate] = ... nlia_func(inFile,zscFile,ringFile,samplerange(1),samplerange(2),... navg,volconv,LISSTtype, pscale, poffset, raux, fid); fclose(fid); lisst.vd = vd; lisst.tau = tau; lisst.dias32 = dias32; lisst.scat = scat; lisst.mzsc = mzsc; lisst.press = press; lisst.temp = temp; lisst.aux1 = aux; lisst.batt = bvolt; lisst.laserref = Lref; lisst.beamc = beam_c; % compute the time stamps in julian and MATLAB dayone = datenum([expYear,1,1,0,0,0]); yearday = floor(vdate(:,1)./100); hour = rem(vdate(:,1),100); min = floor(vdate(:,2)./100); sec = rem(vdate(:,2),100); tm = dayone+yearday+hour./24+min./(24*60)+sec./(24*3600); tj = julian(datevec(tm)); lisst.tj = tj; lisst.tm = tm; return