Skip to content

Commit

Permalink
code for parsing a PDH file
Browse files Browse the repository at this point in the history
  • Loading branch information
ibressler committed Jul 26, 2018
1 parent 85a8b9b commit af59678
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions readPDH.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


def readPDH(ifname):
# function for reading SAXS data files in pdh-format
q, I, IError = [], [], []

# q-range of interest
qmin = 0.001; qmax = 7.0

qlims = [qmin, qmax] # min, max
with open(ifname, 'r') as ifile:
for i in range(5):
inline = ifile.readline()

inline = ifile.readline()
while inline != '<?xml version="1.0" encoding="utf-8"?>\n':
if ((float(inline.split(" ")[1]) < qlims[1]) & (float(inline.split(" ")[1]) >= qlims[0])):
q.append( float(inline.split(" ")[1]) )
I.append( float(inline.split(" ")[2]) )
IError.append( float(inline.split(" ")[1]) )

inline = ifile.readline()

ifile.close()
return q, I, IError

0 comments on commit af59678

Please sign in to comment.