source: Roms_tools/Run_v2.1/forecast_analysis.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 8.2 KB
Line 
1%
2%  forecast_analysis.m
3%
4%  Create an image from the forecast results and send it to the
5%  forecast web page.
6
7%
8%  Further Information: 
9%  http://www.brest.ird.fr/Roms_tools/
10
11%  This file is part of ROMSTOOLS
12%
13%  ROMSTOOLS is free software; you can redistribute it and/or modify
14%  it under the terms of the GNU General Public License as published
15%  by the Free Software Foundation; either version 2 of the License,
16%  or (at your option) any later version.
17%
18%  ROMSTOOLS is distributed in the hope that it will be useful, but
19%  WITHOUT ANY WARRANTY; without even the implied warranty of
20%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21%  GNU General Public License for more details.
22%
23%  You should have received a copy of the GNU General Public License
24%  along with this program; if not, write to the Free Software
25%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26%  MA  02111-1307  USA
27%
28%  Copyright (c) 2006 by Pierrick Penven
29%  e-mail:Pierrick.Penven@ird.fr 
30%
31%  Updated    8-Sep-2006 by Pierrick Penven
32%  Updated    5-Oct-2006 by Pierrick Penven (changes in file names)
33%
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35start
36disp('Forecast analysis')
37%
38% Common parameters
39%
40romstools_param
41%
42% plot the wind speed at noon for each day
43%
44skip=5;
45zoom=0;
46X=30;
47Y=22;
48% time (in matlab time)
49%
50today=floor(now);
51%
52% date in 'Yorig' time
53%
54rundate=datenum(today)-datenum(Yorig,1,1);
55%
56nc=netcdf(grdname);
57lon=nc{'lon_rho'}(:);
58lat=nc{'lat_rho'}(:);
59mask=nc{'mask_rho'}(:);
60angle=nc{'angle'}(:);
61close(nc)
62mask(mask==0)=NaN;
63%
64lonmin=min(min(lon))-zoom;
65lonmax=max(max(lon))+zoom;
66latmin=min(min(lat))-zoom;
67latmax=max(max(lat))+zoom;
68%
69close all
70figure('Units','centimeters',...
71       'Position',[1 1 X Y],...
72       'PaperPosition',[1 1 X Y],...
73       'PaperUnits','centimeters')
74%
75fsize=8;
76nx=7;
77cff1=4;
78cff2=2;
79%
80barwidth=0.2;
81barheight=0.01;
82titleheight=0.01;
83hmargin=0.025;
84vmargin=0.06;
85%
86width=(1-(1+nx)*hmargin)/(nx);
87height=(1-6.6*vmargin-3*barheight-titleheight)/3;
88%
89left1=hmargin;
90%
91bot1=vmargin;
92bot2=bot1+barheight+0.5*vmargin;
93bot3=bot2+height+1.5*vmargin;
94bot4=bot3+barheight+0.5*vmargin;
95bot5=bot4+height+1.5*vmargin;
96bot6=bot5+barheight+0.5*vmargin;
97bot7=bot6+height+1.5*vmargin;
98%
99% title
100%
101subplot('Position',[0.5-0.5*barwidth bot7 barwidth titleheight])
102set(gca,'XTickLabel',[' '])
103xlabel(['ROMS experiment: ',datestr(today)],'FontSize',10)
104%
105% 1: wind stress
106%
107left=left1;
108bot=bot6;
109for tndx=6+8:8:6+8*(nx)
110  subplot('Position',[left bot width height])
111  nc=netcdf('SCRATCH/roms_frc_GFS_0.nc');
112  smstime=[];
113  smstime=nc{'sms_time'}(tndx);
114  if ~isempty(smstime)
115    u=squeeze(nc{'sustr'}(tndx,:,:));
116    v=squeeze(nc{'svstr'}(tndx,:,:));
117    close(nc)
118    stress=mask.*sqrt((u2rho_2d(u)).^2+(v2rho_2d(v)).^2);
119    [ur,vr,lonr,latr,spd]=uv_vec2rho(u,v,lon,lat,angle,mask,skip,[0 0 0 0]);
120     m_proj('mercator',...
121         'lon',[lonmin lonmax],...
122         'lat',[latmin latmax]);
123    [C0,h0]=m_contourf(lon,lat,stress,[0:0.04:0.3],'k');
124    shading flat
125    caxis([0 0.3])
126    hold on
127    m_quiver(lonr,latr,cff1*ur,cff1*vr,0,'k');
128    m_usercoast(coastfileplot,'patch',[.9 .9 .9]);
129    hold off
130    m_grid('box','fancy','xtick',5,'ytick',5,'tickdir','out',...
131           'FontSize',fsize-2);
132    set(findobj('tag','m_grid_color'),'facecolor','white')
133    title([datestr(smstime+datenum(Yorig,1,1))],'FontSize',fsize)
134    left=left+width+hmargin;
135  end
136end
137subplot('Position',[0.5-0.5*barwidth bot5 barwidth barheight])
138x=[0:1];
139y=[0:0.04:0.3];
140[X,Y]=meshgrid(x,y);
141contourf(Y,X,Y,y)
142caxis([0 0.3])
143set(gca,'XTick',[0:0.04:0.3],'YTickLabel',[' '])
144set(gca,'FontSize',fsize)
145xlabel('Wind stress [N.m^{-2}]','FontSize',fsize)
146%
147% 2: Surface currents
148%
149left=left1;
150bot=bot4;
151for tndx=1:nx
152  subplot('Position',[left bot width height])
153  nc=netcdf('SCRATCH/roms_avg.nc');
154  scrumtime=[];
155  scrumtime=(nc{'scrum_time'}(tndx))/(24*3600);
156  if ~isempty(scrumtime)
157    N=length(nc('s_rho'));
158    u=squeeze(nc{'u'}(tndx,N,:,:));
159    v=squeeze(nc{'v'}(tndx,N,:,:));
160    close(nc)
161    spd=mask.*sqrt((u2rho_2d(u)).^2+(v2rho_2d(v)).^2);
162    [ur,vr,lonr,latr,spdr]=uv_vec2rho(u,v,lon,lat,angle,mask,skip,[0 0 0 0]);
163     m_proj('mercator',...
164       'lon',[lonmin lonmax],...
165       'lat',[latmin latmax]);
166    [C0,h0]=m_contourf(lon,lat,100*spd,[0:10:80],'k');
167    shading flat
168    caxis([0 80])
169    hold on
170    m_quiver(lonr,latr,cff2*ur,cff2*vr,0,'k');
171    m_usercoast(coastfileplot,'patch',[.9 .9 .9]);
172    hold off
173    m_grid('box','fancy','xtick',5,'ytick',5,'tickdir','out',...
174           'FontSize',fsize-2);
175    set(findobj('tag','m_grid_color'),'facecolor','white')
176    title([datestr(scrumtime+datenum(Yorig,1,1))],'FontSize',fsize)
177    left=left+width+hmargin;
178  end
179end
180subplot('Position',[0.5-0.5*barwidth bot3 barwidth barheight])
181x=[0:1];
182y=[0:10:80];
183[X,Y]=meshgrid(x,y);
184caxis([0 80])
185contourf(Y,X,Y,y)
186set(gca,'XTick',[0:10:80],'YTickLabel',[' '])
187set(gca,'FontSize',fsize)
188xlabel('Surface currents [cm.s^{-1}]','FontSize',fsize)
189%
190% 3: SST
191%
192left=left1;
193bot=bot2;
194for tndx=1:nx
195  subplot('Position',[left bot width height])
196  nc=netcdf('SCRATCH/roms_avg.nc');
197  scrumtime=[];
198  scrumtime=(nc{'scrum_time'}(tndx))/(24*3600);
199  if ~isempty(scrumtime)
200    N=length(nc('s_rho'));
201    sst=squeeze(nc{'temp'}(tndx,N,:,:));
202    close(nc)
203     m_proj('mercator',...
204         'lon',[lonmin lonmax],...
205         'lat',[latmin latmax]);
206    [C0,h0]=m_contourf(lon,lat,sst,[10:1:25],'k');
207    shading flat
208    caxis([10 25])
209    hold on
210    m_usercoast(coastfileplot,'patch',[.9 .9 .9]);
211    hold off
212    m_grid('box','fancy','xtick',5,'ytick',5,'tickdir','out',...
213           'FontSize',fsize-2);
214    set(findobj('tag','m_grid_color'),'facecolor','white')
215    title([datestr(scrumtime+datenum(Yorig,1,1))],'FontSize',fsize)
216    left=left+width+hmargin;
217  end
218end
219subplot('Position',[0.5-0.5*barwidth bot1 barwidth barheight])
220x=[0:1];
221y=[10:1:25];
222[X,Y]=meshgrid(x,y);
223caxis([10 25])
224contourf(Y,X,Y,y)
225set(gca,'XTick',[10:2:25],'YTickLabel',[' '])
226set(gca,'FontSize',fsize)
227xlabel('SST [^{o}C]','FontSize',fsize)
228%
229% Print the image
230%
231eval(['print -depsc2 roms_',num2str(rundate),'.eps'])
232eval(['!convert -density 85 roms_',num2str(rundate),...
233      '.eps roms_',num2str(rundate),'.jpg'])
234eval(['!cp -f roms_',num2str(rundate),'.jpg roms_realtime.jpg'])
235%
236% send the file to the web site
237%
238%!./envoi.csh roms_realtime.jpg
239%
240close all
241%
242nc=netcdf('SCRATCH/roms_sta_hindcast.nc');
243t1=nc{'scrum_time'}(:)/(24*3600);
244sst1=squeeze(nc{'temp'}(:,1,32));
245bott1=squeeze(nc{'temp'}(:,1,1));
246temp1=squeeze(nc{'temp'}(:,1,:));
247z1=squeeze(nc{'depth'}(:,1,:));
248u1=1e3*squeeze(nc{'u'}(:,1,:));
249v1=1e3*squeeze(nc{'v'}(:,1,:));
250close(nc)
251tmin=min(t1);
252sst1(1)=NaN;
253bott1(1)=NaN;
254u1(1,:)=NaN;
255v1(1,:)=NaN;
256temp1(1,:)=NaN;
257
258nc=netcdf('SCRATCH/roms_sta_forecast.nc');
259t2=nc{'scrum_time'}(:)/(24*3600);
260sst2=squeeze(nc{'temp'}(:,1,32));
261bott2=squeeze(nc{'temp'}(:,1,1));
262temp2=squeeze(nc{'temp'}(:,1,:));
263z2=squeeze(nc{'depth'}(:,1,:));
264u2=1e3*squeeze(nc{'u'}(:,1,:));
265v2=1e3*squeeze(nc{'v'}(:,1,:));
266close(nc)
267temp2=temp2(2:end,:);
268u2=u2(2:end,:);
269v2=v2(2:end,:);
270z2=z2(2:end,:);
271t2=t2(2:end);
272sst2=sst2(2:end);
273bott2=bott2(2:end);
274z=squeeze(z2(1,:));
275t1=t1-tmin;
276t2=t2-tmin;
277
278figure('Units','centimeters',...
279       'Position',[1 1 20 20],...
280       'PaperPosition',[1 1 20 20],...
281       'PaperUnits','centimeters')
282
283subplot(3,1,1)
284pcolor(t1,z,u1')
285hold on
286pcolor(t2,z,u2')
287axis([0 9 -30 0])
288shading flat
289caxis([-250 250])
290colorbar
291title(['Velocity East [mm/s]'])
292ylabel('Depth')
293set(gca,'Xticklabel',[])
294
295subplot(3,1,2)
296pcolor(t1,z,v1')
297hold on
298pcolor(t2,z,v2')
299axis([0 9 -30 0])
300shading flat
301caxis([-250 250])
302colorbar
303title(['Velocity North [mm/s]'])
304ylabel('Depth')
305set(gca,'Xticklabel',[])
306
307subplot(3,1,3)
308pcolor(t1,z,temp1')
309hold on
310pcolor(t2,z,temp2')
311axis([0 9 -30 0])
312shading flat
313caxis([10 15])
314colorbar
315title(['Temperature [^oC]'])
316ylabel('Depth')
317set(gca,'Xtick',[0.5:1:9],...
318    'Xticklabel',datestr(tmin+[0.5:1:9]+datenum(Yorig,1,1),19))
319%
320% Print the image
321%
322eval(['print -depsc2 -painters bob_',num2str(rundate),'.eps'])
323eval(['!convert -density 85 bob_',num2str(rundate),...
324      '.eps bob_',num2str(rundate),'.jpg'])
325eval(['!cp -f bob_',num2str(rundate),'.jpg bob_realtime.jpg'])
326%
327% send the file to the web site
328%
329%!./envoi.csh bob_realtime.jpg
330
331
332
333
334
Note: See TracBrowser for help on using the repository browser.