function [ierr] = plotELCOMprofileBCFile(filename,data,data_type,bcset_no,n_data,datelim,bcsetlist,pltTheme) % function [data,data_type,bcset_no,n_data] = plotELCOMprofileBCFile(filename) % % funcion to plot ELCOM profile boundary condition file input file % outputs figures as eps and tiff % % Inputs Mostly from readELCOMinputFile: % filename : filename used for plot title % data : struct array of data % 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 format long g warning off ierr = 0; if nargin == 8 elseif nargin == 7 pltTheme = []; elseif nargin == 6 pltTheme = []; bcsetlist = []; else disp('Incorrect number of arguments to plotELCOMprofileBCFile') ierr =1; return end % Setup units of various input types variable_mat = setELCOMioTypes; for t = 1:length(data) tmp_date(t) = data(t).CWRdate; end % get profiles within time range pts = find(tmp_date>datelim(1) & tmp_date 0) timeLim = CWRdate2matlab(datelim); else timeLim = [min(time) max(time)]; end % Griddata has problems with large numbers to we'll remove a date0 and then add it on when we plot date0=datenum (1990,1,1); tmptime = time - date0; for i = 1:n_data-1 val =[]; for jj = 1:length(pts)/500:length(pts) j = round(jj); t = (pts(j)); val = [val data(t).data(i+1,:)]; end delX=max(tmptime) - min(tmptime); delX = delX/300; rangeX=min(tmptime):delX:max(tmptime); delY=max(depth) - min(depth); delY = delY/20; rangeY=min(depth):.2:max(depth); % Title variable = char(data_type(i+2)); 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+1))]; 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+1))]; end titlestr(findstr(titlestr,'_'))='-'; if (length (rangeY) ~=1) [X,Y]=meshgrid(rangeX,rangeY); Z=griddata(tmptime,depth,val,X,Y); figure pcolor (X+date0,Y,Z) H = gca; set(H,'position',[.1 .15 .76 .7]); set (H,'ydir','reverse','layer','top') shading flat title(titlestr) % Y axis ylabel ('Depth (m)') % Colorbar clim = get (H,'clim'); axes('position',[.88 .15 .02 .7],'layer','top') imagesc(1,clim,[min(clim):(max(clim)-min(clim))/40:max(clim)]'); axis tight caxis(clim); set(gca,'xtick',[],'xticklabel',[],'ydir','normal','YAxisLocation','right') fv=strmatch(variable,variable_mat(:,1),'exact'); if (isempty(fv)) ytitle = variable; else ytitle = [char(variable_mat(fv,2)),' (',char(variable_mat(fv,3)),')']; end ylabel (ytitle) else val = []; for t = 1:length(data) CWRDate2(t) = data(t).CWRdate; val(t) = data(t).data(i+1,1); end time2=CWRdate2matlab(CWRDate2); figure plot (time2,val) box on H = gca; set(gca,'position',[.1 .15 .85 .7]); set(gca,'xlim',timeLim); % Y axis 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(titlestr) end % 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)') 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); close all end