def test_add_grid_to_parser(self): # Wrong dimensions with self.assertRaises(ValueError): kah.add_grid_to_parser(self.parser, dimensions=5) parser_3D = kah.init_argparse() kah.add_grid_to_parser(parser_3D, dimensions=3) # The [] essentially means "use defaults" args = kah.get_args(parser_3D, []) self.assertEqual(args.resolution, 500) self.assertCountEqual(args.origin, [0, 0, 0]) self.assertCountEqual(args.corner, [1, 1, 1]) # 2D parser_2D = kah.init_argparse() kah.add_grid_to_parser(parser_2D, dimensions=2) # The [] essentially means "use defaults" args = kah.get_args(parser_2D, []) self.assertEqual(args.plane, "xy") self.assertCountEqual(args.origin, [0, 0]) self.assertCountEqual(args.corner, [1, 1]) # 1D parser_1D = kah.init_argparse() kah.add_grid_to_parser(parser_1D, dimensions=1) # The [] essentially means "use defaults" args = kah.get_args(parser_1D, []) self.assertEqual(args.axis, "x") self.assertCountEqual(args.origin, [0]) self.assertCountEqual(args.corner, [1])
# You should have received a copy of the GNU General Public License along with # this program; if not, see <https://www.gnu.org/licenses/>. import logging from math import sqrt from kuibit import argparse_helper as kah from kuibit.simdir import SimDir if __name__ == "__main__": desc = f"""{kah.get_program_name()} prints some of the interesting properties (as from QuasiLocalMeasures) for a given horizon at a given time. Cubic splines are used to interpolate between timesteps.""" parser = kah.init_argparse(desc) parser.add_argument( "--qlm-index", required=True, type=int, help="Index of the horizon according to QuasiLocalMeasures.", ) parser.add_argument( "--time", type=float, default=0, help="Time to consider.", ) parser.add_argument( "--estimate-gamma", action="store_true",
from kuibit.simdir import SimDir from kuibit import argparse_helper as pah from kuibit.visualize_matplotlib import ( setup_matplotlib, add_text_to_figure_corner, save, ) """This script plots the trajectories of given apparent horizons. """ if __name__ == "__main__": setup_matplotlib() desc = """Plot trajectories of given apparent horizons.""" parser = pah.init_argparse(desc) pah.add_figure_to_parser(parser) parser.add_argument( "-t", "--type", type=str, choices=["3D", "xy", "xz", "yz"], default="3D", help="Type of plot: 3D, or of a specific plane (default: %(default)s).", ) parser.add_argument( "-a", "--horizons", type=int,
# this program; if not, see <https://www.gnu.org/licenses/>. import logging import os from kuibit import argparse_helper as kah from kuibit.simdir import SimDir if __name__ == "__main__": desc = f"""{kah.get_program_name()} dumps a specific grid variable resampled to a given grid into a file. Saving as .npz files guarantees the best performances. For 3D data, the default resolution will lead to long processing times. """ parser = kah.init_argparse(description=desc) parser.add_argument("--variable", type=str, required=True, help="Variable to save.") parser.add_argument( "--iteration", type=int, default=-1, help="Iteration to plot. If -1, the latest.", ) parser.add_argument( "--resolution", type=int, default=500,
def setUp(self): self.parser = kah.init_argparse()