-
Notifications
You must be signed in to change notification settings - Fork 1
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 #76 from sfregosi/sf-bug-fixes
Lots of bug fixes
- Loading branch information
Showing
13 changed files
with
522 additions
and
346 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
% S. Fregosi <[email protected]> <https://github.com/sfregosi> | ||
% | ||
% FirstVersion: 05 April 2023 | ||
% Updated: 07 August 2024 | ||
% Updated: 11 September 2024 | ||
% | ||
% Created with MATLAB ver.: 9.13.0.2166757 (R2022b) Update 4 | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
@@ -45,9 +45,9 @@ | |
radius = 2000; | ||
|
||
% create targets file, 3 options to name waypoints | ||
% (1) prefix-based automated naming | ||
prefix = 'WP'; % Any two letters make easy to reference and read options | ||
targetsOut = makeTargetsFile(CONFIG, kmlFile, prefix, radius); | ||
% (1) alphanumeric/prefix-based automated naming | ||
alphaNum = 'WP'; % Any two letters make easy to reference and read options | ||
targetsOut = makeTargetsFile(CONFIG, kmlFile, alphaNum, radius); | ||
% OR | ||
% (2) use a text file with list of waypoint names; will prompt to select .txt | ||
targetsOut = makeTargetsFile(CONFIG, kmlFile, 'file', radius); | ||
|
@@ -64,9 +64,9 @@ | |
% use targetsOut file from above as input targets file | ||
targetsFile = targetsOut; | ||
|
||
% create plot | ||
mapPlannedTrack(CONFIG, targetsFile, CONFIG.glider, bathyOn, figNum) | ||
|
||
% create plot - single track only | ||
mapPlannedTrack(CONFIG, targetsFile, CONFIG.glider, bathyOn, [], figNum) | ||
% 5th argument blank uses default color (orange) | ||
|
||
% get file name only for plot saving | ||
[~, targetsName, ~] = fileparts(targetsFile); | ||
|
@@ -89,10 +89,12 @@ | |
%% (3) Plot bathymetry profile of targets file | ||
|
||
% can specify bathymetry file | ||
bathyFile = 'C:\GIS\etopo\ETOPO2022_bedrock_30arcsec_MHI.tiff'; | ||
plotTrackBathyProfile(CONFIG, targetsFile, bathyFile, figNum) | ||
% OR leave empty to prompt to select file | ||
plotTrackBathyProfile(CONFIG, targetsFile, [], figNum) | ||
bathyFile = 'C:\GIS\etopo\ETOPO2022_bedrock_30arcsec.tiff'; | ||
plotTrackBathyProfile(CONFIG, 'targetsFile', targetsFile, ... | ||
'bathyFile', bathyFile) | ||
% OR leave that argument out to default to CONFIG.map.bathyFile if | ||
% available or prompt if not available | ||
plotTrackBathyProfile(CONFIG, 'targetsFile', targetsFile) | ||
|
||
% save as .png | ||
exportgraphics(gcf, fullfile(CONFIG.path.mission, [CONFIG.glider '_' ... | ||
|
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
function [baseFig] = createBasemap(CONFIG, bathyOn, contourOn, figNum) | ||
function [baseFig] = createBasemap(CONFIG, varargin) | ||
% CREATEBASEMAP Create a basemap of the bathymetry for the mission area | ||
% | ||
% Syntax: | ||
% BASEFIG = CREATEBASEMAP(CONFIG, BATHYON, CONTOURON, FIGNUM, OUTFIG) | ||
% BASEFIG = CREATEBASEMAP(CONFIG, VARARGIN) | ||
% | ||
% Description: | ||
% Function to create a basemap for a glider mission, using the lat | ||
|
@@ -12,13 +12,25 @@ | |
% states at this time). It can be saved as a .fig file that can be | ||
% added to (add glider path, labels, and acoustic encounters). | ||
% | ||
% Bathymetry files can be downloaded from NCEI. For more info on | ||
% selecting a bathymetry file visit: | ||
% https://sfregosi.github.io/agate/#basemap-rasters | ||
% | ||
% Inputs: | ||
% CONFIG [struct] mission/agate configuration variable. | ||
% Required fields: CONFIG.map entries | ||
% bathyOn [double] set to 1 to plot bathymetry or 0 to only plot | ||
% land | ||
% contourOn [double] set to 1 to plot bathymetry contours or 0 for | ||
% no contour lines | ||
% | ||
% all varargins are specified using name-value pairs | ||
% e.g., 'bathyOn', 1, 'figNum', 12 | ||
% | ||
% bathy optional argument for bathymetry plotting | ||
% [double] Set to 1 to plot bathymetry or 0 to only plot | ||
% land. Will look for bathy file in CONFIG.map.bathyFile | ||
% [char] Path to the bathymetry file (if you want to use | ||
% a different one than specified in CONFIG or it is not | ||
% specified in CONFIG | ||
% contourOn [double] optional argument. Set to 1 to plot bathymetry | ||
% contours or 0 for no contour lines. Default is on (1) | ||
% figNum [double] optional to specify figure number so won't | ||
% create repeated versions when updated | ||
% | ||
|
@@ -27,29 +39,53 @@ | |
% | ||
% Examples: | ||
% % Create a basemap that includes bathymetry but no contour lines | ||
% baseFig = createBasemap(CONFIG, 1, 0); | ||
% baseFig = createBasemap(CONFIG, 'contourOn', 0); | ||
% | ||
% See also | ||
% | ||
% Authors: | ||
% S. Fregosi <[email protected]> <https://github.com/sfregosi> | ||
% | ||
% FirstVersion: 09 March 2024 | ||
% Updated: 06 August 2024 | ||
% Updated: 11 September 2024 | ||
% | ||
% Created with MATLAB ver.: 9.13.0.2166757 (R2022b) Update 4 | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
%%%%%%%%%%%%%% | ||
% for testing | ||
% figNum = 82; | ||
%%%%%%%%%%%%%% | ||
|
||
% specify a figure number | ||
if nargin < 4 | ||
figNum = []; | ||
% argument checks | ||
narginchk(1, inf) | ||
|
||
% set defaults | ||
bathyOn = 1; | ||
bathyFile = []; | ||
contourOn = 1; | ||
figNum = []; | ||
|
||
% parse arguments | ||
vIdx = 1; | ||
while vIdx <= length(varargin) | ||
switch varargin{vIdx} | ||
case 'bathy' | ||
if ischar(varargin{vIdx+1}) || isstring(varargin{vIdx+1}) | ||
bathyOn = 1; | ||
bathyFile = varargin{vIdx+1}; | ||
elseif isnumeric(varargin{vIdx+1}) | ||
bathyOn = varargin{vIdx+1}; | ||
bathyFile = []; | ||
end | ||
vIdx = vIdx+2; | ||
case 'contourOn' | ||
contourOn = varargin{vIdx+1}; | ||
vIdx = vIdx+2; | ||
case 'figNum' | ||
figNum = varargin{vIdx+1}; | ||
vIdx = vIdx+2; | ||
otherwise | ||
error('Incorrect argument. Check inputs.'); | ||
end | ||
end | ||
|
||
|
||
%% set up the figure | ||
|
||
if isempty(figNum) | ||
|
@@ -58,7 +94,7 @@ | |
baseFig = figure(figNum); | ||
end | ||
|
||
% mapFigPosition = [100 100 800 600]; | ||
% mapFigPosition = [100 50 800 600]; | ||
% baseFig.Position = mapFigPosition; | ||
baseFig.Name = 'Base map'; | ||
|
||
|
@@ -96,13 +132,23 @@ | |
|
||
if contourOn == 1 || bathyOn == 1 % if either, load raster data | ||
|
||
if isfield(CONFIG.map, 'bathyFile') | ||
bathyFile = CONFIG.map.bathyFile; | ||
else % prompt to choose file | ||
% if not file specified, try to use CONFIG, otherwise prompt | ||
if isempty(bathyFile) | ||
if isfield(CONFIG.map, 'bathyFile') | ||
bathyFile = CONFIG.map.bathyFile; | ||
else % prompt to choose file | ||
[fn, path] = uigetfile(fullfile(CONFIG.path.shp, '*.tif;*.tiff'), ... | ||
'Select etopo raster file'); | ||
bathyFile = fullfile(path, fn); | ||
end | ||
end | ||
% check that the specified one exists, otherwise prompt | ||
if ~exist(bathyFile, 'file') | ||
[fn, path] = uigetfile(fullfile(CONFIG.path.shp, '*.tif;*.tiff'), ... | ||
'Select etopo raster file'); | ||
bathyFile = fullfile(path, fn); | ||
end | ||
|
||
[Z, refvec] = readgeoraster(bathyFile, 'OutputType', 'double', ... | ||
'CoordinateSystemType', 'geographic'); | ||
[Z, refvec] = geocrop(Z, refvec, CONFIG.map.latLim, CONFIG.map.lonLim); | ||
|
@@ -123,10 +169,10 @@ | |
brighten(.4); | ||
|
||
% colorbar for bathymetry is too unreliable | ||
% cb = colorbar; | ||
% cb.Location = 'eastoutside'; | ||
% cb.Label.String = 'depth [m]'; | ||
% cbPosit = cb.Position; | ||
% cb = colorbar; | ||
% cb.Location = 'eastoutside'; | ||
% cb.Label.String = 'depth [m]'; | ||
% cbPosit = cb.Position; | ||
end | ||
|
||
if contourOn == 1 % plot it | ||
|
@@ -143,5 +189,34 @@ | |
'BoundingBox', [CONFIG.map.lonLim' CONFIG.map.latLim']); | ||
geoshow(states, 'FaceColor', [0 0 0], 'EdgeColor', 'k'); | ||
|
||
|
||
% NATURAL EARTH DATA - MINOR ISLANDS PLOTTING % | ||
% % plot land | ||
% % try this default path | ||
% landFile = fullfile(CONFIG.path.shp, 'NaturalEarthData', 'ne_10m_land_scale_rank.shp'); | ||
% % if that's no good, prompt for new file | ||
% if ~exist(landFile, 'file') | ||
% [fn, path] = uigetfile([CONFIG.path.shp '*.shp'], 'Select ne_10m_land_scale_rank.shp'); | ||
% landFile = fullfile(path, fn); | ||
% end | ||
% land = shaperead(landFile, 'BoundingBox', [CONFIG.map.lonLim' CONFIG.map.latLim'], ... | ||
% 'UseGeoCoords', true); | ||
|
||
% % and any minor islands if needed (e.g., for SBI) | ||
% % try this default path | ||
% minIslFile = fullfile(CONFIG.path.shp, 'NaturalEarthData', 'ne_10m_minor_islands.shp'); | ||
% % if that's no good, prompt for new file | ||
% if ~exist(minIslFile, 'file') | ||
% [fn, path] = uigetfile([CONFIG.path_shp '*.shp'], 'Select ne_10m_minor_islands.shp'); | ||
% minIslFile = fullfile(path, fn); | ||
% end | ||
% landmi = shaperead(minIslFile, 'BoundingBox', [CONFIG.map.lonLim' CONFIG.map.latLim'], ... | ||
% 'UseGeoCoords', true); | ||
% | ||
% geoshow(land, 'FaceColor', [0 0 0], 'EdgeColor', 'k') | ||
% geoshow(landmi, 'FaceColor', [0 0 0], 'EdgeColor', 'k') | ||
% | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
function downloadBasestationFiles1(CONFIG) | ||
%downloadBasestationFiles1 download new glider files from basestation | ||
% | ||
% downloadBasestationFiles1(CONFIG) | ||
% Download all .log, .nc, .asc, .eng, .dat, WISPR (ws*), and PMAR (pm*) files | ||
% from a basestation described in CONFIG.bs. This is a replacement for the | ||
% older downloadBasestationFiles() routine. In addition to CONFIG.bs, also | ||
% uses CONFIG.path.bsLocal, which says where to deposit the downloaded files. | ||
function downloadBasestationFiles(CONFIG) | ||
%DOWNLOADBASESTATIONFILES download basestation files locally via SFTP | ||
% | ||
% Syntax: | ||
% DOWNLOADBASESTATIONFILES(CONFIG) | ||
% | ||
% Description: | ||
% Download variety of glider piloting files from the remote | ||
% basestation using SFTP. Downloads all new (not previously | ||
% downloaded) .nc, .log, .eng, .asc, .dat, (glider data files) and | ||
% WISPR (ws*) files. | ||
% | ||
% Download of PMAR (pm*) files/folders is untested. | ||
% Previous version also processed/unzipped ws* files using | ||
% `processWisprDetFile` but that is currently not working so that | ||
% step is commented out. | ||
% Previous version also downloaded pdos and cmdfiles (glider piloting | ||
% files) but that is not included here. | ||
% | ||
% To redownload a file (e.g., if corrupt due to incomplete call in), | ||
% delete the file and re-run. The previous version generated a | ||
% 'cache' file that listed all previously downloaded files for speed. | ||
% This could be implemented in the future. | ||
% | ||
% Inputs: | ||
% CONFIG [struct] mission/agate configuration variable. | ||
% Required fields: CONFIG.bs.cnfFile (path to basestation | ||
% configuration file containing url, username and either | ||
% password or SSH key pair), CONFIG.path.bsLocal (folder | ||
% to deposit downloaded files), and CONFIG.path.bsRemote | ||
% (folder on basestation that contains the relevant files | ||
% e.g., the 'current' folder if using | ||
% basestation3/seaglider.pub) | ||
% | ||
% Outputs: | ||
% Downloads files directly to specified CONFIG.path.bsLocal | ||
% | ||
% Examples: | ||
% downloadBasestationFiles(CONFIG) | ||
% | ||
% See also | ||
% | ||
% Authors: | ||
% S. Fregosi <[email protected]> <https://github.com/sfregosi> | ||
% D. Mellinger <[email protected]> <https://github.com/DMellinger> | ||
% | ||
% FirstVersion: 7/22/2016. | ||
% Originally for AFFOGATO project/CatBasin deployment | ||
% Updated: 10 September 2024 | ||
% | ||
% Created with MATLAB ver.: 9.9.0.1524771 (R2020b) Update 2 | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
|
||
% Get the right sftp() function. Since sftp can exist in multiple places, we | ||
% need the right one - the one MATLAB has in its 'io' toolbox. (I thought using | ||
% "matlab.io.sftp()" would work, but it doesn't.) | ||
% Get the right sftp() function. Since sftp can exist in multiple places, | ||
% we need the right one - the one MATLAB has in its 'io' toolbox. (I | ||
% thought using "matlab.io.sftp()" would work, but it doesn't.) | ||
% | ||
% Find the right sftp and get a handle to it. To find it among all the places | ||
% where sftp() exists, find one whose path includes "toolbox/matlab" (or | ||
% "toolbox\matlab"). Then cd to that directory, make a function handle (which | ||
% will always be to a function in the current directory), and cd back. There has | ||
% to be a better way to do this! | ||
% Find the right sftp and get a handle to it. To find it among all the | ||
% places where sftp() exists, find one whose path includes "toolbox/matlab" | ||
% (or"toolbox\matlab"). Then cd to that directory, make a function handle | ||
% (which will always be to a function in the current directory), and cd | ||
% back. There has to be a better way to do this! | ||
|
||
originalDir = pwd(); | ||
try % use try/catch to cd back to originalDir in case of error | ||
all_sftps = which('-all', 'sftp'); % cell array of all sftp.m locations | ||
|
Oops, something went wrong.