def shanum(filename, dmax=None, noprint=True):
if isinstance(filename, Curve):<EOL><INDENT>curve = filename<EOL>with tempfile.NamedTemporaryFile('<STR_LIT>', delete=False) as f:<EOL><INDENT>curve.save(f)<EOL>filename = f.name<EOL><DEDENT><DEDENT>cmdline = ['<STR_LIT>', filename]<EOL>if dmax is not None:<EOL><INDENT>cmdline.append(str(float(dmax)))<EOL><DEDENT>result = execute_command(cmdline, noprint=noprint)<EOL>for l in result:<EOL><INDENT>l = l.strip()<EOL>if l.startswith('<STR_LIT>'):<EOL><INDENT>dmax = float(l.split('<STR_LIT:=>')[<NUM_LIT:1>])<EOL><DEDENT>elif l.startswith('<STR_LIT>'):<EOL><INDENT>qmax = float(l.split('<STR_LIT:=>')[<NUM_LIT:1>])<EOL><DEDENT>elif l.startswith('<STR_LIT>'):<EOL><INDENT>nsh = float(l.split('<STR_LIT:=>')[<NUM_LIT:1>])<EOL><DEDENT>elif l.startswith('<STR_LIT>'):<EOL><INDENT>nopt = float(l.split('<STR_LIT:=>')[<NUM_LIT:1>])<EOL><DEDENT>elif l.startswith('<STR_LIT>'):<EOL><INDENT>qmaxopt = float(l.split('<STR_LIT:=>')[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>return dmax, nsh, nopt, qmaxopt<EOL>
Execute the shanum program to determine the optimum qmax
    according to an estimation of the optimum number of Shannon
    channels.

    Inputs:
        filename: either a name of an ascii file, or an instance
            of Curve
        dmax: the cut-off of the P(r) function, if known. If None,
            this will be determined by the shanum program
        noprint: if the printout of the program is to be suppressed.

    Outputs: dmax, nsh, nopt, qmaxopt
        dmax: the cut-off of the P(r) function.
        nsh: the estimated number of Shannon channels
        nopt: the optimum number of Shannon channels
        qmaxopt: the optimum value of the high-q cutoff