[sfepy] 03/06: Rename extractor to extractor_sfepy. (Closes: #822435)

Anton Gladky gladk at moszumanska.debian.org
Tue May 3 20:00:48 UTC 2016


This is an automated email from the git hooks/post-receive script.

gladk pushed a commit to branch master
in repository sfepy.

commit 2649ad0e31f3d5f53de8497e40ab1e6059011ab9
Author: Anton Gladky <gladk at debian.org>
Date:   Tue May 3 21:38:29 2016 +0200

    Rename extractor to extractor_sfepy. (Closes: #822435)
---
 ...Rename-extractor.py-to-extractor_sfepy.py.patch | 534 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 535 insertions(+)

diff --git a/debian/patches/0001-Rename-extractor.py-to-extractor_sfepy.py.patch b/debian/patches/0001-Rename-extractor.py-to-extractor_sfepy.py.patch
new file mode 100644
index 0000000..e71a0b8
--- /dev/null
+++ b/debian/patches/0001-Rename-extractor.py-to-extractor_sfepy.py.patch
@@ -0,0 +1,534 @@
+From a2cdc8fde2c3da696589052eb2c18bdc2294e26b Mon Sep 17 00:00:00 2001
+From: Anton Gladky <gladk at debian.org>
+Date: Tue, 3 May 2016 21:09:24 +0200
+Subject: [PATCH] Rename extractor.py to extractor_sfepy.py
+
+---
+ doc/developer_guide.rst               |   2 +-
+ doc/release_notes.rst                 |  14 +--
+ doc/src/extractor.rst                 |   2 +-
+ doc/users_guide.rst                   |   2 +-
+ examples/linear_elasticity/its2D_4.py |   2 +-
+ extractor.py                          | 178 ----------------------------------
+ extractor_sfepy.py                    | 178 ++++++++++++++++++++++++++++++++++
+ setup.py                              |   2 +-
+ test_install.py                       |   2 +-
+ 9 files changed, 191 insertions(+), 191 deletions(-)
+ delete mode 100755 extractor.py
+ create mode 100755 extractor_sfepy.py
+
+diff --git a/doc/developer_guide.rst b/doc/developer_guide.rst
+index 9035c8a..a24cbbe 100644
+--- a/doc/developer_guide.rst
++++ b/doc/developer_guide.rst
+@@ -844,7 +844,7 @@ Main scripts
+ .. toctree::
+    :maxdepth: 2
+ 
+-   src/extractor
++   src/extractor_sfepy
+    src/homogen
+    src/phonon
+    src/postproc
+diff --git a/doc/release_notes.rst b/doc/release_notes.rst
+index 84ec9a9..692bdff 100644
+--- a/doc/release_notes.rst
++++ b/doc/release_notes.rst
+@@ -2112,7 +2112,7 @@ from 2013.4 to 2014.1
+   - fix typo in examples/piezo_elasticity/piezo.py
+   - fix docstring of examples/navier_stokes/stokes_slip_bc.py
+   - update test_install.py to test mesh generation/conversion scripts
+-  - update test_install.py to test probe.py, extractor.py
++  - update test_install.py to test probe.py, extractor_sfepy.py
+ 
+ - general clean up:
+ 
+@@ -3527,7 +3527,7 @@ from 2012.1 to 2012.2
+ 
+   - change default value of omit_facets to False (Mesh.from_file() etc.)
+   - update HDF5MeshIO.read_times() to return also time steps
+-  - update extract_times(), dump_to_vtk(), extractor.py for missing time steps
++  - update extract_times(), dump_to_vtk(), extractor_sfepy.py for missing time steps
+ 
+     - extraction now works with files where not all the time steps are saved
+ 
+@@ -3691,7 +3691,7 @@ from 2011.4 to 2012.1
+     - remove FieldVariable.extend_dofs(), .remove_extra_dofs(), .linearize()
+ 
+   - update recover_bones(), recover_paraflow()
+-  - extractor.py: new --linearization option
++  - extractor_sfepy.py: new --linearization option
+ 
+     - support linearization when dumping to VTK
+     - new create_problem(), parse_linearization()
+@@ -4606,7 +4606,7 @@ from 2011.2 to 2011.3
+ 
+ - scripts:
+ 
+-  - extractor.py: improve help message
++  - extractor_sfepy.py: improve help message
+   - remove sfepy_gui.py
+   - update test_install.py to report success/failure in log of times
+   - update test_install.py to test --config option
+@@ -4772,7 +4772,7 @@ from 2011.1 to 2011.2
+ 
+ - input-output:
+ 
+-  - extractor.py: new --times option
++  - extractor_sfepy.py: new --times option
+   - support for variable time steps:
+ 
+     - new extract_times()
+@@ -5485,7 +5485,7 @@ from 2010.1 to 2010.2
+ 
+   - simple.py: new --log, --quiet options
+   - postproc.py: new --wireframe, --group-names options
+-  - extractor.py: new --same-dir, --to, --step options
++  - extractor_sfepy.py: new --same-dir, --to, --step options
+   - split homogen.py:
+ 
+     - HomogenizationApp moved to sfepy/homogenization/homogen_app.py
+@@ -5597,7 +5597,7 @@ from 2009.4 to 2010.1
+ - miscellaneous updates:
+ 
+   - new --save-regions-as-groups option in simple.py
+-  - move and update functions from extractor.py into time_history.py
++  - move and update functions from extractor_sfepy.py into time_history.py
+   - Oseen solver: leave setup of stabilization parameters to user
+   - allow also 'dq', 'de' call modes in InstantaneousBase._call()
+   - split termsHyperElasticity.py to base, TL and UL parts
+diff --git a/doc/src/extractor.rst b/doc/src/extractor.rst
+index fb6ca5d..a633d60 100644
+--- a/doc/src/extractor.rst
++++ b/doc/src/extractor.rst
+@@ -1,6 +1,6 @@
+ extractor.py script
+ ===================
+ 
+-.. automodule:: extractor
++.. automodule:: extractor_sfepy
+    :members:
+    :undoc-members:
+diff --git a/doc/users_guide.rst b/doc/users_guide.rst
+index 554cfdc..b8224a2 100644
+--- a/doc/users_guide.rst
++++ b/doc/users_guide.rst
+@@ -78,7 +78,7 @@ All top-level *SfePy* scripts (applications) can be run via single
+   Simple wrapper for main SfePy commands.
+ 
+   positional arguments:
+-  {extractor,homogen,phonon,postproc,probe,run_tests,schroedinger,shaper,simple}
++  {extractor_sfepy,homogen,phonon,postproc,probe,run_tests,schroedinger,shaper,simple}
+                         Available SfePy command(s).
+   options               Additional options passed directly to selected
+                         [command].
+diff --git a/examples/linear_elasticity/its2D_4.py b/examples/linear_elasticity/its2D_4.py
+index fd860f2..57c1cd1 100644
+--- a/examples/linear_elasticity/its2D_4.py
++++ b/examples/linear_elasticity/its2D_4.py
+@@ -15,7 +15,7 @@ may need to prefix all the commands with "python " and remove "./"):
+ 
+ 3. optionally, convert results to VTK, and view again::
+ 
+-   ./extractor.py -d its2D.h5
++   ./extractor_sfepy.py -d its2D.h5
+    ./postproc.py its2D.vtk -b
+ 
+ 4. probe the data::
+diff --git a/extractor.py b/extractor.py
+deleted file mode 100755
+index d207129..0000000
+--- a/extractor.py
++++ /dev/null
+@@ -1,178 +0,0 @@
+-#!/usr/bin/env python
+-"""
+-Examples
+---------
+-
+-$ ./extractor.py -e "p e 0 1999" bone.h5
+-$ ./extractor.py -e "p e 0 1999" bone.h5 -a
+-$ ./extractor.py -e "p e 0 1999" bone.h5 -o extracted.h5
+-$ ./extractor.py -e "p e 0 1999" bone.h5 -o extracted.h5 -a
+-"""
+-import os
+-from optparse import OptionParser
+-
+-import sfepy
+-from sfepy.base.base import nm, dict_to_struct, get_default, Struct
+-from sfepy.base.ioutils import get_trunk
+-import sfepy.postprocess.time_history as th
+-
+-def create_problem(filename):
+-    from sfepy.discrete import Problem
+-
+-    problem = Problem.from_conf_file(filename,
+-                                     init_equations=False, init_solvers=False)
+-    return problem
+-
+-def parse_linearization(linearization):
+-    out = {}
+-    for item in linearization.split(','):
+-        key, val = item.split(':')
+-        if key == 'eps':
+-            val = float(val)
+-        elif key in ('min_level', 'max_level'):
+-            val = int(val)
+-        elif key == 'kind':
+-            pass
+-        else:
+-            raise ValueError('wrong linearization option key! (%s)'
+-                             % key)
+-        out[key] = val
+-
+-    return dict_to_struct(out)
+-
+-usage = """%prog [options] [<input file>] <results file>
+-
+-Extract information from a SfePy multi-time-step results file (HDF5
+-format) and/or linearize results with stored higher order DOFs.
+-
+-For the linearization, the original input (problem description) file must
+-be specified as the first argument. Use the option --linearization below
+-to override linearization parameters defined in the input file. The
+-linearization forces --dump option, i.e., output to VTK files.
+-"""
+-
+-help = {
+-    'filename' :
+-    'basename of output file(s) [default: <basename of input file>]',
+-    'dump' :
+-    'dump to sequence of VTK files',
+-    'same_dir' :
+-    'store the dumped VTK files in the directory of filename_in',
+-    'linearization' :
+-    'linearization options. Default values apply if neither command'
+-    ' line nor input file options are set.'
+-    " [default: 'kind:adaptive,min_level:0,max_level:2,eps:1e-2']",
+-    'times' :
+-    'extract and print times of individual time steps',
+-    'from' :
+-    'start dumping from time step ii [default: %default]',
+-    'to' :
+-    'stop dumping at time step ii [default: <last step>]',
+-    'step' :
+-    'use every ii-th step for dumping [default: %default]',
+-    'extract' :
+-    'extract variables according to extraction list.'
+-    " Example: 'u n 10 15, p e 0' means variable 'u' in nodes 10, 15"
+-    " and variable 'p' in element 0",
+-    'average' :
+-    'average vertex variable into cells ("e" extraction mode)'
+-}
+-
+-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()
+-
+-if __name__ == '__main__':
+-    main()
+diff --git a/extractor_sfepy.py b/extractor_sfepy.py
+new file mode 100755
+index 0000000..cca13cb
+--- /dev/null
++++ b/extractor_sfepy.py
+@@ -0,0 +1,178 @@
++#!/usr/bin/env python
++"""
++Examples
++--------
++
++$ ./extractor_sfepy.py -e "p e 0 1999" bone.h5
++$ ./extractor_sfepy.py -e "p e 0 1999" bone.h5 -a
++$ ./extractor_sfepy.py -e "p e 0 1999" bone.h5 -o extracted.h5
++$ ./extractor_sfepy.py -e "p e 0 1999" bone.h5 -o extracted.h5 -a
++"""
++import os
++from optparse import OptionParser
++
++import sfepy
++from sfepy.base.base import nm, dict_to_struct, get_default, Struct
++from sfepy.base.ioutils import get_trunk
++import sfepy.postprocess.time_history as th
++
++def create_problem(filename):
++    from sfepy.discrete import Problem
++
++    problem = Problem.from_conf_file(filename,
++                                     init_equations=False, init_solvers=False)
++    return problem
++
++def parse_linearization(linearization):
++    out = {}
++    for item in linearization.split(','):
++        key, val = item.split(':')
++        if key == 'eps':
++            val = float(val)
++        elif key in ('min_level', 'max_level'):
++            val = int(val)
++        elif key == 'kind':
++            pass
++        else:
++            raise ValueError('wrong linearization option key! (%s)'
++                             % key)
++        out[key] = val
++
++    return dict_to_struct(out)
++
++usage = """%prog [options] [<input file>] <results file>
++
++Extract information from a SfePy multi-time-step results file (HDF5
++format) and/or linearize results with stored higher order DOFs.
++
++For the linearization, the original input (problem description) file must
++be specified as the first argument. Use the option --linearization below
++to override linearization parameters defined in the input file. The
++linearization forces --dump option, i.e., output to VTK files.
++"""
++
++help = {
++    'filename' :
++    'basename of output file(s) [default: <basename of input file>]',
++    'dump' :
++    'dump to sequence of VTK files',
++    'same_dir' :
++    'store the dumped VTK files in the directory of filename_in',
++    'linearization' :
++    'linearization options. Default values apply if neither command'
++    ' line nor input file options are set.'
++    " [default: 'kind:adaptive,min_level:0,max_level:2,eps:1e-2']",
++    'times' :
++    'extract and print times of individual time steps',
++    'from' :
++    'start dumping from time step ii [default: %default]',
++    'to' :
++    'stop dumping at time step ii [default: <last step>]',
++    'step' :
++    'use every ii-th step for dumping [default: %default]',
++    'extract' :
++    'extract variables according to extraction list.'
++    " Example: 'u n 10 15, p e 0' means variable 'u' in nodes 10, 15"
++    " and variable 'p' in element 0",
++    'average' :
++    'average vertex variable into cells ("e" extraction mode)'
++}
++
++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()
++
++if __name__ == '__main__':
++    main()
+diff --git a/setup.py b/setup.py
+index 3c941d3..e646623 100644
+--- a/setup.py
++++ b/setup.py
+@@ -199,7 +199,7 @@ def setup_package():
+ 
+     data_files = main_scripts = [
+         'phonon.py',
+-        'extractor.py',
++        'extractor_sfepy.py',
+         'homogen.py',
+         'postproc.py',
+         'probe.py',
+diff --git a/test_install.py b/test_install.py
+index 3ab0141..6b85ea9 100755
+--- a/test_install.py
++++ b/test_install.py
+@@ -130,7 +130,7 @@ def main():
+     out, err = check_output('python ./simple.py examples/linear_elasticity/linear_elastic.py --format h5')
+     eok += report(out, '...', -2, 5, '4.638192e-18', eps=1e-15)
+ 
+-    out, err = check_output('python ./extractor.py -d cylinder.h5')
++    out, err = check_output('python ./extractor_sfepy.py -d cylinder.h5')
+     eok += report(out, '...', -2, 1, '...done')
+ 
+     out, err = check_output('python ./postproc.py -n --no-offscreen -o cylinder.png cylinder.h5')
+-- 
+2.8.1
+
diff --git a/debian/patches/series b/debian/patches/series
index b4e6505..21ad2a9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 01_remove_google_analytics.patch
+0001-Rename-extractor.py-to-extractor_sfepy.py.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sfepy.git



More information about the debian-science-commits mailing list