1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
%% paramètres
nest_filename='nest_1_20170511000000.nc';
%number of different colors you want to use plotting the velocities
num_colors = 100;
%% lecture des données dans le fichier
% ouverture du fichier
ncid = netcdf.open(nest_filename,'NC_NOWRITE');
% Get the values of Longitude from the nestfile
varidLon = netcdf.inqVarID(ncid,'Longitude');
lonAxis = netcdf.getVar(ncid,varidLon);
% Get the values of Latitude from the nestfile
varidLat = netcdf.inqVarID(ncid,'Latitude');
latAxis = netcdf.getVar(ncid,varidLat);
% Get the values of U-velocity from the nestfile
varidLat = netcdf.inqVarID(ncid,'zu');
uvel = netcdf.getVar(ncid,varidLat);
% Get the values of U-velocity from the nestfile
varidLat = netcdf.inqVarID(ncid,'zv');
vvel = netcdf.getVar(ncid,varidLat);
%close nestfile
netcdf.close(ncid);
%Ci-dessous, les données que l'on peut représenter
%the U-velocity
%the V-velocity
%the speed
%On choisit une de ces données
%% draw U-velocity
% %set land velocities to NaN
% uvel(uvel==2^100)= NaN;
% %calculate min and max value of speed
% minval = min(min(uvel(:,:,1,1)));
% maxval = max(max(uvel(:,:,1,1)));
% %draw U-velocity
% contourlevels = linspace(minval, maxval, num_colors);
% colormap(jet(num_colors));
% contourf(lonAxis,latAxis,uvel(:,:,1,1)',contourlevels,'linestyle','none');
% colorbar;
% axis equal;
%% draw V-velocity
% %set land velocities to NaN
% vvel(vvel==2^100)= NaN;
% %calculate min and max value of speed
% minval = min(min(vvel(:,:,1,1)));
% maxval = max(max(vvel(:,:,1,1)));
% %draw V-velocity
% contourlevels = linspace(minval, maxval,num_colors);
% colormap(jet(num_colors));
% contourf(lonAxis,latAxis,vvel(:,:,1,1)',contourlevels,'linestyle','none');
% colorbar;
% axis equal;
%% draw Speed
%set land velocities to NaN
uvel(uvel==2^100)= NaN;
vvel(vvel==2^100)= NaN;
%calculate speed
speed = sqrt(uvel .* uvel + vvel .* vvel);
%calculate min and max value of speed
minval = min(min(speed(:,:,1,1)));
maxval = max(max(speed(:,:,1,1)));
%draw speed
contourlevels = linspace(minval, maxval,num_colors);
colormap(jet(num_colors));
contourf(lonAxis,latAxis,speed(:,:,1,1)',contourlevels,'linestyle','none');
colorbar;
axis equal; |
Partager