From 7f58c58c1fe94f4a7c4013bf119f563d6bb6017d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:23:48 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/fia/00_download.ipynb | 5 +- scripts/fia/01_raw_to_parquet.ipynb | 3 - scripts/fia/01_raw_to_parquet_part2.ipynb | 5 +- scripts/fluxnet/01_raw_to_parquet.ipynb | 1 - scripts/glas/01_cache_glas_data.ipynb | 60 +++++++++---------- .../global-biomass/01_biomass_to_cogs.ipynb | 4 -- scripts/gridmet/01_gridmet_to_zarr.ipynb | 2 - scripts/grids/make_grid.ipynb | 5 +- scripts/mtbs/02_mtbs_to_zarr.ipynb | 2 - scripts/mtbs/03_mtbs_to_zarr.ipynb | 2 - scripts/mtbs/04_mtbs_perims_to_raster.ipynb | 25 +++----- scripts/nftd/00_download.ipynb | 1 - scripts/nftd/01_nftd_to_cogs.ipynb | 2 - .../02_downsampling_and_reprojection.ipynb | 2 +- scripts/nlcd/00_download.ipynb | 1 - scripts/nlcd/01_nlcd_to_cogs.ipynb | 2 - .../02_downsampling_and_reprojection.ipynb | 2 +- scripts/prism/00_download.ipynb | 6 +- scripts/prism/01_prism_to_cogs.ipynb | 7 +-- .../prism/02_downsample_and_reproject.ipynb | 7 ++- .../01_terraclimate_aux_fileds_to_zarr.ipynb | 1 - .../01_terraclimate_to_zarr3.ipynb | 10 ++-- .../terraclimate/02_terraclimate_regrid.ipynb | 8 +-- .../02_terraclimate_to_fiaplots.ipynb | 6 +- scripts/worldclim/01_raw_to_zarr.ipynb | 7 +-- 25 files changed, 68 insertions(+), 108 deletions(-) diff --git a/scripts/fia/00_download.ipynb b/scripts/fia/00_download.ipynb index bf0584d..7f9d057 100644 --- a/scripts/fia/00_download.ipynb +++ b/scripts/fia/00_download.ipynb @@ -30,9 +30,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "from carbonplan_data.utils import process_sources" - ] + "source": [] }, { "cell_type": "code", @@ -40,7 +38,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import pathlib\n", "import zipfile\n", "\n", diff --git a/scripts/fia/01_raw_to_parquet.ipynb b/scripts/fia/01_raw_to_parquet.ipynb index 3dc1556..b62fb96 100644 --- a/scripts/fia/01_raw_to_parquet.ipynb +++ b/scripts/fia/01_raw_to_parquet.ipynb @@ -32,9 +32,6 @@ "metadata": {}, "outputs": [], "source": [ - "import io\n", - "import os.path\n", - "import pathlib\n", "\n", "import gcsfs\n", "import pandas as pd\n", diff --git a/scripts/fia/01_raw_to_parquet_part2.ipynb b/scripts/fia/01_raw_to_parquet_part2.ipynb index 89bf6cb..4e1af8d 100644 --- a/scripts/fia/01_raw_to_parquet_part2.ipynb +++ b/scripts/fia/01_raw_to_parquet_part2.ipynb @@ -34,9 +34,10 @@ "metadata": {}, "outputs": [], "source": [ - "import fsspec\n", + "import pathlib\n", + "\n", "import dask.dataframe as dd\n", - "import pathlib" + "import fsspec" ] }, { diff --git a/scripts/fluxnet/01_raw_to_parquet.ipynb b/scripts/fluxnet/01_raw_to_parquet.ipynb index cb2d0f2..d4d8e4a 100644 --- a/scripts/fluxnet/01_raw_to_parquet.ipynb +++ b/scripts/fluxnet/01_raw_to_parquet.ipynb @@ -35,7 +35,6 @@ "import pathlib\n", "\n", "import dask.dataframe as dd\n", - "import fsspec\n", "import gcsfs\n", "import pandas as pd\n", "from fsspec.implementations.zip import ZipFileSystem\n", diff --git a/scripts/glas/01_cache_glas_data.ipynb b/scripts/glas/01_cache_glas_data.ipynb index 01743d0..d52aa49 100644 --- a/scripts/glas/01_cache_glas_data.ipynb +++ b/scripts/glas/01_cache_glas_data.ipynb @@ -51,7 +51,6 @@ "# machine urs.earthdata.nasa.gov login myusername password mypassword\n", "# where 'myusername' and 'mypassword' are your Earthdata credentials.\n", "#\n", - "from __future__ import print_function\n", "\n", "import base64\n", "import itertools\n", @@ -62,24 +61,24 @@ "from getpass import getpass\n", "\n", "try:\n", + " from urllib.error import HTTPError, URLError\n", " from urllib.parse import urlparse\n", " from urllib.request import (\n", - " urlopen,\n", + " HTTPCookieProcessor,\n", " Request,\n", " build_opener,\n", - " HTTPCookieProcessor,\n", + " urlopen,\n", " )\n", - " from urllib.error import HTTPError, URLError\n", "except ImportError:\n", - " from urlparse import urlparse\n", " from urllib2 import (\n", - " urlopen,\n", - " Request,\n", + " HTTPCookieProcessor,\n", " HTTPError,\n", + " Request,\n", " URLError,\n", " build_opener,\n", - " HTTPCookieProcessor,\n", + " urlopen,\n", " )\n", + " from urlparse import urlparse\n", "\n", "# short_name = 'GLAH01'\n", "# version = '033'\n", @@ -96,9 +95,9 @@ "URS_URL = \"https://urs.earthdata.nasa.gov\"\n", "CMR_PAGE_SIZE = 2000\n", "CMR_FILE_URL = (\n", - " \"{0}/search/granules.json?provider=NSIDC_ECS\"\n", + " f\"{CMR_URL}/search/granules.json?provider=NSIDC_ECS\"\n", " \"&sort_key[]=start_date&sort_key[]=producer_granule_id\"\n", - " \"&scroll=true&page_size={1}\".format(CMR_URL, CMR_PAGE_SIZE)\n", + " f\"&scroll=true&page_size={CMR_PAGE_SIZE}\"\n", ")\n", "\n", "\n", @@ -138,8 +137,8 @@ " username, account, password = info.authenticators(urlparse(URS_URL).hostname)\n", " errprefix = \"netrc error: \"\n", " except Exception as e:\n", - " if not (\"No such file\" in str(e)):\n", - " print(\"netrc error: {0}\".format(str(e)))\n", + " if \"No such file\" not in str(e):\n", + " print(f\"netrc error: {str(e)}\")\n", " username = None\n", " password = None\n", "\n", @@ -147,13 +146,13 @@ " if not username:\n", " username = get_username()\n", " password = get_password()\n", - " credentials = \"{0}:{1}\".format(username, password)\n", + " credentials = f\"{username}:{password}\"\n", " credentials = base64.b64encode(credentials.encode(\"ascii\")).decode(\"ascii\")\n", "\n", " if url:\n", " try:\n", " req = Request(url)\n", - " req.add_header(\"Authorization\", \"Basic {0}\".format(credentials))\n", + " req.add_header(\"Authorization\", f\"Basic {credentials}\")\n", " opener = build_opener(HTTPCookieProcessor())\n", " opener.open(req)\n", " except HTTPError:\n", @@ -169,7 +168,7 @@ "def build_version_query_params(version):\n", " desired_pad_length = 3\n", " if len(version) > desired_pad_length:\n", - " print('Version string too long: \"{0}\"'.format(version))\n", + " print(f'Version string too long: \"{version}\"')\n", " quit()\n", "\n", " version = str(int(version)) # Strip off any leading zeros\n", @@ -177,7 +176,7 @@ "\n", " while len(version) <= desired_pad_length:\n", " padded_version = version.zfill(desired_pad_length)\n", - " query_params += \"&version={0}\".format(padded_version)\n", + " query_params += f\"&version={padded_version}\"\n", " desired_pad_length -= 1\n", " return query_params\n", "\n", @@ -191,16 +190,16 @@ " polygon=None,\n", " filename_filter=None,\n", "):\n", - " params = \"&short_name={0}\".format(short_name)\n", + " params = f\"&short_name={short_name}\"\n", " params += build_version_query_params(version)\n", - " params += \"&temporal[]={0},{1}\".format(time_start, time_end)\n", + " params += f\"&temporal[]={time_start},{time_end}\"\n", " if polygon:\n", - " params += \"&polygon={0}\".format(polygon)\n", + " params += f\"&polygon={polygon}\"\n", " elif bounding_box:\n", - " params += \"&bounding_box={0}\".format(bounding_box)\n", + " params += f\"&bounding_box={bounding_box}\"\n", " if filename_filter:\n", " option = \"&options[producer_granule_id][pattern]=true\"\n", - " params += \"&producer_granule_id[]={0}{1}\".format(filename_filter, option)\n", + " params += f\"&producer_granule_id[]={filename_filter}{option}\"\n", " return CMR_FILE_URL + params\n", "\n", "\n", @@ -262,7 +261,7 @@ " polygon=polygon,\n", " filename_filter=filename_filter,\n", " )\n", - " print(\"Querying for data:\\n\\t{0}\\n\".format(cmr_query_url))\n", + " print(f\"Querying for data:\\n\\t{cmr_query_url}\\n\")\n", "\n", " cmr_scroll_id = None\n", " ctx = ssl.create_default_context()\n", @@ -282,7 +281,7 @@ " cmr_scroll_id = headers[\"cmr-scroll-id\"]\n", " hits = int(headers[\"cmr-hits\"])\n", " if hits > 0:\n", - " print(\"Found {0} matches.\".format(hits))\n", + " print(f\"Found {hits} matches.\")\n", " else:\n", " print(\"Found no matches.\")\n", " search_page = response.read()\n", @@ -326,8 +325,9 @@ "outputs": [], "source": [ "import os\n", - "import fsspec\n", + "\n", "import dask\n", + "import fsspec\n", "\n", "\n", "@dask.delayed\n", @@ -338,7 +338,7 @@ " return out\n", "\n", " url_count = len(urls)\n", - " print(\"Downloading {0} files...\".format(url_count))\n", + " print(f\"Downloading {url_count} files...\")\n", "\n", " for index, url in enumerate(urls, start=1):\n", " if not credentials and urlparse(url).scheme == \"https\":\n", @@ -359,7 +359,7 @@ " # open(filename, 'wb').write(resp.content)\n", " req = Request(url)\n", " if credentials:\n", - " req.add_header(\"Authorization\", \"Basic {0}\".format(credentials))\n", + " req.add_header(\"Authorization\", f\"Basic {credentials}\")\n", " opener = build_opener(HTTPCookieProcessor())\n", "\n", " with fsspec.open(target_url, mode=\"wb\") as target:\n", @@ -368,11 +368,11 @@ " out.append(target_url)\n", "\n", " except HTTPError as e:\n", - " print(\"HTTPError {0}, {1}\".format(e.code, e.reason), filename)\n", + " print(f\"HTTPError {e.code}, {e.reason}\", filename)\n", " except URLError as e:\n", - " print(\"URLError: {0}\".format(e.reason), filename)\n", - " except IOError:\n", - " print(\"IOError: {0}\".format(e.reason), filename)\n", + " print(f\"URLError: {e.reason}\", filename)\n", + " except OSError:\n", + " print(f\"IOError: {e.reason}\", filename)\n", " except KeyboardInterrupt:\n", " quit()\n", " except:\n", diff --git a/scripts/global-biomass/01_biomass_to_cogs.ipynb b/scripts/global-biomass/01_biomass_to_cogs.ipynb index 1b8cfb5..608f3dd 100644 --- a/scripts/global-biomass/01_biomass_to_cogs.ipynb +++ b/scripts/global-biomass/01_biomass_to_cogs.ipynb @@ -32,12 +32,8 @@ "metadata": {}, "outputs": [], "source": [ - "import io\n", "import os\n", - "import pathlib\n", "\n", - "from google.cloud import storage\n", - "from rasterio.io import MemoryFile\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles\n", "\n", diff --git a/scripts/gridmet/01_gridmet_to_zarr.ipynb b/scripts/gridmet/01_gridmet_to_zarr.ipynb index c3778de..e9c4566 100644 --- a/scripts/gridmet/01_gridmet_to_zarr.ipynb +++ b/scripts/gridmet/01_gridmet_to_zarr.ipynb @@ -32,9 +32,7 @@ "outputs": [], "source": [ "import gcsfs\n", - "import intake\n", "import xarray as xr\n", - "import zarr\n", "from numcodecs.zlib import Zlib\n", "\n", "fs = gcsfs.GCSFileSystem(\n", diff --git a/scripts/grids/make_grid.ipynb b/scripts/grids/make_grid.ipynb index f2c4994..f174cb3 100644 --- a/scripts/grids/make_grid.ipynb +++ b/scripts/grids/make_grid.ipynb @@ -6,11 +6,12 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import os\n", + "from datetime import datetime\n", + "\n", + "import numpy as np\n", "import rasterio as rio\n", "import xarray as xr\n", - "from datetime import datetime\n", "from rasterio.warp import transform\n", "\n", "from carbonplan_data import cat" diff --git a/scripts/mtbs/02_mtbs_to_zarr.ipynb b/scripts/mtbs/02_mtbs_to_zarr.ipynb index f7155ba..9086df5 100644 --- a/scripts/mtbs/02_mtbs_to_zarr.ipynb +++ b/scripts/mtbs/02_mtbs_to_zarr.ipynb @@ -42,9 +42,7 @@ "import gcsfs\n", "import numpy as np\n", "import rasterio\n", - "import rioxarray\n", "import xarray as xr\n", - "import zarr\n", "from numcodecs.zlib import Zlib\n", "from rasterio import Affine\n", "from rasterio.crs import CRS\n", diff --git a/scripts/mtbs/03_mtbs_to_zarr.ipynb b/scripts/mtbs/03_mtbs_to_zarr.ipynb index 8399284..ff72efd 100644 --- a/scripts/mtbs/03_mtbs_to_zarr.ipynb +++ b/scripts/mtbs/03_mtbs_to_zarr.ipynb @@ -42,9 +42,7 @@ "import gcsfs\n", "import numpy as np\n", "import rasterio\n", - "import rioxarray\n", "import xarray as xr\n", - "import zarr\n", "from numcodecs.zlib import Zlib\n", "from rasterio import Affine\n", "from rasterio.crs import CRS\n", diff --git a/scripts/mtbs/04_mtbs_perims_to_raster.ipynb b/scripts/mtbs/04_mtbs_perims_to_raster.ipynb index 9e9222e..099f042 100644 --- a/scripts/mtbs/04_mtbs_perims_to_raster.ipynb +++ b/scripts/mtbs/04_mtbs_perims_to_raster.ipynb @@ -42,24 +42,14 @@ "metadata": {}, "outputs": [], "source": [ - "from carbonplan.data import cat\n", - "import xarray as xr\n", + "import geopandas\n", + "import hvplot.pandas # noqa\n", "import numpy as np\n", - "\n", "import pandas as pd\n", - "\n", - "import geopandas\n", - "\n", "import rasterio\n", - "from rasterio import Affine\n", - "from rasterio.transform import rowcol\n", - "from rasterio.features import rasterize\n", - "from rasterio.transform import from_bounds\n", - "\n", - "import matplotlib.pyplot as plt\n", - "import zarr\n", - "\n", - "import hvplot.pandas # noqa" + "import xarray as xr\n", + "from carbonplan.data import cat\n", + "from rasterio.features import rasterize" ] }, { @@ -158,9 +148,9 @@ "metadata": {}, "outputs": [], "source": [ - "from rio_cogeo.profiles import cog_profiles\n", "from rasterio.io import MemoryFile\n", - "from rio_cogeo.cogeo import cog_translate" + "from rio_cogeo.cogeo import cog_translate\n", + "from rio_cogeo.profiles import cog_profiles" ] }, { @@ -257,7 +247,6 @@ "outputs": [], "source": [ "import intake\n", - "import xarray as xr\n", "from dask.diagnostics import ProgressBar\n", "\n", "cat2 = intake.open_catalog(\n", diff --git a/scripts/nftd/00_download.ipynb b/scripts/nftd/00_download.ipynb index 16debe3..5e85aaa 100644 --- a/scripts/nftd/00_download.ipynb +++ b/scripts/nftd/00_download.ipynb @@ -32,7 +32,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import pathlib\n", "import zipfile\n", "\n", diff --git a/scripts/nftd/01_nftd_to_cogs.ipynb b/scripts/nftd/01_nftd_to_cogs.ipynb index 6fe5607..61656fd 100644 --- a/scripts/nftd/01_nftd_to_cogs.ipynb +++ b/scripts/nftd/01_nftd_to_cogs.ipynb @@ -32,12 +32,10 @@ "metadata": {}, "outputs": [], "source": [ - "import io\n", "import os\n", "import pathlib\n", "\n", "from google.cloud import storage\n", - "from rasterio.io import MemoryFile\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles" ] diff --git a/scripts/nftd/02_downsampling_and_reprojection.ipynb b/scripts/nftd/02_downsampling_and_reprojection.ipynb index ff7b0f8..8e5ed5f 100644 --- a/scripts/nftd/02_downsampling_and_reprojection.ipynb +++ b/scripts/nftd/02_downsampling_and_reprojection.ipynb @@ -52,9 +52,9 @@ "metadata": {}, "outputs": [], "source": [ + "import rasterio\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles\n", - "import rasterio\n", "\n", "dst_profile = cog_profiles.get(\"deflate\")" ] diff --git a/scripts/nlcd/00_download.ipynb b/scripts/nlcd/00_download.ipynb index 25fe6e5..e51dc25 100644 --- a/scripts/nlcd/00_download.ipynb +++ b/scripts/nlcd/00_download.ipynb @@ -31,7 +31,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import pathlib\n", "import zipfile\n", "\n", diff --git a/scripts/nlcd/01_nlcd_to_cogs.ipynb b/scripts/nlcd/01_nlcd_to_cogs.ipynb index a6746ee..e90f867 100644 --- a/scripts/nlcd/01_nlcd_to_cogs.ipynb +++ b/scripts/nlcd/01_nlcd_to_cogs.ipynb @@ -34,12 +34,10 @@ "metadata": {}, "outputs": [], "source": [ - "import io\n", "import os\n", "import pathlib\n", "\n", "from google.cloud import storage\n", - "from rasterio.io import MemoryFile\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles\n", "\n", diff --git a/scripts/nlcd/02_downsampling_and_reprojection.ipynb b/scripts/nlcd/02_downsampling_and_reprojection.ipynb index 0c306fe..867a992 100644 --- a/scripts/nlcd/02_downsampling_and_reprojection.ipynb +++ b/scripts/nlcd/02_downsampling_and_reprojection.ipynb @@ -65,7 +65,7 @@ "outputs": [], "source": [ "import rasterio\n", - "from numpy import asarray, argmax" + "from numpy import argmax, asarray" ] }, { diff --git a/scripts/prism/00_download.ipynb b/scripts/prism/00_download.ipynb index e5f7015..651218a 100644 --- a/scripts/prism/00_download.ipynb +++ b/scripts/prism/00_download.ipynb @@ -6,10 +6,10 @@ "metadata": {}, "outputs": [], "source": [ - "import wget\n", - "import os\n", - "import zipfile\n", "import pathlib\n", + "import zipfile\n", + "\n", + "import wget\n", "\n", "from carbonplan_data.utils import setup\n", "\n", diff --git a/scripts/prism/01_prism_to_cogs.ipynb b/scripts/prism/01_prism_to_cogs.ipynb index 234f467..9721aed 100644 --- a/scripts/prism/01_prism_to_cogs.ipynb +++ b/scripts/prism/01_prism_to_cogs.ipynb @@ -29,20 +29,15 @@ "metadata": {}, "outputs": [], "source": [ - "import io\n", "import os\n", - "import pathlib\n", "\n", + "import xarray as xr\n", "from google.cloud import storage\n", - "from rasterio.io import MemoryFile\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles\n", "\n", "from carbonplan_data.utils import setup\n", "\n", - "import xarray as xr\n", - "import rioxarray\n", - "\n", "storage.blob._DEFAULT_CHUNKSIZE = 5 * 1024 * 1024 # 5 MB\n", "storage.blob._MAX_MULTIPART_SIZE = 5 * 1024 * 1024 # 5 MB" ] diff --git a/scripts/prism/02_downsample_and_reproject.ipynb b/scripts/prism/02_downsample_and_reproject.ipynb index 00a2917..4eda44d 100644 --- a/scripts/prism/02_downsample_and_reproject.ipynb +++ b/scripts/prism/02_downsample_and_reproject.ipynb @@ -33,11 +33,12 @@ "outputs": [], "source": [ "import os\n", - "from carbonplan_data.utils import projections, setup\n", + "\n", + "import fsspec\n", "from rio_cogeo.cogeo import cog_translate\n", "from rio_cogeo.profiles import cog_profiles\n", - "import rasterio\n", - "import fsspec\n", + "\n", + "from carbonplan_data.utils import projections, setup\n", "\n", "dst_profile = cog_profiles.get(\"deflate\")\n", "\n", diff --git a/scripts/terraclimate/01_terraclimate_aux_fileds_to_zarr.ipynb b/scripts/terraclimate/01_terraclimate_aux_fileds_to_zarr.ipynb index 698a2cd..f1af1b7 100644 --- a/scripts/terraclimate/01_terraclimate_aux_fileds_to_zarr.ipynb +++ b/scripts/terraclimate/01_terraclimate_aux_fileds_to_zarr.ipynb @@ -31,7 +31,6 @@ "source": [ "import fsspec\n", "import xarray as xr\n", - "\n", "import zarr" ] }, diff --git a/scripts/terraclimate/01_terraclimate_to_zarr3.ipynb b/scripts/terraclimate/01_terraclimate_to_zarr3.ipynb index 19d8bdd..18d0497 100644 --- a/scripts/terraclimate/01_terraclimate_to_zarr3.ipynb +++ b/scripts/terraclimate/01_terraclimate_to_zarr3.ipynb @@ -32,14 +32,12 @@ "outputs": [], "source": [ "import os\n", - "import fsspec\n", - "import xarray as xr\n", "\n", "import dask\n", - "from dask.distributed import Client\n", - "from dask_gateway import Gateway\n", - "from typing import List\n", + "import fsspec\n", "import urlpath\n", + "import xarray as xr\n", + "from dask_gateway import Gateway\n", "from tqdm import tqdm" ] }, @@ -282,7 +280,7 @@ " .load()\n", " .chunk(chunks)\n", " )\n", - " except Exception as e:\n", + " except Exception:\n", " raise ValueError(source_url)\n", "\n", " mapper = fs.get_mapper(target_url)\n", diff --git a/scripts/terraclimate/02_terraclimate_regrid.ipynb b/scripts/terraclimate/02_terraclimate_regrid.ipynb index 0412e01..60aa7a8 100644 --- a/scripts/terraclimate/02_terraclimate_regrid.ipynb +++ b/scripts/terraclimate/02_terraclimate_regrid.ipynb @@ -39,10 +39,9 @@ "outputs": [], "source": [ "import fsspec\n", + "import numpy as np\n", "import xarray as xr\n", "import xesmf as xe\n", - "import numpy as np\n", - "\n", "from dask.diagnostics import ProgressBar" ] }, @@ -91,7 +90,7 @@ "source": [ "# options\n", "name = \"terraclimate\"\n", - "raw_location = f\"gs://carbonplan-data/raw/terraclimate/4000m/raster.zarr\"\n", + "raw_location = \"gs://carbonplan-data/raw/terraclimate/4000m/raster.zarr\"\n", "target_grid = \"gs://carbonplan-data/processed/grids/conus/4000m/domain.zarr\"\n", "# getting weird errors when writing to carbonplan-data\n", "target_location = f\"gs://carbonplan-data/processed/{name}/conus/4000m/raster.zarr\"" @@ -192,9 +191,10 @@ "metadata": {}, "outputs": [], "source": [ - "import dask\n", "from multiprocessing.pool import ThreadPool\n", "\n", + "import dask\n", + "\n", "with dask.config.set(scheduler=\"threads\", pool=ThreadPool(3)):\n", " with ProgressBar():\n", " mapper2 = fsspec.get_mapper(target_location)\n", diff --git a/scripts/terraclimate/02_terraclimate_to_fiaplots.ipynb b/scripts/terraclimate/02_terraclimate_to_fiaplots.ipynb index 64a1b1a..052ea9d 100644 --- a/scripts/terraclimate/02_terraclimate_to_fiaplots.ipynb +++ b/scripts/terraclimate/02_terraclimate_to_fiaplots.ipynb @@ -6,10 +6,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", - "import pandas as pd\n", - "import fsspec\n", "import dask\n", + "import fsspec\n", + "import pandas as pd\n", + "import xarray as xr\n", "\n", "dask.config.set({\"distributed.logging.distributed\": \"critical\"})" ] diff --git a/scripts/worldclim/01_raw_to_zarr.ipynb b/scripts/worldclim/01_raw_to_zarr.ipynb index f3ba5fc..6b5bdf5 100644 --- a/scripts/worldclim/01_raw_to_zarr.ipynb +++ b/scripts/worldclim/01_raw_to_zarr.ipynb @@ -20,9 +20,8 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", - "\n", - "import fsspec" + "import fsspec\n", + "import xarray as xr" ] }, { @@ -71,7 +70,7 @@ "outputs": [], "source": [ "ds[\"elev\"] = xr.open_rasterio(\n", - " f\"gs://carbonplan-scratch/worldclim-raw/wc2.1_30s_elev.tif\",\n", + " \"gs://carbonplan-scratch/worldclim-raw/wc2.1_30s_elev.tif\",\n", " chunks={\"x\": 8192, \"y\": 8192},\n", ").squeeze(drop=True)" ]