Skip to content

Commit 0570ed4

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
C9GACS-1079 add PR reference number
1 parent bb505a5 commit 0570ed4

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ gaia
3434
^^^^
3535

3636
- New datalink DR4 retrieval type RESIDUAL_IMAGE. [#3489]
37+
- The method ``load_data`` parses ecsv files [#3500].
3738

3839
esa.hubble
3940
^^^^^^^^^^

astroquery/gaia/core.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from astropy.coordinates import Angle
2121
from astropy.io import fits
2222
from astropy.io import votable
23+
from astropy.io.fits import TableHDU, BinTableHDU
2324
from astropy.table import Table
2425
from astropy.units import Quantity
2526
from astropy.utils.decorators import deprecated_renamed_argument
@@ -308,7 +309,9 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retr
308309
shutil.rmtree(path)
309310
else:
310311
for file in files.keys():
311-
os.remove(os.path.join(os.getcwd(), path, file))
312+
final_file = os.path.join(os.getcwd(), path, file)
313+
if os.path.isfile(final_file):
314+
os.remove(final_file)
312315

313316
if verbose:
314317
if output_file_specified:
@@ -340,13 +343,13 @@ def __get_data_files(output_file, path):
340343

341344
if key.endswith('.fits'):
342345
tables = []
343-
with fits.open(value) as hduList:
344-
num_hdus = len(hduList)
345-
for i in range(1, num_hdus):
346-
table = Table.read(hduList[i], format='fits')
347-
Gaia.correct_table_units(table)
348-
tables.append(table)
349-
files[key] = tables
346+
with fits.open(value, memmap=False) as hduList:
347+
for hdu in hduList:
348+
if isinstance(hdu, TableHDU) or isinstance(hdu, BinTableHDU):
349+
table = Table.read(hdu, format='fits')
350+
Gaia.correct_table_units(table)
351+
tables.append(table)
352+
files[key] = tables
350353

351354
elif key.endswith('.xml'):
352355
tables = []

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
10811081
path.unlink()
10821082

10831083

1084-
@pytest.mark.filterwarnings("ignore: ")
1084+
@pytest.mark.filterwarnings("ignore:")
10851085
def test_load_data_fits(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now):
10861086
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
10871087

@@ -1090,7 +1090,7 @@ def test_load_data_fits(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_
10901090

10911091
path = Path(os.getcwd(), output_file)
10921092

1093-
with open(DL_PRODUCTS_CSV, 'rb') as file:
1093+
with open(DL_PRODUCTS_FITS, 'rb') as file:
10941094
zip_bytes = file.read()
10951095

10961096
path.write_bytes(zip_bytes)

0 commit comments

Comments
 (0)