Skip to content

Commit fe692b0

Browse files
committed
cleaning
1 parent 2cffe13 commit fe692b0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hostphot/cutouts/hst.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def get_HST_images(ra: float, dec: float, size: float | u.Quantity = 3,
102102
coords = SkyCoord(
103103
ra=ra, dec=dec, unit=(u.degree, u.degree), frame="icrs"
104104
)
105-
105+
106+
# query observations at the given coordinates
106107
with suppress_stdout():
107108
result = esahubble.cone_search_criteria(
108109
radius=3,
@@ -113,8 +114,8 @@ def get_HST_images(ra: float, dec: float, size: float | u.Quantity = 3,
113114
#filters=filt,
114115
async_job=True,
115116
)
116-
117117
results_df = result.to_pandas()
118+
118119
hdu_list = []
119120
for filt in filters:
120121
check_HST_filters(filt)
@@ -128,7 +129,6 @@ def get_HST_images(ra: float, dec: float, size: float | u.Quantity = 3,
128129
instrument = f"{split_filt[0]}/{split_filt[1]}"
129130
else:
130131
raise ValueError(f"Incorrect filter name: {filt}")
131-
132132
# filter by filter and instrument
133133
obs_df = results_df[results_df["filter"] == filt]
134134
obs_df = obs_df[obs_df.instrument_name == instrument]
@@ -138,6 +138,7 @@ def get_HST_images(ra: float, dec: float, size: float | u.Quantity = 3,
138138
by=["exposure_duration"], ascending=False, inplace=True
139139
)
140140

141+
# start download
141142
filename = f"HST_tmp_{ra}_{dec}" # the extension is added below
142143
for obs_id in obs_df.observation_id:
143144
try:
@@ -153,9 +154,11 @@ def get_HST_images(ra: float, dec: float, size: float | u.Quantity = 3,
153154
temp_file = Path(f"{filename}.fits.gz")
154155
if temp_file.is_file() is False:
155156
hdu_list.append(None)
157+
continue
156158
hdu = fits.open(temp_file)
157159
# remove the temporary files
158160
temp_file.unlink()
161+
# add necessary information to the header
159162
update_HST_header(hdu)
160163
hdu_list.append(hdu)
161164
# HST images are large so need to be trimmed

0 commit comments

Comments
 (0)