Skip to content

Commit 1eacfb3

Browse files
Merge pull request #55 from martinkilbinger/pre_0.1.5
Pre 0.1.5
2 parents ae7839c + 2914881 commit 1eacfb3

2 files changed

Lines changed: 69 additions & 33 deletions

File tree

cs_util/cat.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
from datetime import datetime
1313
from importlib.metadata import version
14+
import healpy as hp
1415

1516
from astropy.io import fits
1617
from astropy.io import ascii
@@ -267,3 +268,40 @@ def read_dndz(file_path):
267268
z_centers = bin_edges2centers(z_edges)
268269

269270
return z_centers, nz, z_edges
271+
272+
273+
def read_hp_mask(input_name, verbose=False):
274+
275+
if verbose:
276+
print(f'Reading mask {input_name}...')
277+
278+
nest = False
279+
280+
# Open input mask
281+
mask, header= hp.read_map(
282+
input_name,
283+
h=True,
284+
nest=nest,
285+
)
286+
for (key, value) in header:
287+
if key == 'ORDERING':
288+
if value == 'RING':
289+
if nest:
290+
raise ValueError(
291+
'input mask has ORDENING=RING, set nest to False'
292+
)
293+
elif value == 'NEST':
294+
if not nest:
295+
raise ValueError(
296+
'input mask has ORDENING=NEST, set nest to True'
297+
)
298+
299+
# Get nside from header
300+
nside = None
301+
for key, value in header:
302+
if key == 'NSIDE':
303+
nside = int(value)
304+
if not nside:
305+
raise KeyError('NSIDE not found in FITS mask header')
306+
307+
return mask, nest, nside

pyproject.toml

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
1-
[tool.poetry]
1+
[project]
22
name = "cs_util"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = "Utility library for CosmoStat"
5-
authors = ["Martin Kilbinger <martin.kilbinger@cea.fr>"]
5+
authors = [
6+
{ name = "Martin Kilbinger", email = "martin.kilbinger@cea.fr" },
7+
]
68
readme = "README.md"
79

8-
[tool.poetry.dependencies]
9-
python = ">=3.11,<3.13"
10-
astropy = "^7.0"
11-
datetime = "^5.5"
12-
numpy = "^1.26.4"
13-
matplotlib = "^3.8.4"
14-
swig = "^4.2.1"
15-
scipy = "^1.13.0"
16-
vos = "^3.6.1"
17-
keyring = "^25.2.0"
18-
pyccl = "^3.0.2"
19-
camb = "^1.5.9"
10+
requires-python = ">=3.11"
2011

21-
[tool.poetry.dev-dependencies]
22-
pytest = "^6.2.5"
23-
pydocstyle = "^6.3.0"
24-
pytest-cov = "^4.1.0"
25-
black = "^23.7.0"
12+
dependencies = [
13+
"astropy>=7.0",
14+
"datetime>=5.5",
15+
"numpy>=1.26.4",
16+
"matplotlib>=3.8.4",
17+
"swig>=4.2.1",
18+
"scipy>=1.13.0",
19+
"vos>=3.6.1",
20+
"keyring>=25.2.0",
21+
"pyccl>=3.0.2",
22+
"camb>=1.5.9",
23+
]
2624

27-
[tool.black]
28-
line-length = 80
25+
[project.optional-dependencies]
26+
lint = [
27+
"black",
28+
]
29+
release = [
30+
"build",
31+
"twine",
32+
]
33+
test = [
34+
"pytest",
35+
"pytest-pydocstyle",
36+
"pytest-cov",
37+
]
2938

30-
[build-system]
31-
requires = ["poetry-core>=1.0.0"]
32-
build-backend = "poetry.core.masonry.api"
33-
34-
[project.urls]
35-
Source = "https://github.com/CosmoStat/cs_util"
36-
Documentation = "https://github.com/CosmoStat/cs_util"
37-
Tracker = "https://github.com/CosmoStat/cs_util/issues"
38-
39-
[tool.pydocstyle]
40-
convention = "numpy"

0 commit comments

Comments
 (0)