[1] | 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 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 35 | start |
---|
| 36 | disp('Forecast analysis') |
---|
| 37 | % |
---|
| 38 | % Common parameters |
---|
| 39 | % |
---|
| 40 | romstools_param |
---|
| 41 | % |
---|
| 42 | % plot the wind speed at noon for each day |
---|
| 43 | % |
---|
| 44 | skip=5; |
---|
| 45 | zoom=0; |
---|
| 46 | X=30; |
---|
| 47 | Y=22; |
---|
| 48 | % time (in matlab time) |
---|
| 49 | % |
---|
| 50 | today=floor(now); |
---|
| 51 | % |
---|
| 52 | % date in 'Yorig' time |
---|
| 53 | % |
---|
| 54 | rundate=datenum(today)-datenum(Yorig,1,1); |
---|
| 55 | % |
---|
| 56 | nc=netcdf(grdname); |
---|
| 57 | lon=nc{'lon_rho'}(:); |
---|
| 58 | lat=nc{'lat_rho'}(:); |
---|
| 59 | mask=nc{'mask_rho'}(:); |
---|
| 60 | angle=nc{'angle'}(:); |
---|
| 61 | close(nc) |
---|
| 62 | mask(mask==0)=NaN; |
---|
| 63 | % |
---|
| 64 | lonmin=min(min(lon))-zoom; |
---|
| 65 | lonmax=max(max(lon))+zoom; |
---|
| 66 | latmin=min(min(lat))-zoom; |
---|
| 67 | latmax=max(max(lat))+zoom; |
---|
| 68 | % |
---|
| 69 | close all |
---|
| 70 | figure('Units','centimeters',... |
---|
| 71 | 'Position',[1 1 X Y],... |
---|
| 72 | 'PaperPosition',[1 1 X Y],... |
---|
| 73 | 'PaperUnits','centimeters') |
---|
| 74 | % |
---|
| 75 | fsize=8; |
---|
| 76 | nx=7; |
---|
| 77 | cff1=4; |
---|
| 78 | cff2=2; |
---|
| 79 | % |
---|
| 80 | barwidth=0.2; |
---|
| 81 | barheight=0.01; |
---|
| 82 | titleheight=0.01; |
---|
| 83 | hmargin=0.025; |
---|
| 84 | vmargin=0.06; |
---|
| 85 | % |
---|
| 86 | width=(1-(1+nx)*hmargin)/(nx); |
---|
| 87 | height=(1-6.6*vmargin-3*barheight-titleheight)/3; |
---|
| 88 | % |
---|
| 89 | left1=hmargin; |
---|
| 90 | % |
---|
| 91 | bot1=vmargin; |
---|
| 92 | bot2=bot1+barheight+0.5*vmargin; |
---|
| 93 | bot3=bot2+height+1.5*vmargin; |
---|
| 94 | bot4=bot3+barheight+0.5*vmargin; |
---|
| 95 | bot5=bot4+height+1.5*vmargin; |
---|
| 96 | bot6=bot5+barheight+0.5*vmargin; |
---|
| 97 | bot7=bot6+height+1.5*vmargin; |
---|
| 98 | % |
---|
| 99 | % title |
---|
| 100 | % |
---|
| 101 | subplot('Position',[0.5-0.5*barwidth bot7 barwidth titleheight]) |
---|
| 102 | set(gca,'XTickLabel',[' ']) |
---|
| 103 | xlabel(['ROMS experiment: ',datestr(today)],'FontSize',10) |
---|
| 104 | % |
---|
| 105 | % 1: wind stress |
---|
| 106 | % |
---|
| 107 | left=left1; |
---|
| 108 | bot=bot6; |
---|
| 109 | for 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 |
---|
| 136 | end |
---|
| 137 | subplot('Position',[0.5-0.5*barwidth bot5 barwidth barheight]) |
---|
| 138 | x=[0:1]; |
---|
| 139 | y=[0:0.04:0.3]; |
---|
| 140 | [X,Y]=meshgrid(x,y); |
---|
| 141 | contourf(Y,X,Y,y) |
---|
| 142 | caxis([0 0.3]) |
---|
| 143 | set(gca,'XTick',[0:0.04:0.3],'YTickLabel',[' ']) |
---|
| 144 | set(gca,'FontSize',fsize) |
---|
| 145 | xlabel('Wind stress [N.m^{-2}]','FontSize',fsize) |
---|
| 146 | % |
---|
| 147 | % 2: Surface currents |
---|
| 148 | % |
---|
| 149 | left=left1; |
---|
| 150 | bot=bot4; |
---|
| 151 | for 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 |
---|
| 179 | end |
---|
| 180 | subplot('Position',[0.5-0.5*barwidth bot3 barwidth barheight]) |
---|
| 181 | x=[0:1]; |
---|
| 182 | y=[0:10:80]; |
---|
| 183 | [X,Y]=meshgrid(x,y); |
---|
| 184 | caxis([0 80]) |
---|
| 185 | contourf(Y,X,Y,y) |
---|
| 186 | set(gca,'XTick',[0:10:80],'YTickLabel',[' ']) |
---|
| 187 | set(gca,'FontSize',fsize) |
---|
| 188 | xlabel('Surface currents [cm.s^{-1}]','FontSize',fsize) |
---|
| 189 | % |
---|
| 190 | % 3: SST |
---|
| 191 | % |
---|
| 192 | left=left1; |
---|
| 193 | bot=bot2; |
---|
| 194 | for 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 |
---|
| 218 | end |
---|
| 219 | subplot('Position',[0.5-0.5*barwidth bot1 barwidth barheight]) |
---|
| 220 | x=[0:1]; |
---|
| 221 | y=[10:1:25]; |
---|
| 222 | [X,Y]=meshgrid(x,y); |
---|
| 223 | caxis([10 25]) |
---|
| 224 | contourf(Y,X,Y,y) |
---|
| 225 | set(gca,'XTick',[10:2:25],'YTickLabel',[' ']) |
---|
| 226 | set(gca,'FontSize',fsize) |
---|
| 227 | xlabel('SST [^{o}C]','FontSize',fsize) |
---|
| 228 | % |
---|
| 229 | % Print the image |
---|
| 230 | % |
---|
| 231 | eval(['print -depsc2 roms_',num2str(rundate),'.eps']) |
---|
| 232 | eval(['!convert -density 85 roms_',num2str(rundate),... |
---|
| 233 | '.eps roms_',num2str(rundate),'.jpg']) |
---|
| 234 | eval(['!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 | % |
---|
| 240 | close all |
---|
| 241 | % |
---|
| 242 | nc=netcdf('SCRATCH/roms_sta_hindcast.nc'); |
---|
| 243 | t1=nc{'scrum_time'}(:)/(24*3600); |
---|
| 244 | sst1=squeeze(nc{'temp'}(:,1,32)); |
---|
| 245 | bott1=squeeze(nc{'temp'}(:,1,1)); |
---|
| 246 | temp1=squeeze(nc{'temp'}(:,1,:)); |
---|
| 247 | z1=squeeze(nc{'depth'}(:,1,:)); |
---|
| 248 | u1=1e3*squeeze(nc{'u'}(:,1,:)); |
---|
| 249 | v1=1e3*squeeze(nc{'v'}(:,1,:)); |
---|
| 250 | close(nc) |
---|
| 251 | tmin=min(t1); |
---|
| 252 | sst1(1)=NaN; |
---|
| 253 | bott1(1)=NaN; |
---|
| 254 | u1(1,:)=NaN; |
---|
| 255 | v1(1,:)=NaN; |
---|
| 256 | temp1(1,:)=NaN; |
---|
| 257 | |
---|
| 258 | nc=netcdf('SCRATCH/roms_sta_forecast.nc'); |
---|
| 259 | t2=nc{'scrum_time'}(:)/(24*3600); |
---|
| 260 | sst2=squeeze(nc{'temp'}(:,1,32)); |
---|
| 261 | bott2=squeeze(nc{'temp'}(:,1,1)); |
---|
| 262 | temp2=squeeze(nc{'temp'}(:,1,:)); |
---|
| 263 | z2=squeeze(nc{'depth'}(:,1,:)); |
---|
| 264 | u2=1e3*squeeze(nc{'u'}(:,1,:)); |
---|
| 265 | v2=1e3*squeeze(nc{'v'}(:,1,:)); |
---|
| 266 | close(nc) |
---|
| 267 | temp2=temp2(2:end,:); |
---|
| 268 | u2=u2(2:end,:); |
---|
| 269 | v2=v2(2:end,:); |
---|
| 270 | z2=z2(2:end,:); |
---|
| 271 | t2=t2(2:end); |
---|
| 272 | sst2=sst2(2:end); |
---|
| 273 | bott2=bott2(2:end); |
---|
| 274 | z=squeeze(z2(1,:)); |
---|
| 275 | t1=t1-tmin; |
---|
| 276 | t2=t2-tmin; |
---|
| 277 | |
---|
| 278 | figure('Units','centimeters',... |
---|
| 279 | 'Position',[1 1 20 20],... |
---|
| 280 | 'PaperPosition',[1 1 20 20],... |
---|
| 281 | 'PaperUnits','centimeters') |
---|
| 282 | |
---|
| 283 | subplot(3,1,1) |
---|
| 284 | pcolor(t1,z,u1') |
---|
| 285 | hold on |
---|
| 286 | pcolor(t2,z,u2') |
---|
| 287 | axis([0 9 -30 0]) |
---|
| 288 | shading flat |
---|
| 289 | caxis([-250 250]) |
---|
| 290 | colorbar |
---|
| 291 | title(['Velocity East [mm/s]']) |
---|
| 292 | ylabel('Depth') |
---|
| 293 | set(gca,'Xticklabel',[]) |
---|
| 294 | |
---|
| 295 | subplot(3,1,2) |
---|
| 296 | pcolor(t1,z,v1') |
---|
| 297 | hold on |
---|
| 298 | pcolor(t2,z,v2') |
---|
| 299 | axis([0 9 -30 0]) |
---|
| 300 | shading flat |
---|
| 301 | caxis([-250 250]) |
---|
| 302 | colorbar |
---|
| 303 | title(['Velocity North [mm/s]']) |
---|
| 304 | ylabel('Depth') |
---|
| 305 | set(gca,'Xticklabel',[]) |
---|
| 306 | |
---|
| 307 | subplot(3,1,3) |
---|
| 308 | pcolor(t1,z,temp1') |
---|
| 309 | hold on |
---|
| 310 | pcolor(t2,z,temp2') |
---|
| 311 | axis([0 9 -30 0]) |
---|
| 312 | shading flat |
---|
| 313 | caxis([10 15]) |
---|
| 314 | colorbar |
---|
| 315 | title(['Temperature [^oC]']) |
---|
| 316 | ylabel('Depth') |
---|
| 317 | set(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 | % |
---|
| 322 | eval(['print -depsc2 -painters bob_',num2str(rundate),'.eps']) |
---|
| 323 | eval(['!convert -density 85 bob_',num2str(rundate),... |
---|
| 324 | '.eps bob_',num2str(rundate),'.jpg']) |
---|
| 325 | eval(['!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 | |
---|