Commit 1fe1a535 authored by Michele Compostella's avatar Michele Compostella
Browse files

Visualization of single frame

parent 269830b7
#####################################################################################################
## Copyright (C) 2019 Udo von Toussaint, F. J. Dominguez-Gutierrez, Markus Rampp, Michele Compostella
## Copyright (C) 2020 Udo von Toussaint, F. J. Dominguez-Gutierrez, Michele Compostella, Markus Rampp
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
......@@ -19,7 +19,7 @@
#####################################################################################################
##
## General Notes:
## FaVa: Fingerprint And VisuAlization. Version: 1.0
## FaVaD: Fingerprint And VisuAlization of Defects. Version: 1.0
## This software provides a workflow for fingerprinting and visualizing defects in damaged crystal
## structures. The theoretical background is presented in: paper_ID
##
......@@ -446,10 +446,10 @@ print("Visualizing results with VISIT")
print()
# Setting parameters in the visualization script
cmd = 'sed -i "18s|.*|input_s = \''+str(param['OUTPUT_PATH'])+f_name+'\' |" '+str(param['VISIT_SCRIPT'])
cmd = 'sed -i "33s|.*|input_s = \''+str(param['OUTPUT_PATH'])+f_name+'\' |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
cmd = 'sed -i "19s|.*|input_v = \''+out_grid+'\' |" '+str(param['VISIT_SCRIPT'])
cmd = 'sed -i "34s|.*|input_v = \''+out_grid+'\' |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
out_frames = str(param['OUTPUT_PATH'])+'visualization/'
......@@ -460,12 +460,23 @@ except FileExistsError:
print("\nWarning: output/frames directory exists. Frames will be overwritten.")
input(" Press Enter to continue.")
print()
cmd = 'sed -i "20s|.*|out_dir = \''+out_frames+'\' |" '+str(param['VISIT_SCRIPT'])
cmd = 'sed -i "35s|.*|out_dir = \''+out_frames+'\' |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
cmd = 'sed -i "21s|.*|out_name = \''+str(param['VIS_NAME'])+'\' |" '+str(param['VISIT_SCRIPT'])
cmd = 'sed -i "36s|.*|out_name = \''+str(param['VIS_NAME'])+'\' |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
if (param['MOVIE_CREATION'] == "True"):
cmd = 'sed -i "38s|.*|fading = True |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
cmd = 'sed -i "39s|.*|n_frames = 360 |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
else:
cmd = 'sed -i "38s|.*|fading = False |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
cmd = 'sed -i "39s|.*|n_frames = 1 |" '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
# Running VisIt
cmd = str(param['VISIT_PATH'])+' -cli -nowin -s '+str(param['VISIT_SCRIPT'])
subprocess.call(cmd,shell=True)
......@@ -476,19 +487,34 @@ cmd = 'rm -f '+str(current)+'/visitlog.py'
subprocess.call(cmd,shell=True)
################
# Movie Creation
################
print("Creating movie")
print()
#############################
# Single frame/Movie Creation
#############################
# Creating movie using bash script
cmd = str(param['MOVIE_SCRIPT'])+' '+out_frames+' '+str(param['VIS_NAME'])
subprocess.call(cmd,shell=True)
if (param['MOVIE_CREATION'] == "True"):
print("Creating movie")
print()
# Creating movie using bash script
cmd = str(param['MOVIE_SCRIPT'])+' '+out_frames+' '+str(param['VIS_NAME'])
subprocess.call(cmd,shell=True)
print("Movie stored in "+str(param['OUTPUT_PATH'])+"visualization/movie/"+str(param['VIS_NAME'])+".mp4")
print()
else:
fileV = out_frames+str(param['VIS_NAME'])+'-0000_V.png'
fileR = out_frames+str(param['VIS_NAME'])+'-0000_R.png'
fileG = out_frames+str(param['VIS_NAME'])+'-0000_G.png'
fileB = out_frames+str(param['VIS_NAME'])+'-0000_B.png'
fileVR = out_frames+str(param['VIS_NAME'])+'-0000_VR.png'
fileVRG = out_frames+str(param['VIS_NAME'])+'-0000_VRG.png'
fileVRGB = out_frames+str(param['VIS_NAME'])+'-0000_VRGB.png'
cmd = '(composite -compose add '+fileV+' '+fileR+' '+fileVR+' && composite -compose add '+fileVR+' '+fileG+' '+fileVRG+' && composite -compose add '+fileVRG+' '+fileB+' '+fileVRGB+') && rm -f '+fileVR+' '+fileVRG
subprocess.call(cmd,shell=True)
print("Single frame stored in "+str(param['OUTPUT_PATH'])+"visualization/"+str(param['VIS_NAME'])+"-0000_VRGB.png")
print()
print("Movie stored in "+str(param['OUTPUT_PATH'])+"visualization/movie/"+str(param['VIS_NAME'])+".mp4")
print()
##########
# Epilogue
......
#####################################################################################################
## Copyright (C) 2020 Udo von Toussaint, F. J. Dominguez-Gutierrez, Michele Compostella, Markus Rampp
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
##################################################################################
## General Notes:
## VisIt script for the visualization of the Descriptor Vectors
## generated with kdtree2
## VisIt script for the visualization of defects in damaged crystal structures
##
## Last update: 05.12.2019
## Last update: 16.01.2020
## Tested with VisIt 2.13.3
## at: Max Planck Computing and Data Facility, Garching
##
## run with:
## visit -cli -nowin -s vis.py
##
## Contact: michele.compostella@mpcdf.mpg.de
##
##################################################################################
# Parameters of the script
input_s = '/root/input/atom_file.xyz'
input_v = '/root/test/near_d.vtk'
out_dir = '/root/test/visualization/'
input_s = '/home/favad/sample/input/atom_file.xyz'
input_v = '/home/favad/sample/output/near_d.vtk'
out_dir = '/home/favad/sample/output/visualization/'
out_name = 'fe'
fading = True # True/False
fading = False
n_frames = 1
# Modules
import math
......@@ -64,8 +80,8 @@ DefineScalarExpression("m_typea","-var3")
DefineScalarExpression("m_void","exp(-var2)")
DefineScalarExpression("voidint","var2-(1.0-var1)")
# Scaling atom size according to variable var4
#DefineScalarExpression("var4","1.")
# Scaling atom size according to the cubic root of variable var4
DefineScalarExpression("av_rad","(var4)^(1./3.)")
def addbox():
......@@ -177,7 +193,7 @@ p.colorTableName = "R"
#p.pointType = p.SphereGeometry
#pointSize = 0.15
p.pointSizeVarEnabled = 1
p.pointSizeVar = "var4"
p.pointSizeVar = "av_rad"
p.pointType = p.Sphere
p.pointSizePixels = 14
SetPlotOptions(p)
......@@ -199,7 +215,7 @@ if fading:
#p.pointType = p.SphereGeometry
#p.pointSize = 0.15
p.pointSizeVarEnabled = 1
p.pointSizeVar = "var4"
p.pointSizeVar = "av_rad"
p.pointType = p.Sphere
p.pointSizePixels = 14
SetPlotOptions(p)
......@@ -279,7 +295,7 @@ else:
#loop over angles
nsteps= 360 #1/360
nsteps= n_frames # 1 to 360
for i in range(0,nsteps):
###
# Step1: colorized volume, black atoms
......
......@@ -50,6 +50,9 @@ VISIT_PATH = /home/favad/software/visit/bin/visit
VISIT_SCRIPT = /home/favad/sample/input/vis.py
# Name for the final frames and movie
VIS_NAME = fe_sample
# Path to the bash script for the movie creation
# Single test frame (default) or full movie (MOVIE_CREATION = True)
MOVIE_CREATION = False
# Path to the bash script for the movie creation, if necessary
MOVIE_SCRIPT = /home/favad/sample/input/movie.sh
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment