查找表/ Loc 排序的问题我试图在这个数据表中找到测量值减半的时间。 我想要的输出是一个汇总表,其中的时间是按样本测量的一半。

这是脚本生成的汇总表,正如您所看到的,半小节的时间是不正确的。

我制作了以下脚本,使用 Loc 排序从该表中查找值,但我很难让它工作。 这个脚本有什么错误吗? 这是我想要做的正确方法,如果不是,有人对我如何做到这一点有任何建议吗?需要注意的一件事是半值可能与时间不完全匹配,因此我将在半测量点之前或之后寻找时间。
Names Default To Here(1);
Data Table( "Data" ) << Summary(
Group( :Sample, ),
Max( :Measurement ),
Freq( "None" ),
Weight( "None" )
);
New Column( "Half Max Measure", Formula (:Name("Max(Measurement)") / 2));
New Column( "Time At Half Measurement", Format ("h:m"), Formula(
dt = Data Table( "Data" );
If(dt:Sample == Sample,
Bracket = Loc Sorted( dt:Measurement << getvalues, :Half Max Measure );
dt:Time[Bracket])));
数据表脚本编写回复:查找表/ Loc 排序的问题“Loc Sorted”需要排序的第一个参数才能正常工作。

另一方面,假设中间存在数据,以下内容可能会给出您想要的内容。
data table("Data") << new column("is match",
formula(:Measurement == Col Max( :Measurement, :Sample ) / 2)
)
如果数据之间可能不存在中间,请检查样本是否在您可以定义的范围内。
回复:查找表/ Loc 排序的问题这是我对解决问题的看法。它处理以下情况:最大测量值是偶数,因此存在从中获取半场时间的确切行,或者如果最大测量值是奇数,它将插入时间值以得出半场时间价值
Names Default To Here( 1 );
dt = Data Table( "Data" );
dtSum = dt << Summary(
Group( :Sample, ),
Max( :Measurement ),
Freq( "None" ),
Weight( "None" ),
Link to Original Data Table( 0 ),
Output Table( "The Summaries" )
);
dtSum << New Column( "Half Max Measure", Set Each Value( :Name( "Max(Measurement)" ) / 2 ) );
dtSum << New Column( "Time At Half Measurement", Format( "h:m:s" ) );
// Get the Half Max Measure
For( i = 1, i <= N Rows( dtSum ), i++,
theRow = dt << get rows where(
dt:Sample == dtsum:Sample[i] & dt:Measurement == dtSum:Half Max Measure[i]
);
If( N Rows( theRow ) > 0,
dtSum:Time At Half Measurement[i] = dt:Time[theRow[1]]
,
// No Measurement was taken at exact Half Time, so interprolate the finding
rowBefore = Max(
dt << get rows where(
dt:Sample == dtsum:Sample[i] & dt:Measurement > dtSum:Half Max Measure[i]
)
);
rowAfter = Min(
dt << get rows where(
dt:Sample == dtsum:Sample[i] & dt:Measurement < dtSum:Half Max Measure[i]
)
);
ratio = (dt:Measurement[rowBefore] - dtSum:Half Max Measure[i]) / (dt:Measurement[
rowBefore] - dt:Measurement[rowAfter]);
dtSum:Time At Half Measurement[i] = dt:Time[rowBefore] + ratio * (dt:Time[rowAfter] -
dt:Time[rowBefore]);
);
);