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

Catch specific exceptions in Herschel_get_spec #294

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions spectroscopy/code_src/herschel_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Herschel PACS & SPIRE (from ESA TAP)
from astroquery.esa.hsa import HSA
from astroquery.exceptions import LoginError
from requests.exceptions import ChunkedEncodingError
from requests.exceptions import ChunkedEncodingError, ConnectionError
import tarfile
from astropy.io import fits
import glob
Expand Down Expand Up @@ -137,8 +137,10 @@ def Herschel_get_spec(sample_table, search_radius_arcsec, datadir, delete_tarfil

except LoginError:
print("This observation is proprietary, which might mean that it is calibration data")
except:
except (ChunkedEncodingError, ConnectionError):
print("Connection to the ESA archive broken")
except tarfile.ReadError:
print(f"Tarfile ReadError. This tarfile may be corrupt {path_to_file}")

#delete tar files
if delete_tarfiles:
Expand All @@ -149,4 +151,3 @@ def Herschel_get_spec(sample_table, search_radius_arcsec, datadir, delete_tarfil
os.remove(filename_tar)

return df_spec

2 changes: 1 addition & 1 deletion spectroscopy/spectra_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ df_spec.append(df_spec_HST)
### 2.3 ESA Archive
```python
# Herschel PACS & SPIRE from ESA TAP using astroquery
#This search is fully functional, but is commented out because it is very slow.
#This search is fully functional, but is commented out because it takes ~4 hours to run to completion
herschel_radius = 1.1
herschel_download_directory = 'data/herschel'

Expand Down