Skip to content

Commit

Permalink
add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Feb 27, 2024
1 parent ed153c6 commit 3ee4bce
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
28 changes: 24 additions & 4 deletions specsanalyzer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,32 +237,52 @@ def convert_image(
data_array = crop_xarray(data_array, ang_min, ang_max, ek_min, ek_max)
except KeyError:
try:
ang_range_min = (
kwds["ang_range_min"]
if "ang_range_min" in kwds
else self._config["ang_range_min"]
)
ang_range_max = (
kwds["ang_range_max"]
if "ang_range_max" in kwds
else self._config["ang_range_max"]
)
ek_range_min = (
kwds["ek_range_min"]
if "ek_range_min" in kwds
else self._config["ek_range_min"]
)
ek_range_max = (
kwds["ek_range_max"]
if "ek_range_max" in kwds
else self._config["ek_range_max"]
)
ang_min = (
kwds.get("ang_range_min", self._config["ang_range_min"])
ang_range_min
* (
data_array.coords[data_array.dims[0]][-1]
- data_array.coords[data_array.dims[0]][0]
)
+ data_array.coords[data_array.dims[0]][0]
)
ang_max = (
kwds.get("ang_range_max", self._config["ang_range_max"])
ang_range_max
* (
data_array.coords[data_array.dims[0]][-1]
- data_array.coords[data_array.dims[0]][0]
)
+ data_array.coords[data_array.dims[0]][0]
)
ek_min = (
kwds.get("ek_range_min", self._config["ek_range_min"])
ek_range_min
* (
data_array.coords[data_array.dims[1]][-1]
- data_array.coords[data_array.dims[1]][0]
)
+ data_array.coords[data_array.dims[1]][0]
)
ek_max = (
kwds.get("ek_range_max", self._config["ek_range_max"])
ek_range_max
* (
data_array.coords[data_array.dims[1]][-1]
- data_array.coords[data_array.dims[1]][0]
Expand Down
33 changes: 29 additions & 4 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,34 @@ def test_cropping():
)
assert converted.Angle[0] == -18
assert converted.Angle[-1] == 17.859375
assert converted.Ekin[0] == 32.69
assert converted.Ekin[-1] == 37.296569767441866

converted = spa.convert_image(
raw_img=tsv_data,
lens_mode=lens_mode,
kinetic_energy=kinetic_energy,
pass_energy=pass_energy,
work_function=work_function,
ek_range_min=0.1,
ek_range_max=0.9,
ang_range_min=0.1,
ang_range_max=0.9,
crop=True,
)
assert converted.Angle[0] == -14.34375
assert converted.Angle[-1] == 14.203125
assert converted.Ekin[0] == 33.16005813953488
assert converted.Ekin[-1] == 36.82651162790698

spa.crop_tool(
raw_img=tsv_data,
lens_mode=lens_mode,
kinetic_energy=kinetic_energy,
pass_energy=pass_energy,
work_function=work_function,
ek_range_min=0,
ek_range_max=1,
ek_range_min=0.1,
ek_range_max=0.9,
ang_range_min=0.1,
ang_range_max=0.9,
apply=True,
Expand All @@ -290,15 +309,17 @@ def test_cropping():

assert converted.Angle[0] == -14.34375
assert converted.Angle[-1] == 14.203125
assert converted.Ekin[0] == 33.16005813953488
assert converted.Ekin[-1] == 36.82651162790698

spa.crop_tool(
raw_img=tsv_data,
lens_mode=lens_mode,
kinetic_energy=45.0,
pass_energy=pass_energy,
work_function=work_function,
ek_range_min=0,
ek_range_max=1,
ek_range_min=0.2,
ek_range_max=0.8,
ang_range_min=0.2,
ang_range_max=0.8,
apply=True,
Expand All @@ -315,6 +336,8 @@ def test_cropping():

assert converted.Angle[0] == -10.828125
assert converted.Angle[-1] == 10.6875
assert converted.Ekin[0] == 48.616686046511624
assert converted.Ekin[-1] == 51.36988372093023

converted = spa.convert_image(
raw_img=tsv_data,
Expand All @@ -327,3 +350,5 @@ def test_cropping():

assert converted.Angle[0] == -14.34375
assert converted.Angle[-1] == 14.203125
assert converted.Ekin[0] == 33.16005813953488
assert converted.Ekin[-1] == 36.82651162790698

0 comments on commit 3ee4bce

Please sign in to comment.