visit icon indicating copy to clipboard operation
visit copied to clipboard

CLI Convenience method to get a list of available variables

Open biagas opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

It can be helpful to know before you call AddPlot if the variable you want to plot is currently available. Checking the return from AddPlot will let you know if it was successful, but it would be better to not pay that cost, perhaps.

I'm thinking of complex scripts where variables to be plotted may be user inputs. Here's a quick recipe to get Scalars (modified from ddcMD.py's GetVariables method)

def GetScalarVariables(db, doExpressions = 1):
    md = GetMetaData(db)
    s = []
    for i in range(md.GetNumScalars()):
        s = s + [md.GetScalars(i).name]
    if doExpressions:
        for i in range(md.exprList.GetNumExpressions()):
            e = md.exprList.GetExpressions(i)
            if(e.type == e.ScalarMeshVar):
                s = s + [e.name]
    scalars = sorted(s)
    return scalars

This quick recipe can be added to our docs, but wouldn't it be nicer to have a convenience method in visitmodule.py that could do the same thing?

biagas avatar Jun 08 '22 20:06 biagas

I might suggest that this function be expanded to support a mesh name (e.g. return variables for a given mesh) and a mask for type (e.g. return scalars and/or vectors and/or tensors)

markcmiller86 avatar Jun 28 '22 23:06 markcmiller86