Skip to content

Commit

Permalink
General: Introduced NDArray option in xrdpattern; Renamed PowderPrope…
Browse files Browse the repository at this point in the history
…rties -> Powder
  • Loading branch information
Somerandomguy10111 committed May 28, 2024
1 parent a34800b commit 363f329
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/t_powder/examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from xrdpattern.core import Labels, CrystalStructure, CrystalBase, Artifacts, PowderProperties
from xrdpattern.core import Labels, CrystalStructure, CrystalBase, Artifacts, Powder

cif_fpath = os.path.join(os.path.dirname(__file__), "test.cif")
cif_fpath2 = os.path.join(os.path.dirname(__file__), 'test2.cif')
Expand All @@ -9,7 +9,7 @@
class Examples:
@staticmethod
def get_sample():
sample = PowderProperties(crystal_structure=Examples.get_crystal(mute=True), crystallite_size=500)
sample = Powder(crystal_structure=Examples.get_crystal(mute=True), crystallite_size=500)
artifact = Examples.get_artifacts()
powder_sample = Labels(powder=sample, artifacts=artifact, is_simulated=True)
return powder_sample
Expand Down
4 changes: 2 additions & 2 deletions tests/t_powder/t_labels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tempfile

from holytools.devtools import Unittest
from xrdpattern.core import Labels, PowderProperties, CrystalStructure, AtomicSite, LabelTensor, Lengths, Angles, \
from xrdpattern.core import Labels, Powder, CrystalStructure, AtomicSite, LabelTensor, Lengths, Angles, \
CrystalBase, Artifacts


Expand Down Expand Up @@ -72,7 +72,7 @@ def make_example_label() -> Labels:
crystal_structure = CrystalStructure(lengths=primitives, angles=angles, base=base)
crystal_structure.space_group = 120

powder = PowderProperties(crystal_structure=crystal_structure, crystallite_size=10.0)
powder = Powder(crystal_structure=crystal_structure, crystallite_size=10.0)
artifacts = Artifacts(primary_wavelength=1.54, secondary_wavelength=1.54, secondary_to_primary=0.5)
return Labels(powder, artifacts, is_simulated=True)

Expand Down
6 changes: 3 additions & 3 deletions xrdpattern/core/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_size(self) -> int:

@dataclass
class Labels:
powder : PowderProperties
powder : Powder
artifacts : Artifacts
is_simulated : bool

Expand Down Expand Up @@ -90,7 +90,7 @@ def make_empty(cls) -> Labels:

structure = CrystalStructure(lengths=lengths, angles=angles, base=base)
# print(f'Empty crystal structure spacegroups = {structure.space_group}')
sample = PowderProperties(crystallite_size=torch.nan, crystal_structure=structure)
sample = Powder(crystallite_size=torch.nan, crystal_structure=structure)
artifacts = Artifacts(primary_wavelength=torch.nan,
secondary_wavelength=torch.nan,
secondary_to_primary=torch.nan,
Expand Down Expand Up @@ -156,7 +156,7 @@ def as_list(self) -> list[float]:


@dataclass
class PowderProperties:
class Powder:
crystal_structure: CrystalStructure
crystallite_size: float = 500
temp_in_celcius : int = 20
Expand Down
6 changes: 3 additions & 3 deletions xrdpattern/core/pattern_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

from holytools.abstract import Picklable
from xrdpattern.core.labels import Labels

from numpy.typing import NDArray

# -------------------------------------------

@dataclass
class PatternData(Picklable):
two_theta_values : list[float]
intensities : list[float]
two_theta_values : list[float] | NDArray
intensities : list[float] | NDArray
label : Labels
name : Optional[str] = None

Expand Down
3 changes: 2 additions & 1 deletion xrdpattern/core/structure/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from pymatgen.symmetry.groups import SpaceGroup
from pymatgen.core import Structure, Lattice
from pymatgen.symmetry.groups import CrystalSystem
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

from .lattice_params import Angles, Lengths
Expand All @@ -25,7 +26,7 @@ class CrystalStructure:
atomic_volume: Optional[float] = None
num_atoms : Optional[int] = None
wyckoff_symbols : Optional[list[str]] = None
crystal_system : Optional[str] = None
crystal_system : Optional[CrystalSystem] = None

def calculate_properties(self):
pymatgen_structure = self.to_pymatgen()
Expand Down

0 comments on commit 363f329

Please sign in to comment.