Matlab script used to do the analysis is **RadialVeloCompa_Sept2013_HFR_ADCP_WERA_ADCPcorrected_v2.m**

Steps of the algorithm:

1- we choose a site to analyze, either PAO (site 1) or PAB (site 2)

2- we load the bathymetry and the HFR sites’coordinates

3- we specify if we use the “old” or “new” calibrations. Usually “New”.

4- we load IML-4 ADCP data (2013) and gps data

5- we make a list of all the HFR files available for the site of interest.

6- we analyze the ADCP data (bin 2 only to get near-surface data):

- We look for the indices of the ADCP time vector corresponding to the time period of interest (here 01 to 30 September 2013).
- For each index, we look for the ADCP position (xadcp,yadcp)(via the gps coordinates).
- We then look for the positions 15min before and 15min after.
- We estimate the mean drift of the ADCP within these 30 minutes (Umean_adcp_u, Umean_adcp_v and U_mean_adcp (total)).
- We find the radial orientation at the ADCP position given by xadcp,yadcp: azimuth in degrees from HFR site to adcp position
- We project U_mean_adcp onto the radial direction to get the radial current components (ur_adcp_proj, vr_adcp_proj).
- We store all the meaningful parameters into a structure named adcp.

7- We analyze the HFR data:

- We look for the indices of the HFR time vector corresponding to the time period of interest (here 01 to 30 September 2013)
- For each index, we load the corresponding HFR file (i.e. 20132440000_pao.mat). Each file contains a grid (X,Y) with radial currents at each grid point (Ur), a corresponding time vector (t) and the angle and distance from the site (theta,r).

- We then look for the HFR grid point nearest the ADCP position at the time of interest.

- We find the HFR Radial velocity at this position and project it onto zonal and meridional components.
- We store all the meaningful parameters into a structure named radar.

This analysis allows us to compare radial velocity components from each HFR site with the ADCP components.

To verify that the HFR looks in the right direction:

# For each time step of the time period of interest, we compute the distance from the HFR site to each grid point. We select the grid points that are at the same range from the HFR site than the grid point closest to the ADCP.

# For each of these grid point (in cyan in the figure), we compute the azimuth the the site coordinates and we extract the radial velocity (total) and its components (zonal and meridional).

#We store all the meaningful parameters into a structure named range.

Results from the whole analysis are stored, for example, under: /run/media/bandma01/SeagateWireless/MEOPAR/Matlab/Analysis/Radial_Comparison/201309/ADCP-PAO/ADCP_PAO_version5adcpCorrected_newcalibrations_v2.mat

**RESULTS WITH OLD CALIBRATIONS**

generated with PlotRadialVeloCompa_Sept2013_HFR_ADCP_WERA_v2.m

**RESULTS WITH NEW CALIBRATIONS**

generated with PlotRadialVeloCompa_Sept2013_HFR_ADCP_WERA_v2.m