Commit 6acb7b96 authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

selective weighting of traces in IFC

parent ee88bdef
......@@ -403,7 +403,7 @@ def scan(
tr_stackmax_indx = tr_stackmax.copy(data=False)
imaxs = num.zeros(len(frames))
for iframe, frame in enumerate(frames):
for iframe, frame in enumerate(frames.T):
imaxs[iframe] = num.argmax(frame)
tr_stackmax_indx.set_ydata(imaxs.astype(num.int32))
......
......@@ -13,11 +13,45 @@ logger = logging.getLogger('lassie.ifc')
guts_prefix = 'lassie'
class TraceSelector(Object):
'''
Filter traces used in an IFC using NSLC-id lists and/or lists of regular
expressions.
'''
white_list = List.T(optional=True, default=[])
white_list_regex = List.T(String.T(default=[]))
def __call__(self, trs):
matched = []
for tr in trs:
nslc = '.'.join(tr.nslc_id)
if self.white_list and nslc in self.white_list:
matched.append(tr)
continue
if self.white_list_regex and util.match_nslc(
self.white_list_regex, nslc):
matched.append(tr)
return matched
def __str__(self):
return '%s:\n wl: %s\n wlre: %s\n' % (
self.__class__.__name__, self.white_list, self.white_list_regex)
class IFC(Object):
'''Image function contribution.'''
name = String.T()
weight = Float.T(default=1.0)
weights = Dict.T(
String.T(),
Float.T(),
optional=True,
help='weight selected traces')
fmin = Float.T()
fmax = Float.T()
shifter = shifter.Shifter.T(optional=True)
......@@ -48,6 +82,23 @@ class IFC(Object):
def preprocess(self, trs, wmin, wmax, tpad_new, deltat_cf):
pass
def get_weights(self, nsls):
if self.weights is None:
return num.ones(len(nsls), dtype=num.float)
else:
weights = num.empty(len(nsls))
selectors = self.weights.keys()
for insl, nsl in enumerate(nsls):
weights[insl] = 1.
for selector in selectors:
if util.match_nslc(selector, nsl):
weights[insl] = self.weights[selector]
break
return weights
class WavePacketIFC(IFC):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment