Home > mrg > MRG_metstation > mrg_met_pp.m

mrg_met_pp

PURPOSE ^

Plots metstation data for display by an external web application

SYNOPSIS ^

function mrg_met_pp(days)

DESCRIPTION ^

 Plots metstation data for display by an external web application

 INPUT
   days    The number of days to display (defualt is 1)

 OUTPUT
   NO OUTPUT AT CONSOLE
   Generates figures for wind-speed, wind direction, air temperature,
   water temperature, 

 REQUIREMENTS
   Assumes you have MRG-metation formatted CSV files in the current
   working directory.

 AUTHORS
   Daniel Pritchard

 LICENCE
   Code distributed as part of the MRG toolbox from the Marine Research
   Group at Queens Univeristy Belfast (QUB) School of Planning
   Architecture and Civil Engineering (SPACE). Distributed under a
   creative commons CC BY-SA licence, retaining full copyright of the
   original authors.

   http://creativecommons.org/licenses/by-sa/3.0/
   http://www.qub.ac.uk/space/
   http://www.qub.ac.uk/research-centres/eerc/

 DEVELOPMENT
   v 1.0   2013-08-16
           First version. DP

% Function Begin!

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mrg_met_pp(days)
0002 % Plots metstation data for display by an external web application
0003 %
0004 % INPUT
0005 %   days    The number of days to display (defualt is 1)
0006 %
0007 % OUTPUT
0008 %   NO OUTPUT AT CONSOLE
0009 %   Generates figures for wind-speed, wind direction, air temperature,
0010 %   water temperature,
0011 %
0012 % REQUIREMENTS
0013 %   Assumes you have MRG-metation formatted CSV files in the current
0014 %   working directory.
0015 %
0016 % AUTHORS
0017 %   Daniel Pritchard
0018 %
0019 % LICENCE
0020 %   Code distributed as part of the MRG toolbox from the Marine Research
0021 %   Group at Queens Univeristy Belfast (QUB) School of Planning
0022 %   Architecture and Civil Engineering (SPACE). Distributed under a
0023 %   creative commons CC BY-SA licence, retaining full copyright of the
0024 %   original authors.
0025 %
0026 %   http://creativecommons.org/licenses/by-sa/3.0/
0027 %   http://www.qub.ac.uk/space/
0028 %   http://www.qub.ac.uk/research-centres/eerc/
0029 %
0030 % DEVELOPMENT
0031 %   v 1.0   2013-08-16
0032 %           First version. DP
0033 %
0034 %% Function Begin!
0035 if nargin < 1
0036     days = 1;
0037 end
0038 
0039 fnameCSV = ['met_data_',datestr(date,'yyyy_mmm'),'.csv'];
0040 f = fopen(fnameCSV);
0041 dat = textscan(f, '%s %f %f %f %f %f %f %f', 'HeaderLines',1, 'delimiter', ',');
0042 %Old data:
0043 %dat = textscan(f, '%s %f %f %f %f %f', 'delimiter', ',');
0044 fclose(f);
0045 
0046 dnum = datenum(char(dat{1}), 'dd/mm/yyyy HH:MM:SS');
0047 ctime = now;
0048 mintime = ctime-days;
0049 ind = dnum > mintime;
0050 
0051 for a = 2:8
0052     nanind = dat{a}==-1e-30;
0053     dat{a}(nanind) = NaN;
0054 end
0055 
0056 imgsize = [0 0 6*5 2*5];
0057 
0058 % Light
0059 par = figure(1);
0060 plot(dnum(ind), dat{2}(ind), '-o', 'MarkerFaceColor', 'b'); 
0061 xlim([mintime ctime]); 
0062 maxpar = max(dat{2}(ind));
0063 ylim([0 max(400,maxpar*1.1)]); 
0064 dateaxis('x', 15);
0065 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0066 ylabel('PAR (\mumol photons m^{-2} s^{-1})')
0067 
0068 set(par,'PaperUnits','centimeters ','PaperPosition',imgsize)
0069 print('-dpng', '-r300', 'web/images/light.png');
0070 
0071 % WindSpeed
0072 ws = figure(1);
0073 plot(dnum(ind), dat{3}(ind), '-o', 'MarkerFaceColor', 'b'); 
0074 xlim([mintime ctime]); 
0075 maxws = max(dat{3}(ind));
0076 ylim([0 max(1,maxws*1.1)]); 
0077 dateaxis('x', 15);
0078 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0079 ylabel('Windspeed (m^{-1} s^{-1})')
0080 
0081 set(ws,'PaperUnits','centimeters ','PaperPosition',imgsize)
0082 print('-dpng', '-r300', 'web/images/ws.png');
0083 
0084 % WindDir
0085 wd = figure(1);
0086 plot(dnum(ind), dat{4}(ind), 'o', 'MarkerFaceColor', 'b'); 
0087 xlim([mintime ctime]); 
0088 ylim([0 360]); 
0089 dateaxis('x', 15);
0090 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0091 ylabel('Wind Direction (\circ)')
0092 
0093 set(wd,'PaperUnits','centimeters ','PaperPosition',imgsize)
0094 print('-dpng', '-r300', 'web/images/wd.png');
0095 
0096 % AirPressure
0097 ap = figure(1);
0098 plot(dnum(ind), dat{5}(ind), '-o', 'MarkerFaceColor', 'b'); 
0099 xlim([mintime ctime]); 
0100 ylim([800 1700]); 
0101 dateaxis('x', 15);
0102 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0103 ylabel('Air Pressure (units)')
0104 
0105 set(ap,'PaperUnits','centimeters ','PaperPosition',imgsize)
0106 print('-dpng', '-r300', 'web/images/ap.png');
0107 
0108 % AirTemp
0109 at = figure(1);
0110 plot(dnum(ind), dat{6}(ind), '-o', 'MarkerFaceColor', 'b'); 
0111 xlim([mintime ctime]); 
0112 ylim([-10 30]); 
0113 dateaxis('x', 15);
0114 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0115 ylabel('Air Temperature (\circ)')
0116 
0117 set(at,'PaperUnits','centimeters ','PaperPosition',imgsize)
0118 print('-dpng', '-r300', 'web/images/at.png');
0119 
0120 % Tidal Level
0121 tl = figure(1);
0122 plot(dnum(ind), dat{7}(ind), '-o', 'MarkerFaceColor', 'b'); 
0123 xlim([mintime ctime]); 
0124  
0125 dateaxis('x', 15);
0126 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0127 ylabel('Tidal Level (units)')
0128 
0129 set(tl,'PaperUnits','centimeters ','PaperPosition',imgsize)
0130 print('-dpng', '-r300', 'web/images/tl.png');
0131 
0132 % Water Temp
0133 wt = figure(1);
0134 plot(dnum(ind), dat{8}(ind), '-o', 'MarkerFaceColor', 'b'); 
0135 xlim([mintime ctime]); 
0136 %ylim([-5 20]);
0137 dateaxis('x', 15);
0138 xlabel([datestr(mintime, 'dd/mm/yyyy'), ' - ', datestr(ctime, 'dd/mm/yyyy')])
0139 ylabel('Water Temperature (\circ)')
0140 
0141 set(wt,'PaperUnits','centimeters ','PaperPosition',imgsize)
0142 print('-dpng', '-r300', 'web/images/wt.png');
0143 
0144 end

Generated on Thu 29-May-2014 21:29:53 by m2html © 2005