added lines to log file
This commit is contained in:
@@ -92,7 +92,7 @@ def run_partialator( proc_dir, name, stream, pointgroup, model, iterations, adu
|
||||
part_sh.write( "module use MX unstable\n" )
|
||||
part_sh.write( "module load crystfel/0.10.2-rhel8\n" )
|
||||
part_sh.write( "partialator -i {0} \\\n".format( stream ) )
|
||||
part_sh.write( " -o merged_{0}.hkl \\\n".format( name ) )
|
||||
part_sh.write( " -o {0}.hkl \\\n".format( name ) )
|
||||
part_sh.write( " -y {0} \\\n".format( pointgroup ) )
|
||||
part_sh.write( " --model={0} \\\n".format( model ) )
|
||||
part_sh.write( " --max-adu={0} \\\n".format( adu ) )
|
||||
@@ -223,15 +223,46 @@ def get_metric( d2_series, cc_series, cut_off ):
|
||||
|
||||
return round( cc_stat, 3 ), cc_tanh
|
||||
|
||||
def get_overall_cc():
|
||||
|
||||
# open cc log file
|
||||
cc_log_file = open( "cc.log" )
|
||||
cc_log = cc_log_file.read()
|
||||
|
||||
# regex example = Overall CC = 0.5970865
|
||||
overcc_pattern = r"Overall\sCC\s=\s(\d\.\d+)"
|
||||
overcc = re.search( overcc_pattern, cc_log ).group(1)
|
||||
|
||||
return overcc
|
||||
|
||||
def get_overall_rsplit():
|
||||
|
||||
# open rsplit log file
|
||||
rsplit_log_file = open( "Rsplit.log" )
|
||||
rsplit_log = rsplit_log_file.read()
|
||||
|
||||
# regex example = Overall Rsplit = 54.58 %
|
||||
overrsplit_pattern = r"Overall\sRsplit\s=\s(\d+\.\d+)"
|
||||
overrsplit = re.search( overrsplit_pattern, rsplit_log ).group(1)
|
||||
|
||||
return overrsplit
|
||||
|
||||
def get_b():
|
||||
|
||||
# open rsplit log file
|
||||
wilson_log_file = open( "wilson.log" )
|
||||
wilson_log = wilson_log_file.read()
|
||||
|
||||
# regex example = B = 41.63 A^2
|
||||
b_factor_pattern = r"B\s=\s(\d+\.\d+)\sA"
|
||||
b_factor = re.search( b_factor_pattern, wilson_log ).group(1)
|
||||
|
||||
return b_factor
|
||||
|
||||
def summary_fig( stats_df, cc_tanh, ccstar_tanh, cc_cut, ccstar_cut ):
|
||||
|
||||
def dto1_d( x ):
|
||||
return 1/x
|
||||
|
||||
def dto1_d2_rev( x ):
|
||||
return 1/x**2
|
||||
def dto1_d2_for( x ):
|
||||
return 1/x**0.5
|
||||
|
||||
# plot results
|
||||
cc_fig, axs = plt.subplots(2, 2)
|
||||
@@ -247,10 +278,10 @@ def summary_fig( stats_df, cc_tanh, ccstar_tanh, cc_cut, ccstar_cut ):
|
||||
axs[0,0].plot( stats_df[ "1_d" ], stats_df.cc, color=color )
|
||||
# plot fit
|
||||
axs[0,0].plot( stats_df[ "1_d" ], cc_tanh, color="tab:grey", linestyle = "dashed" )
|
||||
sax1 = axs[0,0].secondary_xaxis( 'top', functions=( dto1_d, dto1_d ), rotation=90 )
|
||||
sax1 = axs[0,0].secondary_xaxis( 'top', functions=( dto1_d, dto1_d ) )
|
||||
sax1.set_xlabel('d (A)')
|
||||
axs[0,0].tick_params( axis="y", labelcolor=color )
|
||||
axs[0,0].text( 0.1, 0.1, "CC @ 0.2 = {0}".format( cc_cut ), fontsize = 8 )
|
||||
axs[0,0].text( 0.1, 0.1, "CC0.5 @ 0.3 = {0}".format( cc_cut ), fontsize = 8 )
|
||||
|
||||
# cc* plot
|
||||
color = "tab:blue"
|
||||
@@ -275,14 +306,11 @@ def summary_fig( stats_df, cc_tanh, ccstar_tanh, cc_cut, ccstar_cut ):
|
||||
sax3.set_xlabel( 'd (A)' )
|
||||
axs[1,0].tick_params( axis='y', labelcolor=color )
|
||||
|
||||
|
||||
# wilson plot
|
||||
color = "tab:purple"
|
||||
axs[1,1].set_xlabel( "1/d**2 (1/A**2)" )
|
||||
axs[1,1].set_ylabel( "lnI", color=color )
|
||||
axs[1,1].plot( stats_df[ "1_d2" ], stats_df.lnI, color=color )
|
||||
sax4 = axs[1,1].secondary_xaxis( 'top', functions=( dto1_d2_for, dto1_d2_rev ) )
|
||||
sax4.set_xlabel( "d (A)" )
|
||||
axs[1,1].tick_params( axis='y', labelcolor=color )
|
||||
|
||||
# save figure
|
||||
@@ -346,6 +374,15 @@ def main( cwd, name, stream, pointgroup, model, iterations, cell, shells, part_h
|
||||
logger.info( "resolution at CC0.5 at 0.3 = {0}".format( cc_cut ) )
|
||||
logger.info( "resolution at CC* at 0.7 = {0}".format( ccstar_cut ) )
|
||||
|
||||
# scrub other metrics
|
||||
overcc = get_overall_cc()
|
||||
overrsplit = get_overall_rsplit()
|
||||
b_factor = get_b()
|
||||
|
||||
logger.info( "overall CC0.5 = {0}".format( overcc ) )
|
||||
logger.info( "overall Rsplit = {0}".format( overrsplit ) )
|
||||
logger.info( "overall B = {0}".format( b_factor ) )
|
||||
|
||||
# show plots
|
||||
summary_fig( stats_df, cc_tanh, ccstar_tanh, cc_cut, ccstar_cut )
|
||||
|
||||
@@ -440,4 +477,4 @@ if __name__ == "__main__":
|
||||
# run main
|
||||
cwd = os.getcwd()
|
||||
print( "top working directory = {0}".format( cwd ) )
|
||||
main( cwd, args.name, args.stream_file, args.pointgroup, args.model, args.iterations, args.cell_file, args.bins, args.resolution, args.max_adu, args.reservation )
|
||||
main( cwd, args.name, args.stream_file, args.pointgroup, args.model, args.iterations, args.cell_file, args.bins, args.resolution, args.max_adu, args.reservation )
|
||||
|
||||
Reference in New Issue
Block a user