-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort_coords.py
34 lines (22 loc) · 1.11 KB
/
sort_coords.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
#This script was writtem to read in material property files exported from FracMan
#and sort them so that they are in the same order as leapFrog block model export files
import pandas as pd
import argparse
parser = argparse.ArgumentParser(description='Reads Fracman upscaled elemental values and sorts in LeapFrog style')
parser.add_argument('filename')
args = parser.parse_args()
# Extract file name and extension
filename = args.filename
# Open the FracMan export file with pandas to directly build property tables
data = pd.read_csv(filename)
#data = pd.read_csv(filename, skiprows=10, float_precision='round_trip')
#this command is needed when combining two block with SS PT data, prepping for a PTM run
#when dat are pulled from paraview, some nodes are duplicated
z = len(data) - len(data.drop_duplicates())
data = data.drop_duplicates()
#Now sort them on z, then y, then x
a = data.sort_values(["Z","Y","X"], ascending = [True, True, True])
print "There were ", z, " duplicate rows in the file"
#and write the file back to a csv
a.to_csv("processed_" + filename, encoding='utf-8', index=False)