Skip to content

Commit

Permalink
Accept dict as a config along with the poni
Browse files Browse the repository at this point in the history
  • Loading branch information
megyaz committed Oct 24, 2024
1 parent bdf3f4f commit 5651167
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions azint/azint.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ def from_file(cls, filename):
float(config['rot3']),
float(config['wavelength']))

@classmethod
def from_dict(cls, config):
det_name = config['detector']
det_config = {}
if 'detector_config' in config:
det_config = json.loads(config['detector_config'])
if "orientation" in config['detector_config']:
det_config.pop("orientation", None)
det = Detector.factory(det_name, det_config)
return cls(det,
float(config['distance']),
float(config['poni1']),
float(config['poni2']),
float(config['rot1']),
float(config['rot2']),
float(config['rot3']),
float(config['wavelength']))

def rotation_matrix(poni: Poni):
cos_rot1 = np.cos(poni.rot1)
Expand Down Expand Up @@ -172,6 +189,9 @@ def __init__(self,
if isinstance(poni, str):
poni = Poni.from_file(poni)

if isinstance(poni, dict):
poni = Poni.from_dict(poni)

self.unit = unit
self.error_model = error_model

Expand Down

0 comments on commit 5651167

Please sign in to comment.