From cdf578ed1a7db72b71bb37214c6d7de5feebace3 Mon Sep 17 00:00:00 2001 From: zjmorgan Date: Mon, 12 Aug 2024 13:50:50 -0400 Subject: [PATCH] Bug fixes for RHEL9 --- CrystalPlan_version.py | 2 +- crystalplan.py | 2 +- crystalplan.yml | 26 ++++++++++++++++++++++++++ gui/dialog_edit_crystal.py | 2 +- gui/panel_reflection_measurement.py | 13 ++++++++++--- model/crystal_calc.py | 3 +-- model/detectors.py | 3 +-- model/experiment.py | 9 +++------ model/goniometer.py | 29 ++++++++++------------------- model/instrument.py | 17 +++++------------ 10 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 crystalplan.yml diff --git a/CrystalPlan_version.py b/CrystalPlan_version.py index b6aef2f..ca0ca10 100644 --- a/CrystalPlan_version.py +++ b/CrystalPlan_version.py @@ -16,7 +16,7 @@ # revision = re.match("Revision: (\d+)", line).group(1) # return revision -version = '1.5' +version = '1.6' package_name = 'CrystalPlan' description = \ """CrystalPlan is an experiment planning tool for crystallography. You can choose an instrument and supply your sample's lattice parameters to simulate which reflections will be measured, by which detectors and at what wavelengths.""" diff --git a/crystalplan.py b/crystalplan.py index 4ba1a80..af066f1 100755 --- a/crystalplan.py +++ b/crystalplan.py @@ -33,4 +33,4 @@ import CrystalPlan.gui.main if __name__ == '__main__': - CrystalPlan.gui.main.handle_arguments_and_launch(InstalledVersion=True) + CrystalPlan.gui.main.handle_arguments_and_launch(InstalledVersion=False) diff --git a/crystalplan.yml b/crystalplan.yml new file mode 100644 index 0000000..600c7d8 --- /dev/null +++ b/crystalplan.yml @@ -0,0 +1,26 @@ +--- + +name: crystalplan + +channels: + - free + - conda-forge + +dependencies: + - python=2.7 + - traitsui=5.0.0 + - mayavi=4.5.0 + - apptools=4.4.0 + - jsoncpp=0.10.6 + - wxpython=3.0.0 + - numpy + - matplotlib + - vtk=7.1.0 + - weave + - scipy + - gdk-pixbuf + - atk + - gxx_linux-64 + - pip + + diff --git a/gui/dialog_edit_crystal.py b/gui/dialog_edit_crystal.py index ac32fb6..fc13511 100644 --- a/gui/dialog_edit_crystal.py +++ b/gui/dialog_edit_crystal.py @@ -270,7 +270,7 @@ def OnButtonGenerateUB(self, event): def OnButtonReadUB(self, event): """Ask the user to find the UB matrix file""" filename = self.crystal.ub_matrix_last_filename - (path, ignored) = os.path.split( os.path.abspath(filename) ) + (path, filename) = os.path.split( os.path.abspath(filename) ) filters = 'All files (*)|*|Text files (*.txt)|*.txt' dialog = wx.FileDialog ( self, defaultFile=filename, defaultDir=path, message='Choose a UB matrix file', wildcard=filters, style=wx.OPEN ) if dialog.ShowModal() == wx.ID_OK: diff --git a/gui/panel_reflection_measurement.py b/gui/panel_reflection_measurement.py index 4a84db0..62eb432 100644 --- a/gui/panel_reflection_measurement.py +++ b/gui/panel_reflection_measurement.py @@ -233,17 +233,22 @@ def set_measurement(self, refl, meas): #Remove these windows, if they are in there try: - self.flexGridSizer1.RemoveWindow(self.staticTextIntegrated) - self.flexGridSizer1.RemoveWindow(self.buttonPlace) + self.flexGridSizer1.Remove(self.staticTextIntegrated) except: pass - + try: + self.flexGridSizer1.Remove(self.buttonPlace) + except: + pass + if hasattr(meas, "integrated"): #Real measurement self.staticTextWidthLabel.SetLabel(" SigI:") self.staticTextWidth.SetLabel((self.fmt_counts % meas.sigI)) self.staticTextWidth.SetToolTipString(u'Sigma I of the integrated peak intensity') self.staticTextIntegrated.SetLabel((self.fmt_counts % meas.integrated)) + self.flexGridSizer1.Detach(self.buttonPlace) + self.flexGridSizer1.Detach(self.staticTextIntegrated) self.flexGridSizer1.InsertWindow(9, self.staticTextIntegrated, 0, border=0, flag=wx.SHRINK) self.staticTextIntegratedLabel.Show() self.staticTextIntegrated.Show() @@ -253,6 +258,8 @@ def set_measurement(self, refl, meas): self.staticTextWidthLabel.SetLabel("Width:") self.staticTextWidth.SetLabel((fmt % meas.peak_width) + " mm") self.staticTextWidth.SetToolTipString(u'Half-width of the peak on the detector.') + self.flexGridSizer1.Detach(self.buttonPlace) + self.flexGridSizer1.Detach(self.staticTextIntegrated) self.flexGridSizer1.InsertWindow(9, self.buttonPlace, 0, border=8, flag=wx.EXPAND | wx.RIGHT) # Don't show the place button for 4-circle self.buttonPlace.Show( not gui_utils.fourcircle_mode() ) diff --git a/model/crystal_calc.py b/model/crystal_calc.py index 3c87b02..c37641a 100644 --- a/model/crystal_calc.py +++ b/model/crystal_calc.py @@ -378,7 +378,6 @@ def getq_python(azimuth, elevation, wl_output, rot_matrix, wl_input=None): { py::tuple return_val(3); double wl_input = wl_output; - """ @@ -418,7 +417,7 @@ def getq_python(azimuth, elevation, wl_output, rot_matrix, wl_input=None): q[1]=qx * rot_matrix[3+0] + qy * rot_matrix[3+1] + qz * rot_matrix[3+2]; q[2]=qx * rot_matrix[6+0] + qy * rot_matrix[6+1] + qz * rot_matrix[6+2]; return_val = q; - """ +""" getq_code_footer = "return return_val; }" diff --git a/model/detectors.py b/model/detectors.py index ce41fe0..ebdf265 100644 --- a/model/detectors.py +++ b/model/detectors.py @@ -413,8 +413,7 @@ def get_detector_coordinates(self, beam, wl_min=0.0, wl_max=1e6): hits_it[i] = (v > -height/2) && (v < height/2) && (h > -width/2) && (h < width/2); } } - return_val = error_count; - """ + return_val = error_count;""" #Generate a list of the variables used varlist = ['base_point', 'horizontal', 'vertical', 'normal'] diff --git a/model/experiment.py b/model/experiment.py index 44c858d..fd4dc1d 100644 --- a/model/experiment.py +++ b/model/experiment.py @@ -1700,8 +1700,7 @@ def initialize_volume_symmetry_map(self): } } - } - """ + }""" qres = inst.q_resolution n = len(self.inst.qx_list) table = np.array(pg.table) #Turn the list of 3x3 arrays into a Nx3x3 array @@ -1778,8 +1777,7 @@ def apply_volume_symmetry(self, use_inline_c=True): //printf("%d\\n", index); } } - } - """ + }""" varlist = ['old_q', 'qspace_flat', 'numpix', 'order', 'symm'] weave.inline(code, varlist, compiler='gcc', support_code=support) #Reshape it back as a 3D array. @@ -2032,8 +2030,7 @@ def calculate_coverage_stats(self): results[0] = overall_points; results[1] = overall_covered_points; results[2] = overall_redundant_points; - return_val = results; - """ + return_val = results;""" ret_val = weave.inline(code,['qspace', 'qspace_radius', 'q_step', 'qlim', 'total_points', 'qspace_size', 'num', 'covered_points0', 'covered_points1', 'covered_points2', 'covered_points3'], compiler='gcc', support_code = support) #The function returns a tuple diff --git a/model/goniometer.py b/model/goniometer.py index f6c7890..888c982 100644 --- a/model/goniometer.py +++ b/model/goniometer.py @@ -524,7 +524,7 @@ def csv_add_position(self, fileobj, angle_values, count_for, count_value, commen if not allowed: #Can't reach this position fileobj.write("#"" ----- ERROR! This sample orientation could not be achieved with the goniometer, because of '%s'. THE FOLLOWING LINE HAS BEEN COMMENTED OUT ------ ""\n" % reason ) - fileobj.write('#' + csv_line( comment, das_angles + [stopping_criterion, count_value] ) ) + fileobj.write('#' + csv_line( [comment]+ das_angles + [stopping_criterion, count_value] ) ) else: #They are okay fileobj.write(csv_line( [comment] + das_angles + [stopping_criterion, count_value] ) ) @@ -626,8 +626,7 @@ def get_fitness_function_c_code(self): // if (omega < omega_min || omega > omega_max) fitness += 10; return fitness; - } - """ % (args) + }""" % (args) return s @@ -860,8 +859,7 @@ def _angle_fitness_brute(self, rot_angle_list, initial_rotation_matrix, ending_v phi_list.append(phi); chi_list.append(chi); omega_list.append(omega); - } - """ + }""" #Workaround for bug in weave, where it ignores any changes in the support code. code += "\n\n // " + self.__class__.__name__ + "\n" code += "/* " + self.get_fitness_function_c_code() + " */" @@ -1095,8 +1093,7 @@ def get_fitness_function_c_code(self): if (phi > phi_max) fitness += (phi - phi_max) * 1.0; return fitness; - } - """ % (args) + }""" % (args) return s #------------------------------------------------------------------------------- @@ -1236,8 +1233,7 @@ def get_fitness_function_c_code(self): if (phi > phi_max) fitness += (phi - phi_max) * 1.0; return fitness; - } - """ % (args) + }""" % (args) return s @@ -1512,8 +1508,7 @@ def get_fitness_function_c_code(self): if (omega > omega_max) fitness += (omega - omega_max) * 1.0; return fitness; - } - """ % (args) + }""" % (args) return s @@ -1791,8 +1786,7 @@ def get_fitness_function_c_code(self): // if (omega < omega_min || omega > omega_max) fitness += 10; return fitness; - } - """ % (args) + }""" % (args) return s #------------------------------------------------------------------------------- @@ -1977,8 +1971,7 @@ def get_fitness_function_c_code(self): if (omega > omega_max) fitness += (omega - omega_max) * 1.0; return fitness; - } - """ % (args) + } """ % (args) return s @@ -2849,8 +2842,7 @@ def get_fitness_function_c_code(self): return absolute(chi) + omegadiff + absolute(phi)/1000.0; //return absolute(chi) + omegadiff + absolute(phi); - } - """ + }""" #------------------------------------------------------------------------- @@ -2944,8 +2936,7 @@ def get_fitness_function_c_code(self): if (omega > omega_max) fitness += (omega - omega_max) * 1.0; return fitness; - } - """ % (args) + }""" % (args) return s diff --git a/model/instrument.py b/model/instrument.py index 232b30c..3c8d85d 100644 --- a/model/instrument.py +++ b/model/instrument.py @@ -662,8 +662,7 @@ def make_qspace(self): } } //return q_out; - } - """ + }""" _code_calculate_coverage = """ //Loop through pixels using the list given before. @@ -759,8 +758,7 @@ def make_qspace(self): } //for iiy - } - """ + }""" #======================================================================================================== @@ -1155,10 +1153,7 @@ def total_coverage(self, detectors_used, orientations_used, use_inline_c=True): }// for iy } } //for ix - - - } - """ + }""" varlist = ['number_of_ints', 'coverage', 'coverage_size', 'mask1', 'mask2', 'num_coverage', 'coverage_list'] weave.inline(code, varlist, compiler='gcc', support_code = support) @@ -1339,8 +1334,7 @@ def __init__ (self, filename=None, params=dict()): } //numfrac > 0 so we can draw the line } //for iiy - } - """ + }""" #======================================================================================================== def calculate_coverage(self, det_list, angles, sample_U_matrix=np.identity(3), use_inline_c=True): @@ -1632,8 +1626,7 @@ def total_coverage(self, detectors_used, orientations_used, use_inline_c=True, s } //for ix - } - """ + }""" varlist = ['number_of_ints', 'coverage', 'coverage_size', 'num_coverage', 'coverage_list'] weave.inline(code, varlist, compiler='gcc', support_code = support)