Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inital address test warnings #895

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pyrs/calibration/mantid_peakfit_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def peak_alignment_single(self, x, ReturnScalar=False, i_index=2):
"""

paramVec = np.copy(self._calib)
paramVec[i_index] = x
paramVec[i_index] = x[0]

residual = self.get_alignment_residual(paramVec)

Expand Down Expand Up @@ -650,16 +650,16 @@ def set_shift(self, out):
return

def set_distance(self, out):
self._calib[2] = out[0]
self._calib[2] = out[0][0]
self._calibstatus = out[2]
self._caliberr[2] = out[1]
self._caliberr[2] = out[1][0]

return

def set_tth0(self, out):
self._calib[6] = out[0]
self._calib[6] = out[0][0]
self._calibstatus = out[2]
self._caliberr[6] = out[1]
self._caliberr[6] = out[1][0]

return

Expand Down Expand Up @@ -709,9 +709,9 @@ def set_wavelength(self, out):

"""

self._calib[7] = out[0]
self._calib[7] = out[0][0]
self._calibstatus = out[2]
self._caliberr[7] = out[1]
self._caliberr[7] = out[1][0]

return

Expand All @@ -727,9 +727,9 @@ def set_shiftx(self, out):

"""

self._calib[0] = out[0]
self._calib[0] = out[0][0]
self._calibstatus = out[2]
self._caliberr[0] = out[1]
self._caliberr[0] = out[1][0]

return

Expand All @@ -745,9 +745,9 @@ def set_shifty(self, out):

"""

self._calib[1] = out[0]
self._calib[1] = out[0][0]
self._calibstatus = out[2]
self._caliberr[1] = out[1]
self._caliberr[1] = out[1][0]

return

Expand All @@ -762,9 +762,9 @@ def set_calibration(self, out):
-------

"""
self._calib[:] = out[0]
self._calib[:] = out[0][:]
self._calibstatus = out[2]
self._caliberr[:] = out[1]
self._caliberr[:] = out[1][:]

return

Expand Down
2 changes: 1 addition & 1 deletion pyrs/core/monosetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def getFromIndex(index):
@staticmethod
def getFromRotation(mrot):
'''The ``mrot`` (monochromator rotation) log in the NeXus file can be converted into a specific wavelength'''
mrot = float(mrot)
mrot = mrot
if -41.0 < mrot < -38.0:
return MonoSetting.Si333
elif -1.0 < mrot < 1.0:
Expand Down
7 changes: 5 additions & 2 deletions pyrs/core/nexus_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def convert_pulses_to_datetime64(h5obj):
pulse_time = pulse_time * 1.e9 * np.timedelta64(1, 'ns')

# get absolute offset and convert to absolute time
start_time = np.datetime64(h5obj.attrs['offset'])
start_time = np.datetime64(h5obj.attrs['offset'][:-6]) + np.timedelta64(h5obj.attrs['offset'][-5:-3], 'h')

return pulse_time + start_time

Expand All @@ -56,7 +56,7 @@ def calculate_sub_run_time_average(log_property, time_filter) -> float:
'''Determine the time average value of the supplied log'''

if log_property.size() == 1: # single value property just copy
time_average_value = log_property.value
time_average_value = log_property.value[0]
elif time_filter is None: # no filtering means use all values
time_averaged_Run = Run()
time_averaged_Run.addProperty('filtered_log', log_property, False)
Expand Down Expand Up @@ -485,11 +485,14 @@ def get_events_time_nxs(self):
if self._splitter:
# get event index array: same size as pulse times
event_index_array = bank1_events['event_index'][()]
print(self._splitter.times)

# get pulse times
pulse_time_array = convert_pulses_to_datetime64(bank1_events['event_time_zero'])

subrun_eventindex_array = self._generate_subrun_event_indices(pulse_time_array, event_index_array,
event_id_array.size)

# reduce memory foot print
del pulse_time_array, event_index_array

Expand Down
24 changes: 12 additions & 12 deletions pyrs/core/reduce_hb2b_pyrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def _cal_rotation_matrix_x(angle_rad):
:param float angle_rad: roation angle
:return:
"""
rotate_matrix = np.matrix([[1., 0., 0.],
[0., np.cos(angle_rad), -np.sin(angle_rad)],
[0., np.sin(angle_rad), np.cos(angle_rad)]],
'float')
rotate_matrix = np.array([[1., 0., 0.],
[0., np.cos(angle_rad), -np.sin(angle_rad)],
[0., np.sin(angle_rad), np.cos(angle_rad)]],
dtype=np.float32)

return rotate_matrix

Expand All @@ -291,10 +291,10 @@ def _cal_rotation_matrix_y(angle_rad):
:param float angle_rad: roation angle
:return:
"""
rotate_matrix = np.matrix([[np.cos(angle_rad), 0., np.sin(angle_rad)],
[0., 1., 0.],
[-np.sin(angle_rad), 0., np.cos(angle_rad)]],
'float')
rotate_matrix = np.array([[np.cos(angle_rad), 0., np.sin(angle_rad)],
[0., 1., 0.],
[-np.sin(angle_rad), 0., np.cos(angle_rad)]],
dtype=np.float32)

return rotate_matrix

Expand All @@ -306,10 +306,10 @@ def _cal_rotation_matrix_z(angle_rad):
:param float angle_rad: roation angle
:return:
"""
rotate_matrix = np.matrix([[np.cos(angle_rad), -np.sin(angle_rad), 0.],
[np.sin(angle_rad), np.cos(angle_rad), 0.],
[0., 0., 1.]],
'float')
rotate_matrix = np.array([[np.cos(angle_rad), -np.sin(angle_rad), 0.],
[np.sin(angle_rad), np.cos(angle_rad), 0.],
[0., 0., 1.]],
dtype=np.float32)

return rotate_matrix

Expand Down
2 changes: 1 addition & 1 deletion pyrs/dataobjects/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ def _create_scalar_field(self, method, name, *args, **kwargs) -> ScalarFieldSamp
values[indices], errors[indices] = values_i[idx], errors_i[idx]
keep[indices] = keep_i[idx]

values[keep] = np.NAN
values[keep] = np.nan

return ScalarFieldSample(name, values, errors, self.x, self.y, self.z)

Expand Down
6 changes: 5 additions & 1 deletion pyrs/peaks/peak_fit_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def _guess_center(self, x_min, x_max):
y_offset = np.abs(y_vals.max())

# add the first moment to the list of centers
moment = np.sum(x_vals[i_min:i_max] * (y_vals + y_offset)) / np.sum(y_vals + y_offset)
if np.sum(y_vals + y_offset) < 1:
moment = -1
else:
moment = np.sum(x_vals[i_min:i_max] * (y_vals + y_offset)) / np.sum(y_vals + y_offset)

if (x_min < moment < x_max):
center.append(moment)
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_powder_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def test_2theta_calculation():

# compare with gold file
gold_dict = parse_gold_file('tests/data/HB2B_1017_Pixels_Gold.h5')
np.testing.assert_allclose(pixel_positions, gold_dict['positions'], rtol=1E-8)
np.testing.assert_allclose(two_theta_arrays, gold_dict['2theta'], rtol=1E-8)
np.testing.assert_allclose(pixel_positions, gold_dict['positions'], rtol=1E-5)
np.testing.assert_allclose(two_theta_arrays, gold_dict['2theta'], rtol=1E-5)


@pytest.mark.parametrize('project_file_name, mask_file_name, gold_file',
Expand Down
Loading