Skip to content

Commit 59eb72a

Browse files
Merge branch 'develop'
2 parents 0cb8642 + 1c4cc8d commit 59eb72a

File tree

5 files changed

+43
-7
lines changed

5 files changed

+43
-7
lines changed

cs_util/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323

2424
from warnings import warn
2525

26-
__version__ = "0.1.0"
26+
from importlib.metadata import version
27+
28+
__version__ = version("cs_util")

cs_util/cat.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,39 @@ def write_fits_BinTable_file(
168168
hdu_list.writeto(output_path, overwrite=True)
169169

170170

171+
def read_fits_to_dict(file_path):
172+
"""Read Fits To Dict.
173+
174+
Read FITS file and return dictionary.
175+
176+
Parameters
177+
----------
178+
file_path : str
179+
input file path
180+
181+
Returns
182+
-------
183+
dict
184+
file content
185+
186+
Raises
187+
------
188+
IOError
189+
if input file is not found
190+
"""
191+
if not os.path.exists(file_path):
192+
raise IOError(f"Input file '{file_path}' not found")
193+
194+
hdu_list = fits.open(file_path)
195+
data_input = hdu_list[1].data
196+
col_names = hdu_list[1].data.dtype.names
197+
data = {}
198+
for col_name in col_names:
199+
data[col_name] = data_input[col_name]
200+
201+
return data
202+
203+
171204
def bin_edges2centers(bin_edges):
172205
"""Bin Edges To Centers.
173206

cs_util/cosmo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def sigma_crit(z_lens, z_source, cos, d_lens=None, d_source=None):
7979

8080
a_lens = 1 / (1 + z_lens)
8181
a_source = 1 / (1 + z_source)
82-
if not d_lens:
82+
if d_lens is None:
8383
d_lens = cos.angular_diameter_distance(a_lens) * units.Mpc
84-
if not d_source:
84+
if d_source is None:
8585
d_source = cos.angular_diameter_distance(a_source) * units.Mpc
8686

8787
d_lens_source = cos.angular_diameter_distance(a_lens, a_source) * units.Mpc

cs_util/plots.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def savefig(fname, close_fig=True):
4343
fname : str
4444
output file name
4545
close_fig : bool, optional
46-
closes figure if True (default)
46+
closes figure if ``True`` (default); chose ``False``
47+
to display figure in a jupyter notebook
4748
4849
"""
4950
plt.savefig(fname, facecolor="w", bbox_inches="tight")

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ authors = ["Martin Kilbinger <[email protected]>"]
66
readme = "README.md"
77

88
[tool.poetry.dependencies]
9-
python = ">=3.9,<3.12"
10-
astropy = "5.2"
9+
python = ">=3.9,<3.13"
10+
astropy = "^5.0"
1111
camb = "1.5.4"
1212
datetime = "^5.5"
1313
numpy = "^1.26.4"
1414
matplotlib = "^3.8.4"
1515
swig = "^4.2.1"
1616
scipy = "^1.13.0"
17-
# Install pyccl via pip
1817
vos = "^3.6.1"
1918
keyring = "^25.2.0"
19+
pyccl = "^3.0.2"
2020

2121
[tool.poetry.dev-dependencies]
2222
pytest = "^6.2.5"

0 commit comments

Comments
 (0)