From a9c74c72b1efef087432612990babdce847517d0 Mon Sep 17 00:00:00 2001 From: Sean Freeman Date: Thu, 18 Jul 2024 12:40:47 -0500 Subject: [PATCH] black format all notebooks --- ..._statistics_during_feature_detection.ipynb | 81 +++++----- ...mpute_statistics_during_segmentation.ipynb | 101 +++++++------ ...te_statistics_postprocessing_example.ipynb | 109 ++++++++------ .../feature_detection_filtering.ipynb | 82 ++++++---- .../multiple_thresholds_example.ipynb | 112 +++++++++++--- .../position_threshold_example.ipynb | 142 +++++++++++++----- 6 files changed, 406 insertions(+), 221 deletions(-) diff --git a/doc/bulk_statistics/notebooks/compute_statistics_during_feature_detection.ipynb b/doc/bulk_statistics/notebooks/compute_statistics_during_feature_detection.ipynb index cb55918f..e9eb2a73 100644 --- a/doc/bulk_statistics/notebooks/compute_statistics_during_feature_detection.ipynb +++ b/doc/bulk_statistics/notebooks/compute_statistics_during_feature_detection.ipynb @@ -34,6 +34,7 @@ "import shutil\n", "from six.moves import urllib\n", "from pathlib import Path\n", + "\n", "%matplotlib inline" ] }, @@ -60,7 +61,8 @@ "source": [ "# Import tobac itself\n", "import tobac\n", - "print('using tobac version', str(tobac.__version__))" + "\n", + "print(\"using tobac version\", str(tobac.__version__))" ] }, { @@ -78,10 +80,11 @@ "source": [ "# Disable a few warnings:\n", "import warnings\n", - "warnings.filterwarnings('ignore', category=UserWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=FutureWarning, append=True)\n", - "warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)" + "\n", + "warnings.filterwarnings(\"ignore\", category=UserWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=RuntimeWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=FutureWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=pd.io.pytables.PerformanceWarning)" ] }, { @@ -106,7 +109,7 @@ }, "outputs": [], "source": [ - "data_out=Path('../')" + "data_out = Path(\"../\")" ] }, { @@ -123,18 +126,18 @@ "outputs": [], "source": [ "# Download the data: This only has to be done once for all tobac examples and can take a while\n", - "data_file = list(data_out.rglob('data/Example_input_Precip.nc'))\n", + "data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))\n", "if len(data_file) == 0:\n", - " file_path='https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n", - " #file_path='http://zenodo..'\n", - " tempfile=Path('temp.zip')\n", - " print('start downloading data')\n", - " request=urllib.request.urlretrieve(file_path, tempfile)\n", - " print('start extracting data')\n", + " file_path = \"https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip\"\n", + " # file_path='http://zenodo..'\n", + " tempfile = Path(\"temp.zip\")\n", + " print(\"start downloading data\")\n", + " request = urllib.request.urlretrieve(file_path, tempfile)\n", + " print(\"start extracting data\")\n", " shutil.unpack_archive(tempfile, data_out)\n", " tempfile.unlink()\n", - " print('data extracted')\n", - " data_file = list(data_out.rglob('data/Example_input_Precip.nc'))" + " print(\"data extracted\")\n", + " data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))" ] }, { @@ -157,7 +160,7 @@ }, "outputs": [], "source": [ - "Precip=iris.load_cube(str(data_file[0]),'surface_precipitation_average')" + "Precip = iris.load_cube(str(data_file[0]), \"surface_precipitation_average\")" ] }, { @@ -324,7 +327,7 @@ } ], "source": [ - "#display information about the iris cube containing the surface precipitation data:\n", + "# display information about the iris cube containing the surface precipitation data:\n", "display(Precip)" ] }, @@ -341,11 +344,11 @@ }, "outputs": [], "source": [ - "#Set up directory to save output:\n", - "savedir=Path(\"Save\")\n", + "# Set up directory to save output:\n", + "savedir = Path(\"Save\")\n", "if not savedir.is_dir():\n", " savedir.mkdir()\n", - "plot_dir=Path(\"Plot\")\n", + "plot_dir = Path(\"Plot\")\n", "if not plot_dir.is_dir():\n", " plot_dir.mkdir()" ] @@ -380,17 +383,17 @@ }, "outputs": [], "source": [ - "parameters_features={}\n", - "parameters_features['position_threshold']='weighted_diff'\n", - "parameters_features['sigma_threshold']=0.5\n", - "parameters_features['min_distance']=0\n", - "parameters_features['sigma_threshold']=1\n", - "parameters_features['threshold']=[1,2,3,4,5,10,15] #mm/h\n", - "parameters_features['n_erosion_threshold']=0\n", - "parameters_features['n_min_threshold']=3\n", + "parameters_features = {}\n", + "parameters_features[\"position_threshold\"] = \"weighted_diff\"\n", + "parameters_features[\"sigma_threshold\"] = 0.5\n", + "parameters_features[\"min_distance\"] = 0\n", + "parameters_features[\"sigma_threshold\"] = 1\n", + "parameters_features[\"threshold\"] = [1, 2, 3, 4, 5, 10, 15] # mm/h\n", + "parameters_features[\"n_erosion_threshold\"] = 0\n", + "parameters_features[\"n_min_threshold\"] = 3\n", "\n", "# get temporal and spation resolution of the data\n", - "dxy,dt=tobac.get_spacings(Precip)" + "dxy, dt = tobac.get_spacings(Precip)" ] }, { @@ -421,9 +424,9 @@ "outputs": [], "source": [ "statistics = {}\n", - "statistics['mean_precip'] = np.mean\n", - "statistics['total_precip'] = np.sum\n", - "statistics['max_precip'] = np.max" + "statistics[\"mean_precip\"] = np.mean\n", + "statistics[\"total_precip\"] = np.sum\n", + "statistics[\"max_precip\"] = np.max" ] }, { @@ -446,7 +449,7 @@ }, "outputs": [], "source": [ - "statistics['percentiles'] = (np.percentile, {'q': [95,99]})" + "statistics[\"percentiles\"] = (np.percentile, {\"q\": [95, 99]})" ] }, { @@ -485,11 +488,13 @@ ], "source": [ "# Feature detection based on based on surface precipitation field and a range of thresholds\n", - "print('starting feature detection based on multiple thresholds')\n", - "Features= tobac.feature_detection_multithreshold(Precip,dxy,**parameters_features, statistic=statistics) \n", - "print('feature detection done')\n", - "Features.to_hdf(savedir / 'Features.h5','table')\n", - "print('features saved')" + "print(\"starting feature detection based on multiple thresholds\")\n", + "Features = tobac.feature_detection_multithreshold(\n", + " Precip, dxy, **parameters_features, statistic=statistics\n", + ")\n", + "print(\"feature detection done\")\n", + "Features.to_hdf(savedir / \"Features.h5\", \"table\")\n", + "print(\"features saved\")" ] }, { diff --git a/doc/bulk_statistics/notebooks/compute_statistics_during_segmentation.ipynb b/doc/bulk_statistics/notebooks/compute_statistics_during_segmentation.ipynb index 21f51511..0ee1b71a 100644 --- a/doc/bulk_statistics/notebooks/compute_statistics_during_segmentation.ipynb +++ b/doc/bulk_statistics/notebooks/compute_statistics_during_segmentation.ipynb @@ -32,6 +32,7 @@ "import shutil\n", "from six.moves import urllib\n", "from pathlib import Path\n", + "\n", "%matplotlib inline" ] }, @@ -50,10 +51,11 @@ "source": [ "# Disable a few warnings:\n", "import warnings\n", - "warnings.filterwarnings('ignore', category=UserWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=FutureWarning, append=True)\n", - "warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)" + "\n", + "warnings.filterwarnings(\"ignore\", category=UserWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=RuntimeWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=FutureWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=pd.io.pytables.PerformanceWarning)" ] }, { @@ -79,7 +81,8 @@ "source": [ "# Import tobac itself\n", "import tobac\n", - "print('using tobac version', str(tobac.__version__))" + "\n", + "print(\"using tobac version\", str(tobac.__version__))" ] }, { @@ -95,20 +98,20 @@ }, "outputs": [], "source": [ - "data_out=Path('../')\n", + "data_out = Path(\"../\")\n", "# Download the data: This only has to be done once for all tobac examples and can take a while\n", - "data_file = list(data_out.rglob('data/Example_input_Precip.nc'))\n", + "data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))\n", "if len(data_file) == 0:\n", - " file_path='https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n", - " #file_path='http://zenodo..'\n", - " tempfile=Path('temp.zip')\n", - " print('start downloading data')\n", - " request=urllib.request.urlretrieve(file_path, tempfile)\n", - " print('start extracting data')\n", + " file_path = \"https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip\"\n", + " # file_path='http://zenodo..'\n", + " tempfile = Path(\"temp.zip\")\n", + " print(\"start downloading data\")\n", + " request = urllib.request.urlretrieve(file_path, tempfile)\n", + " print(\"start extracting data\")\n", " shutil.unpack_archive(tempfile, data_out)\n", " tempfile.unlink()\n", - " print('data extracted')\n", - " data_file = list(data_out.rglob('data/Example_input_Precip.nc'))" + " print(\"data extracted\")\n", + " data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))" ] }, { @@ -124,11 +127,11 @@ }, "outputs": [], "source": [ - "#Set up directory to save output:\n", - "savedir=Path(\"Save\")\n", + "# Set up directory to save output:\n", + "savedir = Path(\"Save\")\n", "if not savedir.is_dir():\n", " savedir.mkdir()\n", - "plot_dir=Path(\"Plot\")\n", + "plot_dir = Path(\"Plot\")\n", "if not plot_dir.is_dir():\n", " plot_dir.mkdir()" ] @@ -146,7 +149,7 @@ }, "outputs": [], "source": [ - "Precip=iris.load_cube(str(data_file[0]),'surface_precipitation_average')" + "Precip = iris.load_cube(str(data_file[0]), \"surface_precipitation_average\")" ] }, { @@ -169,17 +172,17 @@ }, "outputs": [], "source": [ - "parameters_features={}\n", - "parameters_features['position_threshold']='weighted_diff'\n", - "parameters_features['sigma_threshold']=0.5\n", - "parameters_features['min_distance']=0\n", - "parameters_features['sigma_threshold']=1\n", - "parameters_features['threshold']=[1,2,3,4,5,10,15] #mm/h\n", - "parameters_features['n_erosion_threshold']=0\n", - "parameters_features['n_min_threshold']=3\n", + "parameters_features = {}\n", + "parameters_features[\"position_threshold\"] = \"weighted_diff\"\n", + "parameters_features[\"sigma_threshold\"] = 0.5\n", + "parameters_features[\"min_distance\"] = 0\n", + "parameters_features[\"sigma_threshold\"] = 1\n", + "parameters_features[\"threshold\"] = [1, 2, 3, 4, 5, 10, 15] # mm/h\n", + "parameters_features[\"n_erosion_threshold\"] = 0\n", + "parameters_features[\"n_min_threshold\"] = 3\n", "\n", "# get temporal and spation resolution of the data\n", - "dxy,dt=tobac.get_spacings(Precip)" + "dxy, dt = tobac.get_spacings(Precip)" ] }, { @@ -218,11 +221,11 @@ ], "source": [ "# Feature detection based on based on surface precipitation field and a range of thresholds\n", - "print('starting feature detection based on multiple thresholds')\n", - "Features= tobac.feature_detection_multithreshold(Precip,dxy,**parameters_features) \n", - "print('feature detection done')\n", - "Features.to_hdf(savedir / 'Features.h5','table')\n", - "print('features saved')" + "print(\"starting feature detection based on multiple thresholds\")\n", + "Features = tobac.feature_detection_multithreshold(Precip, dxy, **parameters_features)\n", + "print(\"feature detection done\")\n", + "Features.to_hdf(savedir / \"Features.h5\", \"table\")\n", + "print(\"features saved\")" ] }, { @@ -255,12 +258,12 @@ "outputs": [], "source": [ "# Dictionary containing keyword arguments for segmentation step:\n", - "parameters_segmentation={}\n", - "parameters_segmentation['method']='watershed'\n", - "parameters_segmentation['threshold']=1 # mm/h mixing ratio\n", + "parameters_segmentation = {}\n", + "parameters_segmentation[\"method\"] = \"watershed\"\n", + "parameters_segmentation[\"threshold\"] = 1 # mm/h mixing ratio\n", "\n", "# get temporal and spation resolution of the data\n", - "dxy,dt=tobac.get_spacings(Precip)" + "dxy, dt = tobac.get_spacings(Precip)" ] }, { @@ -291,9 +294,9 @@ "outputs": [], "source": [ "statistics = {}\n", - "statistics['mean_precip'] = np.mean\n", - "statistics['total_precip'] = np.sum\n", - "statistics['max_precip'] = np.max" + "statistics[\"mean_precip\"] = np.mean\n", + "statistics[\"total_precip\"] = np.sum\n", + "statistics[\"max_precip\"] = np.max" ] }, { @@ -316,7 +319,7 @@ }, "outputs": [], "source": [ - "statistics['percentiles'] = (np.percentile, {'q': [95,99]})" + "statistics[\"percentiles\"] = (np.percentile, {\"q\": [95, 99]})" ] }, { @@ -355,12 +358,16 @@ ], "source": [ "# Perform Segmentation and save resulting mask to NetCDF file:\n", - "print('Starting segmentation based on surface precipitation')\n", - "Mask,Features_Precip=tobac.segmentation_2D(Features,Precip,dxy,**parameters_segmentation, statistic=statistics)\n", - "print('segmentation based on surface precipitation performed, start saving results to files')\n", - "iris.save([Mask], savedir / 'Mask_Segmentation_precip.nc', zlib=True, complevel=4) \n", - "Features_Precip.to_hdf(savedir / 'Features_Precip.h5', 'table')\n", - "print('segmentation surface precipitation performed and saved')" + "print(\"Starting segmentation based on surface precipitation\")\n", + "Mask, Features_Precip = tobac.segmentation_2D(\n", + " Features, Precip, dxy, **parameters_segmentation, statistic=statistics\n", + ")\n", + "print(\n", + " \"segmentation based on surface precipitation performed, start saving results to files\"\n", + ")\n", + "iris.save([Mask], savedir / \"Mask_Segmentation_precip.nc\", zlib=True, complevel=4)\n", + "Features_Precip.to_hdf(savedir / \"Features_Precip.h5\", \"table\")\n", + "print(\"segmentation surface precipitation performed and saved\")" ] }, { diff --git a/doc/bulk_statistics/notebooks/compute_statistics_postprocessing_example.ipynb b/doc/bulk_statistics/notebooks/compute_statistics_postprocessing_example.ipynb index 112f07f2..3ed2bb69 100644 --- a/doc/bulk_statistics/notebooks/compute_statistics_postprocessing_example.ipynb +++ b/doc/bulk_statistics/notebooks/compute_statistics_postprocessing_example.ipynb @@ -29,12 +29,13 @@ "import iris\n", "import numpy as np\n", "import pandas as pd\n", - "import xarray as xr \n", + "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import datetime\n", "import shutil\n", "from six.moves import urllib\n", "from pathlib import Path\n", + "\n", "%matplotlib inline" ] }, @@ -61,7 +62,8 @@ "source": [ "# Import tobac itself\n", "import tobac\n", - "print('using tobac version', str(tobac.__version__))" + "\n", + "print(\"using tobac version\", str(tobac.__version__))" ] }, { @@ -79,10 +81,11 @@ "source": [ "# Disable a few warnings:\n", "import warnings\n", - "warnings.filterwarnings('ignore', category=UserWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)\n", - "warnings.filterwarnings('ignore', category=FutureWarning, append=True)\n", - "warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)" + "\n", + "warnings.filterwarnings(\"ignore\", category=UserWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=RuntimeWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=FutureWarning, append=True)\n", + "warnings.filterwarnings(\"ignore\", category=pd.io.pytables.PerformanceWarning)" ] }, { @@ -105,11 +108,11 @@ }, "outputs": [], "source": [ - "#Set up directory to save output:\n", - "savedir=Path(\"Save\")\n", + "# Set up directory to save output:\n", + "savedir = Path(\"Save\")\n", "if not savedir.is_dir():\n", " savedir.mkdir()\n", - "plot_dir=Path(\"Plot\")\n", + "plot_dir = Path(\"Plot\")\n", "if not plot_dir.is_dir():\n", " plot_dir.mkdir()" ] @@ -127,20 +130,20 @@ }, "outputs": [], "source": [ - "data_out=Path('../')\n", + "data_out = Path(\"../\")\n", "# Download the data: This only has to be done once for all tobac examples and can take a while\n", - "data_file = list(data_out.rglob('data/Example_input_Precip.nc'))\n", + "data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))\n", "if len(data_file) == 0:\n", - " file_path='https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n", - " #file_path='http://zenodo..'\n", - " tempfile=Path('temp.zip')\n", - " print('start downloading data')\n", - " request=urllib.request.urlretrieve(file_path, tempfile)\n", - " print('start extracting data')\n", + " file_path = \"https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip\"\n", + " # file_path='http://zenodo..'\n", + " tempfile = Path(\"temp.zip\")\n", + " print(\"start downloading data\")\n", + " request = urllib.request.urlretrieve(file_path, tempfile)\n", + " print(\"start extracting data\")\n", " shutil.unpack_archive(tempfile, data_out)\n", " tempfile.unlink()\n", - " print('data extracted')\n", - " data_file = list(data_out.rglob('data/Example_input_Precip.nc'))" + " print(\"data extracted\")\n", + " data_file = list(data_out.rglob(\"data/Example_input_Precip.nc\"))" ] }, { @@ -156,7 +159,7 @@ }, "outputs": [], "source": [ - "Precip=iris.load_cube(str(data_file[0]),'surface_precipitation_average')" + "Precip = iris.load_cube(str(data_file[0]), \"surface_precipitation_average\")" ] }, { @@ -172,17 +175,17 @@ }, "outputs": [], "source": [ - "parameters_features={}\n", - "parameters_features['position_threshold']='weighted_diff'\n", - "parameters_features['sigma_threshold']=0.5\n", - "parameters_features['min_distance']=0\n", - "parameters_features['sigma_threshold']=1\n", - "parameters_features['threshold']=[1,2,3,4,5,10,15] #mm/h\n", - "parameters_features['n_erosion_threshold']=0\n", - "parameters_features['n_min_threshold']=3\n", + "parameters_features = {}\n", + "parameters_features[\"position_threshold\"] = \"weighted_diff\"\n", + "parameters_features[\"sigma_threshold\"] = 0.5\n", + "parameters_features[\"min_distance\"] = 0\n", + "parameters_features[\"sigma_threshold\"] = 1\n", + "parameters_features[\"threshold\"] = [1, 2, 3, 4, 5, 10, 15] # mm/h\n", + "parameters_features[\"n_erosion_threshold\"] = 0\n", + "parameters_features[\"n_min_threshold\"] = 3\n", "\n", "# get temporal and spation resolution of the data\n", - "dxy,dt=tobac.get_spacings(Precip)" + "dxy, dt = tobac.get_spacings(Precip)" ] }, { @@ -221,11 +224,11 @@ ], "source": [ "# Feature detection based on based on surface precipitation field and a range of thresholds\n", - "print('starting feature detection based on multiple thresholds')\n", - "Features= tobac.feature_detection_multithreshold(Precip,dxy,**parameters_features) \n", - "print('feature detection done')\n", - "Features.to_hdf(savedir / 'Features.h5','table')\n", - "print('features saved')" + "print(\"starting feature detection based on multiple thresholds\")\n", + "Features = tobac.feature_detection_multithreshold(Precip, dxy, **parameters_features)\n", + "print(\"feature detection done\")\n", + "Features.to_hdf(savedir / \"Features.h5\", \"table\")\n", + "print(\"features saved\")" ] }, { @@ -249,12 +252,12 @@ "outputs": [], "source": [ "# Dictionary containing keyword arguments for segmentation step:\n", - "parameters_segmentation={}\n", - "parameters_segmentation['method']='watershed'\n", - "parameters_segmentation['threshold']=1 # mm/h mixing ratio\n", + "parameters_segmentation = {}\n", + "parameters_segmentation[\"method\"] = \"watershed\"\n", + "parameters_segmentation[\"threshold\"] = 1 # mm/h mixing ratio\n", "\n", "# get temporal and spation resolution of the data\n", - "dxy,dt=tobac.get_spacings(Precip)" + "dxy, dt = tobac.get_spacings(Precip)" ] }, { @@ -293,12 +296,18 @@ ], "source": [ "# Perform Segmentation and save resulting mask to NetCDF file:\n", - "print('Starting segmentation based on surface precipitation')\n", - "Mask_Precip,Features_Precip=tobac.segmentation_2D(Features,Precip,dxy,**parameters_segmentation)\n", - "print('segmentation based on surface precipitation performed, start saving results to files')\n", - "iris.save([Mask_Precip], savedir / 'Mask_segmentation_precip.nc', zlib=True, complevel=4) \n", - "Features_Precip.to_hdf(savedir / 'Features_Precip.h5', 'table')\n", - "print('segmentation surface precipitation performed and saved')" + "print(\"Starting segmentation based on surface precipitation\")\n", + "Mask_Precip, Features_Precip = tobac.segmentation_2D(\n", + " Features, Precip, dxy, **parameters_segmentation\n", + ")\n", + "print(\n", + " \"segmentation based on surface precipitation performed, start saving results to files\"\n", + ")\n", + "iris.save(\n", + " [Mask_Precip], savedir / \"Mask_segmentation_precip.nc\", zlib=True, complevel=4\n", + ")\n", + "Features_Precip.to_hdf(savedir / \"Features_Precip.h5\", \"table\")\n", + "print(\"segmentation surface precipitation performed and saved\")" ] }, { @@ -354,9 +363,9 @@ "outputs": [], "source": [ "statistics = {}\n", - "statistics['mean_precip'] = np.mean\n", - "statistics['total_precip'] = np.sum\n", - "statistics['max_precip'] = np.max" + "statistics[\"mean_precip\"] = np.mean\n", + "statistics[\"total_precip\"] = np.sum\n", + "statistics[\"max_precip\"] = np.max" ] }, { @@ -379,7 +388,7 @@ }, "outputs": [], "source": [ - "statistics['percentiles'] = (np.percentile, {'q': [95,99]})" + "statistics[\"percentiles\"] = (np.percentile, {\"q\": [95, 99]})" ] }, { @@ -395,7 +404,9 @@ }, "outputs": [], "source": [ - "features_with_stats = get_statistics_from_mask(Features_Precip, Mask_Precip, Precip, statistic=statistics)" + "features_with_stats = get_statistics_from_mask(\n", + " Features_Precip, Mask_Precip, Precip, statistic=statistics\n", + ")" ] }, { diff --git a/doc/feature_detection/notebooks/feature_detection_filtering.ipynb b/doc/feature_detection/notebooks/feature_detection_filtering.ipynb index 1dcc998d..44c3d3d4 100644 --- a/doc/feature_detection/notebooks/feature_detection_filtering.ipynb +++ b/doc/feature_detection/notebooks/feature_detection_filtering.ipynb @@ -82,13 +82,13 @@ ], "source": [ "# Dimensions here are time, y, x.\n", - "input_field_arr = np.zeros((1,100,200))\n", - "input_field_arr[0, 15:85, 10:185]=50\n", - "input_field_arr[0, 20:80, 20:80]=100\n", + "input_field_arr = np.zeros((1, 100, 200))\n", + "input_field_arr[0, 15:85, 10:185] = 50\n", + "input_field_arr[0, 20:80, 20:80] = 100\n", "input_field_arr[0, 40:60, 125:170] = 100\n", - "input_field_arr[0, 30:40, 30:40]=200\n", - "input_field_arr[0, 50:75, 50:75]=200\n", - "input_field_arr[0, 55:70, 55:70]=300\n", + "input_field_arr[0, 30:40, 30:40] = 200\n", + "input_field_arr[0, 50:75, 50:75] = 200\n", + "input_field_arr[0, 55:70, 55:70] = 300\n", "\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", @@ -118,10 +118,14 @@ } ], "source": [ - "# We now need to generate an Iris DataCube out of this dataset to run tobac feature detection. \n", - "# One can use xarray to generate a DataArray and then convert it to Iris, as done here. \n", - "input_field_iris = xr.DataArray(input_field_arr, dims=['time', 'Y', 'X'], coords={'time': [np.datetime64('2019-01-01T00:00:00')]}).to_iris()\n", - "# Version 2.0 of tobac (currently in development) will allow the use of xarray directly with tobac. " + "# We now need to generate an Iris DataCube out of this dataset to run tobac feature detection.\n", + "# One can use xarray to generate a DataArray and then convert it to Iris, as done here.\n", + "input_field_iris = xr.DataArray(\n", + " input_field_arr,\n", + " dims=[\"time\", \"Y\", \"X\"],\n", + " coords={\"time\": [np.datetime64(\"2019-01-01T00:00:00\")]},\n", + ").to_iris()\n", + "# Version 2.0 of tobac (currently in development) will allow the use of xarray directly with tobac." ] }, { @@ -164,23 +168,36 @@ ], "source": [ "thresholds = [50, 100, 150, 200]\n", - "fig, axarr = plt.subplots(2,2, figsize=(10,6))\n", + "fig, axarr = plt.subplots(2, 2, figsize=(10, 6))\n", "sigma_values = [0, 1, 2, 5]\n", "for sigma_value, ax in zip(sigma_values, axarr.flatten()):\n", - " single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', sigma_threshold=sigma_value)\n", - " \n", + " single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " sigma_threshold=sigma_value,\n", + " )\n", + "\n", " # This is what tobac sees\n", - " filtered_field = scipy.ndimage.gaussian_filter(input_field_arr[0], sigma=sigma_value)\n", + " filtered_field = scipy.ndimage.gaussian_filter(\n", + " input_field_arr[0], sigma=sigma_value\n", + " )\n", " color_mesh = ax.pcolormesh(filtered_field)\n", " plt.colorbar(color_mesh, ax=ax)\n", " # Plot all features detected\n", - " ax.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + " ax.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + " )\n", " ax.legend()\n", " if sigma_value == 0:\n", " sigma_val_str = \"0 (off)\"\n", " else:\n", " sigma_val_str = \"{0}\".format(sigma_value)\n", - " ax.set_title(\"sigma_threshold= \"+ sigma_val_str)\n", + " ax.set_title(\"sigma_threshold= \" + sigma_val_str)\n", "plt.tight_layout()\n", "plt.show()" ] @@ -225,31 +242,44 @@ ], "source": [ "thresholds = [100]\n", - "fig, axarr = plt.subplots(2,2, figsize=(10,6))\n", + "fig, axarr = plt.subplots(2, 2, figsize=(10, 6))\n", "erosion_values = [0, 5, 10, 15]\n", "for erosion, ax in zip(erosion_values, axarr.flatten()):\n", - " single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', n_erosion_threshold=erosion)\n", - " \n", + " single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " n_erosion_threshold=erosion,\n", + " )\n", + "\n", " # Create our mask- this is what tobac does internally for each threshold.\n", - " tobac_mask = 1*(input_field_arr[0] >= thresholds[0])\n", - " \n", + " tobac_mask = 1 * (input_field_arr[0] >= thresholds[0])\n", + "\n", " if erosion > 0:\n", - " # This is the parameter for erosion that gets passed to the scikit-image library. \n", + " # This is the parameter for erosion that gets passed to the scikit-image library.\n", " footprint = np.ones((erosion, erosion))\n", - " # This is what tobac sees after erosion. \n", - " filtered_mask = skimage.morphology.binary_erosion(tobac_mask, footprint).astype(np.int64)\n", + " # This is what tobac sees after erosion.\n", + " filtered_mask = skimage.morphology.binary_erosion(tobac_mask, footprint).astype(\n", + " np.int64\n", + " )\n", " else:\n", " filtered_mask = tobac_mask\n", "\n", " color_mesh = ax.pcolormesh(filtered_mask)\n", " # Plot all features detected\n", - " ax.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + " ax.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + " )\n", " ax.legend()\n", " if erosion == 0:\n", " sigma_val_str = \"0 (off)\"\n", " else:\n", " sigma_val_str = \"{0}\".format(erosion)\n", - " ax.set_title(\"n_erosion_threshold= \"+ sigma_val_str)\n", + " ax.set_title(\"n_erosion_threshold= \" + sigma_val_str)\n", "plt.tight_layout()\n", "plt.show()" ] diff --git a/doc/feature_detection/notebooks/multiple_thresholds_example.ipynb b/doc/feature_detection/notebooks/multiple_thresholds_example.ipynb index 64f427a6..39bd33ed 100644 --- a/doc/feature_detection/notebooks/multiple_thresholds_example.ipynb +++ b/doc/feature_detection/notebooks/multiple_thresholds_example.ipynb @@ -73,13 +73,13 @@ ], "source": [ "# Dimensions here are time, y, x.\n", - "input_field_arr = np.zeros((1,100,200))\n", - "input_field_arr[0, 15:85, 10:185]=50\n", - "input_field_arr[0, 20:80, 20:80]=100\n", + "input_field_arr = np.zeros((1, 100, 200))\n", + "input_field_arr[0, 15:85, 10:185] = 50\n", + "input_field_arr[0, 20:80, 20:80] = 100\n", "input_field_arr[0, 40:60, 125:170] = 100\n", - "input_field_arr[0, 30:40, 30:40]=200\n", - "input_field_arr[0, 50:75, 50:75]=200\n", - "input_field_arr[0, 55:70, 55:70]=300\n", + "input_field_arr[0, 30:40, 30:40] = 200\n", + "input_field_arr[0, 50:75, 50:75] = 200\n", + "input_field_arr[0, 55:70, 55:70] = 300\n", "\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", @@ -118,7 +118,11 @@ } ], "source": [ - "input_field_iris = xr.DataArray(input_field_arr, dims=['time', 'Y', 'X'], coords={'time': [np.datetime64('2019-01-01T00:00:00')]}).to_iris()" + "input_field_iris = xr.DataArray(\n", + " input_field_arr,\n", + " dims=[\"time\", \"Y\", \"X\"],\n", + " coords={\"time\": [np.datetime64(\"2019-01-01T00:00:00\")]},\n", + ").to_iris()" ] }, { @@ -160,13 +164,26 @@ } ], "source": [ - "thresholds = [50,]\n", + "thresholds = [\n", + " 50,\n", + "]\n", "# Using 'center' here outputs the feature location as the arithmetic center of the detected feature\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold='center')\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=\"center\",\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", "plt.title(\"Single Threshold of 50\")\n", "plt.show()" @@ -203,13 +220,26 @@ } ], "source": [ - "thresholds = [150,]\n", + "thresholds = [\n", + " 150,\n", + "]\n", "# Using 'center' here outputs the feature location as the arithmetic center of the detected feature\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold='center')\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=\"center\",\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", "plt.title(\"Single Threshold of 150\")\n", "plt.show()" @@ -261,14 +291,27 @@ } ], "source": [ - "thresholds = [100, ]\n", + "thresholds = [\n", + " 100,\n", + "]\n", "# Using 'center' here outputs the feature location as the arithmetic center of the detected feature\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold='center')\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=\"center\",\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", "plt.title(\"Single Threshold of 100\")\n", "plt.show()" @@ -307,12 +350,23 @@ "source": [ "thresholds = [50, 100, 150, 200]\n", "# Using 'center' here outputs the feature location as the arithmetic center of the detected feature\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold='center')\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=\"center\",\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", "plt.title(\"Thresholds: [50, 100, 150, 200]\")\n", "plt.show()" @@ -344,17 +398,27 @@ "source": [ "thresholds = [50, 100, 150, 200, 250]\n", "# Using 'center' here outputs the feature location as the arithmetic center of the detected feature\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold='center')\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=\"center\",\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "\n", "# Plot all features detected\n", "for i, threshold in enumerate(thresholds):\n", - " thresholded_points = single_threshold_features[single_threshold_features['threshold_value'] == threshold]\n", - " plt.scatter(x=thresholded_points['hdim_2'].values, \n", - " y=thresholded_points['hdim_1'].values, \n", - " color='C'+str(i),\n", - " label=\"Threshold: \"+str(threshold))\n", + " thresholded_points = single_threshold_features[\n", + " single_threshold_features[\"threshold_value\"] == threshold\n", + " ]\n", + " plt.scatter(\n", + " x=thresholded_points[\"hdim_2\"].values,\n", + " y=thresholded_points[\"hdim_1\"].values,\n", + " color=\"C\" + str(i),\n", + " label=\"Threshold: \" + str(threshold),\n", + " )\n", "plt.legend()\n", "plt.title(\"Thresholds: [50, 100, 150, 200]\")\n", "plt.show()" diff --git a/doc/feature_detection/notebooks/position_threshold_example.ipynb b/doc/feature_detection/notebooks/position_threshold_example.ipynb index 37a1231b..016fb245 100644 --- a/doc/feature_detection/notebooks/position_threshold_example.ipynb +++ b/doc/feature_detection/notebooks/position_threshold_example.ipynb @@ -73,13 +73,13 @@ ], "source": [ "# Dimensions here are time, y, x.\n", - "input_field_arr = np.zeros((1,100,200))\n", - "input_field_arr[0, 15:85, 10:185]=50\n", - "input_field_arr[0, 20:80, 20:80]=100\n", + "input_field_arr = np.zeros((1, 100, 200))\n", + "input_field_arr[0, 15:85, 10:185] = 50\n", + "input_field_arr[0, 20:80, 20:80] = 100\n", "input_field_arr[0, 40:60, 125:170] = 100\n", - "input_field_arr[0, 30:40, 30:40]=200\n", - "input_field_arr[0, 50:75, 50:75]=200\n", - "input_field_arr[0, 55:70, 55:70]=300\n", + "input_field_arr[0, 30:40, 30:40] = 200\n", + "input_field_arr[0, 50:75, 50:75] = 200\n", + "input_field_arr[0, 55:70, 55:70] = 300\n", "\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", @@ -109,10 +109,14 @@ } ], "source": [ - "# We now need to generate an Iris DataCube out of this dataset to run tobac feature detection. \n", - "# One can use xarray to generate a DataArray and then convert it to Iris, as done here. \n", - "input_field_iris = xr.DataArray(input_field_arr, dims=['time', 'Y', 'X'], coords={'time': [np.datetime64('2019-01-01T00:00:00')]}).to_iris()\n", - "# Version 2.0 of tobac (currently in development) will allow the use of xarray directly with tobac. " + "# We now need to generate an Iris DataCube out of this dataset to run tobac feature detection.\n", + "# One can use xarray to generate a DataArray and then convert it to Iris, as done here.\n", + "input_field_iris = xr.DataArray(\n", + " input_field_arr,\n", + " dims=[\"time\", \"Y\", \"X\"],\n", + " coords={\"time\": [np.datetime64(\"2019-01-01T00:00:00\")]},\n", + ").to_iris()\n", + "# Version 2.0 of tobac (currently in development) will allow the use of xarray directly with tobac." ] }, { @@ -154,15 +158,28 @@ } ], "source": [ - "thresholds = [50,]\n", - "position_threshold = 'center'\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold=position_threshold)\n", + "thresholds = [\n", + " 50,\n", + "]\n", + "position_threshold = \"center\"\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=position_threshold,\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", - "plt.title(\"position_threshold \"+ position_threshold)\n", + "plt.title(\"position_threshold \" + position_threshold)\n", "plt.show()" ] }, @@ -205,15 +222,28 @@ } ], "source": [ - "thresholds = [50,]\n", - "position_threshold = 'extreme'\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold=position_threshold)\n", + "thresholds = [\n", + " 50,\n", + "]\n", + "position_threshold = \"extreme\"\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=position_threshold,\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", - "plt.title(\"position_threshold \"+ position_threshold)\n", + "plt.title(\"position_threshold \" + position_threshold)\n", "plt.show()" ] }, @@ -256,15 +286,28 @@ } ], "source": [ - "thresholds = [50,]\n", - "position_threshold = 'weighted_diff'\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold=position_threshold)\n", + "thresholds = [\n", + " 50,\n", + "]\n", + "position_threshold = \"weighted_diff\"\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=position_threshold,\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", - "plt.title(\"position_threshold \"+ position_threshold)\n", + "plt.title(\"position_threshold \" + position_threshold)\n", "plt.show()" ] }, @@ -307,15 +350,28 @@ } ], "source": [ - "thresholds = [50,]\n", - "position_threshold = 'weighted_abs'\n", - "single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold=position_threshold)\n", + "thresholds = [\n", + " 50,\n", + "]\n", + "position_threshold = \"weighted_abs\"\n", + "single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=position_threshold,\n", + ")\n", "plt.pcolormesh(input_field_arr[0])\n", "plt.colorbar()\n", "# Plot all features detected\n", - "plt.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + "plt.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + ")\n", "plt.legend()\n", - "plt.title(\"position_threshold \"+ position_threshold)\n", + "plt.title(\"position_threshold \" + position_threshold)\n", "plt.show()" ] }, @@ -357,18 +413,30 @@ } ], "source": [ - "thresholds = [50,]\n", - "fig, axarr = plt.subplots(2,2, figsize=(10,6))\n", - "testing_thresholds = ['center', 'extreme', 'weighted_diff', 'weighted_abs']\n", + "thresholds = [\n", + " 50,\n", + "]\n", + "fig, axarr = plt.subplots(2, 2, figsize=(10, 6))\n", + "testing_thresholds = [\"center\", \"extreme\", \"weighted_diff\", \"weighted_abs\"]\n", "for position_threshold, ax in zip(testing_thresholds, axarr.flatten()):\n", - "\n", - " single_threshold_features = tobac.feature_detection_multithreshold(field_in = input_field_iris, dxy = 1000, threshold=thresholds, target='maximum', position_threshold=position_threshold)\n", + " single_threshold_features = tobac.feature_detection_multithreshold(\n", + " field_in=input_field_iris,\n", + " dxy=1000,\n", + " threshold=thresholds,\n", + " target=\"maximum\",\n", + " position_threshold=position_threshold,\n", + " )\n", " color_mesh = ax.pcolormesh(input_field_arr[0])\n", " plt.colorbar(color_mesh, ax=ax)\n", " # Plot all features detected\n", - " ax.scatter(x=single_threshold_features['hdim_2'].values, y=single_threshold_features['hdim_1'].values, color='r', label=\"Detected Features\")\n", + " ax.scatter(\n", + " x=single_threshold_features[\"hdim_2\"].values,\n", + " y=single_threshold_features[\"hdim_1\"].values,\n", + " color=\"r\",\n", + " label=\"Detected Features\",\n", + " )\n", " ax.legend()\n", - " ax.set_title(\"position_threshold \"+ position_threshold)\n", + " ax.set_title(\"position_threshold \" + position_threshold)\n", "plt.tight_layout()\n", "plt.show()" ]