Skip to content

Commit

Permalink
review of non-equidistant fix (#4855)
Browse files Browse the repository at this point in the history
  • Loading branch information
luithefirst committed Jul 17, 2024
1 parent bb44633 commit d287999
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/Aardvark.Data.Photometry/LightMeasurementData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ public partial class LightMeasurementData : IFieldCodeable, IAwakeable
/// Symmetry across C0-C180 plane - [0, 180]
/// Symmetry across C90-C270 plane - [270, 90] in LDT or [90, 270] in IES
/// Symmetry across C0-C180 and C90-C270 planes - [0, 90]
/// NOTE: This is different to the angles in an LDT that always cover [0, 360)
/// </summary>
public double[] HorizontalAngles;

/// <summary>
/// Vertical angles of measurement in degree where 0 is pointing to the bottom and 180 to the top.
/// Typical measurement angles ranges are [0, 180], [0, 90] and [90, 180].
/// NOTE: This is different to the angles in an LDT that always cover [0, 180]
/// </summary>
public double[] VerticalAngles;

Expand Down Expand Up @@ -305,7 +307,16 @@ private Matrix<double> FixNonEquidistantAngleStep(double[] angles, Matrix<double
var valuesPerPlane = data.SX;
var planeCount = data.SY;

var angleRange = angles[angles.Length - 1] - angles[0];
// get angular range of measurement data
var first = angles[0];
var last = angles[angles.Length - 1];

// first might: 0, -90? or 270
// last might be 90, 180, 360
if (first > last)
last += 360;

var angleRange = last - first;
var elementCount = (long)(angleRange / minStep) + 1;

if (elementCount >= 4096)
Expand Down
7 changes: 6 additions & 1 deletion src/Aardvark.Data.Photometry/PhotometryDataCalculations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ public static double CalculateLumFlux(Matrix<double> equiDistantData, VerticalRa

/// <summary>
/// Calculates the luminous flux from the measurement data.
///
/// NOTE/ISSUE: Only works of euqidistance measurement data !! -> throws NotImplementedException
/// </summary>
public double CalculateLumFlux()
{
if (IsNonEquidistant(this.HorizontalAngles) || IsNonEquidistant(this.VerticalAngles))
throw new NotImplementedException();

var lumFlux = 0.0;

double segmentAreaFull = 0.0; // full sphere segment area till current angle when looping over data
Expand Down Expand Up @@ -108,7 +113,7 @@ public double CalculateLumFlux()
segmentAreaFull = segmentAreaPhi1;

// weight data points by circumference of measurement angle
var weight1 = a; // circumference is actually 2pi * r, but the constant factor can be omitted when calculating the weighed average
var weight1 = a; // circumference is actually 2pi * r, but the constant factor (2pi) can be omitted when calculating the weighed average

// if a weight is 0, this means we are the pole (0° or 180°) -> give half weight to pole sample
if (weight0 == 0) weight0 = weight1 * 0.5;
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/CSharpTests/PhotometryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Aardvark.Data.Photometry
[TestFixture]
public class PhotometryTest
{
static readonly string PhotometryDataPath = @"C:\Users\luksch\Desktop\Photometry Test Files";
static readonly string PhotometryDataPath = @"\\euclid\Hilite\Data\IntensityProfileTestLights\Photometry UnitTest Files";

[Test]
public void GetCPlaneTest()
Expand Down

0 comments on commit d287999

Please sign in to comment.