1313two_pi = sc .constants .pi * (2.0 * sc .units .rad )
1414
1515
16- def speed_to_wavelength (x : sc .Variable , unit : str = ' angstrom' ) -> sc .Variable :
16+ def speed_to_wavelength (x : sc .Variable , unit : str = " angstrom" ) -> sc .Variable :
1717 """
1818 Convert neutron speeds to wavelengths.
1919
@@ -27,7 +27,7 @@ def speed_to_wavelength(x: sc.Variable, unit: str = 'angstrom') -> sc.Variable:
2727 return (1.0 / (m_over_h * x )).to (unit = unit )
2828
2929
30- def wavelength_to_speed (x : sc .Variable , unit : str = ' m/s' ) -> sc .Variable :
30+ def wavelength_to_speed (x : sc .Variable , unit : str = " m/s" ) -> sc .Variable :
3131 """
3232 Convert neutron wavelengths to speeds.
3333
@@ -41,7 +41,7 @@ def wavelength_to_speed(x: sc.Variable, unit: str = 'm/s') -> sc.Variable:
4141 return (1.0 / (m_over_h * x )).to (unit = unit )
4242
4343
44- def speed_to_energy (x : sc .Variable , unit = ' meV' ) -> sc .Variable :
44+ def speed_to_energy (x : sc .Variable , unit = " meV" ) -> sc .Variable :
4545 """
4646 Convert neutron speeds to energies.
4747
@@ -52,10 +52,10 @@ def speed_to_energy(x: sc.Variable, unit='meV') -> sc.Variable:
5252 unit:
5353 The unit of the output energies.
5454 """
55- return (const .m_n * x * x ).to (unit = unit )
55+ return (( 0.5 * const .m_n ) * x * x ).to (unit = unit )
5656
5757
58- def energy_to_speed (x : sc .Variable , unit = ' m/s' ) -> sc .Variable :
58+ def energy_to_speed (x : sc .Variable , unit = " m/s" ) -> sc .Variable :
5959 """
6060 Convert neutron energies to speeds.
6161
@@ -66,7 +66,7 @@ def energy_to_speed(x: sc.Variable, unit='m/s') -> sc.Variable:
6666 unit:
6767 The unit of the output speeds.
6868 """
69- return sc .sqrt (x / const .m_n ).to (unit = unit )
69+ return sc .sqrt (x / ( 0.5 * const .m_n ) ).to (unit = unit )
7070
7171
7272def one_mask (
@@ -97,8 +97,8 @@ def var_to_dict(var: sc.Variable) -> dict:
9797 The variable to convert.
9898 """
9999 return {
100- ' value' : var .values .tolist () if var .ndim > 0 else float (var .value ),
101- ' unit' : str (var .unit ),
100+ " value" : var .values .tolist () if var .ndim > 0 else float (var .value ),
101+ " unit" : str (var .unit ),
102102 }
103103
104104
0 commit comments