def test_smad_uint16(self): stat = hdstats.smad_pcm(self.data, self.gm) intdata = (self.data * 10000).astype(np.uint16) intdata[1,1,0,:] = 0 intstat = hdstats.smad_pcm(intdata, self.gm, nodata=0) npt.assert_approx_equal(np.nanmean(stat), np.nanmean(intstat), significant=4)
def gm_tmad(arr, **kw): """ arr: a high dimensional numpy array where the last dimension will be reduced. returns: a numpy array with one less dimension than input. """ gm = hdstats.nangeomedian_pcm(arr, **kw) nt = kw.pop('num_threads', None) emad = hdstats.emad_pcm(arr, gm, num_threads=nt)[:,:, np.newaxis] smad = hdstats.smad_pcm(arr, gm, num_threads=nt)[:,:, np.newaxis] bcmad = hdstats.bcmad_pcm(arr, gm, num_threads=nt)[:,:, np.newaxis] return np.concatenate([gm, emad, smad, bcmad], axis=-1)
def test_bcmad(self): bcmad = hdstats.smad_pcm(self.data, self.gm) assert bcmad.shape == (200, 200)
def test_smad_baddata(self): baddata = self.data[:3,:3,:,:].copy() baddata[1,1,0,:] = np.nan smad = hdstats.smad_pcm(baddata, self.gm) assert np.isnan(smad[1,1])