Example of a Custom DataSet

Consider the following example where an existing near field is examined. When the magnitude of the field at any point exceeds 5 V m , the custom DataSet stores that value. For all other values it is zero.
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)
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
    target[index].above5V = 0
pf.DataSet.ForAllValues(process5Vthreshold, custom, nf1)


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.