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)) ]
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
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
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))]
def __setitem__(self, attribute, dat): self.registrations[attribute] = self._java_object.registerBytes( serialize_numpy(dat, 'd'))
def __setitem__(self, attribute, dat): self.registrations[attribute] = self._java_object.registerBytes(serialize_numpy(dat, "d"))