0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

displaySingleInitFieldY_170422.ipynb > v0.1-v0.3

Last updated at Posted at 2017-04-21
Environment
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)

data preparation

$ ./adda -grid 25 -store_int_field -maxiter 3000

Then make the symbolic link for the IntField-Y file into the directory where you will use the following Jupyter code.

code v0.1

Jupyter code.

This code shows single result from InitFieldY for a given index of the Z coordinate value.

displaySingleInitFieldY_170422.ipynb
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import sys


'''
v0.1 Apr. 22, 2017
   - show one result only
      + add show_single()
      + remove show_group()
=== branched from [displayInitFieldY_170419.ipynb] ===
v0.4 Apr. 20, 2017
   - show [Ex.r], [Ex.i], [Ey.r], [Er.i], [Ez.r], [Ez.i]
v0.3 Apr. 20, 2017
   - display for various [zz] values
   - add show_xymap()
v0.2 Apr. 20, 2017
   - set [PICK_UP_ZZ_VALUE] from zz_unique[]
   - use [ALLOWABLE_DIFF_ZZ]
v0.1 Apr. 19, 2017
   - display Ex.r[] without limiting [PICK_UP_ZZ_VALUE]
'''
# codingrule:PEP8

data = np.genfromtxt('IntField-Y', delimiter=' ')
xs, ys, zs = data[1:, 0], data[1:, 1], data[1:, 2]
Exr, Exi = data[1:, 4], data[2:, 4]
Eyr, Eyi = data[3:, 4], data[4:, 4]
Ezr, Ezi = data[5:, 4], data[6:, 4]

# print(zs)
zz_unique = np.unique(zs)
print(len(zz_unique))
print(zz_unique)
plt_y1 = np.array([])


def show_xymap(pick_up_zz, target):
    SIZE_MAP_X, SIZE_MAP_Y = 30, 30
    MIN_X, MIN_Y = -6, -6  # -6: based on coordinate values
    RANGE_X = 6 - MIN_X  # 6: based on coordinate values
    RANGE_Y = 6 - MIN_Y  # 6: based on coordinate values
    rmap = [[0.0 for yi in range(SIZE_MAP_Y)] for xi in range(SIZE_MAP_X)]

    # instead of [sys.float_info.epsilon], which is 2.22044604925e-16
    ALLOWABLE_DIFF_ZZ = 1.0e-10

    for idx, xyz in enumerate(zip(xs, ys, zs)):
        xx, yy, zz = xyz
        if abs(zz - pick_up_zz) >= ALLOWABLE_DIFF_ZZ:
            continue
        xidx = int(SIZE_MAP_X * (xx - MIN_X) / RANGE_X)
        yidx = int(SIZE_MAP_Y * (yy - MIN_Y) / RANGE_Y)
        #rmap[xidx][yidx] = Exr[idx]
        rmap[xidx][yidx] = target[idx]

    wrkarr = np.array(rmap)
    figmap = np.reshape(wrkarr, (SIZE_MAP_X, SIZE_MAP_Y))
    plt.imshow(figmap, extent=(0, SIZE_MAP_X, 0, SIZE_MAP_Y), cmap=cm.jet)


def show_single(atarget, index):
    show_xymap(zz_unique[index], atarget)
    plt.tight_layout()
    plt.show()

print('Ex.r[12]')
show_group(Exr, 12)

print('Ey.i[16]')
show_group(Eyi, 16)

print('Ez.r[8]')
show_group(Ezr, 8)

result

qiita.png

qiita.png

qiita.png

v0.2 > show colorbar

v0.3 > fix bug for artifacts by map size

displaySingleInitFieldY_170422.ipynb
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import sys


'''
v0.3 Apr. 22, 2017
   - change display map size from [30,30] to [25,25]
v0.2 Apr. 22, 2017
   - show colorbar
v0.1 Apr. 22, 2017
   - show one result only
      + add show_single()
      + remove show_group()
=== branched from [displayInitFieldY_170419.ipynb] ===
v0.4 Apr. 20, 2017
   - show [Ex.r], [Ex.i], [Ey.r], [Er.i], [Ez.r], [Ez.i]
v0.3 Apr. 20, 2017
   - display for various [zz] values
   - add show_xymap()
v0.2 Apr. 20, 2017
   - set [PICK_UP_ZZ_VALUE] from zz_unique[]
   - use [ALLOWABLE_DIFF_ZZ]
v0.1 Apr. 19, 2017
   - display Ex.r[] without limiting [PICK_UP_ZZ_VALUE]
'''
# codingrule:PEP8

data = np.genfromtxt('IntField-Y', delimiter=' ')
xs, ys, zs = data[1:, 0], data[1:, 1], data[1:, 2]
Exr, Exi = data[1:, 4], data[2:, 4]
Eyr, Eyi = data[3:, 4], data[4:, 4]
Ezr, Ezi = data[5:, 4], data[6:, 4]

# print(zs)
zz_unique = np.unique(zs)
print(len(zz_unique))
print(zz_unique)
plt_y1 = np.array([])


def show_xymap(pick_up_zz, target):
    SIZE_MAP_X, SIZE_MAP_Y = 25, 25
    MIN_X, MIN_Y = -6, -6  # -6: based on coordinate values
    RANGE_X = 6 - MIN_X  # 6: based on coordinate values
    RANGE_Y = 6 - MIN_Y  # 6: based on coordinate values
    rmap = [[0.0 for yi in range(SIZE_MAP_Y)] for xi in range(SIZE_MAP_X)]

    # instead of [sys.float_info.epsilon], which is 2.22044604925e-16
    ALLOWABLE_DIFF_ZZ = 1.0e-10

    for idx, xyz in enumerate(zip(xs, ys, zs)):
        xx, yy, zz = xyz
        if abs(zz - pick_up_zz) >= ALLOWABLE_DIFF_ZZ:
            continue
        xidx = int(SIZE_MAP_X * (xx - MIN_X) / RANGE_X)
        yidx = int(SIZE_MAP_Y * (yy - MIN_Y) / RANGE_Y)
        #rmap[xidx][yidx] = Exr[idx]
        rmap[xidx][yidx] = target[idx]

    wrkarr = np.array(rmap)
    figmap = np.reshape(wrkarr, (SIZE_MAP_X, SIZE_MAP_Y))
    plt.imshow(figmap, extent=(0, SIZE_MAP_X, 0, SIZE_MAP_Y), cmap=cm.jet)
    plt.colorbar()

def show_single(atarget, index):
    show_xymap(zz_unique[index], atarget)
    plt.tight_layout()
    plt.show()

print('Ex.r[12]')
show_group(Exr, 12)

print('Ey.i[16]')
show_group(Eyi, 16)

print('Ez.r[8]')
show_group(Ezr, 8)

qiita.png

v0.4 > fix bug > NameError: name 'show_group' is not defined

displaySingleInitFieldY_170422.ipynb
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import sys


'''
v0.4 Jun. 03, 2017
    - fix bug > NameError: name 'show_group' is not defined
v0.3 Apr. 22, 2017
   - change display map size from [30,30] to [25,25]
v0.2 Apr. 22, 2017
   - show colorbar
v0.1 Apr. 22, 2017
   - show one result only
      + add show_single()
      + remove show_group()
=== branched from [displayInitFieldY_170419.ipynb] ===
v0.4 Apr. 20, 2017
   - show [Ex.r], [Ex.i], [Ey.r], [Er.i], [Ez.r], [Ez.i]
v0.3 Apr. 20, 2017
   - display for various [zz] values
   - add show_xymap()
v0.2 Apr. 20, 2017
   - set [PICK_UP_ZZ_VALUE] from zz_unique[]
   - use [ALLOWABLE_DIFF_ZZ]
v0.1 Apr. 19, 2017
   - display Ex.r[] without limiting [PICK_UP_ZZ_VALUE]
'''
# codingrule:PEP8

data = np.genfromtxt('IntField-Y', delimiter=' ')
xs, ys, zs = data[1:, 0], data[1:, 1], data[1:, 2]
Exr, Exi = data[1:, 4], data[2:, 4]
Eyr, Eyi = data[3:, 4], data[4:, 4]
Ezr, Ezi = data[5:, 4], data[6:, 4]

# print(zs)
zz_unique = np.unique(zs)
print(len(zz_unique))
print(zz_unique)
plt_y1 = np.array([])


def show_xymap(pick_up_zz, target):
    SIZE_MAP_X, SIZE_MAP_Y = 25, 25
    MIN_X, MIN_Y = -6, -6  # -6: based on coordinate values
    RANGE_X = 6 - MIN_X  # 6: based on coordinate values
    RANGE_Y = 6 - MIN_Y  # 6: based on coordinate values
    rmap = [[0.0 for yi in range(SIZE_MAP_Y)] for xi in range(SIZE_MAP_X)]

    # instead of [sys.float_info.epsilon], which is 2.22044604925e-16
    ALLOWABLE_DIFF_ZZ = 1.0e-10

    for idx, xyz in enumerate(zip(xs, ys, zs)):
        xx, yy, zz = xyz
        if abs(zz - pick_up_zz) >= ALLOWABLE_DIFF_ZZ:
            continue
        xidx = int(SIZE_MAP_X * (xx - MIN_X) / RANGE_X)
        yidx = int(SIZE_MAP_Y * (yy - MIN_Y) / RANGE_Y)
        #rmap[xidx][yidx] = Exr[idx]
        rmap[xidx][yidx] = target[idx]

    wrkarr = np.array(rmap)
    figmap = np.reshape(wrkarr, (SIZE_MAP_X, SIZE_MAP_Y))
    plt.imshow(figmap, extent=(0, SIZE_MAP_X, 0, SIZE_MAP_Y), cmap=cm.jet)
    plt.colorbar()

def show_single(atarget, index):
    show_xymap(zz_unique[index], atarget)
    plt.tight_layout()
    plt.show()

print('Ex.r[12]')
show_single(Exr, 12)

print('Ey.i[16]')
show_single(Eyi, 16)

print('Ez.r[8]')
show_single(Ezr, 8)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?