From c691fa17f36a930eeda554dc58b33a735341985b Mon Sep 17 00:00:00 2001 From: Patrick Avery Date: Tue, 21 Nov 2023 15:16:27 -0600 Subject: [PATCH] Add property for point group number to material The material's (or unitcell's) point group can now be accessed via a `pgnum` property. This also adds some dicts that store this info. Signed-off-by: Patrick Avery --- hexrd/constants.py | 3 +++ hexrd/material.py | 5 +++++ hexrd/unitcell.py | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/hexrd/constants.py b/hexrd/constants.py index 409e4953a..fa92fbcc7 100644 --- a/hexrd/constants.py +++ b/hexrd/constants.py @@ -1159,6 +1159,9 @@ def is_writable_file(path): 'td': '2dm', 'oh': '3dgh' } +# The above dict must be in the correct order for this to work +SYM_PG_to_PGNUM = {pg: i + 1 for i, pg in enumerate(SYM_GL_PG)} +SYM_PGNUM_to_PG = {v: k for k, v in SYM_PG_to_PGNUM.items()} # Set the __version__ variable try: diff --git a/hexrd/material.py b/hexrd/material.py index ff2802edc..029cbe52b 100644 --- a/hexrd/material.py +++ b/hexrd/material.py @@ -852,6 +852,11 @@ def _set_sgnum(self, v): sgnum = property(_get_sgnum, _set_sgnum, None, "Space group number") + + @property + def pgnum(self): + return self.unitcell.pgnum + # property: beamEnergy def _get_beamEnergy(self): diff --git a/hexrd/unitcell.py b/hexrd/unitcell.py index 8dd72ff08..094981dc2 100644 --- a/hexrd/unitcell.py +++ b/hexrd/unitcell.py @@ -1661,6 +1661,14 @@ def sgnum(self, val): self.CalcDensity() self.calc_absorption_length() + @property + def pgnum(self): + return constants.SYM_PG_to_PGNUM[self.point_group] + + @property + def point_group(self): + return self._pointGroup + @property def atom_pos(self): return self._atom_pos