Partial implementation of global fit option using msr2data.
This commit is contained in:
parent
2e2f4554a9
commit
924edcf70f
1130
src/external/MuSRFitGUI/MSR.pm
vendored
1130
src/external/MuSRFitGUI/MSR.pm
vendored
File diff suppressed because it is too large
Load Diff
78
src/external/MuSRFitGUI/MuSRFit4.pm
vendored
78
src/external/MuSRFitGUI/MuSRFit4.pm
vendored
@ -282,13 +282,12 @@ sub CreateAllInput()
|
||||
$All{"LRBF"} = this->{ui}->histsLRBF->text;
|
||||
my @Hists = split(/,/, $All{"LRBF"} );
|
||||
# Lifetime corrections in enabled/visible only for SingleHis fits
|
||||
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
|
||||
this->{ui}->ltc->setHidden(1);
|
||||
$All{"fittype"}=2;
|
||||
}
|
||||
elsif ( $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
if ( $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
this->{ui}->ltc->setHidden(0);
|
||||
$All{"fittype"}=0;
|
||||
} else {
|
||||
this->{ui}->ltc->setHidden(1);
|
||||
$All{"fittype"}=2;
|
||||
}
|
||||
|
||||
# From Fitting Tab
|
||||
@ -419,10 +418,9 @@ sub CreateAllInput()
|
||||
my $Parameters=$Paramcomp[$Component-1];
|
||||
my @Params = split( /\s+/, $Parameters );
|
||||
|
||||
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
|
||||
if ( $Component == 1 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB" )) {
|
||||
unshift( @Params, "Alpha" );
|
||||
}
|
||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
} elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
unshift( @Params, ( "No", "NBg" ) );
|
||||
}
|
||||
|
||||
@ -441,7 +439,7 @@ sub CreateAllInput()
|
||||
}
|
||||
|
||||
# Is there any point of sharing, multiple runs?
|
||||
if ( $#RUNS == 0 && $All{"FitAsyType"} eq "Asymmetry") {
|
||||
if ( $#RUNS == 0 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB")) {
|
||||
$Shared = 1;
|
||||
}
|
||||
elsif ( $#RUNS == 0 && $#Hists == 0 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
@ -534,47 +532,52 @@ sub CallMSRCreate()
|
||||
if ($Answer) {
|
||||
if ( $All{"FitAsyType"} eq "Asymmetry") {
|
||||
if ($All{"RUNSType"}) {
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSR(\%All);
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRUni(\%All);
|
||||
# Open output file FILENAME.msr
|
||||
open( OUTF,q{>},"$FILENAME" );
|
||||
print OUTF ("$FullMSRFile");
|
||||
close(OUTF);
|
||||
} else {
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSR(\%All);
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRUni(\%All);
|
||||
# Open output file FILENAME.msr
|
||||
open( OUTF,q{>},"$FILENAME" );
|
||||
print OUTF ("$FullMSRFile");
|
||||
close(OUTF);
|
||||
# if it is multiple runs then the produced file is a template
|
||||
my $FILENAME=$All{"FILENAME"}.".msr";
|
||||
my $Extension = "_".$All{"BeamLine"}."_".$All{"YEAR"};
|
||||
if ($All{"BeamLine"} eq "LEM (PPC)") {
|
||||
$Extension = "_LEM_".$All{"YEAR"};
|
||||
}
|
||||
} else {
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRGLB(\%All);
|
||||
my @RUNS = split( /,/,MSR::ExpandRunNumbers($All{"RunNumbers"}));
|
||||
my @Hists = split( /,/, $All{"LRBF"} );
|
||||
# Write to template file
|
||||
open( OUTF,q{>},"$RUNS[0]_tmpl.msr" );
|
||||
print OUTF ("$FullMSRFile");
|
||||
close(OUTF);
|
||||
|
||||
if (-e $FILENAME) {
|
||||
my $RUN0 = $FILENAME;
|
||||
$RUN0 =~ s/$Extension//g;
|
||||
$RUN0 =~ s/.msr//g;
|
||||
my $cmd = $All{"RunNumbers"};
|
||||
$cmd =~ s/,/ /g;
|
||||
$cmd = "msr2data \[".$cmd."\] ".$Extension." msr-".$RUN0." global";
|
||||
$cmd = $cmd."; mv $RUN0+global$Extension.msr ".$FILENAME;
|
||||
# Change runs line in the final global fit
|
||||
my $NSpectra = ($#RUNS+1)*($#Hists+1);
|
||||
my $NewRunLine = "runs ".join(" ",(1...$NSpectra));
|
||||
# Use msr2data to generate global fit MSR file
|
||||
my $RunList = join(" ",@RUNS);
|
||||
my $cmd = "msr2data \[".$RunList."\] "." _tmpl msr-".$RUNS[0]." global";
|
||||
# create the global file
|
||||
print $cmd."\n";
|
||||
my $pid = open(FTO,"$cmd 2>&1 |");
|
||||
while (<FTO>) {
|
||||
this->{ui}->fitTextOutput->append("$_");
|
||||
}
|
||||
close(FTO);
|
||||
# change the stupid name
|
||||
my $StupidName = $RUNS[0]."+global_tmpl.msr";
|
||||
# change stupid default runs line
|
||||
$cmd = "cp $StupidName $FILENAME; perl -pi -e 's/runs.*?(?=\n)/$NewRunLine/s' $FILENAME";
|
||||
$pid = open(FTO,"$cmd 2>&1 |");
|
||||
print $cmd."\n";
|
||||
while (<FTO>) {
|
||||
this->{ui}->fitTextOutput->append("$_");
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ( $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRSingleHist(\%All);
|
||||
# Open output file FILENAME.msr
|
||||
open( OUTF,q{>},"$FILENAME" );
|
||||
print OUTF ("$FullMSRFile");
|
||||
close(OUTF);
|
||||
close(FTO);
|
||||
# feed in values of parameters if they exist
|
||||
|
||||
}
|
||||
UpdateMSRFileInitTable();
|
||||
}
|
||||
@ -615,6 +618,7 @@ sub UpdateMSRFileInitTable()
|
||||
# if there is only one more = minimum, check $#Param=6
|
||||
|
||||
# To summarize, check the value of $#Param
|
||||
my $name=$Param[2];
|
||||
my $value=1.0*$Param[3];
|
||||
my $error = 1.0*$Param[4];
|
||||
my $minvalue=0.0;
|
||||
@ -640,6 +644,8 @@ sub UpdateMSRFileInitTable()
|
||||
$QTable->setItem($PCount,1,Qt::TableWidgetItem());
|
||||
$QTable->setItem($PCount,2,Qt::TableWidgetItem());
|
||||
$QTable->setItem($PCount,3,Qt::TableWidgetItem());
|
||||
# Set also label or row
|
||||
$QTable->verticalHeaderItem($PCount)->setText($name);
|
||||
$QTable->item($PCount,0)->setText($value);
|
||||
$QTable->item($PCount,1)->setText($error);
|
||||
$QTable->item($PCount,2)->setText($minvalue);
|
||||
@ -710,7 +716,7 @@ sub ActivateShComp()
|
||||
my $Parameters=$Paramcomp[$Component-1];
|
||||
my @Params = split( /\s+/, $Parameters );
|
||||
|
||||
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
|
||||
if ( $Component == 1 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB")) {
|
||||
unshift( @Params, "Alpha" );
|
||||
}
|
||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
@ -821,7 +827,7 @@ sub GoFit()
|
||||
# Check here is the number of histograms makes sense
|
||||
# other wise give error.
|
||||
my @Hists = split( /,/, $All{"LRBF"} );
|
||||
if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) {
|
||||
if (($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB") && $#Hists != 1) {
|
||||
# we have a problem here send error message
|
||||
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
||||
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
||||
@ -856,7 +862,7 @@ sub GoPlot()
|
||||
# Check here is the number of histograms makes sense
|
||||
# other wise give error.
|
||||
my @Hists = split( /,/, $All{"LRBF"} );
|
||||
if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) {
|
||||
if (($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB") && $#Hists != 1) {
|
||||
# we have a problem here send error message
|
||||
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
||||
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
||||
@ -1019,7 +1025,7 @@ sub InitializeFunctions()
|
||||
my @Params = split( /\s+/, $Parameters );
|
||||
|
||||
# Alpha, No and NBg are counted in the parameters
|
||||
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
|
||||
if ( $Component == 1 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB" )) {
|
||||
unshift( @Params, "Alpha" );
|
||||
}
|
||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||
|
9
src/external/MuSRFitGUI/MuSRFit4.ui
vendored
9
src/external/MuSRFitGUI/MuSRFit4.ui
vendored
@ -231,7 +231,7 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Asymmetry</string>
|
||||
<string>Asymmetry GLB</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -241,12 +241,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Asymmetry GLB</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Single Hist GLB</string>
|
||||
<string>Asymmetry</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
7
src/external/MuSRFitGUI/Ui_MuSRFit4.pm
vendored
7
src/external/MuSRFitGUI/Ui_MuSRFit4.pm
vendored
@ -5,7 +5,7 @@
|
||||
#################################################################################
|
||||
## Form generated from reading UI file 'MuSRFit4.ui'
|
||||
##
|
||||
## Created: Mon Jan 29 14:11:03 2018
|
||||
## Created: Mon Feb 5 15:38:20 2018
|
||||
## by: Qt User Interface Compiler version 4.8.7
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
@ -3199,10 +3199,9 @@ sub retranslateUi {
|
||||
$self->{browse}->setWhatsThis( Qt::Application::translate( 'MuSRFit4', "Browse to select data files for fitting.", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
$self->{browse}->setText( Qt::Application::translate( 'MuSRFit4', "Browse", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
$self->{fitAsyTypeLabel}->setText( Qt::Application::translate( 'MuSRFit4', "Fit type", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
$self->{fitAsyType}->insertItems(0, [Qt::Application::translate( 'MuSRFit4', "Asymmetry", undef, Qt::Application::UnicodeUTF8() ),
|
||||
$self->{fitAsyType}->insertItems(0, [Qt::Application::translate( 'MuSRFit4', "Asymmetry GLB", undef, Qt::Application::UnicodeUTF8() ),
|
||||
Qt::Application::translate( 'MuSRFit4', "Single Hist", undef, Qt::Application::UnicodeUTF8() ),
|
||||
Qt::Application::translate( 'MuSRFit4', "Asymmetry GLB", undef, Qt::Application::UnicodeUTF8() ),
|
||||
Qt::Application::translate( 'MuSRFit4', "Single Hist GLB", undef, Qt::Application::UnicodeUTF8() )]);
|
||||
Qt::Application::translate( 'MuSRFit4', "Asymmetry", undef, Qt::Application::UnicodeUTF8() )]);
|
||||
$self->{histsLRBFLabel}->setText( Qt::Application::translate( 'MuSRFit4', "Histograms list", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
$self->{histsLRBF}->setText( Qt::Application::translate( 'MuSRFit4', "1 5,3 7", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
$self->{runsAuto}->setTitle( Qt::Application::translate( 'MuSRFit4', "RUN Numbers", undef, Qt::Application::UnicodeUTF8() ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user