Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Jul 9, 2021
1 parent d8529ce commit 831f6ba
Show file tree
Hide file tree
Showing 8 changed files with 1,650 additions and 554 deletions.
2,107 changes: 1,598 additions & 509 deletions Crystallography.Controls/Crystal/AtomControl.resx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2021.7.6.1051</AssemblyVersion>
<FileVersion>2021.7.6.1051</FileVersion>
<AssemblyVersion>2021.7.9.0922</AssemblyVersion>
<FileVersion>2021.7.9.0922</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2021.7.6.1051</AssemblyVersion>
<FileVersion>2021.7.6.1051</FileVersion>
<AssemblyVersion>2021.7.9.0922</AssemblyVersion>
<FileVersion>2021.7.9.0922</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
38 changes: 21 additions & 17 deletions Crystallography/Detector/Ring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,16 @@ public static void FindSpots(IntegralProperty iP, double DeviationFactor)
var tempRMax = new int[thread];
SetTiltParameter();

FindSpotsThread0Delegate[] d0 = new FindSpotsThread0Delegate[thread];
IAsyncResult[] ar0 = new IAsyncResult[thread];
for (i = 0; i < thread; i++)
d0[i] = new FindSpotsThread0Delegate(FindSpotsThread0);
for (i = 0; i < thread; i++)
ar0[i] = d0[i].BeginInvoke(yThreadMin[i], yThreadMax[i], ref r, ref tempRMax[i], null, null);//各スレッド起動転送
for (i = 0; i < thread; i++)//スレッド終了待ち
d0[i].EndInvoke(ref r, ref tempRMax[i], ar0[i]);
//FindSpotsThread0Delegate[] d0 = new FindSpotsThread0Delegate[thread];
//IAsyncResult[] ar0 = new IAsyncResult[thread];
//for (i = 0; i < thread; i++)
// d0[i] = new FindSpotsThread0Delegate(FindSpotsThread0);
//for (i = 0; i < thread; i++)
// ar0[i] = d0[i].BeginInvoke(yThreadMin[i], yThreadMax[i], ref r, ref tempRMax[i], null, null);//各スレッド起動転送
//for (i = 0; i < thread; i++)//スレッド終了待ち
// d0[i].EndInvoke(ref r, ref tempRMax[i], ar0[i]);
Parallel.For(0, thread, i => FindSpotsThread0(yThreadMin[i], yThreadMax[i], ref r, ref tempRMax[i]));


//rMaxの最大値をきめる
rMax = tempRMax.Max();
Expand All @@ -435,14 +437,16 @@ public static void FindSpots(IntegralProperty iP, double DeviationFactor)
tempContributedPixels[i] = new double[rMax];
}
//ここからスレッド1起動
FindSpotsThread1Delegate[] d1 = new FindSpotsThread1Delegate[thread];
IAsyncResult[] ar1 = new IAsyncResult[thread];
for (i = 0; i < thread; i++)
d1[i] = new FindSpotsThread1Delegate(FindSpotsThread1);
for (i = 0; i < thread; i++)
ar1[i] = d1[i].BeginInvoke(yThreadMin[i], yThreadMax[i], r, ref tempSumOfIntensity[i], ref tempSumOfIntensitySquare[i], ref tempContributedPixels[i], null, null);//各スレッド起動転送
for (i = 0; i < thread; i++)//スレッド終了待ち
d1[i].EndInvoke(ref tempSumOfIntensity[i], ref tempSumOfIntensitySquare[i], ref tempContributedPixels[i], ar1[i]);
//FindSpotsThread1Delegate[] d1 = new FindSpotsThread1Delegate[thread];
//IAsyncResult[] ar1 = new IAsyncResult[thread];
//for (i = 0; i < thread; i++)
// d1[i] = new FindSpotsThread1Delegate(FindSpotsThread1);
//for (i = 0; i < thread; i++)
// ar1[i] = d1[i].BeginInvoke(yThreadMin[i], yThreadMax[i], r, ref tempSumOfIntensity[i], ref tempSumOfIntensitySquare[i], ref tempContributedPixels[i], null, null);//各スレッド起動転送
//for (i = 0; i < thread; i++)//スレッド終了待ち
// d1[i].EndInvoke(ref tempSumOfIntensity[i], ref tempSumOfIntensitySquare[i], ref tempContributedPixels[i], ar1[i]);

Parallel.For(0, thread, i => FindSpotsThread1(yThreadMin[i], yThreadMax[i], r, ref tempSumOfIntensity[i], ref tempSumOfIntensitySquare[i], ref tempContributedPixels[i]));

//Thread1の結果をまとめる
double[] ContributedPixels = new double[rMax];
Expand Down Expand Up @@ -498,7 +502,7 @@ public static void FindSpots(IntegralProperty iP, double DeviationFactor)
}
}

private delegate void FindSpotsThread0Delegate(int yMin, int yMax, ref int[] r, ref int rMax);
//private delegate void FindSpotsThread0Delegate(int yMin, int yMax, ref int[] r, ref int rMax);

public static void FindSpotsThread0(int yMin, int yMax, ref int[] r, ref int rMax)
{
Expand Down
6 changes: 2 additions & 4 deletions Crystallography/PeakSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ public static PointD FitPeakAsSimple(double angle, double range, PointD[] pt)
return new PointD(x, temp);
}

public delegate void FitPeakDelegate(PointD[] pt, bool BackgroundFitting, double RemoveBadSN, ref PeakFunction p);


public static void FitPeakThread(PointD[] pt, bool BackgroundFitting, double RemoveBadSN, ref PeakFunction p)
{
PeakFunction[] param = new PeakFunction[1];
Expand All @@ -409,8 +408,7 @@ public static void FitPeakThread(PointD[] pt, bool BackgroundFitting, double Rem
p = param[0];
}

public delegate bool FitMultiPeaksDelegate(PointD[] pt, bool BackgroundFitting, double RemoveBadSN, ref PeakFunction[] p);


/// <summary>
/// 複数ピークをフィッティングする. 戻り値は、R値
/// </summary>
Expand Down
40 changes: 22 additions & 18 deletions PDIndexer/FormFitting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,26 +316,30 @@ public void Fitting()
if (!checkBoxPatternDecomposition.Checked)
{
#region ピーク分離モードではないとき
List<FittingPeak.FitPeakDelegate> d = new List<FittingPeak.FitPeakDelegate>();
List<IAsyncResult> ar = new List<IAsyncResult>();
//List<FittingPeak.FitPeakDelegate> d = new List<FittingPeak.FitPeakDelegate>();
//List<IAsyncResult> ar = new List<IAsyncResult>();

for (int i = 0; i < TargetCrystal.Plane.Count; i++)
if (TargetCrystal.Plane[i].IsFittingChecked && TargetCrystal.Plane[i].SerchOption != PeakFunctionForm.Simple)
{
d.Add(new FittingPeak.FitPeakDelegate(FittingPeak.FitPeakThread));
ar.Add(d[d.Count - 1].BeginInvoke(TargetProfile.Pt.ToArray(), true, 0, ref TargetCrystal.Plane[i].peakFunction, null, null));
}
int n = 0;
for (int i = 0; i < TargetCrystal.Plane.Count; i++)
{
if (TargetCrystal.Plane[i].IsFittingChecked && TargetCrystal.Plane[i].SerchOption != PeakFunctionForm.Simple)
{
d[n].EndInvoke(ref TargetCrystal.Plane[i].peakFunction, ar[n]);
TargetCrystal.Plane[i].XObs = TargetCrystal.Plane[i].peakFunction.X;
TargetCrystal.Plane[i].observedIntensity = TargetCrystal.Plane[i].peakFunction.GetIntegral() / (dp.Profile.Pt[1].X - dp.Profile.Pt[0].X);
n++;
Parallel.For(0, TargetCrystal.Plane.Count, i =>
{
if (TargetCrystal.Plane[i].IsFittingChecked && TargetCrystal.Plane[i].SerchOption != PeakFunctionForm.Simple)
{

FittingPeak.FitPeakThread(TargetProfile.Pt.ToArray(), true, 0, ref TargetCrystal.Plane[i].peakFunction);
//d.Add(new FittingPeak.FitPeakDelegate(FittingPeak.FitPeakThread));
//ar.Add(d[d.Count - 1].BeginInvoke(TargetProfile.Pt.ToArray(), true, 0, ref TargetCrystal.Plane[i].peakFunction, null, null));
}
}
});
//int n = 0;
//for (int i = 0; i < TargetCrystal.Plane.Count; i++)
//{
// if (TargetCrystal.Plane[i].IsFittingChecked && TargetCrystal.Plane[i].SerchOption != PeakFunctionForm.Simple)
// {
// d[n].EndInvoke(ref TargetCrystal.Plane[i].peakFunction, ar[n]);
// TargetCrystal.Plane[i].XObs = TargetCrystal.Plane[i].peakFunction.X;
// TargetCrystal.Plane[i].observedIntensity = TargetCrystal.Plane[i].peakFunction.GetIntegral() / (dp.Profile.Pt[1].X - dp.Profile.Pt[0].X);
// n++;
// }
//}
#endregion
}
//ピーク分離フィッティングモードのとき
Expand Down
4 changes: 2 additions & 2 deletions PDIndexer/PDIndexer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2021.7.6.1047</AssemblyVersion>
<FileVersion>2021.7.6.1047</FileVersion>
<AssemblyVersion>2021.7.9.0925</AssemblyVersion>
<FileVersion>2021.7.9.0925</FileVersion>
<ApplicationIcon>App.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions PDIndexer/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static public string RecentHistory
/// </summary>
static public string History =
"History" +
"\r\n ver4.402(2021/07/09) Fixed a minor bug when fitting peaks." +
"\r\n ver4.401(2021/07/06) Fixed a minor bug when loading MPLOT FILE files." +
"\r\n ver4.400(2021/07/05) Fixed a minor bug when loading gsa files." +
"\r\n ver4.399(2021/07/02) Target framework is changed to .Net 5.0. Added new EOSs (Fratanduono+ 2021)." +
Expand Down

0 comments on commit 831f6ba

Please sign in to comment.