def gen_i2x(self): """ Regenerate the ijk to xyz space convertion functions """ shape = self.shape = self.data.shape x0 = self.info['range']['begin'] x1 = self.info['range']['end'] lg = self.info['range']['log'] # i0 = 0 # i1 = len(self.data[i]) if self.debug: print("*** starting xyz:", x0, "ending xyz:", x1, "shape:", shape, "ndim:", self.ndim) lst = [] for i in range(self.ndim): if lg[i] is None or lg[i] == False: # Log scale is not applied, everything is linear if shape[i] == 1: # Start stop at the same point lst.append(lambda x: x0[i]) else: lst.append(linearFunc(0, x0[i], shape[i], x1[i])) elif isinstance(lg[i], (int, float)): # Log scale applied, given log base. lst.append(expFunc(x0[i], 0, x1[i], shape[i], base=lg[i])) elif lg[i] == True: # Log scale applied, use default base lst.append(expFunc(x0[i], 0, x1[i], shape[i])) else: raise ValueError("Log scale descriptor can only be int,\ float, True, False or None, given: " + str(lg[i])) return lst
def gen_x2i(self): """ Regenerate the xyz to ijk space convertion functions """ shape = self.shape = self.data.shape x0 = self.info['range']['begin'] x1 = self.info['range']['end'] lg = self.info['range']['log'] # i0 = 0 # i1 = len(self.data[i]) lst = [] for i in range(self.ndim): if lg[i] is None or lg[i] == False: # Log scale is not applied, everything is linear if x0[i] == x1[i]: # Start stop at the same point lst.append(lambda x: 0) else: lst.append(linearFunc(x0[i], 0, x1[i], shape[i])) elif isinstance(lg[i], int) or isinstance(lg[i], float): # Log scale applied, given log base. lst.append(logFunc(x0[i], 0, x1[i], shape[i], base=lg[i])) elif lg[i] == True: # Log scale applied, use default base lst.append(logFunc(x0[i], 0, x1[i], shape[i])) else: raise(ValueError, "Log scale descriptor can only be int,\ float, True, False or None, given: " + str(lg[i])) return lst