File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,9 @@ class CrystalStructure(JsonDataclass):
2727 phase_fraction : Optional [float ] = None
2828
2929 def __post_init__ (self ):
30- if not 0 <= self .phase_fraction <= 1 :
31- raise ValueError (f'Phase fraction must be between 0 and 1. Got { self .phase_fraction } ' )
30+ if not self .phase_fraction is None :
31+ if not 0 <= self .phase_fraction <= 1 :
32+ raise ValueError (f'Phase fraction must be between 0 and 1. Got { self .phase_fraction } ' )
3233
3334 @classmethod
3435 def from_cif (cls , cif_content : str ) -> CrystalStructure :
Original file line number Diff line number Diff line change 11import numpy as np
22
3- from xrdpattern .xrd import XrdData , XrdAnode
3+ from xrdpattern .xrd import XrdData , XrdAnode , XrayInfo
44
55
66class DatParser :
@@ -21,7 +21,7 @@ def extract_multi(self, fpath : str) -> list[XrdData]:
2121 x ,y = x [l :], y [l :]
2222
2323 new_pattern = XrdData .make_unlabeled (two_theta_values = pattern_angles , intensities = pattern_intensities )
24- new_pattern .powder_experiment .xray_info = XrdAnode . Cu . get_xray_info ()
24+ new_pattern .powder_experiment .xray_info = XrayInfo . copper_xray ()
2525 patterns .append (new_pattern )
2626
2727 return patterns
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
12from dataclasses import dataclass
23from typing import Optional
34
@@ -9,6 +10,10 @@ class XrayInfo(JsonDataclass):
910 primary_wavelength : Optional [float ]
1011 secondary_wavelength : Optional [float ]
1112
13+ @classmethod
14+ def copper_xray (cls ) -> XrayInfo :
15+ return cls .from_anode (element = XrdAnode .Cu )
16+
1217 @classmethod
1318 def from_anode (cls , element : str ):
1419 MATERIAL_TO_WAVELNGTHS = {
You can’t perform that action at this time.
0 commit comments