Closed kakearney closed 4 years ago
I have removed bathymetry_chord(). You are correct that it serves narrow purpose and I think it will get users into more trouble than it is worth. For bathymetry_search I have replaced the search for nearest grid cells with grid densification and interpolation as you have suggested. I think the points are ordered by the chosen reference variable rather than the order of the input (see below) but please let me know if I have misunderstood this comment.
% Order bathymetry_section by xref.
[xvar,xvar_inds] = sort(xvar);
bath_section = bath_section(xvar_inds);
lon_section = lon_section(xvar_inds);
lat_section = lat_section(xvar_inds);
time_section = time_section(xvar_inds);
I am closing this issue but feel free to reopen it if these fixes are not sufficient. Thank you for the helpful advice on this.
Both bathymetry_section and bathymetry_chord suffer from issues regarding how they order the output points when plotting against a transect.
For bathymetry_section, there are two issues. The first is that it uses the coordinates of the closest-matching-grid cell, rather than the input coordinates, along the x axis. Unless the input line is parallel to the specified axis (i.e. an east/west line paired with lon, or a north/south line paired with lat), this may cause strong reduction in the plotted x-coordinate resolution relative to the input coordinates. The points are also plotted in the order they appear in the input, rather than in increasing order with longitude and/or latitude, which can be an issue for any set of points whose x-coordinate dataset (x for xref='lon' or y for xref='lat') is not monotonically increasing.
For bathymetry_chord, the output can get even messier. The general idea behind this function appears to be to plot the bathymetry along a transect line. However, it only does so in a very limited context: when the line is parallel to the specified x axis, and the specified
width
is approximately equal to or less than to the resolution of the bathymetry dataset. Anything else results in a mess of lines doubling back on themselves, due to the way grid cell within the polygon are collected.A demonstration:
(Note: this code uses some of my personal toolbox: plotgrid, minmax, multitextloc)