File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import os
34import tempfile
45from collections .abc import Generator
56from io import BytesIO
@@ -255,11 +256,14 @@ def read_fits_image(map_file_pointer: str | Path | UPath) -> np.ndarray:
255256 value at each index corresponds to the number of objects found at the healpix pixel.
256257 """
257258 map_file_pointer = get_upath (map_file_pointer )
258- with tempfile .NamedTemporaryFile () as _tmp_file :
259+ with tempfile .NamedTemporaryFile (delete = False ) as _tmp_file :
259260 with map_file_pointer .open ("rb" ) as _map_file :
260- map_data = _map_file .read ()
261- _tmp_file .write (map_data )
262- return Skymap .from_fits (_tmp_file .name ).values
261+ _tmp_file .write (_map_file .read ())
262+ tmp_path = _tmp_file .name
263+ try :
264+ return Skymap .from_fits (tmp_path ).values
265+ finally :
266+ os .unlink (tmp_path )
263267
264268
265269def write_fits_image (histogram : np .ndarray , map_file_pointer : str | Path | UPath ):
You can’t perform that action at this time.
0 commit comments