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 77 78 79 80 81 82
|
%% fichiers entres
%% premier fichier pour dessiner la carte de fond
nest_filename='fichier_fond.nc';
%% mon fichier de sortie qui va me permettre de dessiner les trajectoires
traj_filename='exemple_trajectoire.nc';
%% read in the nest data
% open nestfile
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
varidU = netcdf.inqVarID(ncid,'zu');
uvel = netcdf.getVar(ncid,varidU);
%close nestfile
netcdf.close(ncid);
%% draw the land
%layer of depth. layer = 1 is the surface.
layer=1;
%divide velocities in land(value=1) and water(value=0)
%velocity of land is 2^100
mask=squeeze(uvel(:,:,layer,1));
mask(mask<2^100)=0;
mask(mask==2^100)= 1;
%draw the land and water
contourf(lonAxis,latAxis,mask',[0.5 0.5],'linestyle','none');
%color of the land in rgb color model
colormap([0.75 0.75 0.75])
%% read in the trajectory data
% open trajectory file
ncid = netcdf.open(traj_filename,'NC_NOWRITE');
% Get the values of time
varidTime = netcdf.inqVarID(ncid,'time');
time = netcdf.getVar(ncid,varidTime);
% Get the values of Longitude
varidLon = netcdf.inqVarID(ncid,'lon');
lon = netcdf.getVar(ncid,varidLon);
% Get the values of Latitude
varidLat = netcdf.inqVarID(ncid,'lat');
lat = netcdf.getVar(ncid,varidLat);
% Get the values of depths
varidDepth = netcdf.inqVarID(ncid,'depth');
depth = netcdf.getVar(ncid,varidDepth);
% Get the values of status
varidStatus = netcdf.inqVarID(ncid,'exitcode');
status = netcdf.getVar(ncid,varidStatus);
% Get the values of release date (in julian)
varidrel = netcdf.inqVarID(ncid,'releasedate');
release = netcdf.getVar(ncid,varidrel);
%close nestfile
netcdf.close(ncid);
lat(lat>999) = NaN;
lon(lon>999) = NaN;
%number of trajectories
num_traj = size(lat,2);
%different color for each trajectory
colors=jet(num_traj);
%% plot all the trajectories
hold on;
for i=1:num_traj
plot(lon(:,i), lat(:,i),'color','red');
end
hold off;
%print title
title(['nb particules = ',num2str(num_traj),'titre']);
axis equal; |
Partager