[1] | 1 | function test_forcing(frcname,grdname,thefield,thetime,skip,coastfileplot) |
---|
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3 | % |
---|
| 4 | % Plot a variable from the forcing file |
---|
| 5 | % |
---|
| 6 | % Further Information: |
---|
| 7 | % http://www.brest.ird.fr/Roms_tools/ |
---|
| 8 | % |
---|
| 9 | % This file is part of ROMSTOOLS |
---|
| 10 | % |
---|
| 11 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published |
---|
| 13 | % by the Free Software Foundation; either version 2 of the License, |
---|
| 14 | % or (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
| 17 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License for more details. |
---|
| 20 | % |
---|
| 21 | % You should have received a copy of the GNU General Public License |
---|
| 22 | % along with this program; if not, write to the Free Software |
---|
| 23 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
| 24 | % MA 02111-1307 USA |
---|
| 25 | % |
---|
| 26 | % Copyright (c) 2002-2006 by Pierrick Penven |
---|
| 27 | % e-mail:Pierrick.Penven@ird.fr |
---|
| 28 | % |
---|
| 29 | % Updated 31-Aug-2006 by Pierrick Penven |
---|
| 30 | % Updated 25-Oct-2006 by Pierrick Penven (uwnd and vwnd) |
---|
| 31 | % |
---|
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 33 | % |
---|
| 34 | niceplot=1; |
---|
| 35 | i=0; |
---|
| 36 | for time=thetime |
---|
| 37 | i=i+1; |
---|
| 38 | |
---|
| 39 | subplot(2,length(thetime)/2,i) |
---|
| 40 | |
---|
| 41 | nc=netcdf(frcname); |
---|
| 42 | stime=nc{'sms_time'}(time); |
---|
| 43 | if isempty(stime) |
---|
| 44 | stime=nc{'bulk_time'}(time); |
---|
| 45 | if isempty(stime) |
---|
| 46 | error('TEST_FORCING: Is it a forcing or a bulk file ?') |
---|
| 47 | end |
---|
| 48 | u=nc{'uwnd'}(time,:,:); |
---|
| 49 | v=nc{'vwnd'}(time,:,:); |
---|
| 50 | if thefield(1:3)=='spd' |
---|
| 51 | field=sqrt((u2rho_2d(u)).^2+(v2rho_2d(v)).^2); |
---|
| 52 | fieldname='wind speed'; |
---|
| 53 | else |
---|
| 54 | field=nc{thefield}(time,:,:); |
---|
| 55 | fieldname=nc{thefield}.long_name(:); |
---|
| 56 | end |
---|
| 57 | else |
---|
| 58 | u=nc{'sustr'}(time,:,:); |
---|
| 59 | v=nc{'svstr'}(time,:,:); |
---|
| 60 | if thefield(1:3)=='spd' |
---|
| 61 | field=sqrt((u2rho_2d(u)).^2+(v2rho_2d(v)).^2); |
---|
| 62 | fieldname='wind speed'; |
---|
| 63 | else |
---|
| 64 | field=nc{thefield}(time,:,:); |
---|
| 65 | fieldname=nc{thefield}.long_name(:); |
---|
| 66 | end |
---|
| 67 | end |
---|
| 68 | close(nc); |
---|
| 69 | % |
---|
| 70 | % Read the grid |
---|
| 71 | % |
---|
| 72 | nc=netcdf(grdname); |
---|
| 73 | if strcmp(thefield,'sustr') | strcmp(thefield,'uwnd') |
---|
| 74 | lon=nc{'lon_u'}(:); |
---|
| 75 | lat=nc{'lat_u'}(:); |
---|
| 76 | mask=nc{'mask_u'}(:); |
---|
| 77 | elseif strcmp(thefield,'svstr') | strcmp(thefield,'vwnd') |
---|
| 78 | lon=nc{'lon_v'}(:); |
---|
| 79 | lat=nc{'lat_v'}(:); |
---|
| 80 | mask=nc{'mask_v'}(:); |
---|
| 81 | else |
---|
| 82 | lon=nc{'lon_rho'}(:); |
---|
| 83 | lat=nc{'lat_rho'}(:); |
---|
| 84 | mask=nc{'mask_rho'}(:); |
---|
| 85 | end |
---|
| 86 | angle=nc{'angle'}(:); |
---|
| 87 | result=close(nc); |
---|
| 88 | mask(mask==0)=NaN; |
---|
| 89 | % |
---|
| 90 | % compute the vectors |
---|
| 91 | % |
---|
| 92 | [ured,vred,lonred,latred,speed]=uv_vec2rho(u,v,lon,lat,angle,... |
---|
| 93 | mask,skip,[0 0 0 0]); |
---|
| 94 | % |
---|
| 95 | % Make the plot |
---|
| 96 | % |
---|
| 97 | if niceplot==1 |
---|
| 98 | domaxis=[min(min(lon)) max(max(lon)) min(min(lat)) max(max(lat))]; |
---|
| 99 | m_proj('mercator',... |
---|
| 100 | 'lon',[domaxis(1) domaxis(2)],... |
---|
| 101 | 'lat',[domaxis(3) domaxis(4)]); |
---|
| 102 | |
---|
| 103 | m_pcolor(lon,lat,mask.*field); |
---|
| 104 | shading flat |
---|
| 105 | drawnow |
---|
| 106 | colorbar |
---|
| 107 | hold on |
---|
| 108 | m_quiver(lonred,latred,ured,vred,'k'); |
---|
| 109 | if ~isempty(coastfileplot) |
---|
| 110 | m_usercoast(coastfileplot,'patch',[.9 .9 .9]); |
---|
| 111 | end |
---|
| 112 | hold off |
---|
| 113 | title([fieldname,' - day: ',num2str(stime)]) |
---|
| 114 | m_grid('box','fancy',... |
---|
| 115 | 'xtick',5,'ytick',5,'tickdir','out',... |
---|
| 116 | 'fontsize',7); |
---|
| 117 | else |
---|
| 118 | imagesc(mask.*field) |
---|
| 119 | title([fieldname,' - day: ',num2str(stime)]) |
---|
| 120 | end |
---|
| 121 | end |
---|
| 122 | |
---|
| 123 | |
---|