def transformdata_1d(x, f, plotflag): transform_id = np.mod(plotflag // 10, 10) transform = [lambda f, x: f, lambda f, x: 1 - f, lambda f, x: cumtrapz(f, x), lambda f, x: 1 - cumtrapz(f, x), lambda f, x: np.log(f), lambda f, x: np.log1p(-f), lambda f, x: np.log(cumtrapz(f, x)), lambda f, x: np.log1p(-cumtrapz(f, x)), lambda f, x: 10*np.log10(f) ][transform_id] return transform(f, x)
def tau_integ(chi_in, height): ''' Integrates the opacity to get the optical depth tau ''' chi = N.transpose(chi_in) tau = N.zeros(chi.shape) try: # if there is a masked array, sum only over used depth points mm = N.invert(chi[0].mask) zcut = N.where(mm == 1)[0][0] tau[:,zcut+1:] = cumtrapz(chi[:,mm], x=-height[mm]) except AttributeError: tau[:,1:] = cumtrapz(chi, x=-height) return tau
def transformdata(x, f, plotflag): transFlag = np.mod(plotflag // 10, 10) if transFlag == 0: data = f elif transFlag == 1: data = 1 - f elif transFlag == 2: data = cumtrapz(f, x) elif transFlag == 3: data = 1 - cumtrapz(f, x) if transFlag in (4, 5): if transFlag == 4: data = -np.log1p(-cumtrapz(f, x)) else: if any(f < 0): raise ValueError('Invalid plotflag: Data or dataCI is negative, but must be positive') data = 10 * np.log10(f) return data
def to_cdf(self): if isinstance(self.args, (list, tuple)): # Multidimensional data raise NotImplementedError('integration for ndim>1 not implemented') cdf = np.hstack((0, cumtrapz(self.data, self.args))) return PlotData(cdf, np.copy(self.args), xlab='x', ylab='F(x)')