From 732cba94e7b6c7e921c5d2923e40d8645abcf24b Mon Sep 17 00:00:00 2001 From: crvernon Date: Tue, 14 Mar 2023 20:37:55 -0400 Subject: [PATCH 1/2] use tempdir instead of named tempfile --- cerf/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cerf/utils.py b/cerf/utils.py index 80895b5..3bc66b4 100644 --- a/cerf/utils.py +++ b/cerf/utils.py @@ -1,4 +1,4 @@ - +import os import logging import tempfile @@ -331,14 +331,17 @@ def ingest_sited_data(run_year, # update data type metadata.update(dtype=np.uint32) - with tempfile.NamedTemporaryFile() as tmpfile: + with tempfile.TemporaryDirectory() as tempdir: + + # construct temporary raster file name + out_temp_rast = os.path.join(tempdir, "cerf_temp_raster.tif") # write array as spatial in a temp file - with rasterio.open(tmpfile, "w", **metadata) as dest: + with rasterio.open(out_temp_rast, "w", **metadata) as dest: dest.write(index_arr, 1) # read temp file to use for grid search - with rasterio.open(tmpfile.name) as idx: + with rasterio.open(out_temp_rast) as idx: index_generator = idx.sample(df_active[["xcoord", "ycoord"]].values) located_index_list = [i[0] for i in index_generator] From 684b668e81addf1200abbf8f46155375068bc0eb Mon Sep 17 00:00:00 2001 From: crvernon Date: Tue, 14 Mar 2023 20:39:10 -0400 Subject: [PATCH 2/2] update to v2.3.2 --- cerf/__init__.py | 2 +- cerf/install_supplement.py | 3 ++- docs/source/conf.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cerf/__init__.py b/cerf/__init__.py index 021c43d..a676aff 100644 --- a/cerf/__init__.py +++ b/cerf/__init__.py @@ -8,4 +8,4 @@ from .install_supplement import install_package_data -__version__ = "2.3.1" +__version__ = "2.3.2" diff --git a/cerf/install_supplement.py b/cerf/install_supplement.py index 66011f1..995c3ee 100644 --- a/cerf/install_supplement.py +++ b/cerf/install_supplement.py @@ -38,7 +38,8 @@ class InstallSupplement: '2.2.0': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1', '2.2.1': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1', '2.3': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1', - '2.3.1': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1'} + '2.3.1': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1', + '2.3.2': 'https://zenodo.org/record/6998151/files/cerf_package_data.zip?download=1'} def __init__(self, data_dir=None): diff --git a/docs/source/conf.py b/docs/source/conf.py index 0025dd9..b5fa5bc 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,7 +16,7 @@ import sphinx_rtd_theme # import cerf -version = "2.3.1" #str(cerf.__version__) +version = "2.3.2" #str(cerf.__version__) sys.path.insert(0, os.path.abspath('../../'))