Skip to content

Commit a531225

Browse files
author
jngaravitoc
committed
changing basis_params dictionary param
1 parent 5c04c99 commit a531225

3 files changed

Lines changed: 31 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
## [0.2.2] – 2025-12-24
4+
5+
### Added
6+
- Docstrings in basis module
7+
- Support to build cylindrical basis
8+
9+
### Changed
10+
- Rename basis_build folder to match pyEXP naming convention
11+
- Basis module was refactor
12+
13+
### Fixed
14+
- A typo in make_model was fixed
15+
- Prevented log10 of zero in density smoothing

EXPtools/basis/basis_utils.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def write_config(basis_params):
174174

175175
return yaml.dump(config_dict, sort_keys=False)
176176

177-
def make_basis(R, D, Mtotal, **basis_params):
177+
def make_basis(R, D, Mtotal, basis_params, physical_units=True):
178178
"""
179179
Construct a basis from a given radial density profile.
180180
@@ -188,6 +188,9 @@ def make_basis(R, D, Mtotal, **basis_params):
188188
Total mass normalization (default is 1.0).
189189
basis_params : dict
190190
basis parameters e.g., basis_id, nmax, lmax
191+
For the descriptions of the basis_params please see the EXP description:
192+
https://github.com/EXP-code/EXP-docs/blob/93207da758d34cf10092650a840cdb23180b859a/topics/yamlconfig.rst#L229
193+
191194
192195
Returns
193196
-------
@@ -200,6 +203,11 @@ def make_basis(R, D, Mtotal, **basis_params):
200203
the supplied density profile and total mass.
201204
- It then builds a basis either spherical (`sphereSL`) or cylindrical using `EXPtools.make_config`
202205
and returns the corresponding `pyEXP` basis object.
206+
207+
TODO:
208+
-----
209+
- check cache values are consitent with basis_params
210+
- informce float for rmapping
203211
"""
204212

205213
if "modelname" not in basis_params.keys():
@@ -208,13 +216,15 @@ def make_basis(R, D, Mtotal, **basis_params):
208216
if "cachename" not in basis_params.keys():
209217
basis_params['cachename']="test_cache.txt"
210218

211-
R, D, _, _ = make_model(
219+
_ = make_model(
212220
R, D, Mtotal=Mtotal,
213-
output_filename=basis_params['modelname']
221+
output_filename=basis_params['modelname'],
222+
physical_units=physical_units
214223
)
215224

216225

226+
217227
config = write_config(basis_params)
218228

219229
basis = pyEXP.basis.Basis.factory(config)
220-
return basis
230+
return basis

EXPtools/ios/ios.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
read AGAMA coefficients into EXP
77
"""
88

9-
import os
9+
1010
import numpy as np
11-
from pytest import approx
1211
import pyEXP
13-
from EXPtools.basis_builder.basis_utils import make_config
14-
15-
DATAPATH = "../../tests/data/"
16-
12+
from EXPtools.basis.basis_utils import make_config
1713

1814
def exp_coefficients(coeffile, config, **kwargs):
1915
"""
@@ -42,38 +38,5 @@ def exp_coefficients(coeffile, config, **kwargs):
4238
coefs = pyEXP.coefs.Coefs.factory(coeffile)
4339
return basis, coefs
4440

45-
## tests
46-
47-
def _exp_coefficients():
48-
"""
49-
Test
50-
"""
51-
coeftest = os.path.join(DATAPATH, "spherical_hernquist_halo_coef.h5")
52-
config = make_config('sphereSL', numr=51, rmin=0.02,
53-
rmax=1.9799999999999995, lmax=5, nmax=10, scale=1,
54-
modelname=DATAPATH+'SLGrid.empirical_spherical_hernquist_halo',
55-
cachename=DATAPATH+".slgrid_spherical_hernquist_halo")
56-
basis, coefs = exp_coefficients(coeftest, config)
57-
58-
basis_density = np.log10(basis.getBasis()[0][0]['density'].flatten()[0::20])
59-
basis_true = np.array([2.52452473, 2.52007596, 2.51333528, 2.50305991,
60-
2.4872475, 2.46254365, 2.42296872, 2.35670352,
61-
2.23560574, 2.02788039, 1.82455463, 1.61151223,
62-
1.38374334, 1.13708294, 0.86224642, 0.55234052,
63-
0.19739773, -0.20560017, -0.66084427, -1.1953064 ])
64-
65-
66-
assert basis_density == approx(basis_true)
6741

68-
assert coefs.getAllCoefs().shape == approx((21, 10, 1))
69-
70-
first_coefs = np.array([1.58866402e+00, 1.61446863e-02, -1.21213618e-03,
71-
1.94620389e-03, 8.00640342e-04, -9.05078238e-04,
72-
-1.89598446e-03, -8.74281279e-04, 1.00354378e-03,
73-
4.03461871e-04])
74-
75-
assert coefs.getAllCoefs()[0].real.flatten() == approx(first_coefs)
76-
return basis, coefs
7742

78-
if __name__ == "__main__":
79-
_exp_coefficients()

0 commit comments

Comments
 (0)