debugged and added all argparse

This commit is contained in:
Beale John Henry
2025-05-08 00:37:38 +02:00
parent 2acd84d8a9
commit 0c9a90f77d

View File

@@ -110,6 +110,9 @@ def extract_xtals( chunk ):
cell_df = scrub_cells( line ) cell_df = scrub_cells( line )
cells_df = pd.concat( ( cells_df, cell_df ) ) cells_df = pd.concat( ( cells_df, cell_df ) )
# reset index of cells_df
cells_df = cells_df.reset_index( drop=True )
return xtals, cells_df return xtals, cells_df
def extract_header( chunk ): def extract_header( chunk ):
@@ -278,7 +281,7 @@ def main( input_file, output, cell_tolerance, angle_tolerance, ideal_centre ):
print( "done" ) print( "done" )
def list_of_floats(arg): def list_of_floats(arg):
return list(map(int, arg.split(','))) return list(map(float, arg.split(',')))
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@@ -292,23 +295,32 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"-o", "-o",
"--output", "--output",
help="output stream file with sampled xtals", help="output stream file name. '.stream will be added'",
type=str, type=str,
default="sample" default="sample"
) )
# parser.add_argument( parser.add_argument(
# "-n", "-c",
# "--sample", "--cell_tolerance",
# help="size of sample to take from input.stream", help="tolerance for cell lengths. 0.2 is default.",
# type=int, type=float,
# required=True default=0.2
# ) )
parser.add_argument(
"-a",
"--angle_tolerance",
help="tolerance for cell angles. 0.25 is default.",
type=float,
default=0.25
)
parser.add_argument(
"-i",
"--ideal_centre",
help="ideal lengths to be selected around. List of floats - e.g. 78.5, 78.5, 38.45, 90, 90, 90",
type=list_of_floats,
required=True
)
args = parser.parse_args() args = parser.parse_args()
cell_tolerance = 0.2
angle_tolerance = 0.5
ideal_centre = [ 78.5, 78.5, 38.45, 90, 90, 90 ]
# run main # run main
main( args.stream, args.output, cell_tolerance, angle_tolerance, ideal_centre ) main( args.stream, args.output, args.cell_tolerance, args.angle_tolerance, args.ideal_centre )