visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
412 stars 110 forks source link

CLI Convenience method to get a list of available variables #17728

Open biagas opened 2 years ago

biagas commented 2 years ago

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?

markcmiller86 commented 2 years ago

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)