Skip to content

Commit e9fce8f

Browse files
parsing: Swicthed out copper xray_info
1 parent a9ddfc1 commit e9fce8f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

xrdpattern/crystal/components/crystal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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:

xrdpattern/parsing/dat/dat_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22

3-
from xrdpattern.xrd import XrdData, XrdAnode
3+
from xrdpattern.xrd import XrdData, XrdAnode, XrayInfo
44

55

66
class 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

xrdpattern/xrd/xray.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from dataclasses import dataclass
23
from 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 = {

0 commit comments

Comments
 (0)