Skip to content

Commit f0d622d

Browse files
authored
Merge pull request #1135 from ToFuProject/devel
Prepare 1.8.17
2 parents 24ee38c + 822ff43 commit f0d622d

File tree

58 files changed

+7102
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7102
-629
lines changed

.github/workflows/test-complete-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macOS-latest]
16+
os: [ubuntu-latest, macOS-latest] # , windows-latest
1717
python-version: ['3.8', '3.9', '3.10', '3.11']
1818
exclude:
1919
- python-version: ['3.11']

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ Polygon3
1313

1414
######## Requirements with Version Specifier ########
1515
datastock>=0.0.54
16-
bsplines2d>=0.0.27
16+
bsplines2d>=0.0.29
1717
spectrally>=0.0.9
1818
Cython>=0.26

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def get_version_tofu(path=_HERE):
325325
"Polygon3",
326326
"cython>=0.26",
327327
"datastock>=0.0.54",
328-
"bsplines2d>=0.0.27",
328+
"bsplines2d>=0.0.29",
329329
"spectrally>=0.0.9",
330330
],
331331
python_requires=">=3.6",

tofu/data/_class02_sample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def main(
292292
)(itoti)
293293

294294
if out_l:
295-
i1 = np.floor(itoti).astype(int)
296-
i1[i1 == ioki.sum()] -= 1
295+
i1 = np.floor(itoti - 1e-14).astype(int)
296+
# i1[i1 == ioki.sum()] -= 1
297297

298298
llen[slin] = length1[sli2][i1]
299299
lentot[slin] = length0[sli2][i1]

tofu/data/_class02_save2stp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,6 @@ def _get_data_polyline(
10391039
iso=None,
10401040
):
10411041

1042-
10431042
# ----------------
10441043
# prepare
10451044
# ----------------
@@ -1094,7 +1093,7 @@ def _get_data_polyline(
10941093
ipts = i0_poly + np.arange(nptsi)
10951094

10961095
col = dcolor[k0]
1097-
if color_by_pixel is not False and ii%2 == 1:
1096+
if color_by_pixel is not False and ii % 2 == 1:
10981097
col = np.r_[col]
10991098
icol = np.argmin(col)
11001099
col[icol] += (np.max(col) - col[icol]) * color_by_pixel

tofu/data/_class02_single_point_camera.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,15 @@ def _rays_intersection(
456456
py = ptsy[0, ...]
457457
pz = ptsz[0, ...]
458458

459+
# safety check
460+
if px.size <= 1:
461+
msg = (
462+
f"Intersection fof rays '{kray}' for single_pt_cam:\n"
463+
"\t- Cannot compute intersection without at least 2 rays!\n"
464+
f"\t- rays.shape = {px.shape}\n"
465+
)
466+
raise Exception(msg)
467+
459468
# unit vectors
460469
vx, vy, vz = coll.get_rays_vect(
461470
kray,

tofu/data/_class08_Diagnostic.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# tofu
1313
from ._class07_Camera import Camera as Previous
1414
from . import _class8_check as _check
15+
from . import _class08_show as _show
1516
from . import _class8_compute as _compute
1617
from . import _class08_get_data as _get_data
1718
from . import _class08_concatenate_data as _concatenate
@@ -50,18 +51,6 @@
5051
class Diagnostic(Previous):
5152

5253
_which_diagnostic = 'diagnostic'
53-
_show_in_summary = 'all'
54-
55-
_dshow = dict(Previous._dshow)
56-
_dshow.update({
57-
'diagnostic': [
58-
'is2d',
59-
'spectro',
60-
'PHA',
61-
'camera',
62-
'signal',
63-
],
64-
})
6554

6655
def add_diagnostic(
6756
self,
@@ -145,6 +134,22 @@ def remove_diagnostic(self, key=None, key_cam=None):
145134
key_cam=key_cam,
146135
)
147136

137+
# -------------------
138+
# show
139+
# -------------------
140+
141+
def _get_show_obj(self, which=None):
142+
if which == self._which_diagnostic:
143+
return _show._show
144+
else:
145+
return super()._get_show_obj(which)
146+
147+
def _get_show_details(self, which=None):
148+
if which == self._which_diagnostic:
149+
return _show._show_details
150+
else:
151+
super()._get_show_details(which)
152+
148153
# -----------------
149154
# utilities
150155
# -----------------
@@ -559,6 +564,10 @@ def compute_diagnostic_vos(
559564
# spectro-only
560565
rocking_curve_fw=None,
561566
rocking_curve_max=None,
567+
# cleanup
568+
cleanup_pts=None,
569+
cleanup_lamb=None,
570+
compact_lamb=None,
562571
# bool
563572
check=None,
564573
verb=None,
@@ -605,6 +614,10 @@ def compute_diagnostic_vos(
605614
# spectro-only
606615
rocking_curve_fw=rocking_curve_fw,
607616
rocking_curve_max=rocking_curve_max,
617+
# cleanup
618+
cleanup_pts=cleanup_pts,
619+
cleanup_lamb=cleanup_lamb,
620+
compact_lamb=compact_lamb,
608621
# bool
609622
visibility=visibility,
610623
check=check,
@@ -1537,8 +1550,7 @@ def plot_diagnostic_geometrical_coverage(
15371550
dmargin=None,
15381551
tit=None,
15391552
cmap=None,
1540-
vmin=None,
1541-
vmax=None,
1553+
dvminmax=None,
15421554
):
15431555
""" Plot the geometrical coverage of a diagnostic, in a cross-section
15441556
@@ -1583,8 +1595,7 @@ def plot_diagnostic_geometrical_coverage(
15831595
config=plot_config,
15841596
dcolor=dcolor,
15851597
cmap=cmap,
1586-
vmin=vmin,
1587-
vmax=vmax,
1598+
dvminmax=dvminmax,
15881599
dax=dax,
15891600
fs=fs,
15901601
dmargin=dmargin,

tofu/data/_class08_interpolate_along_los.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def main(
223223
)[key_coords]['data']
224224

225225
# interpolate
226-
q2dy = coll.interpolate_profile2d(
226+
q2dy = coll.interpolate(
227227
keys=key_integrand,
228228
x0=Ri,
229229
x1=pts_z,
@@ -239,13 +239,23 @@ def main(
239239
)[key_integrand]['data']
240240

241241
# check shape
242-
if q2dx['data'].shape != q2dy['data'].shape:
243-
msg = "The two interpolated quantities must have same shape!"
242+
if q2dx.shape != q2dy.shape:
243+
msg = (
244+
"The two interpolated quantities must have same shape!\n"
245+
f"\t- '{key_coords}': {q2dx.shape}\n"
246+
f"\t- '{key_integrand}': {q2dy.shape}\n"
247+
)
244248
raise Exception(msg)
245249

250+
# axis_los
251+
wbs = coll._which_bsplines
252+
kbs = coll.ddata[key_integrand][wbs][0]
253+
rbs = coll.dobj[wbs][kbs]['ref']
254+
axis_los = coll.ddata[key_integrand]['ref'].index(rbs[0])
255+
246256
# prepare
247-
dx[kk] = np.full(q2d.shape, np.nan)
248-
dy[kk] = np.full(q2d.shape, np.nan)
257+
dx[kk] = np.full(q2dx.shape, np.nan)
258+
dy[kk] = np.full(q2dx.shape, np.nan)
249259

250260
# isok
251261
isok = np.isfinite(q2dx) & np.isfinite(q2dy) & np.isfinite(Ri)
@@ -307,6 +317,7 @@ def main(
307317

308318
dind = _get_dind(
309319
coll=coll,
320+
key_cam=key_cam,
310321
doptics=doptics,
311322
dx=dx,
312323
dy=dy,
@@ -574,7 +585,7 @@ def _interpolate_along_los_reshape(
574585
else:
575586
ref[ii] = 1
576587

577-
# None not macthing xdata (e.g.: domain)
588+
# None not matching xdata (e.g.: domain)
578589
xdata = xdata.reshape(ref) * np.ones(ydata.shape)
579590

580591
return xdata, ydata, axis_los
@@ -587,6 +598,7 @@ def _interpolate_along_los_reshape(
587598

588599
def _get_dind(
589600
coll=None,
601+
key_cam=None,
590602
doptics=None,
591603
dx=None,
592604
dy=None,
@@ -596,7 +608,7 @@ def _get_dind(
596608
# loop on cameras
597609

598610
dind = {}
599-
for kcam in doptics.keys():
611+
for kcam in key_cam:
600612

601613
klos = doptics[kcam]['los']
602614

@@ -636,8 +648,8 @@ def _get_dind(
636648
# -----------
637649
# safety check
638650

639-
lc = [np.any(inan[ind>=0]), (ind == -1).sum() < nnan]
640-
if any(lc):
651+
lc = [np.any(inan[ind >= 0]), (ind == -1).sum() < nnan]
652+
if any(lc):
641653
msg = (
642654
"Inconsistent nans!\n"
643655
f"\t- lc: {lc}\n"
@@ -669,7 +681,6 @@ def interpolate_along_los_plot(
669681
dax=None,
670682
):
671683

672-
673684
# -------------
674685
# check inputs
675686
# -------------
@@ -814,4 +825,4 @@ def _plot_check(
814825
) + str(err)
815826
raise Exception(msg)
816827

817-
return dcolor
828+
return dcolor

tofu/data/_class08_save2json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _extract_diagnostic(
136136
exdef = [
137137
'doptics',
138138
'signal',
139-
'nb geom matrix'
139+
'nb geom_matrix'
140140
]
141141
if isinstance(excluded, str):
142142
excluded = [excluded]

0 commit comments

Comments
 (0)