g_res.m 2.08 KB
 Dany Dumont committed Apr 18, 2019 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 ``````function res = g_res_field(LON, LAT, field) % g_res_field - Function calculating the loss of resolution with de distance % from the camera % % Inputs: % % LON : Longitude matrix obtained from g_rect % LAT : Latitude matrix obtained from g_rect % field : 'true' for field case. 'false' for lab case. % % Outputs: % % res : The field of resolution which is degrading with distance from % the camera % % Author: Daniel Bourgault % Institut des sciences de la mer de Rimouski % % email: daniel_bourgault@uqar.ca % Website: http://demeter.uqar.ca/g_rect/ % February 2013 % % Author: Elie Dumas-Lefebvre % Institut des Science de la Mer de Rimouski % % Note: Matricial formulation of the calculation for a faster execution % % email: elie.dumas-lefebvre@uqar.ca % March 2019 % % LAT and LON difference in the x-axis dLATi = diff(LAT, 1, 2); dLONi = diff(LON, 1, 2); % LAT and LON difference in the y-axis dLATj = diff(LAT, 1, 1); dLONj = diff(LON, 1, 1); % Mean LAT in both x and y axis LAT_meani = 0.5*(LAT(:, 2:end) + LAT(:, 1:end-1)); LAT_meanj = 0.5*(LAT(2:end, :) + LAT(1:end-1, :)); % Add a point at boundaries such that the resolution matrix % has the same size of the LAT LON matrices dLATi(:,end+1) = dLATi(:,end); dLONi(:,end+1) = dLONi(:,end); dLATj(end+1,:) = dLATj(end,:); dLONj(end+1,:) = dLONj(end,:); LAT_meani(:,end+1) = LAT_meani(:,end); LAT_meanj(end+1,:) = LAT_meani(end,:); % Conversion from degree to meters meterPerDegLat = 1852*60.0; meterPerDegLoni = meterPerDegLat.*cosd(LAT_meani); meterPerDegLonj = meterPerDegLat.*cosd(LAT_meanj); if field % Conversion from degrees to meters dxi = dLONi.*meterPerDegLoni; dxj = dLONj.*meterPerDegLonj; dyi = dLATi.*meterPerDegLat; dyj = dLATj.*meterPerDegLat; else % Lab case. Data are already in meters. No conversion required. dxi = dLONi; dxj = dLONj; dyi = dLATi; dyj = dLATj; end % Distances in x and y axis deltai = sqrt(dxi.^2 + dyi.^2); deltaj = sqrt(dxj.^2 + dyj.^2); % field of resolution res = sqrt(deltai.^2 + deltaj.^2); `````` Daniel Bourgault committed Jan 09, 2015 83 ``end``