def autorg(filename, mininterval=None, qminrg=None, qmaxrg=None, noprint=True):
if isinstance(filename, Curve):<EOL><INDENT>curve = filename<EOL>with tempfile.NamedTemporaryFile('<STR_LIT>',<EOL>delete=False) as f:<EOL><INDENT>curve.save(f)<EOL>filename = f.name<EOL><DEDENT><DEDENT>cmdline = ['<STR_LIT>', filename, '<STR_LIT>', '<STR_LIT>']<EOL>if mininterval is not None:<EOL><INDENT>cmdline.extend(['<STR_LIT>', str(mininterval)])<EOL><DEDENT>if qminrg is not None:<EOL><INDENT>cmdline.extend(['<STR_LIT>', str(qminrg)])<EOL><DEDENT>if qmaxrg is not None:<EOL><INDENT>cmdline.extend(['<STR_LIT>', str(qmaxrg)])<EOL><DEDENT>result = execute_command(cmdline, noprint=noprint)<EOL>Rg, dRg, I0, dI0, idxfirst, idxlast, quality, aggregation, filename = result[<NUM_LIT:0>].split(None, <NUM_LIT:8>)<EOL>try:<EOL><INDENT>curve<EOL><DEDENT>except NameError:<EOL><INDENT>curve = Curve.new_from_file(filename)<EOL><DEDENT>else:<EOL><INDENT>os.unlink(filename)<EOL><DEDENT>return ErrorValue(float(Rg), float(dRg)), ErrorValue(float(I0), float(dI0)), curve.q[int(idxfirst) - <NUM_LIT:1>], curve.q[<EOL>int(idxlast) - <NUM_LIT:1>], float(quality), float(aggregation)<EOL>
Execute autorg.

    Inputs:
        filename: either a name of an ascii file, or an instance of Curve.
        mininterval: the minimum number of points in the Guinier range
        qminrg: the maximum value of qmin*Rg. Default of autorg is 1.0
        qmaxrg: the maximum value of qmax*Rg. Default of autorg is 1.3
        noprint: if the output of autorg should be redirected to the null 
            device.

    Outputs:
        Rg as an ErrorValue
        I0 as an ErrorValue
        qmin: the lower end of the chosen Guinier range
        qmax: the upper end of the chosen Guinier range
        quality: the quality parameter, between 0 and 1
        aggregation: float, the extent of aggregation