Example of a Custom DataSet
nf1 = pf.NearField.GetDataSet("Horn.StandardConfiguration1.NearField1") -- Create custom dataset custom = pf.DataSet.New() for axisNum = 1,nf1.Axes.Count do sourceAxis = nf1.Axes[axisNum] custom.Axes:Add(sourceAxis.Name, sourceAxis.Unit, sourceAxis.Values) end custom.Quantities:Add("above5V", "scalar", "V/m") -- Populate the values function process5Vthreshold(index, target, source1) local magEx = source1[index].EFieldComp1:Magnitude() local magEy = source1[index].EFieldComp2:Magnitude() local magEz = source1[index].EFieldComp3:Magnitude() local totalE = math.sqrt(magEx^2 + magEy^2 + magEz^2) if (totalE >= 5) then target[index].above5V = totalE else target[index].above5V = 0 end end pf.DataSet.ForAllValues(process5Vthreshold, custom, nf1) print(custom) return custom
Here the DataSet called custom has the same spatial axes of the source near field. An arbitrarily defined quantity was added. For each position on every axis, a scalar value must be defined in order for the DataSet to be valid. The DataSet was created entirely within the script. The Axes and Quantities were added to the DataSet and the data was populated. Results that were created in this way can also be plotted on a 3D or 2D view, similar to any internal data type.