


Sample script to extract and generate m_map contours of tracer variables
Modify to suit your requirements
DESCRIPTION:
Extracts data from FVCOM and generates contour plots using m_map
INPUT:
OUTPUT:
EXAMPLE USAGE
See scripts and modify at will
Author(s):
Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory)
Revision history
==============================================================================

0001 % Sample script to extract and generate m_map contours of tracer variables 0002 % Modify to suit your requirements 0003 % 0004 % DESCRIPTION: 0005 % Extracts data from FVCOM and generates contour plots using m_map 0006 % 0007 % INPUT: 0008 % 0009 % 0010 % 0011 % OUTPUT: 0012 % 0013 % EXAMPLE USAGE 0014 % See scripts and modify at will 0015 % 0016 % Author(s): 0017 % Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory) 0018 % 0019 % Revision history 0020 % 0021 %============================================================================== 0022 addpath ../utilities 0023 %%----------------------------------------------------------- 0024 % set directories default values 0025 % 0026 FVCOM_root = ''; 0027 FVCOM_data_dir='/home_nfs/rito/models/FVCOM/runCO2_leak/output/'; 0028 FVCOM_mat_dir='../mat/'; 0029 FVCOM_plot_dir='../plots/'; 0030 FVCOM_ ='./'; 0031 % 0032 time_offset = 678942; % from FVCOM time to matlab time 0033 %% 0034 %------------------------------------------------------------------------------ 0035 % set casename specifics here 0036 %------------------------------------------------------------------------------ 0037 % 0038 casename='co2_S5'; 0039 experiment_name='slowleak' 0040 [plotOPTS.range_lat ,plotOPTS.range_lon] = deal([50.1 50.4],[ -4.5 -3.85]); 0041 base_year = datenum(2006,1,1,0,0,0); 0042 files_FVCOM ='co2_S5.1.2.1_0002.nc'% 0043 date_range={'30/01/06 00:00:00','01/02/06 23:00:00'}; % -1 if all available data wanted 0044 plotOPTS.fig_name = [casename '_' experiment_name]; 0045 var_2_xtractFVCOM = {'Itime','Itime2','xc','yc','h','siglay','siglev','zeta','salinity','u','v'}; 0046 dt=1/24; % time step of output in days. 0047 % Time record to extract 0048 % 0049 STnum = datenum(date_range{1},'dd/mm/yy HH:MM:SS'); 0050 ENDnum = datenum(date_range{2},'dd/mm/yy HH:MM:SS'); 0051 Time_record=STnum:dt:ENDnum; 0052 CD=pwd 0053 %% 0054 %------------------------------------------------------------------------------ 0055 % Specify What indices to read from FVCOM file 0056 %------------------------------------------------------------------------------ 0057 node_idx= -1 % to extract all nodes from netcdf file 0058 nele_idx=-1 % to extract all elements from netcdf file 0059 siglev_idx=-1 % to extract all water levels from netcdf file 0060 siglay_idx=-1 % to extract all water levels from netcdf file 0061 0062 %% 0063 %------------------------------------------------------------------------------ 0064 % load mesh information for current casename This is generated at preproc 0065 % stage (see %%%% matlab script) 0066 %------------------------------------------------------------------------------ 0067 load(fullfile(FVCOM_mat_dir, [casename, 'mesh'])); 0068 plotOPTS.mesh=mesh; 0069 0070 %% 0071 %------------------------------------------------------------------------------ 0072 % Specify variable and conditions of plot 0073 %------------------------------------------------------------------------------ 0074 % if you have a coastline that can be directly used by m_map here is the 0075 % place to put it! 0076 plotOPTS.coastline_file=[FVCOM_mat_dir 'tamar3_0coast.mat']; 0077 % m_map projection information 0078 plotOPTS.zone=30; 0079 plotOPTS.ell='grs80'; 0080 % variable to plot 0081 plotOPTS.var_plot = 'PH'; 0082 % color limits for the colorbar 0083 plotOPTS.clims=[6.0 8.0] 0084 plotOPTS.do_mesh=0; % don't display mesh 1 to overlay mesh 0085 plotOPTS.nz_plot=1;% layer to plot 0086 plotOPTS.Time_record=Time_record; % time steps to make plots (1 for single or more for animation) 0087 %% ------------------------------------------------------------------------ 0088 %% 0089 %------------------------------------------------------------------------------ 0090 % read FVCOM data. See read_netCDF_FVCOM.m for help 0091 %------------------------------------------------------------------------------ 0092 % 0093 FVCOM_data=read_netCDF_FVCOM('time',date_range,'data_dir',FVCOM_data_dir ,... 0094 'file_netcdf',files_FVCOM,'node_idx',node_idx,'nele_idx',nele_idx,'siglev_idx',siglev_idx,... 0095 'siglay_idx',siglay_idx,'varnames',var_2_xtractFVCOM) 0096 % put variables into a strcuture variable 0097 for vv=1:length(var_2_xtractFVCOM) 0098 FVCOM.(var_2_xtractFVCOM{vv}) = FVCOM_data{vv}; 0099 end 0100 0101 %% 0102 %------------------------------------------------------------------------------ 0103 % Do surface contour plots 0104 %------------------------------------------------------------------------------ 0105 % select figure to plot on 0106 plotOPTS.figure=1; 0107 PLotoutS=do_surface_plot(plotOPTS,FVCOM) 0108 % PLotoutS has the figure handles or last handle if a time series is being 0109 % plot 0110 %------------------------------------------------------------------------------ 0111 % Do vector maps at single or multiple levels plots 0112 %------------------------------------------------------------------------------ 0113 plotOPTS.figure=2; 0114 % plotOPTS.nz_plot_vec optional. If it exists, it will overlay vectors from 0115 % the specified layers, otherwise it uses layer from nz_plot 0116 plotOPTS.nz_plot_vec=[1,10]; 0117 plotOPTS.data_dec=5; 0118 plotOPTS.vel_sca=5; % scaling for ploting vectors with m_map m_vec. 0119 plotOPTS.pause=0.5 % pause between generation of plots 0120 % vector plots requires correct lat and lon for u and v positions: FVCOM.xc 0121 % and FVCOM.yc. Remember to extract them 0122 PLotoutV=do_vector_plot(plotOPTS,FVCOM)