-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #777 from aodn/bug_binmapping
Bug binmapping
- Loading branch information
Showing
3 changed files
with
153 additions
and
32 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
Preprocessing/+NortekADCP/adcp_adjusted_distances_nortek3beam.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function nonMappedHeightAboveSensorBeam = adcp_adjusted_distances_nortek3beam(roll, pitch, distAlongBeams, beamAngle, number_of_beams) | ||
% function nonMappedHeightAboveSensorBeam = adcp_adjusted_distances_nortek3beam(roll, pitch, distAlongBeams, beamAngle, number_of_beams) | ||
% | ||
% Adjusts height above sensor for each beam in adcpBinMapping.m | ||
% Can read 3 beam Nortek instruments. | ||
% Uses the beam angle and the roll/pitch of the instrument. | ||
% No adjustement when tilt is zero, | ||
% nonMappedHeightAboveSensorBeam will be the same than distAlongBeams. | ||
% | ||
% Inputs: | ||
% | ||
% roll - 1D single precision array (Ntime), the internal roll angles in degrees | ||
% pitch - 1D single precision array (Ntime), the internal pitch angles in degrees | ||
% distAlongBeams - 1D array (Nbins), the internal distance along beam for each bin | ||
% beamAngle - scalar, beam angle from the instrument | ||
% number_of_beams - interger, number of beams on the ADCP | ||
% | ||
% Outputs: | ||
% | ||
% nonMappedHeightAboveSensorBeam - 3D single precision array (Ntime, Nbins, Nbeams), | ||
% tilt adjusted height above sensor for | ||
% each of the 3 beams | ||
% | ||
% Example: | ||
% | ||
% roll_ini = [-180:10:180]'; | ||
% pitch_ini = [-180:10:180]'; | ||
% distAlongBeams = [20:20:600]; | ||
% beamAngle = 0.3; | ||
% number_of_beams = 3; | ||
% | ||
% x = NortekADCP.adcp_adjusted_distances_nortek3beam(roll_ini,pitch_ini,distAlongBeams,beamAngle,number_of_beams); | ||
% | ||
% idx0 = find(roll_ini == 0); | ||
% for i=1:number_of_beams; assert(isequal(x(idx0,:,i), distAlongBeams)); assert(~isequal(x(~idx0,:,i), distAlongBeams)); end | ||
% | ||
% | ||
|
||
narginchk(5,5) | ||
|
||
number_of_beams = 3; | ||
nBins = length(distAlongBeams); | ||
|
||
% set to single precision | ||
nonMappedHeightAboveSensorBeam = nan(length(pitch), length(distAlongBeams), number_of_beams, 'single'); | ||
|
||
nonMappedHeightAboveSensorBeam(:,:,1) = (cos(beamAngle - pitch) / cos(beamAngle)) * distAlongBeams; | ||
nonMappedHeightAboveSensorBeam(:,:,1) = repmat(cos(roll), 1, nBins) .* nonMappedHeightAboveSensorBeam(:,:,1); | ||
|
||
beamAngleX = atan(tan(beamAngle) * cos(60 * pi / 180)); % beams 2 and 3 angle projected on the X axis | ||
beamAngleY = atan(tan(beamAngle) * cos(30 * pi / 180)); % beams 2 and 3 angle projected on the Y axis | ||
|
||
nonMappedHeightAboveSensorBeam(:,:,2) = (cos(beamAngleX + pitch) / cos(beamAngleX)) * distAlongBeams; | ||
nonMappedHeightAboveSensorBeam(:,:,2) = repmat(cos(beamAngleY + roll) / cos(beamAngleY), 1, nBins) .* nonMappedHeightAboveSensorBeam(:,:,2); | ||
|
||
nonMappedHeightAboveSensorBeam(:,:,3) = (cos(beamAngleX + pitch) / cos(beamAngleX)) * distAlongBeams; | ||
nonMappedHeightAboveSensorBeam(:,:,3) = repmat(cos(beamAngleY - roll) / cos(beamAngleY), 1, nBins) .* nonMappedHeightAboveSensorBeam(:,:,3); | ||
|
||
end | ||
|
75 changes: 75 additions & 0 deletions
75
Preprocessing/+TeledyneADCP/adcp_adjusted_distances_rdi4beam.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
function nonMappedHeightAboveSensorBeam = adcp_adjusted_distances_rdi4beam(roll, pitch, pitchSign, distAlongBeams, beamAngle, number_of_beams) | ||
% function nonMappedHeightAboveSensorBeam = adcp_adjusted_distances_rdi4beam(roll, pitch, pitchSign, distAlongBeams, beamAngle, number_of_beams) | ||
% | ||
% Adjusts height above sensor for each beam in adcpBinMapping.m | ||
% Can read 4 beam RDI instruments. | ||
% Uses the beam angle and the roll/pitch of the instrument. | ||
% No adjustement when tilt is zero, | ||
% nonMappedHeightAboveSensorBeam will be the same than distAlongBeams. | ||
% Deals with up and down facing ADCPs | ||
% | ||
% Inputs: | ||
% | ||
% roll - 1D single precision array (Ntime), the internal roll angles in degrees | ||
% pitch - 1D single precision array (Ntime), the internal pitch angles in degrees | ||
% pitchSign - integer (-1 or 1), pitch sign based on the ADCP's orientation | ||
% distAlongBeams - 1D array (Nbins), the internal distance along beam for each bin | ||
% beamAngle - scalar, beam angle from the instrument | ||
% number_of_beams - interger, number of beams on the ADCP | ||
% | ||
% Outputs: | ||
% | ||
% nonMappedHeightAboveSensorBeam - 3D single precision array (Ntime, Nbins, Nbeams), | ||
% tilt adjusted height above sensor for | ||
% each of the 4 beams | ||
% | ||
% Example: | ||
% | ||
% %testing for up and down facing ADCPs - no change for beam 1 and 2 (roll) | ||
% %changes only for beam 3 and 4 (pitch) | ||
% | ||
% roll_ini = [-180:10:180]'; | ||
% pitch_ini = [-180:10:180]'; | ||
% pitchSign_up = 1; | ||
% pitchSign_down = -1; | ||
% distAlongBeams = [20:20:600]; | ||
% beamAngle = 0.3; | ||
% number_of_beams = 4; | ||
% | ||
% x_up = TeledyneADCP.adcp_adjusted_distances_rdi4beam(roll_ini,pitch_ini,pitchSign_up,distAlongBeams,beamAngle,number_of_beams); | ||
% x_down = TeledyneADCP.adcp_adjusted_distances_rdi4beam(roll_ini,pitch_ini,pitchSign_down,distAlongBeams,beamAngle,number_of_beams); | ||
% | ||
% assert(isequal(x_up(:,:,1), x_down(:,:,1))); | ||
% assert(isequal(x_up(:,:,2), x_down(:,:,2))); | ||
% assert(~isequal(x_up(:,:,3), x_down(:,:,3))); | ||
% assert(~isequal(x_up(:,:,4), x_down(:,:,4))); | ||
% | ||
% idx0 = find(roll_ini == 0); | ||
% for i=1:number_of_beams; assert(isequal(x_up(idx0,:,i), distAlongBeams)); assert(isequal(x_down(idx0,:,i), distAlongBeams)); end | ||
% for i=1:number_of_beams; assert(~isequal(x_up(~idx0,:,i), distAlongBeams)); assert(~isequal(x_down(~idx0,:,i), distAlongBeams)); end | ||
% | ||
% | ||
|
||
narginchk(6,6) | ||
|
||
nmh=1; | ||
if pitchSign < 0 | ||
% adjust nonMappedHeightAboveSensorBeam sign when downfacing | ||
nmh = -1; | ||
% adjust roll when downfacing | ||
roll = roll-pi; | ||
end | ||
|
||
CP = cos(pitchSign * pitch); | ||
CR = cos(roll); | ||
|
||
% set to single precision | ||
nonMappedHeightAboveSensorBeam = nan(length(pitch), length(distAlongBeams), number_of_beams, 'single'); | ||
|
||
nonMappedHeightAboveSensorBeam(:,:,1) = nmh * (CP .* (cos(beamAngle + roll) / cos(beamAngle) .* distAlongBeams)); | ||
nonMappedHeightAboveSensorBeam(:,:,2) = nmh * (CP .* (cos(beamAngle - roll) / cos(beamAngle) .* distAlongBeams)); | ||
nonMappedHeightAboveSensorBeam(:,:,3) = nmh * (CR .* (cos(beamAngle - pitchSign * pitch) / cos(beamAngle) .* distAlongBeams)); | ||
nonMappedHeightAboveSensorBeam(:,:,4) = nmh * (CR .* (cos(beamAngle + pitchSign * pitch) / cos(beamAngle) .* distAlongBeams)); | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters