def test_ver_sec_subsamp(od_in, subsampMethod): cutout_kwargs = {'timeRange': [od_in.dataset['time'][0].values, od_in.dataset['time'][-1].values]} plt.close() fig, ax = plt.subplots(1, 1) if subsampMethod in ['error', None]: with pytest.raises(ValueError): vertical_section(od_in, varName='Temp', meanAxes=True, cutout_kwargs=cutout_kwargs, subsampMethod=subsampMethod) else: if subsampMethod == 'mooring_array': Xmoor = [od_in.dataset['XC'].min().values, od_in.dataset['XC'].max().values] Ymoor = [od_in.dataset['YC'].min().values, od_in.dataset['YC'].max().values] subsamp_kwargs = {'Xmoor': Xmoor, 'Ymoor': Ymoor} use_dist = False else: Xsurv = [od_in.dataset['XC'].min().values, od_in.dataset['XC'].mean().values, od_in.dataset['XC'].max().values] Ysurv = [od_in.dataset['YC'].min().values, od_in.dataset['YC'].mean().values, od_in.dataset['YC'].max().values] subsamp_kwargs = {'Xsurv': Xsurv, 'Ysurv': Ysurv} use_dist = True ax = vertical_section(od_in, varName='Temp', ax=ax, meanAxes=True, cutout_kwargs=cutout_kwargs, subsampMethod=subsampMethod, subsamp_kwargs=subsamp_kwargs, use_dist=use_dist) assert isinstance(ax, plt.Axes)
def test_ver_facet(od_in, contourName): od_in = od_in.compute.weighted_mean(varNameList="Temp", axesList="time") plt.close() if contourName == "Depth": with pytest.raises(ValueError): ax = vertical_section(od_in, varName="Temp", contourName=contourName) else: ax = vertical_section(od_in, varName="Temp", contourName=contourName) assert isinstance(ax, xr.plot.FacetGrid)
def test_ver_sec_subsamp(od_in, subsampMethod): cutout_kwargs = { "timeRange": [od_in.dataset["time"][0].values, od_in.dataset["time"][-1].values] } contour_kwargs = {"levels": 10, "cmap": "viridis"} plt.close() fig, ax = plt.subplots(1, 1) if subsampMethod in ["error", None]: with pytest.raises(ValueError): vertical_section( od_in, varName="Temp", meanAxes=True, cutout_kwargs=cutout_kwargs, subsampMethod=subsampMethod, ) else: if subsampMethod == "mooring_array": Xmoor = [ od_in.dataset["XC"].min().values, od_in.dataset["XC"].max().values ] Ymoor = [ od_in.dataset["YC"].min().values, od_in.dataset["YC"].max().values ] subsamp_kwargs = {"Xmoor": Xmoor, "Ymoor": Ymoor} use_dist = False else: Xsurv = [ od_in.dataset["XC"].min().values, od_in.dataset["XC"].mean().values, od_in.dataset["XC"].max().values, ] Ysurv = [ od_in.dataset["YC"].min().values, od_in.dataset["YC"].mean().values, od_in.dataset["YC"].max().values, ] subsamp_kwargs = {"Xsurv": Xsurv, "Ysurv": Ysurv} use_dist = True ax = vertical_section( od_in, varName="Temp", ax=ax, meanAxes=True, cutout_kwargs=cutout_kwargs, subsampMethod=subsampMethod, subsamp_kwargs=subsamp_kwargs, use_dist=use_dist, contour_kwargs=contour_kwargs, ) assert isinstance(ax, plt.Axes)
def test_ver_sec(od_in, varName, contourName): plt.close() if "mooring_dist" in od_in.dataset.variables: ds = od_in.dataset.drop_vars("mooring_dist") od_in = OceanDataset(ds) contour_kwargs = {"levels": 10} clabel_kwargs = {"fontsize": 10} meanAxes = True intAxes = False else: contour_kwargs = None clabel_kwargs = None meanAxes = False intAxes = True ax = vertical_section( od_in, varName=varName, contourName=contourName, meanAxes=meanAxes, intAxes=intAxes, contour_kwargs=contour_kwargs, clabel_kwargs=clabel_kwargs, ) assert isinstance(ax, plt.Axes)
def test_ver_sec_error(od_in): od_in = od_in.compute.weighted_mean(varNameList="Temp") with pytest.raises(ValueError): vertical_section(od_in, varName="Temp", contourName="w_mean_Temp")