Skip to content

Commit

Permalink
Merge pull request #43 from rmahfuz/visualizations
Browse files Browse the repository at this point in the history
Added animation capability
  • Loading branch information
drsteve authored Aug 8, 2018
2 parents a9270b9 + 5d1ee53 commit 09a7346
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 86 deletions.
17 changes: 16 additions & 1 deletion Scripts/viz/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
Execution instructions:
1) Put all netCDF restart files for which visulaizations are to be generated in the nc_files directory.
2) Populate/modify config.txt as desired.
2) Modify config.txt as desired.
3) Execute 'bash ram.sh'
4) Look for the generated images in the images directory

Notes regarding the configuration file:

Format: Anything before the colon is the property name, sometimes followed by possible values in parantheses. Anything after the colon is the property value. Property values are case-sensitive


Streamline source type: A sphere generates lesser streamlines. A slice of the magnetic field is a more appropriate choice
Plasma pressure display: Choose a species whose plasma pressure will be displayed
Camera Position: where the camera is
Camera Focal Point: where the camera is looking
Camera View Up: TODO
Scale: Indicate if you choose to see the scale
Movie: To generate images, set it to 'no'. To generate a movie, specify the groupname (first few characters that are common to all the restart files) whose movie is to be generated.
SaveState: Setting this to True will save the state in the images directory, so that the state can be loaded in the Paraview GUI later
6 changes: 5 additions & 1 deletion Scripts/viz/config.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Anything before the colon is the property name, after the colon is the property value. Property values are case-sensitive
Streamline source type (sphere or slice): slice
Plasma pressure display (electron/proton/heliumion/oxygenion): proton
Camera angle:
Camera Position: 30, 30, 30
Camera Focal Point: 2, 2, 2
Camera View Up: 0, 0.8, 0.6
Scale (on/off): off
Movie (no/groupName): restart_d20130317
SaveState (True/False): True
Binary file added Scripts/viz/nc_files/restart_d20130317_t003000.nc
Binary file not shown.
Binary file added Scripts/viz/nc_files/restart_d20130317_t010000.nc
Binary file not shown.
Binary file added Scripts/viz/nc_files/restart_d20130317_t013000.nc
Binary file not shown.
Binary file added Scripts/viz/nc_files/restart_d20130317_t020000.nc
Binary file not shown.
Binary file not shown.
36 changes: 24 additions & 12 deletions Scripts/viz/ram_automate1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def read_config():
'''Reads configurations from config.txt'''
global properties
property_labels = ['Streamline source type', 'Plasma pressure display', 'Camera angle', 'Scale']
property_labels = ['Streamline source type', 'Plasma pressure display', 'Camera Position', 'Camera Focal Point', 'Camera View Up', 'Scale', 'Movie', 'SaveState']
with open('config.txt', 'r') as to_read:
lines = to_read.readlines()
if len(lines) - 1 != len(property_labels):
Expand All @@ -39,26 +39,30 @@ def gen_vts(fileName):
par_data = data['PParT'].tolist(); per_data = data['PPerT'].tolist()

to_write += '\t\t\t\t<DataArray type="Float32" Name="electron pressure" NumberOfComponents="1" format="ascii">\n'
for i in range(25):
for j in range(20):

for i in range(nT):
for j in range(nR):
to_write += '\t\t\t\t\t' + str(par_data[i][j][0] + 2*per_data[i][j][0]) + '\n'
to_write += '\t\t\t\t</DataArray>\n'

to_write += '\t\t\t\t<DataArray type="Float32" Name="proton pressure" NumberOfComponents="1" format="ascii">\n'
for i in range(25):
for j in range(20):

for i in range(nT):
for j in range(nR):
to_write += '\t\t\t\t\t' + str(par_data[i][j][1] + 2*per_data[i][j][1]) + '\n'
to_write += '\t\t\t\t</DataArray>\n'

to_write += '\t\t\t\t<DataArray type="Float32" Name="heliumion pressure" NumberOfComponents="1" format="ascii">\n'
for i in range(25):
for j in range(20):

for i in range(nT):
for j in range(nR):
to_write += '\t\t\t\t\t' + str(par_data[i][j][2] + 2*per_data[i][j][2]) + '\n'
to_write += '\t\t\t\t</DataArray>\n'

to_write += '\t\t\t\t<DataArray type="Float32" Name="oxygenion pressure" NumberOfComponents="1" format="ascii">\n'
for i in range(25):
for j in range(20):

for i in range(nT):
for j in range(nR):
to_write += '\t\t\t\t\t' + str(par_data[i][j][3] + 2*per_data[i][j][3]) + '\n'
to_write += '\t\t\t\t</DataArray>\n'

Expand Down Expand Up @@ -195,8 +199,16 @@ def gen_sphere():
read_config() #read configurations from config.txt
#Get vts files for all netcdf files in the given directory:
files = os.listdir(sys.argv[1])
for item in files:
if item[-3:] == '.nc':
gen_vts(item)

if properties['Movie'] == 'no':
for item in files:
if item[-3:] == '.nc':
gen_vts(item)
else:
grp = properties['Movie']
for item in files:
if item[-3:] == '.nc' and item[:len(grp)] == grp:
gen_vts(item)

if properties['Streamline source type'] == 'sphere':
gen_sphere() #generates sphere.vts in vts_files directory
Loading

0 comments on commit 09a7346

Please sign in to comment.