diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff167b90..ef3589c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,3 +56,10 @@ repos: hooks: - id: nbstripout args: ["--keep-output"] + + - repo: https://github.com/nbQA-dev/nbQA + rev: 1.8.5 + hooks: + - id: nbqa-black + - id: nbqa-ruff + args: ["--fix", "--ignore=E402,B018"] diff --git a/tutorials/tutorial_01_DataDownload.ipynb b/tutorials/tutorial_01_DataDownload.ipynb index 2f0cba74..5d754c3e 100644 --- a/tutorials/tutorial_01_DataDownload.ipynb +++ b/tutorials/tutorial_01_DataDownload.ipynb @@ -55,13 +55,10 @@ "metadata": {}, "outputs": [], "source": [ - "\n", - "username = \"\" # likely your mail\n", - "password = \"\" # likely your mail\n", + "username = \"\" # likely your mail\n", + "password = \"\" # likely your mail\n", "base_dir = \" 90\n", "da_precip = ds_single_timestep[variable]\n", - "da_liquid = da_precip.where(da_is_liquid, 0) # set to 0 where is not True\n", - "da_solid = da_precip.where(~da_is_liquid, 0) # set to 0 where is True\n", + "da_liquid = da_precip.where(da_is_liquid, 0) # set to 0 where is not True\n", + "da_solid = da_precip.where(~da_is_liquid, 0) # set to 0 where is True\n", "\n", - "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Liquid\")\n", + "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Liquid\")\n", "p = da_liquid.gpm.plot_map(cbar_kwargs=cbar_kwargs, **plot_kwargs, add_colorbar=False)\n", - "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Solid\")\n", + "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Solid\")\n", "p = da_solid.gpm.plot_map(ax=p.axes, cbar_kwargs=cbar_kwargs, **plot_kwargs, add_colorbar=False)\n", "_ = p.axes.set_title(label=da_solid.gpm.title())" ] @@ -4258,7 +4258,7 @@ "# Crop by extent\n", "extent = get_country_extent(\"United States\")\n", "ds_us = ds.gpm.crop(extent=extent)\n", - "ds_us[variable].isel(time=0).gpm.plot_map()\n" + "ds_us[variable].isel(time=0).gpm.plot_map()" ] }, { diff --git a/tutorials/tutorial_02_PMW_1C.ipynb b/tutorials/tutorial_02_PMW_1C.ipynb index 61b87128..8c1bcaa0 100644 --- a/tutorials/tutorial_02_PMW_1C.ipynb +++ b/tutorials/tutorial_02_PMW_1C.ipynb @@ -131,7 +131,7 @@ "start_time = datetime.datetime.strptime(\"2020-08-02 12:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "end_time = datetime.datetime.strptime(\"2020-08-03 12:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "# Specify the product and product type\n", - "product = \"1C-MHS-METOPB\" # 1C-GMI, 1C-SSMIS-F17, ...\n", + "product = \"1C-MHS-METOPB\" # 1C-GMI, 1C-SSMIS-F17, ...\n", "product_type = \"RS\"\n", "# Specify the version\n", "version = 7" @@ -163,7 +163,7 @@ " verbose=True,\n", " progress_bar=True,\n", " check_integrity=False,\n", - ")\n" + ")" ] }, { @@ -3616,7 +3616,7 @@ "source": [ "# List some variables of interest\n", "variables = [\n", - " \"Tc\", # \"Tb\" if PMW 1B product\n", + " \"Tc\", # \"Tb\" if PMW 1B product\n", "]\n", "# Load the dataset\n", "ds = gpm.open_dataset(\n", @@ -4243,7 +4243,7 @@ } ], "source": [ - "variable = \"Tc\" # \"Tb\" if PMW 1B product\n", + "variable = \"Tc\" # \"Tb\" if PMW 1B product\n", "da = ds[variable]\n", "da" ] @@ -4593,11 +4593,11 @@ } ], "source": [ - "variable = \"Tc\" # \"Tb\" if PMW 1B product\n", + "variable = \"Tc\" # \"Tb\" if PMW 1B product\n", "da = ds[variable]\n", "print(\"xr.Dataset gpm methods:\", dir(ds.gpm))\n", "print(\"\")\n", - "print(\"xr.DataArray gpm methods:\", dir(da.gpm))\n" + "print(\"xr.DataArray gpm methods:\", dir(da.gpm))" ] }, { @@ -5357,7 +5357,7 @@ } ], "source": [ - "ds.gpm.is_spatial_2d # because the xarray.Dataset also contains the channel dimension !" + "ds.gpm.is_spatial_2d # because the xarray.Dataset also contains the channel dimension !" ] }, { @@ -5435,7 +5435,7 @@ } ], "source": [ - "da = ds[variable].isel(pmw_frequency=0).isel(along_track=slice(0,8000))\n", + "da = ds[variable].isel(pmw_frequency=0).isel(along_track=slice(0, 8000))\n", "da.gpm.plot_map()" ] }, @@ -5706,7 +5706,7 @@ "da = ds[variable].isel(pmw_frequency=0, along_track=slice(0, 8000))\n", "\n", "# Crop by extent\n", - "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", + "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", "list_isel_dict = da.gpm.get_crop_slices_by_extent(extent)\n", "print(list_isel_dict)\n", "for isel_dict in list_isel_dict:\n", @@ -5714,7 +5714,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] }, { @@ -5834,7 +5834,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] } ], diff --git a/tutorials/tutorial_02_PMW_2A.ipynb b/tutorials/tutorial_02_PMW_2A.ipynb index 62692f2b..5dbc1a23 100644 --- a/tutorials/tutorial_02_PMW_2A.ipynb +++ b/tutorials/tutorial_02_PMW_2A.ipynb @@ -135,10 +135,10 @@ "start_time = datetime.datetime.strptime(\"2020-08-01 12:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "end_time = datetime.datetime.strptime(\"2020-08-02 12:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "# Specify the product and product type\n", - "product = \"2A-MHS-METOPB\" # \"2A-GMI\", \"2A-SSMIS-F17\", ...\n", + "product = \"2A-MHS-METOPB\" # \"2A-GMI\", \"2A-SSMIS-F17\", ...\n", "product_type = \"RS\"\n", "# Specify the version\n", - "version = 5 # 7" + "version = 5 # 7" ] }, { @@ -5927,7 +5927,7 @@ "source": [ "# List some variables of interest\n", "variables = [\n", - " \"surfacePrecipitation\",\n", + " \"surfacePrecipitation\",\n", " \"rainWaterPath\",\n", " \"iceWaterPath\",\n", " \"cloudWaterPath\",\n", @@ -6676,7 +6676,7 @@ "da = ds[variable]\n", "print(\"xr.Dataset gpm methods:\", dir(ds.gpm))\n", "print(\"\")\n", - "print(\"xr.DataArray gpm methods:\", dir(da.gpm))\n" + "print(\"xr.DataArray gpm methods:\", dir(da.gpm))" ] }, { @@ -6895,7 +6895,7 @@ } ], "source": [ - "da = ds[variable].isel(along_track=slice(0,8000))\n", + "da = ds[variable].isel(along_track=slice(0, 8000))\n", "da.gpm.plot_map()" ] }, @@ -7156,7 +7156,7 @@ "da = ds[variable].isel(along_track=slice(0, 8000))\n", "\n", "# Crop by extent\n", - "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", + "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", "list_isel_dict = da.gpm.get_crop_slices_by_extent(extent)\n", "print(list_isel_dict)\n", "for isel_dict in list_isel_dict:\n", @@ -7164,7 +7164,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] }, { @@ -7284,7 +7284,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] } ], diff --git a/tutorials/tutorial_02_RADAR_2A.ipynb b/tutorials/tutorial_02_RADAR_2A.ipynb index 54f54b30..10833db3 100644 --- a/tutorials/tutorial_02_RADAR_2A.ipynb +++ b/tutorials/tutorial_02_RADAR_2A.ipynb @@ -114,7 +114,7 @@ "start_time = datetime.datetime.strptime(\"2020-07-05 02:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "end_time = datetime.datetime.strptime(\"2020-07-05 06:00:00\", \"%Y-%m-%d %H:%M:%S\")\n", "# Specify the product and product type\n", - "product = \"2A-DPR\" # 2A-PR\n", + "product = \"2A-DPR\" # 2A-PR\n", "product_type = \"RS\"\n", "# Specify the version\n", "version = 7" @@ -146,7 +146,7 @@ " verbose=True,\n", " progress_bar=True,\n", " check_integrity=False,\n", - ")\n" + ")" ] }, { @@ -22458,7 +22458,7 @@ "da = ds[variable]\n", "print(\"xr.Dataset gpm methods:\", dir(ds.gpm))\n", "print(\"\")\n", - "print(\"xr.DataArray gpm methods:\", dir(da.gpm))\n" + "print(\"xr.DataArray gpm methods:\", dir(da.gpm))" ] }, { @@ -23210,7 +23210,7 @@ } ], "source": [ - "ds.gpm.is_spatial_2d # because the xarray.Dataset also contains the range and frequency dimensions !" + "ds.gpm.is_spatial_2d # because the xarray.Dataset also contains the range and frequency dimensions !" ] }, { @@ -23340,7 +23340,7 @@ } ], "source": [ - "ds[variable].isel(along_track=slice(500,1200)).gpm.plot_map()" + "ds[variable].isel(along_track=slice(500, 1200)).gpm.plot_map()" ] }, { @@ -23642,7 +23642,7 @@ } ], "source": [ - "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Liquid\")\n", + "plot_kwargs, cbar_kwargs = gpm.get_plot_kwargs(\"IMERG_Liquid\")\n", "da.isel(along_track=slice(500, 1000)).gpm.plot_map(cbar_kwargs=cbar_kwargs, **plot_kwargs)" ] }, @@ -23709,7 +23709,7 @@ ], "source": [ "# Crop by extent\n", - "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", + "extent = (-172, -67, 19, 72) # (xmin, xmax, ymin, ymax)\n", "list_isel_dict = ds.gpm.get_crop_slices_by_extent(extent)\n", "print(list_isel_dict)\n", "for isel_dict in list_isel_dict:\n", @@ -23717,7 +23717,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] }, { @@ -23847,7 +23847,7 @@ " slice_title = da_subset.gpm.title(add_timestep=True)\n", " p = da_subset.gpm.plot_map()\n", " p.axes.set_extent(extent)\n", - " p.axes.set_title(label=slice_title)\n" + " p.axes.set_title(label=slice_title)" ] }, {