Skip to content

Commit 4ed41c9

Browse files
committed
Merge branch 'upstream-objcryst':
* PowderPatternDiffraction: add GetFhklObsSq() and HasFhklObsSq() * Use a valid XML output for a Molecule RigidGroup, writing atoms as Atom1, Atom2 etc... instead of repeating the Atom attribute. Fixes vincefn/objcryst#52. The saved files will not be backwards-compatible (readable but the list of atoms in the rigid group will not be read) * Fix double loop in PowderPattern::PrepareIntegratedRfactor.
2 parents c71eb53 + 8e8a68c commit 4ed41c9

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/ObjCryst/ObjCryst/Molecule.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <algorithm>
2626
#include <iomanip>
2727
#include <ctime>
28+
#include <boost/format.hpp>
2829

2930
#include "ObjCryst/Quirks/VFNStreamFormat.h"
3031
#include "ObjCryst/ObjCryst/Molecule.h"
@@ -2292,8 +2293,12 @@ void Molecule::XMLOutput(ostream &os,int indent)const
22922293
for(pos=mvRigidGroup.begin();pos!=mvRigidGroup.end();++pos)
22932294
{
22942295
XMLCrystTag tagg("RigidGroup",false,true);
2295-
for(set<MolAtom *>::const_iterator at=(*pos)->begin();at!=(*pos)->end();++at)
2296-
tagg.AddAttribute("Atom",(*at)->GetName());
2296+
// Need to use Atom1, Atom2 etc.. so a valid XML is produced
2297+
// See https://github.com/vincefn/objcryst/issues/52
2298+
// This won't be backwards-compatible
2299+
int idx = 0;
2300+
for (set<MolAtom*>::const_iterator at = (*pos)->begin(); at != (*pos)->end(); ++at)
2301+
tagg.AddAttribute((boost::format("Atom%d") %idx++).str(), (*at)->GetName());
22972302
/*
22982303
tagg.AddAttribute("Q0",(*pos)->mQuat.Q0());
22992304
tagg.AddAttribute("Q1",(*pos)->mQuat.Q1());
@@ -2384,7 +2389,7 @@ void Molecule::XMLInput(istream &is,const XMLCrystTag &tag)
23842389
{
23852390
RigidGroup s;
23862391
for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
2387-
if("Atom"==tagg.GetAttributeName(i))
2392+
if(tagg.GetAttributeName(i).rfind("Atom", 0)==0)
23882393
s.insert(&(this->GetAtom(tagg.GetAttributeValue(i))));
23892394
this->AddRigidGroup(s);
23902395
}

src/ObjCryst/ObjCryst/PowderPattern.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,19 @@ unsigned int PowderPatternDiffraction::GetProfileFitNetNbObs()const
12981298
return nb;
12991299
}
13001300

1301+
bool PowderPatternDiffraction::HasFhklObsSq() const
1302+
{
1303+
if(mpLeBailData==NULL) return false;
1304+
return mpLeBailData->GetFhklObsSq().size() > 0;
1305+
}
1306+
1307+
const CrystVector_REAL& PowderPatternDiffraction::GetFhklObsSq() const
1308+
{
1309+
if(mpLeBailData==NULL)
1310+
throw ObjCrystException("PowderPatternDiffraction::GetFhklObsSq(): no extracted intensities available");
1311+
return mpLeBailData->GetFhklObsSq();
1312+
}
1313+
13011314
void PowderPatternDiffraction::CalcPowderPattern() const
13021315
{
13031316
this->GetNbReflBelowMaxSinThetaOvLambda();
@@ -6559,7 +6572,7 @@ void PowderPattern::PrepareIntegratedRfactor()const
65596572
for(int i=0;i<mPowderPatternComponentRegistry.GetNb();i++)
65606573
{
65616574
const CrystVector_long vLim=mPowderPatternComponentRegistry.GetObj(i).GetBraggLimits();
6562-
for(i=0;i<vLim.numElements();i++) vLimits.push_back(vLim(i));
6575+
for(int j=0;j<vLim.numElements();j++) vLimits.push_back(vLim(j));
65636576
}
65646577
if(vLimits.size()<2)
65656578
{

src/ObjCryst/ObjCryst/PowderPattern.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ class PowderPatternDiffraction : virtual public PowderPatternComponent,public Sc
420420
* No over paremeters (profile, background) are taken into account
421421
*/
422422
unsigned int GetProfileFitNetNbObs()const;
423+
/// Return true if there are extracted (le Bail) squared structure factors, false otherwise
424+
bool HasFhklObsSq() const;
425+
/** Get the extracted structure factors modulus (squared), e.g. using the Le Bail method.
426+
*
427+
* Note that the number of reflections listed is limited to the evaluated ones,
428+
*which is usually smaller than the H,K and L arrays.
429+
*
430+
* Raises an exception if this is not available.
431+
*/
432+
const CrystVector_REAL& GetFhklObsSq() const;
423433
protected:
424434
virtual void CalcPowderPattern() const;
425435
virtual void CalcPowderPattern_FullDeriv(std::set<RefinablePar *> &vPar);

0 commit comments

Comments
 (0)