Skip to content

Commit 09a7346

Browse files
authored
Merge pull request #43 from rmahfuz/visualizations
Added animation capability
2 parents a9270b9 + 5d1ee53 commit 09a7346

9 files changed

Lines changed: 178 additions & 86 deletions

Scripts/viz/README.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
Execution instructions:
12
1) Put all netCDF restart files for which visulaizations are to be generated in the nc_files directory.
2-
2) Populate/modify config.txt as desired.
3+
2) Modify config.txt as desired.
34
3) Execute 'bash ram.sh'
45
4) Look for the generated images in the images directory
6+
7+
Notes regarding the configuration file:
8+
9+
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
10+
11+
12+
Streamline source type: A sphere generates lesser streamlines. A slice of the magnetic field is a more appropriate choice
13+
Plasma pressure display: Choose a species whose plasma pressure will be displayed
14+
Camera Position: where the camera is
15+
Camera Focal Point: where the camera is looking
16+
Camera View Up: TODO
17+
Scale: Indicate if you choose to see the scale
18+
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.
19+
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

Scripts/viz/config.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Anything before the colon is the property name, after the colon is the property value. Property values are case-sensitive
22
Streamline source type (sphere or slice): slice
33
Plasma pressure display (electron/proton/heliumion/oxygenion): proton
4-
Camera angle:
4+
Camera Position: 30, 30, 30
5+
Camera Focal Point: 2, 2, 2
6+
Camera View Up: 0, 0.8, 0.6
57
Scale (on/off): off
8+
Movie (no/groupName): restart_d20130317
9+
SaveState (True/False): True
91.1 MB
Binary file not shown.
91.1 MB
Binary file not shown.
91.1 MB
Binary file not shown.
91.1 MB
Binary file not shown.
91 MB
Binary file not shown.

Scripts/viz/ram_automate1.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def read_config():
1313
'''Reads configurations from config.txt'''
1414
global properties
15-
property_labels = ['Streamline source type', 'Plasma pressure display', 'Camera angle', 'Scale']
15+
property_labels = ['Streamline source type', 'Plasma pressure display', 'Camera Position', 'Camera Focal Point', 'Camera View Up', 'Scale', 'Movie', 'SaveState']
1616
with open('config.txt', 'r') as to_read:
1717
lines = to_read.readlines()
1818
if len(lines) - 1 != len(property_labels):
@@ -39,26 +39,30 @@ def gen_vts(fileName):
3939
par_data = data['PParT'].tolist(); per_data = data['PPerT'].tolist()
4040

4141
to_write += '\t\t\t\t<DataArray type="Float32" Name="electron pressure" NumberOfComponents="1" format="ascii">\n'
42-
for i in range(25):
43-
for j in range(20):
42+
43+
for i in range(nT):
44+
for j in range(nR):
4445
to_write += '\t\t\t\t\t' + str(par_data[i][j][0] + 2*per_data[i][j][0]) + '\n'
4546
to_write += '\t\t\t\t</DataArray>\n'
4647

4748
to_write += '\t\t\t\t<DataArray type="Float32" Name="proton pressure" NumberOfComponents="1" format="ascii">\n'
48-
for i in range(25):
49-
for j in range(20):
49+
50+
for i in range(nT):
51+
for j in range(nR):
5052
to_write += '\t\t\t\t\t' + str(par_data[i][j][1] + 2*per_data[i][j][1]) + '\n'
5153
to_write += '\t\t\t\t</DataArray>\n'
5254

5355
to_write += '\t\t\t\t<DataArray type="Float32" Name="heliumion pressure" NumberOfComponents="1" format="ascii">\n'
54-
for i in range(25):
55-
for j in range(20):
56+
57+
for i in range(nT):
58+
for j in range(nR):
5659
to_write += '\t\t\t\t\t' + str(par_data[i][j][2] + 2*per_data[i][j][2]) + '\n'
5760
to_write += '\t\t\t\t</DataArray>\n'
5861

5962
to_write += '\t\t\t\t<DataArray type="Float32" Name="oxygenion pressure" NumberOfComponents="1" format="ascii">\n'
60-
for i in range(25):
61-
for j in range(20):
63+
64+
for i in range(nT):
65+
for j in range(nR):
6266
to_write += '\t\t\t\t\t' + str(par_data[i][j][3] + 2*per_data[i][j][3]) + '\n'
6367
to_write += '\t\t\t\t</DataArray>\n'
6468

@@ -195,8 +199,16 @@ def gen_sphere():
195199
read_config() #read configurations from config.txt
196200
#Get vts files for all netcdf files in the given directory:
197201
files = os.listdir(sys.argv[1])
198-
for item in files:
199-
if item[-3:] == '.nc':
200-
gen_vts(item)
202+
203+
if properties['Movie'] == 'no':
204+
for item in files:
205+
if item[-3:] == '.nc':
206+
gen_vts(item)
207+
else:
208+
grp = properties['Movie']
209+
for item in files:
210+
if item[-3:] == '.nc' and item[:len(grp)] == grp:
211+
gen_vts(item)
212+
201213
if properties['Streamline source type'] == 'sphere':
202214
gen_sphere() #generates sphere.vts in vts_files directory

0 commit comments

Comments
 (0)