resout.write_header(output_header) for time_index, time in tqdm(resin.subset_time( args.start, args.end, args.ech), unit='frame'): values = do_calculations_in_frame(necessary_equations, resin, time_index, output_header.var_IDs, output_header.np_float_type, is_2d=output_header.is_2d, us_equation=None) resout.write_entire_frame(output_header, time, values) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf', 'out_slf', 'shift']) group_var = parser.add_argument_group( 'Serafin variables (optional)', 'See variables abbrevations on https://github.com/CNR-Engineering/PyTelTools/wiki/Notations-of-variables' ) group_var.add_argument('--var2del', nargs='+', help='variable(s) to delete', default=[], metavar=('VA', 'VB')) group_var.add_argument('--var2add', nargs='+', help='variable(s) to add', default=[], metavar=('VA', 'VB'))
values = np.empty((output_header.nb_var, output_header.nb_nodes), dtype=output_header.np_float_type) with Serafin.Write(args.out_slf, args.lang, overwrite=args.force) as resout: resout.write_header(output_header) time_index = len(resin.time) - 1 time = resin.time[-1] if args.time is None else args.time for i, var_ID in enumerate(output_header.var_IDs): values[i, :] = resin.read_var_in_frame(time_index, var_ID) resout.write_entire_frame(output_header, time, values) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf', 'out_slf', 'shift']) parser.add_argument( '--time', help='time in seconds to write last frame (set to frame time by default)', type=float) parser.add_group_general(['force', 'verbose']) if __name__ == '__main__': args = parser.parse_args() try: slf_last(args) except (Serafin.SerafinRequestError, Serafin.SerafinValidationError): # Message is already reported by slf logger sys.exit(1)
output_header.add_variable_from_ID(var_ID) with Serafin.Write(args.out_slf, args.lang, overwrite=args.force) as resout: resout.write_header(output_header) vars_2d = np.empty((output_header.nb_var, output_header.nb_nodes_2d), dtype=output_header.np_float_type) for time_index, time in enumerate(tqdm(resin.time, unit='frame')): if args.aggregation is not None: vars_2d = vertical_calculator.max_min_mean_in_frame(time_index) else: for i, var in enumerate(output_header.var_IDs): vars_2d[i, :] = resin.read_var_in_frame_as_3d(time_index, var)[args.layer - 1, :] resout.write_entire_frame(output_header, time, vars_2d) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf', 'out_slf', 'shift']) group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--layer', help='layer number (1=lower, nb_planes=upper)', type=int, metavar=1) group.add_argument('--aggregation', help='operation over the vertical', choices=('max', 'min', 'mean')) parser.add_argument('--vars', nargs='+', help='variable(s) deduced from Z', default=[], choices=('B', 'S', 'H')) parser.add_group_general(['force', 'verbose']) if __name__ == '__main__': args = parser.parse_args() try: slf_3d_to_2d(args) except (Serafin.SerafinRequestError, Serafin.SerafinValidationError): # Message is already reported by slf logger sys.exit(1)
from pyteltools.utils.cli import PyTelToolsArgParse from pyteltools.workflow.workflow_gui import WorkflowWelcomeWindow def exec_gui(window): """ Execute a simple GUI application @param window <PyQt5.QtWidgets.QWidget>: window to display """ app = QApplication(sys.argv) window = window() window.show() app.exec_() parser = PyTelToolsArgParse(description=__doc__) parser.add_argument('-c', '--interface', help='select and open corresponding GUI', choices=('classic', 'workflow')) if __name__ == '__main__': args = parser.parse_args() # suppress explicitly traceback silencing sys._excepthook = sys.excepthook sys.excepthook = exception_hook if args.interface is None: run_gui_app() else:
weight = calculator.weights[j] volume = calculator.volume_in_frame_in_polygon(weight, values, calculator.polygons[j]) if calculator.volume_type == VolumeCalculator.POSITIVE: for v in volume: i_result.append(settings.FMT_FLOAT.format(v)) else: i_result.append(settings.FMT_FLOAT.format(volume)) result.append(i_result) # Write CSV mode = 'w' if args.force else 'x' with open(args.out_csv, mode) as out_csv: calculator.write_csv(result, out_csv, args.sep) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf']) parser.add_argument('in_polygons', help='set of polygons file (*.shp, *.i2s)') parser.add_argument('--ech', type=int, help='frequency sampling of input', default=1) parser.add_argument('--upper_var', help='upper variable', metavar='VA', required=True) parser.add_argument('--lower_var', help='lower variable', metavar='VB', default=None) parser.add_argument('--detailed', help='add positive and negative volumes', action='store_true') parser.add_known_argument('out_csv') parser.add_group_general(['force', 'verbose']) if __name__ == '__main__': args = parser.parse_args() try: slf_volume(args)
resin.header.np_float_type, is_2d=True, us_equation=STRICKLER_EQUATION, ori_values=ori_values) resout.write_entire_frame(output_header, time, values) row = [time] for j in range(len(calculator.polygons)): weight = calculator.weights[j] volume = calculator.volume_in_frame_in_polygon( weight, values[pos_TAU], calculator.polygons[j]) row.append(volume) csvwriter.writerow(row) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf', 'out_slf', 'out_csv']) parser.add_argument('in_polygons', help='polygons file (*.shp)') parser.add_argument('--in_strickler_zones', help='strickler zones file (*.shp)') parser.add_argument( '--in_strickler_attr', help='attribute to read strickler values `--in_stricker_zone`') help_friction_laws = ', '.join( ['%i=%s' % (i, law) for i, law in enumerate(FRICTION_LAWS)]) group_var.add_argument('--friction_law', type=int, help='friction law identifier: %s' % help_friction_laws, choices=range(len(FRICTION_LAWS)), default=STRICKLER_ID) parser.add_group_general(['force', 'verbose'])
values.append(resin.read_var_in_frame(time_index, var_ID)) for j in range(len(polylines)): intersections = calculator.intersections[j] flux = calculator.flux_in_frame(intersections, values) i_result.append(settings.FMT_FLOAT.format(flux)) result.append(i_result) # Write CSV mode = 'w' if args.force else 'x' with open(args.out_csv, mode) as out_csv: calculator.write_csv(result, out_csv, args.sep) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf']) parser.add_argument('in_sections', help='set of lines file (*.shp, *.i2s)') parser.add_argument('--ech', type=int, help='frequency sampling of input', default=1) parser.add_argument('--scalars', nargs='*', help='scalars to integrate (up to 2)', default=[], metavar=('VA', 'VB')) parser.add_argument('--vectors', nargs=2, help='couple of vectors to integrate (X and Y vectors)', default=[], metavar=('VX', 'VY')) parser.add_known_argument('out_csv') parser.add_group_general(['force', 'verbose']) if __name__ == '__main__': args = parser.parse_args() try: slf_flux2d(args)
if args.long: csvwriter.writerow(values_long + [var_ID, settings.NAN_STR]) else: values.append(settings.NAN_STR) else: (i, j, k), interpolator = point_interpolator int_value = settings.FMT_FLOAT.format(interpolator.dot(var[[i, j, k]])) if args.long: csvwriter.writerow(values_long + [var_ID, int_value]) else: values.append(int_value) if not args.long: csvwriter.writerow(values) parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf']) parser.add_argument('in_points', help='set of points file (*.shp)') parser.add_known_argument('out_csv') parser.add_argument('--long', help='write CSV with long format (variables are also in rows) instead of wide format', action='store_true') parser.add_argument('--vars', nargs='+', help='variable(s) to extract (by default: every variables)', default=None, metavar=('VA', 'VB')) parser.add_group_general(['force', 'verbose']) if __name__ == '__main__': args = parser.parse_args() try: slf_int2d(args) except (Serafin.SerafinRequestError, Serafin.SerafinValidationError):