Ejemplo n.º 1
0
 def interpolate(fromtopo, data, order=2, fill=None):
     usable_keys = []
     for k in registrations.iterkeys():
         if k in fromtopo.registrations:
             usable_keys.append(k)
     if not usable_keys:
         raise RuntimeError('no registration found that links topologies')
     the_key = usable_keys[0]
     # Prep the data into java arrays
     jmask = serialize_numpy(
         np.asarray([1 if d is not None else 0 for d in data]), 'd')
     jdata = serialize_numpy(
         np.asarray([d if d is not None else 0 for d in data]), 'd')
     # okay, next step is to call out to the java...
     maskres = self._java_object.interpolateBytes(
         fromtopo.registrations[the_key],
         self.registrations[the_key].coordinates, order, jdata)
     datares = self._java_object.interpolateBytes(
         fromtopo.registrations[the_key],
         self.registrations[the_key].coordinates, order, jmask)
     # then interpret the results...
     return [
         datares[i] if maskres[i] == 1 else fill
         for i in range(len(maskres))
     ]
Ejemplo n.º 2
0
 def __init__(self, triangles, registrations):
     # First: make a java object for the topology:
     faces = serialize_numpy(triangles.T, "i")
     topo = java_link().jvm.nben.geometry.spherical.MeshTopology.fromBytes(faces)
     # Okay, make our registration dictionary
     d = {k: topo.registerBytes(serialize_numpy(v, "d")) for (k, v) in registrations.iteritems()}
     # That's all really
     self.__dict__["_java_object"] = topo
     self.__dict__["registrations"] = d
Ejemplo n.º 3
0
 def __init__(self, triangles, registrations):
     # First: make a java object for the topology:
     faces = serialize_numpy(triangles.T, 'i')
     topo = java_link().jvm.nben.geometry.spherical.MeshTopology.fromBytes(
         faces)
     # Okay, make our registration dictionary
     d = {
         k: topo.registerBytes(serialize_numpy(v, 'd'))
         for (k, v) in registrations.iteritems()
     }
     # That's all really
     self.__dict__['_java_object'] = topo
     self.__dict__['registrations'] = d
Ejemplo n.º 4
0
 def interpolate(fromtopo, data, order=2, fill=None):
     usable_keys = []
     for k in registrations.iterkeys():
         if k in fromtopo.registrations:
             usable_keys.append(k)
     if not usable_keys:
         raise RuntimeError("no registration found that links topologies")
     the_key = usable_keys[0]
     # Prep the data into java arrays
     jmask = serialize_numpy(np.asarray([1 if d is not None else 0 for d in data]), "d")
     jdata = serialize_numpy(np.asarray([d if d is not None else 0 for d in data]), "d")
     # okay, next step is to call out to the java...
     maskres = self._java_object.interpolateBytes(
         fromtopo.registrations[the_key], self.registrations[the_key].coordinates, order, jdata
     )
     datares = self._java_object.interpolateBytes(
         fromtopo.registrations[the_key], self.registrations[the_key].coordinates, order, jmask
     )
     # then interpret the results...
     return [datares[i] if maskres[i] == 1 else fill for i in range(len(maskres))]
Ejemplo n.º 5
0
 def __setitem__(self, attribute, dat):
     self.registrations[attribute] = self._java_object.registerBytes(
         serialize_numpy(dat, 'd'))
Ejemplo n.º 6
0
 def __setitem__(self, attribute, dat):
     self.registrations[attribute] = self._java_object.registerBytes(serialize_numpy(dat, "d"))