def plot(self, field="field", fig=None, ax=None): # pragma: no cover """ Plot the spatial random field. Parameters ---------- field : :class:`str`, optional Field that should be plotted. Can be: "field", "raw_field", "krige_field", "err_field" or "krige_var". Default: "field" fig : :class:`Figure` or :any:`None` Figure to plot the axes on. If `None`, a new one will be created. Default: `None` ax : :class:`Axes` or :any:`None` Axes to plot on. If `None`, a new one will be added to the figure. Default: `None` """ # just import if needed; matplotlib is not required by setup from gstools.field.plot import plot_field, plot_vec_field # check if we have a vector field, this check should be sufficient # for all but very edgy edge cases, which ate not going to be plotted # anyway if self.field.shape[0] == self.model.dim: if self.model.dim == 2: r = plot_vec_field(self, field, fig, ax) else: raise RuntimeError( "Streamflow plotting only supported for 2d case." ) else: r = plot_field(self, field, fig, ax) return r
def plot( self, field="field", fig=None, ax=None, **kwargs ): # pragma: no cover """ Plot the spatial random field. Parameters ---------- field : :class:`str`, optional Field that should be plotted. Default: "field" fig : :class:`Figure` or :any:`None` Figure to plot the axes on. If `None`, a new one will be created. Default: `None` ax : :class:`Axes` or :any:`None` Axes to plot on. If `None`, a new one will be added to the figure. Default: `None` **kwargs Forwarded to the plotting routine. """ # just import if needed; matplotlib is not required by setup from gstools.field.plot import plot_field, plot_vec_field if self.value_type is None: raise ValueError( "Field value type not set! " "Specify 'scalar' or 'vector' before plotting." ) if self.value_type == "scalar": r = plot_field(self, field, fig, ax, **kwargs) elif self.value_type == "vector": if self.dim == 2: r = plot_vec_field(self, field, fig, ax, **kwargs) else: raise NotImplementedError( "Streamflow plotting only supported for 2d case." ) else: raise ValueError(f"Unknown field value type: {self.value_type}") return r