Skip to content

Commit 7782052

Browse files
committed
[#1152] show('synth sig') and show_details('synth sig') operational
1 parent a7440d1 commit 7782052

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

tofu/data/_class08_Diagnostic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from ._class07_Camera import Camera as Previous
1414
from . import _class8_check as _check
1515
from . import _class08_show as _show
16+
from . import _class08_show_synth_sig as _show_synth_sig
1617
from . import _class8_compute as _compute
1718
from . import _class08_get_data as _get_data
1819
from . import _class08_concatenate_data as _concatenate
@@ -53,6 +54,7 @@
5354
class Diagnostic(Previous):
5455

5556
_which_diagnostic = 'diagnostic'
57+
_which_synth_sig = 'synth sig'
5658

5759
def add_diagnostic(
5860
self,
@@ -143,12 +145,16 @@ def remove_diagnostic(self, key=None, key_cam=None):
143145
def _get_show_obj(self, which=None):
144146
if which == self._which_diagnostic:
145147
return _show._show
148+
elif which == self._which_synth_sig:
149+
return _show_synth_sig._show
146150
else:
147151
return super()._get_show_obj(which)
148152

149153
def _get_show_details(self, which=None):
150154
if which == self._which_diagnostic:
151155
return _show._show_details
156+
elif which == self._which_synth_sig:
157+
return _show_synth_sig._show_details
152158
else:
153159
return super()._get_show_details(which)
154160

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Wed Jul 24 09:36:24 2024
4+
5+
@author: dvezinet
6+
"""
7+
8+
9+
#############################################
10+
#############################################
11+
# DEFAULTS
12+
#############################################
13+
14+
15+
_LORDER = [
16+
'camera', 'data', 'diag',
17+
'geom_matrix', 'integrand',
18+
'method', 'res',
19+
]
20+
21+
22+
#############################################
23+
#############################################
24+
# Show
25+
#############################################
26+
27+
28+
def _show(coll=None, which=None, lcol=None, lar=None, show=None):
29+
30+
# ---------------------------
31+
# column names
32+
# ---------------------------
33+
34+
wsynth = coll._which_synth_sig
35+
lcol.append([which] + _LORDER)
36+
37+
# ---------------------------
38+
# list of keys
39+
# ---------------------------
40+
41+
lkey = [
42+
k1 for k1 in coll._dobj.get(which, {}).keys()
43+
if show is None or k1 in show
44+
]
45+
46+
# ---------------------------
47+
# loop on keys
48+
# ---------------------------
49+
50+
lar0 = []
51+
for k0 in lkey:
52+
53+
# initialize with key
54+
arr = [k0]
55+
56+
# dsynth
57+
dsynth = coll.dobj[wsynth][k0]
58+
59+
# loop
60+
for k1 in _LORDER:
61+
62+
# cameras, data
63+
if k1 in ['camera', 'data']:
64+
if dsynth.get(k1) is None:
65+
nn = ''
66+
elif len(dsynth[k1]) <= 3:
67+
nn = str(dsynth[k1])
68+
else:
69+
nn = f'[{dsynth[k1][0]}, ..., {dsynth[k1][-1]}]'
70+
71+
# los
72+
else:
73+
nn = str(dsynth[k1])
74+
75+
arr.append(nn)
76+
77+
lar0.append(arr)
78+
79+
lar.append(lar0)
80+
81+
return lcol, lar
82+
83+
84+
#############################################
85+
#############################################
86+
# Show single diag
87+
#############################################
88+
89+
90+
def _show_details(coll=None, key=None, lcol=None, lar=None, show=None):
91+
92+
# ---------------------------
93+
# get basics
94+
# ---------------------------
95+
96+
wcam = coll._which_cam
97+
wsynth = coll._which_synth_sig
98+
dsynth = coll.dobj[wsynth][key]
99+
100+
# ---------------------------
101+
# column names
102+
# ---------------------------
103+
104+
lcol.append([wcam, 'shape', 'sig', 'shape'] + _LORDER[2:])
105+
106+
# ---------------------------
107+
# data
108+
# ---------------------------
109+
110+
lar0 = []
111+
for ii, kcam in enumerate(dsynth[wcam]):
112+
113+
# camera
114+
arr = [kcam, str(coll.dobj[wcam][kcam]['dgeom']['shape'])]
115+
116+
# data
117+
kdata = dsynth['data'][ii]
118+
arr += [kdata, str(coll.ddata[kdata]['data'].shape)]
119+
120+
for k1 in _LORDER[2:]:
121+
nn = str(dsynth[k1])
122+
arr.append(nn)
123+
124+
# aggregate
125+
lar0.append(arr)
126+
127+
lar.append(lar0)
128+
129+
return lcol, lar

0 commit comments

Comments
 (0)