Updating WeightMode plugins |
The RelaxISPlugin_WeightMode changed the definition of the CalculateWeights function to be in line with the new common data structures for EIS data.
The definition for the CalculateWeights function has changed. The argument type was changed to use specific value types instead of generic jagged Double arrays.
The data argument of the function is now a IListEISValue and is populated with the values already transformed into the correct transfer function (the previous arrays also contained transformed values, meaning no change in this detail).
Instead of returning a jagged array where result[0] contained the weights for the real residuals and result[1] contained the weights for the imaginary residuals the function now returns a IListComplex, that contains Complex one value per input EISValue. The real part of this value is used as the weight for the real residual, and the imaginary part is used as the weight for the imginary residual.
Further, the InvalidImpedanceDataException field was removed. It was replaced by the InvalidImpedanceDataException class, which is thrown by relevant functions instead.
Introduce using statements for the relevant namespaces.
using System.Collections.Generic; using RelaxIS_SDK.Common; using RelaxIS_SDK.libMath;
Find the function definition of the CalculateWeights function.
public override double[][] CalculateWeights(double[][] data)
Replace it with the new function definition.
public override IList<Complex> CalculateWeights(IList<EISValue> data)
Adjust the way data is returned from the function. You can create the result list from the previous function implementation as shown below.
public override IList<Complex> CalculateWeights(IList<EISValue> data) { // [...] Code to generate the previous weight arrays // assuming after this there exist two arrays: // double[] weightsReal, weightsImag; // with: weightsReal.Length == weightsImag.Length var res = new List<Complex>(); for (var i = 0; i < weightsReal; i++) { res.Add(new Complex(weightsReal[i], weightsImag[i])); } }
However, it might be advisable to update the function definition to directly create the list of Complex values instead of generating the intermediate arrays in order to make the function more efficient and easier to read.
Identify where the exception was thrown.
throw InvalidImpedanceDataException;
Replace this with the throwing a new InvalidImpedanceDataException object.
throw new InvalidImpedanceDataException();