def get(self, names=None, burn=None, clip=None):
if names is None: names = list(self.dtype.names)
names = np.array(names,ndmin=1)
missing = names[~np.in1d(names,self.dtype.names)]
if len(missing):
msg = "field(s) named %s not found"%(missing)
raise ValueError(msg)
#idx = np.where(np.in1d(self.dtype.names,names))[0]
idx = np.array([self.dtype.names.index(n) for n in names])
# Remove zero entries
zsel = ~np.all(self.ndarray==0,axis=1)
# Remove burn entries
bsel = np.zeros(len(self),dtype=bool)
bsel[slice(burn,None)] = 1
data = self.ndarray[:,idx][bsel&zsel]
if clip is not None:
from astropy.stats import sigma_clip
mask = sigma_clip(data,sig=clip,copy=False,axis=0).mask
data = data[np.where(~mask.any(axis=1))]
return data
评论列表
文章目录