Commit 462532cb authored by Pierre Cazenave's avatar Pierre Cazenave

Merge branch 'dev' of gitlab.ecosystem-modelling.pml.ac.uk:fvcom/pyfvcom into dev

parents f51796dc 5cbe3d1c
Pipeline #786 canceled with stage
......@@ -922,7 +922,7 @@ class CrossPlotter(Plotter):
if self.title:
self.axes.set_title(self.title)
def cross_section_init(self, cross_section_points, dist_res = 50, variable_at_cells=False):
def cross_section_init(self, cross_section_points, dist_res = 50, variable_at_cells=False, wetting_and_drying=True):
# sample the cross section
[sub_samp, sample_cells, sample_nodes] = getcrossectiontriangles(cross_section_points[0], self.triangles, self.x, self.y, dist_res)
......@@ -985,13 +985,16 @@ class CrossPlotter(Plotter):
chan_y_raw[np.isnan(chan_y_raw)] = max_zeta
self.chan_x, self.chan_y = self._chan_corners(chan_x_raw, chan_y_raw)
# sort out wetting and drying nodes
if variable_at_cells:
self.ds.load_data(['wet_cells'])
self.wet_points_data = np.asarray(self.ds.data.wet_cells[:,self.sel_points], dtype=bool)
# sort out wetting and drying nodes if requested
if wetting_and_drying:
if variable_at_cells:
self.ds.load_data(['wet_cells'])
self.wet_points_data = np.asarray(self.ds.data.wet_cells[:,self.sel_points], dtype=bool)
else:
self.ds.load_data(['wet_nodes'])
self.wet_points_data = np.asarray(self.ds.data.wet_nodes[:,self.sel_points], dtype=bool)
else:
self.ds.load_data(['wet_nodes'])
self.wet_points_data = np.asarray(self.ds.data.wet_nodes[:,self.sel_points], dtype=bool)
self.wet_points_data = np.asarray(np.ones((self.ds.dims.time, len(self.sel_points))), dtype=bool)
self.ylim_vals = [np.floor(np.nanmin(self.cross_plot_y_pcolor)), np.ceil(np.nanmax(self.cross_plot_y_pcolor)) + 1]
self.xlim_vals = [np.nanmin(self.cross_plot_x_pcolor), np.nanmax(self.cross_plot_x_pcolor)]
......
......@@ -1996,6 +1996,17 @@ class RegularReader(FileReader):
""" Compatibility function. """
return self.closest_node(*args, **kwargs)
def closest_node(self, where, cartesian=False, threshold=np.inf, vincenty=False, haversine=False):
if cartesian:
raise ValueError('No cartesian coordinates defined')
else:
lat_rav, lon_rav = np.meshgrid(self.grid.lat, self.grid.lon)
x, y = lon_rav.ravel(), lat_rav.ravel()
index = self._closest_point(x, y, x, y, where, threshold=threshold, vincenty=vincenty, haversine=haversine)
if len(index) == 1:
index = index[0]
return np.unravel_index(index, (len(self.grid.lon), len(self.grid.lat)))
class HYCOMReader(RegularReader):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment