Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalisation #24

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
67f3315
Fix cosmetic 'bug'where the Tangra Settings form title includes the …
MurrayForbes Jun 17, 2021
a55905b
Changed the order of the image file types are listed in the saveFileD…
MurrayForbes Jun 18, 2021
b275da8
Changed last 'if else' to an 'else' and removed comment as per Hristo…
MurrayForbes Jun 18, 2021
c5d1bf1
Replaced spaces with tabs in front of the opening and closing braces.
MurrayForbes Jun 18, 2021
4c9efb0
Merge branch 'hpavlov:master' into master
MurrayForbes Jun 19, 2021
7c1ee3c
Correct spelling mistakes in light curve plot's legend ('devided'-->'…
MurrayForbes Jun 19, 2021
78032f2
Change code indenting from tabs to spaces in method miSaveAsImage_Cli…
MurrayForbes Jun 19, 2021
8b547fe
Remember (and use as the default value next time) the image file form…
MurrayForbes Jun 20, 2021
dd587ca
Moved SaveAsImageType from TangraConfig class to Generic class.
MurrayForbes Jun 21, 2021
272772c
tidy up formatting in source code (TangraConfig.cs and frmLightCurve…
MurrayForbes Jun 21, 2021
0593ee6
Change the SaveAsImageFormat enum values from lower case to Pascal ca…
MurrayForbes Jun 24, 2021
4eee9fc
Save gitignore file, amemded to exclude /.vs files from Git changes.
MurrayForbes Jun 24, 2021
55b494f
Second attempt at adding /.vs to the gitignore file
MurrayForbes Jun 24, 2021
3bfae68
Merge branch 'SaveLightCurveDefaultImageFileFormat' of https://github…
MurrayForbes Jun 24, 2021
3f26829
Another attempt to get gitignore and the /.vs files synchronised.
MurrayForbes Jun 24, 2021
718234b
Remove unused field 'SaveAsImageType'.
MurrayForbes Jun 26, 2021
eb6df08
Correction to variable name, to follow the right naming convention (f…
MurrayForbes Jun 26, 2021
09326b8
Auto-suggest the video file name as the file name (with the appropria…
MurrayForbes Jun 26, 2021
d58cf8e
Auto-suggest video's file name when saving light curve plot's file ty…
MurrayForbes Jun 27, 2021
16954db
Delete ProjectSettings.json
hpavlov Jun 27, 2021
7c33de4
Delete VSWorkspaceState.json
hpavlov Jun 27, 2021
658a365
Manually deleted the /.vs directory.
MurrayForbes Jun 27, 2021
2d1f960
Merge branch 'AutoSuggestNameWithLastUsedExtension' of https://github…
MurrayForbes Jun 27, 2021
6c936dd
Merge branch 'SaveLightCurveDefaultImageFileFormat'
MurrayForbes Jun 28, 2021
4b6494b
Merge branch 'hpavlov:master' into master
MurrayForbes Jun 28, 2021
a1a4a5e
Merge branch 'master' of https://github.com/MurrayForbes/tangra3
MurrayForbes Jun 28, 2021
a02e7cc
Allow the user to have more than one star used to do the normalisatio…
MurrayForbes Oct 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file added .vs/tangra3/v16/Browse.VC.db
Binary file not shown.
25 changes: 19 additions & 6 deletions Tangra 3/Controller/LightCurveContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ internal enum LightCurveMode
private int m_Binning = 0;
private int m_BinningFirstFrame = 0;
private int m_Normalisation = -1;
private FilterType m_Filter = FilterType.NoFilter;
private bool[] m_Normalisations = new bool[4];
private FilterType m_Filter = FilterType.NoFilter;
private NormalisationMethod m_NormMethod = NormalisationMethod.Average4Frame;
private float[] m_ReProcessApertures = new float[4];
private int[] m_ReProcessFitAreas = new int[4];
Expand All @@ -102,7 +103,7 @@ internal enum LightCurveMode
public uint MinFrame;
public uint MaxFrame;
public int ObjectCount;

public uint m_SelectedFrameNo = 0;

private XAxisMode m_XAxisMode;
Expand Down Expand Up @@ -140,6 +141,7 @@ public uint SelectedFrameNo
private ProcessingType m_bu_ProcessingType = ProcessingType.SignalMinusBackground;
private int m_bu_Binning = 0;
private int m_bu_Normalisation = -1;
private bool[] m_bu_Normalisations = new bool[4];
private FilterType m_bu_Filter = FilterType.NoFilter;
private NormalisationMethod mbu__NormMethod = NormalisationMethod.Average4Frame;
private float[] m_bu_ReProcessApertures = new float[4];
Expand All @@ -155,7 +157,10 @@ internal void PrepareForCancelling()
m_bu_ProcessingType = m_ProcessingType;
m_bu_Binning = m_Binning;
m_bu_Normalisation = m_Normalisation;
m_bu_Filter = m_Filter;
for (int i = 0; i < 4; i++)
m_bu_Normalisations[i] = m_Normalisations[i];

m_bu_Filter = m_Filter;
mbu__NormMethod = m_NormMethod;
bu_SelectedFrameNo = SelectedFrameNo;

Expand All @@ -178,7 +183,10 @@ internal void CancelChanges()
m_ProcessingType = m_bu_ProcessingType;
m_Binning = m_bu_Binning;
m_Normalisation = m_bu_Normalisation;
m_Filter = m_bu_Filter;
for (int i = 0; i < 4; i++)
m_Normalisations[i] = m_bu_Normalisations[i];

m_Filter = m_bu_Filter;
m_NormMethod = mbu__NormMethod;
SelectedFrameNo = bu_SelectedFrameNo;

Expand Down Expand Up @@ -313,6 +321,11 @@ public int Normalisation
}
}

public bool[] Normalisations
{
get { return m_Normalisations; }
}

public FilterType Filter
{
get { return m_Filter; }
Expand All @@ -327,15 +340,15 @@ public FilterType Filter
}
}

public NormalisationMethod NormMethod
public NormalisationMethod NormMethod
{
get { return m_NormMethod; }
set
{
if (m_NormMethod != value)
{
m_NormMethod = value;
// If the normalization is specified, changing the method will make the data durty
// If the normalization is specified, changing the method will make the data dirty
m_Dirty = m_Normalisation > -1;
}
}
Expand Down
102 changes: 71 additions & 31 deletions Tangra 3/VideoOperations/LightCurves/frmLightCurve.Computations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,44 +269,84 @@ private void ComputeBinning()

private void PerformNormalization()
{
// Calculate the normalisation factor for each star chosen as a normalisation star
// and then calculate the normalisation factor averaged over all normalisation stars.

List<double> normalIndexes = new List<double>();
List<double> averagedNormalIndexes = new List<double>();

int numberOfNormalisationStars = 0;

switch(m_LightCurveController.Context.NormMethod)
for (int starIndx = 0; starIndx < m_Header.ObjectCount; starIndx++)
{
case LightCurveContext.NormalisationMethod.LinearFit:
if (m_LightCurveController.Context.Binning > 0)
PerformLinearFitBinnedNormalisation(ref normalIndexes);
else
PerformLinearFitReadingsNormalisation(ref normalIndexes);
break;

if (!m_LightCurveController.Context.Normalisations[starIndx]) continue;

case LightCurveContext.NormalisationMethod.FrameByFrame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 1);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 1);
break;
normalIndexes.Clear();

case LightCurveContext.NormalisationMethod.Average4Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 4);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 4);
break;
numberOfNormalisationStars++;

case LightCurveContext.NormalisationMethod.Average8Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 8);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 8);
break;
m_LightCurveController.Context.Normalisation = starIndx;

case LightCurveContext.NormalisationMethod.Average16Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 16);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 16);
break;
switch (m_LightCurveController.Context.NormMethod)
{
case LightCurveContext.NormalisationMethod.LinearFit:
if (m_LightCurveController.Context.Binning > 0)
PerformLinearFitBinnedNormalisation(ref normalIndexes);
else
PerformLinearFitReadingsNormalisation(ref normalIndexes);
break;

case LightCurveContext.NormalisationMethod.FrameByFrame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 1);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 1);
break;

case LightCurveContext.NormalisationMethod.Average4Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 4);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 4);
break;

case LightCurveContext.NormalisationMethod.Average8Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 8);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 8);
break;

case LightCurveContext.NormalisationMethod.Average16Frame:
if (m_LightCurveController.Context.Binning > 0)
PerformAverageBinnedNormalisation(ref normalIndexes, 16);
else
PerformAverageReadingsNormalisation(ref normalIndexes, 16);
break;
}

if (numberOfNormalisationStars == 1)
{
for (int indx = 0; indx < normalIndexes.Count; indx++)
{
averagedNormalIndexes.Add(normalIndexes[indx]);
}
}
else
{
for (int indx = 0; indx < normalIndexes.Count; indx++)
{
averagedNormalIndexes[indx] = averagedNormalIndexes[indx] + normalIndexes[indx];
}
}

}

// calculate the normalisation factor averaged over all the normalisation stars
for (int indx = 0; indx < normalIndexes.Count; indx++)
{
normalIndexes[indx] = averagedNormalIndexes[indx] / numberOfNormalisationStars;
}

int minValue = int.MaxValue;
Expand Down
Loading