<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.uni-due.de/agk/index.php?action=history&amp;feed=atom&amp;title=Dbl-dump</id>
	<title>Dbl-dump - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.uni-due.de/agk/index.php?action=history&amp;feed=atom&amp;title=Dbl-dump"/>
	<link rel="alternate" type="text/html" href="https://wiki.uni-due.de/agk/index.php?title=Dbl-dump&amp;action=history"/>
	<updated>2026-08-10T08:53:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.uni-due.de/agk/index.php?title=Dbl-dump&amp;diff=1338&amp;oldid=prev</id>
		<title>Lothar.brendel: new</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-due.de/agk/index.php?title=Dbl-dump&amp;diff=1338&amp;oldid=prev"/>
		<updated>2026-07-20T13:51:18Z</updated>

		<summary type="html">&lt;p&gt;new&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The script can be useful e.g. when plotting data from the dbl-files on the fly. It reads 1D or 2D dbl-files from a &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;-directory and writes an ASCII table to stdout. More than one dbl-file (from the same grid) can be specified as arguments, producing a table with more than two columns.&lt;br /&gt;
&lt;br /&gt;
The first argument is a &amp;quot;selector&amp;quot; specifying the location of the cut in the 2D case: &amp;#039;&amp;#039;ix1&amp;#039;&amp;#039;&amp;lt;code&amp;gt;,&amp;lt;/code&amp;gt; or just &amp;#039;&amp;#039;ix1&amp;#039;&amp;#039; yields a cut with fixed \(x_1\)-coordinate, while &amp;lt;code&amp;gt;,&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;ix2&amp;#039;&amp;#039; produces one with fixed \(x_2\)-coordinate. The integers &amp;#039;&amp;#039;ix1&amp;#039;&amp;#039; and &amp;#039;&amp;#039;ix2&amp;#039;&amp;#039;, respectively, denote the corresponding cell-number. (In the 1D case, the selector can be any character.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; copy&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3                                                                                                                                                                        &lt;br /&gt;
&lt;br /&gt;
# L.B. 2026                                                                                                                                                                                   &lt;br /&gt;
&lt;br /&gt;
import os&lt;br /&gt;
from sys import argv,stdout,stderr&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
if len(argv) &amp;lt; 3:&lt;br /&gt;
    print(f&amp;quot;usage: {os.path.basename(argv[0])} &amp;lt;selector&amp;gt; &amp;lt;dbl-file1&amp;gt; ...&amp;quot;,file=stderr)&lt;br /&gt;
    exit(1)&lt;br /&gt;
&lt;br /&gt;
sel = argv[1].split(&amp;#039;,&amp;#039;)&lt;br /&gt;
dbl_fn = argv[2]&lt;br /&gt;
dbl_dir = os.path.dirname(dbl_fn)&lt;br /&gt;
if not dbl_dir:&lt;br /&gt;
    dbl_dir=&amp;quot;.&amp;quot;&lt;br /&gt;
grid_fn = dbl_dir+&amp;quot;/grid.out&amp;quot;&lt;br /&gt;
time_fn = dbl_dir+&amp;quot;/dbl.out&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# parse &amp;quot;dbl.out&amp;quot; for time                                                                                                                                                                    &lt;br /&gt;
t = {}&lt;br /&gt;
with open(time_fn) as time:&lt;br /&gt;
    for line in time:&lt;br /&gt;
        line = line.split()&lt;br /&gt;
        t[int(line[0])] = float(line[1])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# pre-parse &amp;quot;grid.out&amp;quot;                                                                                                                                                                        &lt;br /&gt;
with open(grid_fn) as grid:&lt;br /&gt;
    dims = 0&lt;br /&gt;
    shape = []&lt;br /&gt;
    skip = []&lt;br /&gt;
    for k,line in enumerate(grid):&lt;br /&gt;
        if line[0] == &amp;quot;#&amp;quot;:&lt;br /&gt;
            if &amp;quot;DIMENSIONS&amp;quot; in line:&lt;br /&gt;
                dims = int(line.split()[-1])&lt;br /&gt;
        elif line[0] in &amp;quot;0123456789&amp;quot;:&lt;br /&gt;
            line = line.split()&lt;br /&gt;
            if len(line) == 1 and line[0] != &amp;quot;1&amp;quot;:&lt;br /&gt;
                skip.append(k+1)&lt;br /&gt;
                shape.append(int(line[0]))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# read grid from &amp;quot;grid.out&amp;quot;                                                                                                                                                                   &lt;br /&gt;
pos = []&lt;br /&gt;
for skip,n in zip(skip,shape):&lt;br /&gt;
    axis = np.loadtxt(grid_fn,skiprows=skip,max_rows=n)&lt;br /&gt;
    pos.append(axis[:,1:].mean(1))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# read data file(s)                                                                                                                                                                           &lt;br /&gt;
for dbl_fn in argv[2:]:&lt;br /&gt;
&lt;br /&gt;
    data = np.fromfile(dbl_fn,dtype=&amp;quot;&amp;lt;f8&amp;quot;).reshape(list(reversed(shape))).transpose()&lt;br /&gt;
&lt;br /&gt;
    it = int(dbl_fn.split(&amp;#039;.&amp;#039;)[-2])&lt;br /&gt;
    header = f&amp;quot;# {os.path.basename(dbl_fn)}\n# t = {t[it]}\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    if dims==1:&lt;br /&gt;
        data = np.vstack((pos[0],data)).transpose()&lt;br /&gt;
    elif dims==2:&lt;br /&gt;
        if len(sel)==1 or sel[1]==&amp;quot;&amp;quot;:  # f(y), x fixed                                                                                                                                        &lt;br /&gt;
            ix1 = int(sel[0])&lt;br /&gt;
            header += f&amp;quot;# x1 = {pos[0][ix1]}&amp;quot;&lt;br /&gt;
            data = np.vstack((pos[1],data[ix1])).transpose()&lt;br /&gt;
        else:&lt;br /&gt;
            ix2 = int(sel[1])&lt;br /&gt;
            header += f&amp;quot;# x2 = {pos[1][ix2]}&amp;quot;&lt;br /&gt;
            data = np.vstack((pos[0],data[:,ix2])).transpose()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f&amp;quot;{argv[0]}: {dbl_fn} is on a {dims}D grid, can only handle 1D and 2D.&amp;quot;,file=stderr)&lt;br /&gt;
        exit(1)&lt;br /&gt;
&lt;br /&gt;
    print(header)&lt;br /&gt;
    np.savetxt(stdout,data,delimiter=&amp;#039;\t&amp;#039;)&lt;br /&gt;
    print()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lothar.brendel</name></author>
	</entry>
</feed>