added functionality for supporting the GL front-end
This commit is contained in:
parent
ba848f6924
commit
c323511b05
@ -2,6 +2,8 @@ import sys
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
from xml.dom.minidom import Document
|
||||
|
||||
import numpy as np
|
||||
from scipy.spatial import KDTree
|
||||
|
||||
@ -23,7 +25,7 @@ class grid(object):
|
||||
q = array (1D) of physical values
|
||||
"""
|
||||
|
||||
if verts:
|
||||
if verts != None:
|
||||
self.verts = np.array(verts)
|
||||
self.tree = KDTree(self.verts)
|
||||
if q:
|
||||
@ -142,6 +144,33 @@ class grid(object):
|
||||
r += "%s\n" % v
|
||||
return r
|
||||
|
||||
def normalize_q(self, new_max = 0.1):
|
||||
largest_number = np.max(np.abs(self.q))
|
||||
self.q *= new_max/largest_number
|
||||
|
||||
|
||||
|
||||
def get_xml(self):
|
||||
doc = Document()
|
||||
ps = doc.createElement("points")
|
||||
doc.appendChild(ps)
|
||||
for i in zip(self.verts, self.q):
|
||||
p = doc.createElement("point")
|
||||
|
||||
p.setAttribute("x", str(i[0][0]))
|
||||
p.setAttribute('y', str(i[0][1]))
|
||||
p.setAttribute('z', str(i[0][2]))
|
||||
p.setAttribute('q', str(i[1] ))
|
||||
ps.appendChild(p)
|
||||
|
||||
return doc
|
||||
|
||||
def toxml(self):
|
||||
return self.get_xml().toxml()
|
||||
def toprettyxml(self):
|
||||
return self.get_xml().toprettyxml()
|
||||
|
||||
|
||||
|
||||
|
||||
class delaunay_grid(grid):
|
||||
|
Loading…
Reference in New Issue
Block a user