Skip to content

Commit be2e985

Browse files
authored
Merge pull request #58 from ToFuProject/devel
Prepare 0.0.3
2 parents 74f2229 + 207967f commit be2e985

31 files changed

+2426
-767
lines changed

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@
175175
# of executable for the target platform.
176176
entry_points={
177177
'console_scripts': [
178-
'spectrally-version=scripts.spectrallyversion:main',
179-
'specrally-custom=scripts.spectrallycustom:main',
180-
'spectrally=scripts.spectrally_bash:main',
178+
'spectrally-version=spectrally.scripts.spectrallyversion:main',
179+
'specrally-custom=spectrally.scripts.spectrallycustom:main',
180+
'spectrally=spectrally.scripts.spectrally_bash:main',
181181
],
182182
},
183183
# include_dirs=[np.get_include()],

spectrally/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import warnings
66

77

8+
from .version import __version__
89
from ._class02_SpectralFit import SpectralFit as Collection
910
from ._saveload import load
10-
from . import tests
1111
from ._class01_show import *
1212
from ._class01_display_models import *
13+
from . import tests
14+
from . import tutorials
1315

1416

1517
_PKG = 'spectrally'

spectrally/_class00_plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def plot_axvlines(
267267
# if ne_scale is None:
268268
# ne_scale = 'log'
269269
# if Te_scale is None:
270-
# Te_scale = 'linear'
270+
# Te_scale = 'poly'
271271

272272
# return
273273

@@ -506,4 +506,4 @@ def plot_dominance_map(
506506
)
507507
508508
return dax
509-
"""
509+
"""

spectrally/_class01_SpectralModel.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def add_spectral_model(
6161
'key': {'ref': k0, k1: [c0, c1], k2: [c0, c1]}
6262
6363
Available function types for dmodel are:
64-
- 'linear': typically a linear background
64+
- 'poly': typically a polynomial background
6565
- 'exp': typically an exponential background
6666
- 'gauss': typically a doppler-broadened line
6767
- 'lorentz': ypically a natural-broadened line
6868
- 'pvoigt': typically a doppler-and-natural broadened line
6969
7070
dconstraints holds a dict of constraints groups.
7171
Each group is a dict with a 'ref' variable
72-
Other variables (keys) are compued as linear functions of 'ref'
72+
Other variables (keys) are compued as poly functions of 'ref'
7373
7474
Parameters
7575
----------
@@ -202,6 +202,7 @@ def get_spectral_model_moments(
202202
key=None,
203203
key_data=None,
204204
lamb=None,
205+
returnas=None,
205206
):
206207
"""
207208
@@ -221,6 +222,10 @@ def get_spectral_model_moments(
221222
key to the data to be used as input for the model's free variables
222223
lamb:str or 1d np.ndarray, optional
223224
wavelenth vector to be used for computing limited integrals
225+
returnas: str
226+
Flag indicating whether to return dout as:
227+
- 'dict_arrays': nested dict of {'ktype': {'kvar': array}}
228+
- 'dict_varnames': dict of {'kfunc_var': values}
224229
225230
Returns
226231
-------
@@ -234,6 +239,7 @@ def get_spectral_model_moments(
234239
key=key,
235240
key_data=key_data,
236241
lamb=lamb,
242+
returnas=returnas,
237243
)
238244

239245
return dout

spectrally/_class01_check_constraints.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88

9+
import copy
910
import itertools as itt
1011

1112

@@ -148,6 +149,7 @@ def _check(
148149
# Format
149150
# ------------
150151

152+
dconstraints = copy.deepcopy(dconstraints)
151153
for k0, v0 in dconstraints.items():
152154
for k1, v1 in v0.items():
153155
if k1 != 'ref':

spectrally/_class01_check_model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ def _dmodel_err(key, dmodel):
101101
pstr = ", ".join([f"'{tpar[0]}': {tpar[1]}" for tpar in lpar])
102102
stri = f"\t- 'f{ii}': " + "{" + f"'type': '{k0}', {pstr}" + "}"
103103

104-
if k0 == 'linear':
104+
if k0 == 'poly':
105105
lstr.append("\t# background-oriented")
106106
elif k0 == 'gauss':
107107
lstr.append("\t# spectral lines-oriented")
108-
elif k0 == 'pulse1':
108+
elif k0 == 'pulse_exp':
109109
lstr.append("\t# pulse-oriented")
110110
lstr.append(stri)
111111

@@ -183,7 +183,7 @@ def _check_dmodel(
183183
# check key
184184

185185
if isinstance(k0, int):
186-
if typ in ['linear', 'exp']:
186+
if typ in ['poly', 'exp']:
187187
k1 = f'bck{ibck}'
188188
ibck += 1
189189
else:

spectrally/_class01_display_models.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def _get_xx(xx, ftype):
140140
# set if None
141141
# -------------
142142

143-
lbck = ['linear', 'exp_lamb']
143+
lbck = ['poly', 'exp_lamb']
144144
llines = ['gauss', 'lorentz', 'pvoigt', 'voigt']
145-
lpulse = ['pulse1', 'pulse2', 'lognorm']
145+
lpulse = ['pulse_exp', 'pulse_gauss', 'lognorm']
146146

147147
if xx is None:
148148
if ftype in lbck + llines:
@@ -201,12 +201,13 @@ def _get_dpar_xfree(ftype, xx):
201201
# xfree
202202
# ---------------
203203

204-
if ftype == 'linear':
204+
if ftype == 'poly':
205205

206-
a1 = -1/Dx
207-
a0 = 2 - a1 * x0
206+
a0 = 1
207+
a1 = -0.2
208+
a2 = -1
208209

209-
xfree = np.r_[a0, a1]
210+
xfree = np.r_[a0, a1, a2]
210211

211212
elif ftype == 'exp_lamb':
212213

@@ -252,7 +253,7 @@ def _get_dpar_xfree(ftype, xx):
252253

253254
xfree = np.r_[amp, vccos, sigma, gam]
254255

255-
elif ftype == 'pulse1':
256+
elif ftype == 'pulse_exp':
256257

257258
amp = 1
258259
t0 = 0.3
@@ -261,7 +262,7 @@ def _get_dpar_xfree(ftype, xx):
261262

262263
xfree = np.r_[amp, t0, t_up, t_down]
263264

264-
elif ftype == 'pulse2':
265+
elif ftype == 'pulse_gauss':
265266

266267
amp = 1
267268
t0 = 0.3

spectrally/_class01_dparams.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _get_scale(
184184
# bck
185185
# ------------
186186
187-
if typ == 'linear':
187+
if typ == 'poly':
188188
189189
if var == 'c0':
190190
pass
@@ -614,4 +614,4 @@ def fit12d_dscales(dscales=None, dinput=None):
614614
indbs=dinput['valid']['indbs'],
615615
)
616616
return dscales
617-
"""
617+
"""

0 commit comments

Comments
 (0)