Skip to content

Commit

Permalink
some further fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Sep 19, 2024
1 parent e3af246 commit 2a69836
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions sed/calibrator/momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,9 @@ def spline_warp_estimate(
if "creation_date" in self.correction:
datestring = datetime.fromtimestamp(
self.correction["creation_date"],
).strftime
("%m/%d/%Y, %H:%M:%S",)
).strftime(
"%m/%d/%Y, %H:%M:%S",
)
logger.info(
"No landmarks defined, using momentum correction parameters "
f"generated on {datestring}",
Expand Down Expand Up @@ -1873,6 +1874,7 @@ def append_k_axis(
new_x_column: str = None,
new_y_column: str = None,
calibration: dict = None,
suppress_output: bool = False,
**kwds,
) -> tuple[pd.DataFrame | dask.dataframe.DataFrame, dict]:
"""Calculate and append the k axis coordinates (kx, ky) to the events dataframe.
Expand All @@ -1892,6 +1894,8 @@ def append_k_axis(
momentum calibration. Defaults to config["momentum"]["ky_column"].
calibration (dict, optional): Dictionary containing calibration parameters.
Defaults to 'self.calibration' or config["momentum"]["calibration"].
suppress_output (bool, optional): Option to suppress output of diagnostic information.
Defaults to False.
**kwds: Keyword parameters for momentum calibration. Parameters are added
to the calibration dictionary.
Expand Down Expand Up @@ -1938,6 +1942,12 @@ def append_k_axis(
if len(kwds) > 0:
raise TypeError(f"append_k_axis() got unexpected keyword arguments {kwds.keys()}.")

if "creation_date" in calibration and not suppress_output:
datestring = datetime.fromtimestamp(calibration["creation_date"]).strftime(
"%m/%d/%Y, %H:%M:%S",
)
logger.info(f"Using momentum calibration parameters generated on {datestring}")

try:
(df[new_x_column], df[new_y_column]) = detector_coordinates_2_k_coordinates(
r_det=df[x_column],
Expand Down
1 change: 1 addition & 0 deletions sed/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ def apply_momentum_calibration(
tdf, _ = self.mc.append_k_axis(
df=self._timed_dataframe,
calibration=calibration,
suppress_output=True,
**kwds,
)

Expand Down
1 change: 0 additions & 1 deletion tutorial/4_hextof_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@
" d={'value':1.0,'min': .2, 'max':1.0, 'vary':False},\n",
" t0={'value':5e-7, 'min': 1e-7, 'max': 1e-6, 'vary':True},\n",
" E0={'value': 0., 'min': -100, 'max': 100, 'vary': True},\n",
" verbose=True,\n",
")"
]
},
Expand Down

0 comments on commit 2a69836

Please sign in to comment.