Skip to content

Commit c1fc082

Browse files
authored
Merge pull request #86 from grahamWroberts/main
added q interpolation and trimming high q values
2 parents 7c95713 + aba01e0 commit c1fc082

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

AFL/double_agent/TreePipeline.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,22 @@ def calculate(self, dataset):
128128
data = self._get_variable(dataset)
129129
dataset[self.output_variable] = ('sample', [self.encoding[l] for l in data.data])
130130
return(self)
131+
132+
class TrimQ(PipelineOp):
133+
def __init__(self, input_variable, output_variable, input_index, output_index, new_values, name = "q interpolation"):
134+
super().__init__(input_variable = input_variable,
135+
output_variable = output_variable,
136+
name=name)
137+
self.input_index = input_index
138+
self.output_index = output_index
139+
self.new_values = new_values
140+
141+
def calculate(self, dataset):
142+
old_q = dataset[self.input_index].data
143+
old_I = dataset[self.input_variable].data
144+
new_I = np.array([np.interp(self.new_values, old_q, old_I[i,:]) for i in range(old_I.shape[0])])
145+
new_coords = [c if c != self.input_index else self.output_index for c in list(dataset[self.input_variable].coords) ]
146+
dataset.coords[self.output_index] = self.new_values
147+
#dataset[self.output_variable] = (['sample','trimmed_q'], new_I)
148+
dataset[self.output_variable] = ([c if c != self.input_index else self.output_index for c in dataset[self.input_variable].dims ], new_I)
149+
return(self)

0 commit comments

Comments
 (0)