Skip to content

Commit

Permalink
Merged with master. Refs #8096.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Oct 9, 2013
1 parent def77d7 commit e0b2f58
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace DataHandling
void parseTableWorkspace();

/// Map containing the name of value of each parameter required by .irf file
std::map<std::string, double> mParameters;
std::map<std::string, double> m_profileParamMap;

/// Input table workspace
DataObjects::TableWorkspace_sptr inpWS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ namespace DataHandling
else if (boost::starts_with(line,"END"))
{
// Ignore END line
g_log.debug() << "END line of bank";
g_log.debug("END line of bank." );
}
else
{
Expand Down Expand Up @@ -726,6 +726,7 @@ namespace DataHandling
return tablews;
}

#if 0
// TODO - Implement this
int LoadFullprofResolution::searchProfile()
{
Expand All @@ -746,6 +747,7 @@ namespace DataHandling


}
#endif

} // namespace DataHandling
} // namespace Mantid
Expand Down
151 changes: 122 additions & 29 deletions Code/Mantid/Framework/DataHandling/src/SaveFullprofResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace DataHandling
void SaveFullprofResolution::parseTableWorkspace()
{
// 1. Clear the parameter
mParameters.clear();
m_profileParamMap.clear();

// 2. Check the table workspace
std::vector<std::string> colnames = inpWS->getColumnNames();
Expand Down Expand Up @@ -138,13 +138,13 @@ namespace DataHandling
std::string parname;
double parvalue;
row >> parname >> parvalue;
mParameters.insert(std::make_pair(parname, parvalue));
m_profileParamMap.insert(std::make_pair(parname, parvalue));
}

// 4. Debug output
stringstream dbss("Imported Parameter Table: \n");
map<string, double>::iterator mit;
for (mit = mParameters.begin(); mit != mParameters.end(); ++mit)
for (mit = m_profileParamMap.begin(); mit != m_profileParamMap.end(); ++mit)
dbss << setw(20) << mit->first << " = " << setprecision(5) << mit->second << endl;
cout << dbss.str();

Expand All @@ -157,32 +157,32 @@ namespace DataHandling
std::string SaveFullprofResolution::toProf10IrfString(int bankid)
{
// 1. Get all parameter values
double tofmin = mParameters["tof-min"];
double tofmax = mParameters["tof-max"];
double zero = mParameters["Zero"];
double zerot = mParameters["Zerot"];
double tofstep = mParameters["step"];
double dtt1 = mParameters["Dtt1"];
double dtt1t = mParameters["Dtt1t"];
double dtt2t = mParameters["Dtt2t"];
double xcross = mParameters["Tcross"];
double width = mParameters["Width"];
double sig2 = mParameters["Sig2"];
double sig1 = mParameters["Sig1"];
double sig0 = mParameters["Sig0"];
double gam2 = mParameters["Gam2"];
double gam1 = mParameters["Gam1"];
double gam0 = mParameters["Gam0"];
double alph0 = mParameters["Alph0"];
double alph1 = mParameters["Alph1"];
double alph0t = mParameters["Alph0t"];
double alph1t = mParameters["Alph1t"];
double beta0 = mParameters["Beta0"];
double beta1 = mParameters["Beta1"];
double beta0t = mParameters["Beta0t"];
double beta1t = mParameters["Beta1t"];
int profindex = static_cast<int>(floor(mParameters["Profile"] + 0.5));
double twotheta = mParameters["twotheta"];
double tofmin = m_profileParamMap["tof-min"];
double tofmax = m_profileParamMap["tof-max"];
double zero = m_profileParamMap["Zero"];
double zerot = m_profileParamMap["Zerot"];
double tofstep = m_profileParamMap["step"];
double dtt1 = m_profileParamMap["Dtt1"];
double dtt1t = m_profileParamMap["Dtt1t"];
double dtt2t = m_profileParamMap["Dtt2t"];
double xcross = m_profileParamMap["Tcross"];
double width = m_profileParamMap["Width"];
double sig2 = m_profileParamMap["Sig2"];
double sig1 = m_profileParamMap["Sig1"];
double sig0 = m_profileParamMap["Sig0"];
double gam2 = m_profileParamMap["Gam2"];
double gam1 = m_profileParamMap["Gam1"];
double gam0 = m_profileParamMap["Gam0"];
double alph0 = m_profileParamMap["Alph0"];
double alph1 = m_profileParamMap["Alph1"];
double alph0t = m_profileParamMap["Alph0t"];
double alph1t = m_profileParamMap["Alph1t"];
double beta0 = m_profileParamMap["Beta0"];
double beta1 = m_profileParamMap["Beta1"];
double beta0t = m_profileParamMap["Beta0t"];
double beta1t = m_profileParamMap["Beta1t"];
int profindex = static_cast<int>(floor(m_profileParamMap["Profile"] + 0.5));
double twotheta = m_profileParamMap["twotheta"];

// 2. Deal with profile index
if (profindex == 0)
Expand Down Expand Up @@ -258,7 +258,100 @@ namespace DataHandling
// TODO - Wrok on this
std::string SaveFullprofResolution::toProf9IrfString(int bankid)
{
// 1. Get all parameter values
double tofmin = m_profileParamMap["tof-min"];
double tofmax = m_profileParamMap["tof-max"];
double zero = m_profileParamMap["Zero"];
double tofstep = m_profileParamMap["step"];
double dtt1 = m_profileParamMap["Dtt1"];
double dtt2 = m_profileParamMap["Dtt2"];
double xcross = m_profileParamMap["Tcross"];
double width = m_profileParamMap["Width"];
double sig2 = m_profileParamMap["Sig2"];
double sig1 = m_profileParamMap["Sig1"];
double sig0 = m_profileParamMap["Sig0"];
double gam2 = m_profileParamMap["Gam2"];
double gam1 = m_profileParamMap["Gam1"];
double gam0 = m_profileParamMap["Gam0"];
double alph0 = m_profileParamMap["Alph0"];
double alph1 = m_profileParamMap["Alph1"];
double alph0t = m_profileParamMap["Alph0t"];
double alph1t = m_profileParamMap["Alph1t"];
double beta0 = m_profileParamMap["Beta0"];
double beta1 = m_profileParamMap["Beta1"];
double beta0t = m_profileParamMap["Beta0t"];
double beta1t = m_profileParamMap["Beta1t"];
int profindex = static_cast<int>(floor(m_profileParamMap["Profile"] + 0.5));
double twotheta = m_profileParamMap["twotheta"];

// 2. Deal with profile index
if (profindex == 0)
{
profindex = 10;
}

// 3. Write out
std::stringstream content;

content << fixed;
content << " Instrumental resolution function for POWGEN/SNS J.P. Hodges 2011-09-02 ireso: 6" << std::endl;
content << "! To be used with function NPROF=" << profindex << " in FullProf (Res=6)" << std::endl;
content << "! ---------------------------------------------- Bank " << bankid << " CWL = 0.5330A" << std::endl;
content << "! Type of profile function: back-to-back exponentials * pseudo-Voigt" << std::endl;
content << "NPROF " << profindex << std::endl;

content << "! Tof-min(us) step Tof-max(us)" << std::endl;
content << "TOFRG "
<< setprecision(3) << tofmin << " "
<< setw(16) << setprecision(5) << tofstep << " "
<< setw(16) << setprecision(3) << tofmax << std::endl;

content << "! Zero Dtt1" << std::endl;
content << "ZD2TOF "
<< setprecision(5) << zero
<< setw(16) << setprecision(5) << dtt1 << std::endl;

content << "! Zerot Dtt1t Dtt2t x-cross Width" << std::endl;
content << "ZD2TOT "
<< setprecision(5) << zerot
<< setw(16) << setprecision(5) << dtt1t
<< setw(16) << setprecision(5) << dtt2t
<< setw(16) << setprecision(10) << xcross
<< setw(16) << setprecision(5) << width << std::endl;

content << "! TOF-TWOTH of the bank" << std::endl;
content << "TWOTH " << setprecision(3) << twotheta << std::endl;

// Note that sig0, sig1 and sig2 used in LeBail/Mantid framework are of the definition in manual.
// In .irf file, Sig-0, Sig-1 and Sig-2 are the squared values;
content << "! Sig-2 Sig-1 Sig-0" << std::endl;
content << "SIGMA "
<< setprecision(6) << sig2*sig2
<< setw(16) << setprecision(6) << sig1*sig1
<< setw(16) << setprecision(6) << sig0*sig0 << std::endl;

content << "! Gam-2 Gam-1 Gam-0" << std::endl;
content << "GAMMA "
<< setw(16) << setprecision(6) << gam2 << " "
<< setw(16) << setprecision(6) << gam1 << " "
<< setw(16) << setprecision(6) << gam0 << "\n";

content << "! alph0 beta0 alph1 beta1" << std::endl;
content << "ALFBE "
<< setprecision(6) << alph0 << " " <<
setw(16) << setprecision(6) << beta0 << " " <<
setw(16) << setprecision(6) << alph1 << " " <<
setw(16) << setprecision(6) << beta1 << std::endl;

content << "! alph0t beta0t alph1t beta1t" << std::endl;
content << "ALFBT "
<< setprecision(6) << alph0t << " "
<< setw(16) << setprecision(6) << beta0t << " "
<< setw(16) << setprecision(6) << alph1t << " "
<< setw(16) << setprecision(6) << beta1t << std::endl;
content << "END" << std::endl;

return content.str();


return "";
Expand Down

0 comments on commit e0b2f58

Please sign in to comment.