Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
ogs-utils
Commits
754469ec
Commit
754469ec
authored
7 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
script for merging two scalar data arrays into a 2d data array.
parent
6dbd3c0e
No related branches found
No related tags found
1 merge request
!1
script for merging two scalar data arrays into a 2d data array.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
post/mergeDataArrays.py
+38
-0
38 additions, 0 deletions
post/mergeDataArrays.py
with
38 additions
and
0 deletions
post/mergeDataArrays.py
0 → 100755
+
38
−
0
View file @
754469ec
#!/usr/bin/env python2
from
vtk
import
*
from
sys
import
argv
,
exit
if
len
(
argv
)
<
6
:
print
"
Usage:
"
,
argv
[
0
],
"
input.vtu scalar1 scalar2 vector_2d output.vtu
"
exit
(
1
)
input_file
=
argv
[
1
]
output_file
=
argv
[
5
]
print
(
"
Reading from
"
,
input_file
)
print
(
"
Writing to
"
,
output_file
)
r
=
vtkXMLUnstructuredGridReader
()
r
.
SetFileName
(
input_file
)
r
.
Update
()
m
=
r
.
GetOutput
()
point_data
=
m
.
GetPointData
()
scalar_array_1
=
point_data
.
GetArray
(
argv
[
2
])
scalar_array_2
=
point_data
.
GetArray
(
argv
[
3
])
new_array
=
vtkDoubleArray
()
new_array
.
SetNumberOfComponents
(
2
)
new_array
.
SetNumberOfTuples
(
scalar_array_1
.
GetNumberOfTuples
())
new_array
.
SetName
(
argv
[
4
])
new_array
.
CopyComponent
(
0
,
scalar_array_1
,
0
)
new_array
.
CopyComponent
(
1
,
scalar_array_2
,
0
)
point_data
.
AddArray
(
new_array
)
point_data
.
RemoveArray
(
argv
[
2
])
point_data
.
RemoveArray
(
argv
[
3
])
w
=
vtkXMLUnstructuredGridWriter
()
w
.
SetFileName
(
output_file
)
w
.
SetInputData
(
m
)
w
.
SetDataModeToAscii
()
w
.
SetCompressorTypeToNone
()
w
.
Update
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment