LLNL / Silo

Mesh and Field I/O Library and Scientific Database
https://silo.llnl.gov
Other
25 stars 22 forks source link

toc object returned from python interface not iterable or introspectable #372

Open markcmiller86 opened 3 months ago

markcmiller86 commented 3 months ago

In the python interface, DBGetToc() returns a toc object that that object is useless except to print. A program needs to be able to iterate over it, introspect it, etc.

markcmiller86 commented 2 months ago

So, it looks like this is possible...

>>> x=db.GetToc()
>>> print(x)
nvar = 30
var_names = (_fileinfo, _meshtv_defvars, _meshtvinfo, _silolibinfo, cycle, dx_data, dy_data, dz_data, fl_nodelist, fl_shapecnt, fl_shapesize, fl_zoneno, mat1_dims, mat1_matlist, mat1_matnos, mesh1_align_nodal, mesh1_align_zonal, mesh1_coord0, mesh1_coord1, mesh1_coord2, mesh1_max_extents, mesh1_min_extents, t_data, time, u_data, v_data, w_data, zl_nodelist, zl_shapecnt, zl_shapesize)
nucdmesh = 1
ucdmesh_names = (mesh1)
nobj = 2
obj_names = (fl, zl)
nucdvar = 7
ucdvar_names = (dx, dy, dz, t, u, v, w)
nmat = 1
mat_names = (mat1)

>>> type(x)
<type 'DBtoc'>
>>> dir(x)
[]
>>> x.nvar
30
>>> x.var_names
('_fileinfo', '_meshtv_defvars', '_meshtvinfo', '_silolibinfo', 'cycle', 'dx_data', 'dy_data', 'dz_data', 'fl_nodelist', 'fl_shapecnt', 'fl_shapesize', 'fl_zoneno', 'mat1_dims', 'mat1_matlist', 'mat1_matnos', 'mesh1_align_nodal', 'mesh1_align_zonal', 'mesh1_coord0', 'mesh1_coord1', 'mesh1_coord2', 'mesh1_max_extents', 'mesh1_min_extents', 't_data', 'time', 'u_data', 'v_data', 'w_data', 'zl_nodelist', 'zl_shapecnt', 'zl_shapesize')
>>> x.nobj
2
>>> x.nmat
1
>>> x.mat_names
('mat1',)
>>> x.nucdvar
7

I think the issue is that dir() and help() don't produce useful output for a DBtoc() object.