function [ierr] = plotELCOMupdateFile(filename,data,data_type,bcset_no,n_data,datelim,bcsetlist,pltTheme) % function [data,data_type,bcset_no,n_data] = plotELCOMupdateFile(filename) % % funcion to plot ELCOM boundary condition file input file % outputs figures as eps and tiff % % Inputs Mostly from readELCOMinputFile: % filename : filename used for plot title % data : matrix of data (1st column is time or depth) % data_type : cell array of data_types in file % bcset_no : bcset no for each header % n_data : no of data columns specified in header % file_type : File type (one of 'BC','PROFILE','INITIAL') % datelim : array of min and max dates to plot in CWR format % bcsetlist : structure giving bcset_no and bc_name % eg: bcsetlist.bcset_no = [1 2] % eg: bcsetlist.bc_name = [{'River A'},{'Dam Wall Outflow'} ] % pltTheme : (optional) string for input to setPlotTheme % % Outputs % ierr : error flag % % Uses: % exportfig.m % CWRdate2matlab.m % % Written by C. Dallimore 27 July 04 ierr = 0; if nargin == 8 elseif nargin == 7 pltTheme = []; elseif nargin == 6 pltTheme = []; bcsetlist = []; else disp('Incorrect number of arguments to plotELCOMupdateFile') ierr =1; return end % Setup units of various input types variable_mat = setELCOMioTypes; % Sort out time data CWRDate = data(:,1); time=CWRdate2matlab(CWRDate); CWRDate_end = data(:,2); time_end=CWRdate2matlab(CWRDate_end); if (datelim(1) > 0) timeLim = CWRdate2matlab(datelim); else timeLim = [min(time) max(time_end)]; end for (i = 1:n_data) figure hold on for t = 1:length(time) plot ([time(t),time_end(t)],[data(t,i+2) data(t,i+2)],'-o') end box on H = gca; % X axis axes(H) set (H,'xlim',timeLim) % ensure 5 ticks on X axis dxt = timeLim(2)-timeLim(1); xt_new = timeLim(1):dxt/4:timeLim(2); set(H,'Xtick',xt_new) set(H,'Xticklabel',' ') datetick('x',20,'keeplimits','keepticks') xlabel('Date (dd/mm/yy)') % Y axis variable = char(data_type(i+2)); fv=strmatch(variable,variable_mat(:,1),'exact'); if (isempty(fv)) ytitle = variable; else ytitle = char(variable_mat(fv,2)); dims = char(variable_mat(fv,3)); if ~isempty(dims) ytitle = [ytitle,' (',dims,')']; end end ylabel (ytitle) % Title if bcset_no == 0 titlestr = ['BC FILE: ',filename]; figtitle = [filename(1:length(filename)-4),'-',variable]; else if (isempty(bcsetlist)) titlestr = ['BC FILE: ',filename,' BC set: ',int2str(bcset_no(i+2))]; else ind = find(bcset_no(i+1)==bcsetlist.bcset_no); bc_name = char(bcsetlist.bc_name(ind)); titlestr = ['BC FILE: ',filename,' BC: ',bc_name]; end figtitle = [filename(1:length(filename)-4),'-',variable,'-',int2str(bcset_no(i+2))]; end titlestr(findstr(titlestr,'_'))='-'; title(titlestr) setPlotTheme(pltTheme); % Output to file opts = struct('width',6,'color','rgb','renderer','painters'); exportfig (gcf,[figtitle,'.eps'],opts,'format','eps','preview','tiff'); exportfig (gcf,[figtitle,'.jpg'],opts,'format','jpeg','resolution',100); end