From f2e70a061c5d16c548c810d109e7eab44e52c668 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Fri, 8 Mar 2024 11:39:28 +0100 Subject: [PATCH] Fix modes and tests --- satpy/readers/sar_c_safe.py | 2 +- satpy/tests/reader_tests/test_sar_c_safe.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/satpy/readers/sar_c_safe.py b/satpy/readers/sar_c_safe.py index 4e416b8777..e11bcbded3 100644 --- a/satpy/readers/sar_c_safe.py +++ b/satpy/readers/sar_c_safe.py @@ -583,7 +583,7 @@ def get_dataset(self, key, info): @cached_property def _data(self): - data = xr.open_dataarray(open_file_or_filename(self.filename), engine="rasterio", + data = xr.open_dataarray(open_file_or_filename(self.filename, mode="rb"), engine="rasterio", chunks="auto" ).squeeze() self.chunks = data.data.chunksize diff --git a/satpy/tests/reader_tests/test_sar_c_safe.py b/satpy/tests/reader_tests/test_sar_c_safe.py index be4dfb6e1a..9e24c00c4e 100644 --- a/satpy/tests/reader_tests/test_sar_c_safe.py +++ b/satpy/tests/reader_tests/test_sar_c_safe.py @@ -20,7 +20,6 @@ import os from datetime import datetime from enum import Enum -from io import BytesIO from pathlib import Path import numpy as np @@ -106,12 +105,15 @@ def noise_filehandler(noise_file, annotation_filehandler): @pytest.fixture(scope="module") -def noise_with_holes_filehandler(annotation_filehandler): +def noise_with_holes_filehandler(annotation_filehandler, tmpdir_factory): """Create a noise filehandler from data with holes.""" filename_info = dict(start_time=START_TIME, end_time=END_TIME, polarization="vv") - noise_filehandler = Denoiser(BytesIO(noise_xml_with_holes), - filename_info, None, - image_shape=annotation_filehandler.image_shape) + noise_xml_file = tmpdir_factory.mktemp("data").join("noise_with_holes.xml") + with open(noise_xml_file, "wb") as fd: + fd.write(noise_xml_with_holes) + noise_filehandler = Denoiser(noise_xml_file, + filename_info, None, + image_shape=annotation_filehandler.image_shape) return noise_filehandler