Go to www.awrcorp.com
Back to search page Click to download printable version of this guide.
Sampling Fields Along a Line

Starting from an analyst.IField object you can use scripting to evaluate the field values along a line defined by a start and end point using the SampleAlongLine function:

          sample = Field_1.SampleAlongLine((-.02, 0.005, 0.0025), (0, 0.005, 0.0025), 100))
          print(sample)
        

The function takes 3 arguments:

  1. Point 1 - Tuple of doubles indicating start point of the line in meters.

  2. Point 2 - Tuple of doubles indicating end point of the line in meters.

  3. Number of Samples - Number of points to sample along the line.

The function returns a tuple of doubles formatted as:

          Point 0 x, Point 0 y, Point 0 z, [Field at Point 0], Point 1 x, Point 1 y, Point 1 z, [Field at Point 1], ...
        

Where the contents of [Field at Point n] depend on the various factors including:

  1. Dimension of the field (FDD_SCALAR, FDD_VECTOR. This can be checked by calling IField::GetDataDimension(). The scalar case will return 1 value per point and the vector case will return 3 values per point.

  2. Data type of the field (FDT_FLOAT, FDT_FLOAT_COMPLEX, FDT_DOUBLE, FDT_DOUBLE_COMPLEX). This can be checked by calling IField::GetDataType(). The real cases will return 1 value per component and the complex cases will return 2 values per component.

Taking this into consideration, sampling a complex vector field will return 6 values per sample point (x.real, x.imag, y.real, y.imag, z.real, z.imag). Sampling a real vector field will return 3 values per sample point (x, y, z).

Please send email to awr.support@ni.com if you would like to provide feedback on this article. Please make sure to include the article link in the email.

Legal and Trademark Notice