Пример #1
0
def main():
    parser = OptionParser(usage=usage, version='%prog')
    parser.add_option('-l',
                      '--logarithmic',
                      action='store_true',
                      dest='logarithmic',
                      default=False,
                      help=helps['logarithmic'])
    options, args = parser.parse_args()

    if (len(args) == 1):
        filename = args[0]
    else:
        parser.print_help()
        return

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['lines.markersize'] = 9
    fontsize = 16

    steps, times, nts, dts = extract_times(filename)
    dts[-1] = nm.nan

    ax = plt.subplot(211)
    if options.logarithmic:
        l1, = ax.semilogy(steps, dts, 'b')
    else:
        l1, = ax.plot(steps, dts, 'b')
    ax.set_xlabel('step', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    ax = ax.twinx()
    l2, = ax.plot(steps, times, 'g')
    ax.set_ylabel(r'$t$', fontsize=fontsize)
    ax.legend([l1, l2], [r'$\Delta t$', r'$t$'], loc=0)

    ax = plt.subplot(212)
    if options.logarithmic:
        ax.semilogy(times, dts, 'b+')
    else:
        ax.plot(times, dts, 'b+')
    ax.set_xlabel(r'$t$', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    plt.show()
Пример #2
0
def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument('--version', action='version', version='%(prog)s')
    parser.add_argument('-l',
                        '--logarithmic',
                        action='store_true',
                        dest='logarithmic',
                        default=False,
                        help=helps['logarithmic'])
    parser.add_argument('filename')
    options = parser.parse_args()

    filename = options.filename

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['lines.markersize'] = 9
    fontsize = 16

    steps, times, nts, dts = extract_times(filename)
    dts[-1] = nm.nan

    ax = plt.subplot(211)
    if options.logarithmic:
        l1, = ax.semilogy(steps, dts, 'b')
    else:
        l1, = ax.plot(steps, dts, 'b')
    ax.set_xlabel('step', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    ax = ax.twinx()
    l2, = ax.plot(steps, times, 'g')
    ax.set_ylabel(r'$t$', fontsize=fontsize)
    ax.legend([l1, l2], [r'$\Delta t$', r'$t$'], loc=0)

    ax = plt.subplot(212)
    if options.logarithmic:
        ax.semilogy(times, dts, 'b+')
    else:
        ax.plot(times, dts, 'b+')
    ax.set_xlabel(r'$t$', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    plt.show()
Пример #3
0
def main():
    parser = OptionParser(usage=usage, version='%prog')
    parser.add_option('-l', '--logarithmic',
                      action='store_true', dest='logarithmic',
                      default=False, help=helps['logarithmic'])
    options, args = parser.parse_args()

    if (len(args) == 1):
        filename = args[0]
    else:
        parser.print_help()
        return

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['lines.markersize'] = 9
    fontsize = 16

    steps, times, nts, dts = extract_times(filename)
    dts[-1] = nm.nan

    ax = plt.subplot(211)
    if options.logarithmic:
        l1, = ax.semilogy(steps, dts, 'b')
    else:
        l1, = ax.plot(steps, dts, 'b')
    ax.set_xlabel('step', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    ax = ax.twinx()
    l2, = ax.plot(steps, times, 'g')
    ax.set_ylabel(r'$t$', fontsize=fontsize)
    ax.legend([l1, l2], [r'$\Delta t$', r'$t$'], loc=0)

    ax = plt.subplot(212)
    if options.logarithmic:
        ax.semilogy(times, dts, 'b+')
    else:
        ax.plot(times, dts, 'b+')
    ax.set_xlabel(r'$t$', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    plt.show()
Пример #4
0
def main():
    parser = OptionParser(usage=usage, version="%prog")
    parser.add_option(
        "-l", "--logarithmic", action="store_true", dest="logarithmic", default=False, help=helps["logarithmic"]
    )
    options, args = parser.parse_args()

    if len(args) == 1:
        filename = args[0]
    else:
        parser.print_help()
        return

    plt.rcParams["lines.linewidth"] = 3
    plt.rcParams["lines.markersize"] = 9
    fontsize = 16

    steps, times, nts, dts = extract_times(filename)
    dts[-1] = nm.nan

    ax = plt.subplot(211)
    if options.logarithmic:
        l1, = ax.semilogy(steps, dts, "b")
    else:
        l1, = ax.plot(steps, dts, "b")
    ax.set_xlabel("step", fontsize=fontsize)
    ax.set_ylabel(r"$\Delta t$", fontsize=fontsize)
    ax.grid(True)

    ax = ax.twinx()
    l2, = ax.plot(steps, times, "g")
    ax.set_ylabel(r"$t$", fontsize=fontsize)
    ax.legend([l1, l2], [r"$\Delta t$", r"$t$"], loc=0)

    ax = plt.subplot(212)
    if options.logarithmic:
        ax.semilogy(times, dts, "b+")
    else:
        ax.plot(times, dts, "b+")
    ax.set_xlabel(r"$t$", fontsize=fontsize)
    ax.set_ylabel(r"$\Delta t$", fontsize=fontsize)
    ax.grid(True)

    plt.show()
Пример #5
0
def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument('--version', action='version', version='%(prog)s')
    parser.add_argument('-l', '--logarithmic',
                        action='store_true', dest='logarithmic',
                        default=False, help=helps['logarithmic'])
    parser.add_argument('filename')
    options = parser.parse_args()

    filename = options.filename

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['lines.markersize'] = 9
    fontsize = 16

    steps, times, nts, dts = extract_times(filename)
    dts[-1] = nm.nan

    ax = plt.subplot(211)
    if options.logarithmic:
        l1, = ax.semilogy(steps, dts, 'b')
    else:
        l1, = ax.plot(steps, dts, 'b')
    ax.set_xlabel('step', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    ax = ax.twinx()
    l2, = ax.plot(steps, times, 'g')
    ax.set_ylabel(r'$t$', fontsize=fontsize)
    ax.legend([l1, l2], [r'$\Delta t$', r'$t$'], loc=0)

    ax = plt.subplot(212)
    if options.logarithmic:
        ax.semilogy(times, dts, 'b+')
    else:
        ax.plot(times, dts, 'b+')
    ax.set_xlabel(r'$t$', fontsize=fontsize)
    ax.set_ylabel(r'$\Delta t$', fontsize=fontsize)
    ax.grid(True)

    plt.show()
Пример #6
0
def main():
    parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
    parser.add_option('-o',
                      '',
                      metavar='filename',
                      action='store',
                      dest='output_filename_trunk',
                      default=None,
                      help=help['filename'])
    parser.add_option('-d',
                      '--dump',
                      action='store_true',
                      dest='dump',
                      default=False,
                      help=help['dump'])
    parser.add_option('',
                      '--same-dir',
                      action='store_true',
                      dest='same_dir',
                      default=False,
                      help=help['same_dir'])
    parser.add_option('-l',
                      '--linearization',
                      metavar='options',
                      action='store',
                      dest='linearization',
                      default=None,
                      help=help['linearization'])
    parser.add_option('',
                      '--times',
                      action='store_true',
                      dest='times',
                      default=False,
                      help=help['times'])
    parser.add_option('-f',
                      '--from',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_from',
                      default=0,
                      help=help['from'])
    parser.add_option('-t',
                      '--to',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_to',
                      default=None,
                      help=help['to'])
    parser.add_option('-s',
                      '--step',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_by',
                      default=1,
                      help=help['step'])
    parser.add_option('-e',
                      '--extract',
                      metavar='list',
                      action='store',
                      dest='extract',
                      default=None,
                      help=help['extract'])
    parser.add_option('-a',
                      '--average',
                      action='store_true',
                      dest='average',
                      default=False,
                      help=help['average'])

    (options, args) = parser.parse_args()

    nargs = len(args)
    if nargs == 1:
        filename_results = args[0]
        linearize = False

    elif nargs == 2:
        filename_in, filename_results = args
        linearize = True
        options.dump = True

    else:
        parser.print_help()
        return

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print '%d %e %e %e' % (step, time, nts[ii], dts[ii])

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive',
                                   min_level=0,
                                   max_level=2,
                                   eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({
                'fields': problem.fields,
                'linearization': linearization
            })

        if options.step_to is None:
            args.update({'step0': options.step_from})

        else:
            args.update({
                'steps':
                nm.arange(options.step_from,
                          options.step_to + 1,
                          options.step_by,
                          dtype=nm.int)
            })

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts,
                                 options.output_filename_trunk + '.h5')

        else:
            print dict_to_struct(ths, flag=(1, 1, 1)).str_all()
Пример #7
0
def main():
    parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
    parser.add_option('-o', '', metavar='filename',
                      action='store', dest='output_filename_trunk',
                      default=None, help=help['filename'])
    parser.add_option('-d', '--dump', action='store_true', dest='dump',
                       default=False, help=help['dump'])
    parser.add_option('', '--same-dir', action='store_true', dest='same_dir',
                      default=False, help=help['same_dir'])
    parser.add_option('-l', '--linearization', metavar='options',
                      action='store', dest='linearization',
                      default=None, help=help['linearization'])
    parser.add_option('', '--times', action='store_true', dest='times',
                      default=False, help=help['times'])
    parser.add_option('-f', '--from', type=int, metavar='ii',
                      action='store', dest='step_from',
                      default=0, help=help['from'])
    parser.add_option('-t', '--to', type=int, metavar='ii',
                      action='store', dest='step_to',
                      default=None, help=help['to'])
    parser.add_option('-s', '--step', type=int, metavar='ii',
                      action='store', dest='step_by',
                      default=1, help=help['step'])
    parser.add_option('-e', '--extract', metavar='list',
                      action='store', dest='extract',
                      default=None, help=help['extract'])
    parser.add_option('-a', '--average', action='store_true', dest='average',
                      default=False, help=help['average'])

    (options, args) = parser.parse_args()

    nargs = len(args)
    if nargs == 1:
        filename_results = args[0]
        linearize = False

    elif nargs == 2:
        filename_in, filename_results = args
        linearize = True
        options.dump = True

    else:
        parser.print_help()
        return

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print('%d %e %e %e' % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive', min_level=0,
                                   max_level=2, eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({'fields' : problem.fields,
                         'linearization' : linearization})

        if options.step_to is None:
            args.update({'step0' : options.step_from})

        else:
            args.update({'steps' : nm.arange(options.step_from,
                                             options.step_to + 1,
                                             options.step_by, dtype=nm.int)})

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts, options.output_filename_trunk + '.h5')

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
Пример #8
0
def main():
    parser = ArgumentParser(description=__doc__,
                            formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + sfepy.__version__)
    parser.add_argument('--debug',
                        action='store_true',
                        dest='debug',
                        default=False,
                        help=helps['debug'])
    parser.add_argument('-o',
                        metavar='filename',
                        action='store',
                        dest='output_filename_trunk',
                        default=None,
                        help=helps['filename'])
    parser.add_argument('-d',
                        '--dump',
                        action='store_true',
                        dest='dump',
                        default=False,
                        help=helps['dump'])
    parser.add_argument('--same-dir',
                        action='store_true',
                        dest='same_dir',
                        default=False,
                        help=helps['same_dir'])
    parser.add_argument('-l',
                        '--linearization',
                        metavar='options',
                        action='store',
                        dest='linearization',
                        default=None,
                        help=helps['linearization'])
    parser.add_argument('--times',
                        action='store_true',
                        dest='times',
                        default=False,
                        help=helps['times'])
    parser.add_argument('-f',
                        '--from',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_from',
                        default=0,
                        help=helps['from'])
    parser.add_argument('-t',
                        '--to',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_to',
                        default=None,
                        help=helps['to'])
    parser.add_argument('-s',
                        '--step',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_by',
                        default=1,
                        help=helps['step'])
    parser.add_argument('-e',
                        '--extract',
                        metavar='list',
                        action='store',
                        dest='extract',
                        default=None,
                        help=helps['extract'])
    parser.add_argument('-a',
                        '--average',
                        action='store_true',
                        dest='average',
                        default=False,
                        help=helps['average'])
    parser.add_argument('input_file', nargs='?', default=None)
    parser.add_argument('results_file')
    options = parser.parse_args()

    if options.debug:
        from sfepy.base.base import debug_on_error
        debug_on_error()

    filename_in = options.input_file
    filename_results = options.results_file

    if filename_in is None:
        linearize = False
    else:
        linearize = True
        options.dump = True

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print('%d %e %e %e' % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive',
                                   min_level=0,
                                   max_level=2,
                                   eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({
                'fields': problem.fields,
                'linearization': linearization
            })

        if options.step_to is None:
            args.update({'step0': options.step_from})

        else:
            args.update({
                'steps':
                nm.arange(options.step_from,
                          options.step_to + 1,
                          options.step_by,
                          dtype=nm.int)
            })

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts,
                                 options.output_filename_trunk + '.h5')

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
Пример #9
0
def main():
    parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument("--version", action="version", version="%(prog)s " + sfepy.__version__)
    parser.add_argument("--debug", action="store_true", dest="debug", default=False, help=helps["debug"])
    parser.add_argument(
        "-o", metavar="filename", action="store", dest="output_filename_trunk", default=None, help=helps["filename"]
    )
    parser.add_argument("-d", "--dump", action="store_true", dest="dump", default=False, help=helps["dump"])
    parser.add_argument("--same-dir", action="store_true", dest="same_dir", default=False, help=helps["same_dir"])
    parser.add_argument(
        "-l",
        "--linearization",
        metavar="options",
        action="store",
        dest="linearization",
        default=None,
        help=helps["linearization"],
    )
    parser.add_argument("--times", action="store_true", dest="times", default=False, help=helps["times"])
    parser.add_argument(
        "-f", "--from", type=int, metavar="ii", action="store", dest="step_from", default=0, help=helps["from"]
    )
    parser.add_argument(
        "-t", "--to", type=int, metavar="ii", action="store", dest="step_to", default=None, help=helps["to"]
    )
    parser.add_argument(
        "-s", "--step", type=int, metavar="ii", action="store", dest="step_by", default=1, help=helps["step"]
    )
    parser.add_argument(
        "-e", "--extract", metavar="list", action="store", dest="extract", default=None, help=helps["extract"]
    )
    parser.add_argument("-a", "--average", action="store_true", dest="average", default=False, help=helps["average"])
    parser.add_argument("input_file", nargs="?", default=None)
    parser.add_argument("results_file")
    options = parser.parse_args()

    if options.debug:
        from sfepy.base.base import debug_on_error

        debug_on_error()

    filename_in = options.input_file
    filename_results = options.results_file

    if filename_in is None:
        linearize = False
    else:
        linearize = True
        options.dump = True

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print("%d %e %e %e" % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk, get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results), os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind="adaptive", min_level=0, max_level=2, eps=1e-2)
            aux = problem.conf.options.get("linearization", None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({"fields": problem.fields, "linearization": linearization})

        if options.step_to is None:
            args.update({"step0": options.step_from})

        else:
            args.update({"steps": nm.arange(options.step_from, options.step_to + 1, options.step_by, dtype=nm.int)})

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts, options.output_filename_trunk + ".h5")

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())