changed all __main__ scripts to console_main() functions to be used as entry points
This commit is contained in:
parent
f487691e03
commit
00124bbdcc
8 changed files with 45 additions and 18 deletions
BIN
__init__.py
BIN
__init__.py
Binary file not shown.
|
@ -263,7 +263,9 @@ def get_ylims_and_yticks(ylims):
|
|||
return ylims, yticks
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
def console_main():
|
||||
from argparse import ArgumentParser
|
||||
parser = ArgumentParser(description='Plot power spectra of fields')
|
||||
|
||||
|
@ -403,5 +405,8 @@ if __name__ == "__main__":
|
|||
fig.savefig(args.output)
|
||||
else:
|
||||
fig.savefig(args.directory+'power_spectrum.png')
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
||||
|
|
@ -149,8 +149,7 @@ def plot_imshow_diff(data_list,
|
|||
return fig, axes
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
from argparse import ArgumentParser
|
||||
parser = ArgumentParser(description='Comparisons of fields slices.')
|
||||
|
||||
|
@ -223,3 +222,8 @@ if __name__ == "__main__":
|
|||
fig.savefig(args.output,bbox_inches='tight')
|
||||
else:
|
||||
fig.savefig(args.directory+'slices.jpg',bbox_inches='tight')
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
||||
|
|
9
main.py
9
main.py
|
@ -220,7 +220,7 @@ def check_consistency(card_dict, mode):
|
|||
raise ValueError(f"ModulePMCOLA is not 1: ModulePMCOLA={card_dict["ModulePMCOLA"]}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
from argparse import ArgumentParser
|
||||
from args_main import register_arguments_main
|
||||
from timestepping import register_arguments_timestepping, main_timestepping
|
||||
|
@ -238,4 +238,9 @@ if __name__ == "__main__":
|
|||
register_arguments_card(parser)
|
||||
register_arguments_cosmo(parser)
|
||||
parsed_args = parser.parse_args()
|
||||
main(parsed_args)
|
||||
main(parsed_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
||||
|
|
@ -36,8 +36,7 @@ def convert_snapshot_to_density(snapshot_path, output_path, N=None, corner=(0.0,
|
|||
print("Done.")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
parser = argparse.ArgumentParser(description="Convert snapshot to density.")
|
||||
parser.add_argument(
|
||||
"-S",
|
||||
|
@ -76,4 +75,8 @@ if __name__ == "__main__":
|
|||
output_path=args.output,
|
||||
N=args.N,
|
||||
corner=args.corner,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
|
@ -115,8 +115,7 @@ def field_to_field(
|
|||
print("Done.")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="Convert a field from one size to another.")
|
||||
parser.add_argument("-i","--input_file", type=str, help="Input field file")
|
||||
|
@ -128,4 +127,8 @@ if __name__ == "__main__":
|
|||
parser.add_argument("-BC","--boundary_conditions", type=int, default=1, help="Boundary conditions (1: periodic, 3: non-periodic)")
|
||||
args = parser.parse_args()
|
||||
|
||||
field_to_field(args.input_file, args.output_file, args.output_size, args.output_L, args.output_dpm, args.output_corner, args.boundary_conditions)
|
||||
field_to_field(args.input_file, args.output_file, args.output_size, args.output_L, args.output_dpm, args.output_corner, args.boundary_conditions)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
|
@ -99,8 +99,7 @@ def gather_tiles(folder, tile_base, L, Np, N_TILES, buffer):
|
|||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
parser = argparse.ArgumentParser(description="Gather density from tiles.")
|
||||
parser.add_argument("-d","--folder", type=str, default="./", help="Folder containing the tiles")
|
||||
parser.add_argument("--tile_base", type=str, default="sCOLA_tile", help="Base name of the tiles")
|
||||
|
@ -121,4 +120,9 @@ if __name__ == "__main__":
|
|||
Np_tile = Np//N_TILES
|
||||
dpm = L/Np_tile
|
||||
|
||||
gather_tiles(folder, tile_base, L, Np, N_TILES, buffer)
|
||||
gather_tiles(folder, tile_base, L, Np, N_TILES, buffer)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
|
@ -462,9 +462,7 @@ def scola_submit(directory,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def console_main():
|
||||
parser = argparse.ArgumentParser(description="Submit slurm jobs for sCOLA tiles.")
|
||||
|
||||
parser.add_argument("-d", "--directory", type=str, default="./", help="Main directory where the output will be saved (if other dir and filenames are not specified).")
|
||||
|
@ -496,4 +494,9 @@ if __name__ == "__main__":
|
|||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
console_main()
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue