Skip to content

Commit 03db8d3

Browse files
committed
Merge branch 'dev'
2 parents db340ee + b5e73ab commit 03db8d3

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ If you make use of HostPhot, please cite the following [paper](https://joss.theo
168168

169169
## What's new
170170

171+
v3.1.1
172+
173+
* Fixing minor bug when calculating dust extinction for Legacy Survey (Issue [#12](https://github.com/temuller/hostphot/issues/12))
174+
* Saving input for aperture extraction
175+
171176
v3.1.0
172177

173178
* Using DES DR2 instead of DR1

src/hostphot/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = "3.1.0"
3+
__version__ = "3.1.1"

src/hostphot/cutouts/des.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,12 @@ def get_DES_images(ra: float, dec: float, size: float | u.Quantity = 3, filters:
102102
hdu_list = []
103103
for url, url_w in zip(url_list, url_w_list):
104104
# combine image+weights on a single fits file
105-
#image_hdu = fits.open(url, timeout=120)
106105
image_hdu = open_fits_from_url(url)
107106
hdu = fits.PrimaryHDU(image_hdu[0].data, header=image_hdu[0].header)
108107
if url_w is None:
109108
hdu_sublist = fits.HDUList([hdu])
110109
else:
111110
print(url_w)
112-
#weight_hdu = fits.open(url_w, timeout=120)
113111
weight_hdu = open_fits_from_url(url_w)
114112
hdu_err = fits.ImageHDU(
115113
weight_hdu[0].data, header=weight_hdu[0].header

src/hostphot/photometry/dust.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _download_dustmaps():
3232
maps_files = dust_files + mask_files
3333
existing_files = [file.is_file() for file in maps_files]
3434

35-
if not all(existing_files) == True:
35+
if not all(existing_files):
3636
# download dust maps
3737
sfdmaps_url = "https://github.com/kbarbary/sfddata/archive/master.tar.gz"
3838
response = requests.get(sfdmaps_url)
@@ -124,8 +124,8 @@ def calc_extinction(
124124
125125
Parameters
126126
----------
127-
filter_wave: Filter's wavelength range.
128-
filter_response: Filter's response function.
127+
filt: Filter name.
128+
survvey: Survey name.
129129
ra: Right ascension.
130130
dec: Declinationin degrees.
131131
scaling: Calibration of the Milky Way dust maps. Either ``0.86``
@@ -144,7 +144,8 @@ def calc_extinction(
144144
# https://datalab.noirlab.edu/ls/bass.php
145145
# declination above ~32 and above the galactic plane
146146
gal_coords = SkyCoord(ra=ra * u.degree, dec=dec * u.degree, frame="icrs")
147-
if (dec > 32.375) and (gal_coords.b.value > 0):
147+
b_gal = gal_coords.galactic.b.value
148+
if (dec > 32.375) and (b_gal > 0):
148149
version = "BASS+MzLS"
149150
else:
150151
version = "DECam"

src/hostphot/photometry/global_photometry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def extract_aperture(
161161
deblend_cont: float = 0.005,
162162
save_plots: bool = True,
163163
save_aperture_params: bool = True,
164+
save_input: bool = True,
164165
) -> tuple[np.ndarray, WCS, float, float, bool]:
165166
"""Calculates the aperture for a given galaxy.
166167
@@ -193,6 +194,7 @@ def extract_aperture(
193194
To entirely disable deblending, set to 1.0.
194195
save_plots: If `True`, the mask and galaxy aperture figures are saved.
195196
save_aperture_params: If `True`, the extracted mask parameters are saved into a pickle file.
197+
save_input: Whether to save the input parameters.
196198
197199
Returns
198200
-------
@@ -202,6 +204,11 @@ def extract_aperture(
202204
scale: Scale for the Kron radius.
203205
flip: Whether to flip the orientation of the aperture.
204206
"""
207+
input_params = locals() # dictionary
208+
# save input parameters
209+
if save_input is True:
210+
inputs_file = Path(workdir, name, survey, "input_aperture_parameters.csv")
211+
store_input(input_params, inputs_file)
205212
# initial checks
206213
check_survey_validity(survey)
207214
check_work_dir(workdir)

tests/test_cutouts.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import pytest
2+
import warnings
13
import unittest
24
from pathlib import Path
35
from hostphot.cutouts import download_images, set_HST_image, set_JWST_image
4-
6+
from pyvo.dal import DALServiceError
57

68
class TestHostPhot(unittest.TestCase):
79
def __init__(self, *args, **kwargs):
@@ -74,8 +76,6 @@ def test_cutouts_VISTA(self):
7476
"VIDEO": [36.1, -5],
7577
"VIKING": [220.5, 0.0],
7678
}
77-
78-
7979
for version, coords in surveys.items():
8080
ra, dec = coords
8181
#try:
@@ -89,13 +89,17 @@ def test_cutouts_VISTA(self):
8989
)
9090

9191
def test_cutouts_SkyMapper(self):
92-
download_images(
93-
self.sn_name,
94-
self.ra,
95-
self.dec,
96-
overwrite=True,
97-
survey="SkyMapper",
98-
)
92+
try:
93+
download_images(
94+
self.sn_name,
95+
self.ra,
96+
self.dec,
97+
overwrite=True,
98+
survey="SkyMapper",
99+
)
100+
except DALServiceError as e:
101+
warnings.warn(f"SkyMapper SIAP service failed: {e}", RuntimeWarning)
102+
pytest.skip("SkyMapper SIAP service unavailable or returned 500")
99103

100104
def test_cutouts_SPLUS(self):
101105
name = "SPLUS_test"

0 commit comments

Comments
 (0)