Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not overwriting MAST download of incomplete file #3231

Open
eas342 opened this issue Feb 27, 2025 · 1 comment
Open

Not overwriting MAST download of incomplete file #3231

eas342 opened this issue Feb 27, 2025 · 1 comment

Comments

@eas342
Copy link

eas342 commented Feb 27, 2025

I believe astroquery.mast should be able to download and write over an incomplete file. However, it still is corrupted/incomplete even when the code recognizes the file as incomplete. Here are the steps to re-produce.

from astroquery.mast import Observations
from astropy.io import fits
fileN = 'jw01185103001_02102_00001-seg001_nrcalong_rate.fits'
with open(fileN,'wb') as f:
    f.write(b'junk')
Observations.download_file('mast:jwst/product/'+fileN)
tmpHDU = fits.open(fileN)

I get OSError: Empty or corrupt FITS file whereas I was expecting astroquery to download a new file because it detects that the cached one is incomplete.

I'm using astroquery 0.4.10.dev9927 on Python 3.12.2

@Pharisaeus
Copy link

I was expecting astroquery to download a new file because it detects that the cached one is incomplete.

That's not how "resume download" generally works. In pretty much every http client (like wget) and also what astroquery seems to do ( https://github.com/astropy/astroquery/blob/main/astroquery/query.py#L455 ) "resume" will download only the "missing" part of the file and append it to already existing file. This way if you have 10GB file and your download crashed at last 1MB you only need to download 1MB and not whole file again.

Your "test" does not showcase a normal scenario because you put junk into the file, instead of actual prefix of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants