Skip to content

Commit

Permalink
Bug fixes for RHEL9
Browse files Browse the repository at this point in the history
  • Loading branch information
zjmorgan committed Aug 12, 2024
1 parent 06e00b4 commit cdf578e
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion CrystalPlan_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion crystalplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
26 changes: 26 additions & 0 deletions crystalplan.yml
Original file line number Diff line number Diff line change
@@ -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


2 changes: 1 addition & 1 deletion gui/dialog_edit_crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions gui/panel_reflection_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() )
Expand Down
3 changes: 1 addition & 2 deletions model/crystal_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
"""


Expand Down Expand Up @@ -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; }"


Expand Down
3 changes: 1 addition & 2 deletions model/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
9 changes: 3 additions & 6 deletions model/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
29 changes: 10 additions & 19 deletions model/goniometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] ) )
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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() + " */"
Expand Down Expand Up @@ -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

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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);
}
"""
}"""


#-------------------------------------------------------------------------
Expand Down Expand Up @@ -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


Expand Down
17 changes: 5 additions & 12 deletions model/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ def make_qspace(self):
}
}
//return q_out;
}
"""
}"""

_code_calculate_coverage = """
//Loop through pixels using the list given before.
Expand Down Expand Up @@ -759,8 +758,7 @@ def make_qspace(self):
} //for iiy
}
"""
}"""


#========================================================================================================
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit cdf578e

Please sign in to comment.