Skip to content

Commit

Permalink
Fixed a bug and cleaned code. Refs #6968.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Aug 20, 2013
1 parent 39ebb37 commit 8bfb90e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class DLLExport SaveGSASInstrumentFile : public API::Algorithm
void writePRMSingleBank(std::map<unsigned int, std::map<std::string, double> > bankprofilemap,
unsigned int bankid, std::string prmfilename);

///
void makeParameterConsistent();

/// Caclualte L2 from DIFFC and L1
double calL2FromDtt1(double difc, double L1, double twotheta);
Expand Down
72 changes: 15 additions & 57 deletions Code/Mantid/Framework/Algorithms/src/SaveGSASInstrumentFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,22 @@ namespace Algorithms
map<unsigned int, map<string, double> > bankprofileparammap;
parseProfileTableWorkspace(m_inpWS, bankprofileparammap);

//
makeParameterConsistent();
// Deal with a default
if (m_vecBankID2File.size() == 0)
{
// Default is to export all banks
for (map<unsigned int, map<string, double> >::iterator miter = bankprofileparammap.begin();
miter != bankprofileparammap.end(); ++miter)
{
unsigned int bankid = miter->first;
m_vecBankID2File.push_back(bankid);
}
sort(m_vecBankID2File.begin(), m_vecBankID2File.end());
}
g_log.debug() << "Number of banks to output = " << m_vecBankID2File.size() << ".\n";


// Convert to GSAS
convertToGSAS(m_vecBankID2File, m_gsasFileName, bankprofileparammap);

return;
Expand Down Expand Up @@ -477,61 +490,6 @@ namespace Algorithms
return;
}

//----------------------------------------------------------------------------------------------
/** Some parameter can come from 3 sources (1) default in code; (2) input table workspace and
* (3) user-specified property. Set up this kind of parameter from all possible source
* with proper prioirty
*/
void SaveGSASInstrumentFile::makeParameterConsistent()
{
g_log.warning("This one may not be useful at all. ");
return;

#if 0
// Make input parameters consistent
for (size_t i = 0; i < m_vecBankID2File.size(); ++i)
{
unsigned int bankid = m_vecBankID2File[i];
map<unsigned int, map<string, double> >::iterator biter = bankprofileparammap.find(bankid);
if (biter == bankprofileparammap.end())
{
stringstream errss;
errss << "Bank " << bankid << " does not exist in input workspace. "
<< "Input file/tableworkspace constains " << bankprofileparammap.size() << " banks. ";
g_log.error(errss.str());
throw runtime_error(errss.str());
}

if (m_2theta != EMPTY_DBL())
{
m_configuration->setParameter(bankid, "2Theta", m_2theta);
}
else
{
double tth = getValueFromMap(biter->second, "twotheta");
if (tth != EMPTY_DBL())
m_configuration->setParameter(bankid,"2Theta", tth);
}

// L1
if (m_L1 != EMPTY_DBL())
{
m_configuration->setParameter(bankid, "L1", m_L1);
}

// L2
if (m_L2 != EMPTY_DBL())
{
m_configuration->setParameter(bankid, "L2", m_L2);
}
}

// FIXME - the data structure to store the instrument/profile parameters is still NOT clear.
#endif

return;
}

//----------------------------------------------------------------------------------------------
/** Parse profile table workspace to a map (the new ...
*/
Expand Down

0 comments on commit 8bfb90e

Please sign in to comment.