add p-group to output geom name, now uses default geom file from crmx-tools

This commit is contained in:
Beale John Henry
2023-03-22 14:26:41 +01:00
parent aceed99f22
commit 558d610cf3

View File

@@ -57,7 +57,7 @@ def scrub_poni( path_to_poni_file ):
return poni1_p, poni2_p, eV, round( float( clen )*1000, 5 )
def write_new_positions( path_to_geom, beam_x, beam_y, clen, energy ):
def write_new_positions( path_to_geom, beam_x, beam_y, clen, energy, p_group ):
# open current geometry file
current_geom_file = open( path_to_geom, "r" ).read()
@@ -93,7 +93,7 @@ def write_new_positions( path_to_geom, beam_x, beam_y, clen, energy ):
# create geom new file
geom_start = path_to_geom[:-5]
new_geom_name = "{0}_{1}.geom".format( geom_start, date )
new_geom_name = "crmx8M_{0}_{1}.geom".format( p_group, date )
# write new geom file
f = open( new_geom_name, "w" )
@@ -111,7 +111,7 @@ if __name__ == "__main__":
"--geom",
help="give the path to the cristallina 8M geom file to be updated",
type=str,
default="/sf/cristallina/data/p20558/work/geom/optimised_geom_file/p20558_hewl_op.geom",
default="/sf/cristallina/applications/mx/crmx-tools/geom_files/crmx8M_230322.geom",
)
parser.add_argument(
"-x",
@@ -149,20 +149,22 @@ if __name__ == "__main__":
)
parser.add_argument(
"-p",
"--p-group",
"--p_group",
help="p-group name",
type=str,
)
args = parser.parse_args()
# run geom converter
if args.poni is not None:
if args.p_group is None:
print( "you must specify a p-group that the .geom file is associated with\n\nfor example -p p20560" )
elif args.poni is not None:
print( "reading poni file" )
beam_y, beam_x, eV, clen = scrub_poni( args.poni )
print( "beam x, beam_y = {0}, {1}\nphoton_energy = {2}\nclen = {3}".format( beam_x, beam_y, eV, clen ) )
new_geom_name = write_new_positions( args.geom, beam_x, beam_y, clen, eV )
new_geom_name = write_new_positions( args.geom, beam_x, beam_y, clen, eV, args.p_group )
print( "updated .geom file with poni calculations\n new .geom = {0}".format( new_geom_name ) )
else:
print( "manually input positions" )
print( "beam x, beam_y = {0}, {1}\nphoton_energy = {2}\nclen = {3}".format( args.beam_x, args.beam_y, args.energy, args.clen ) )
new_geom_name = write_new_positions( args.geom, args.beam_x, args.beam_y, args.clen, args.energy )
new_geom_name = write_new_positions( args.geom, args.beam_x, args.beam_y, args.clen, args.energy, args.p_group )
print( "updated .geom file with poni calculations\nnew .geom = {0}".format( new_geom_name ) )