def determine_orbit(config, meas, output_file = None): """ Performs orbit determination given config and measurements. Args: config: OD configuration (Dictionary, file name, text file-like object, or JSON encoded string). meas: List of measurements (List, file name, text file-like object, or JSON encoded string). output_file: If specified, the orbit fit will be written to the file name or text file-like object given. Returns: Orbit determination results in the same format as config (Dictionary or JSON encoded string). """ with RemoteServer.channel() as chan: stub = estimation_pb2_grpc.EstimationStub(chan) resp = stub.determineOrbit(messages_pb2.DetermineOrbitInput( config = build_settings(config), measurements = build_measurements(meas))) fitdata = convert_estimation(resp.array) if (output_file): write_output_file(output_file, fitdata) return(fitdata)
def propagate_orbits(config_list, output_file=None): """ Propagates the given objects in parallel. Args: config_list: List of configurations (each a dictionary, file name, text file-like object, or JSON encoded string). output_file: If specified, the output will be written to the file name or text file-like object given. Returns: Propagated state vectors at desired time intervals (List of dictionaries). """ with RemoteServer.channel() as chan: stub = propagation_pb2_grpc.PropagationStub(chan) resp = stub.propagate( messages_pb2.SettingsArray( array=[build_settings(p) for p in config_list])) propdata = convert_propagation(resp.array) if (output_file): write_output_file(output_file, propdata) return (propdata)
def async_helper(resp): prop_data = convert_propagation(resp.result().array) if (output_file): write_output_file(output_file, prop_data) channel.close() if (async_callback): async_callback(prop_data, async_extra) return (prop_data)
def async_helper(resp): fit_data = convert_estimation(resp.result().array) if (output_file): write_output_file(output_file, fit_data) channel.close() if (async_callback): async_callback(fit_data, async_extra) return (fit_data)
def async_helper(resp): sim_data = convert_measurements(resp.result().array) if (output_file): write_output_file(output_file, sim_data) channel.close() if (async_callback): async_callback(sim_data, async_extra) return (sim_data)
def determine_orbit(config, meas, output_file=None): """ Performs orbit determination given config and measurements. Args: config: OD configuration (Dictionary, file name, text file-like object, or JSON encoded string). meas: List of measurements (List, file name, text file-like object, or JSON encoded string). output_file: If specified, the orbit fit will be written to the file name or text file-like object given. Returns: Orbit determination results. """ if (isinstance(config, list)): od_output = [] else: od_output = None config = [config] if (od_output is None): meas = [meas] if (output_file and not isinstance(output_file, list)): output_file = [output_file] with RemoteServer.channel() as channel: stub = estimation_pb2_grpc.EstimationStub(channel) requests = [ stub.determineOrbit.future( messages_pb2.DetermineOrbitInput( config=build_settings(c), measurements=build_measurements(m))) for c, m in zip(config, meas) ] for idx, req in enumerate(requests): try: fit_data = convert_estimation(req.result().array) except Exception as exc: fit_data = format_exc() if (od_output is None): od_output = fit_data else: od_output.append(fit_data) if (output_file): write_output_file(output_file[idx], fit_data) return (od_output)
def simulate_measurements(config, output_file=None): """ Simulates measurement data given a configuration. Args: config: Simulation configuration (Dictionary, file name, text file-like object, or JSON encoded string). output_file: If specified, the measurements will be written to the file name or text file-like object given. Returns: Simulated measurements. """ if (isinstance(config, list)): sim_output = [] else: sim_output = None config = [config] if (output_file and not isinstance(output_file, list)): output_file = [output_file] with RemoteServer.channel() as channel: stub = simulation_pb2_grpc.SimulationStub(channel) requests = [ stub.simulateMeasurements.future(build_settings(c)) for c in config ] for idx, req in enumerate(requests): try: sim_data = convert_measurements(req.result().array) except Exception as exc: sim_data = format_exc() if (sim_output is None): sim_output = sim_data else: sim_output.append(sim_data) if (output_file): write_output_file(output_file[idx], sim_data) return (sim_output)
def simulate_measurements(config, output_file=None): """ Simulates measurement data given a configuration. Args: config: Simulation configuration (Dictionary, file name, text file-like object, or JSON encoded string). output_file: If specified, the measurements will be written to the file name or text file-like object given. Returns: Simulated measurements in the same format as config (Dictionary or JSON encoded string). """ with RemoteServer.channel() as chan: stub = simulation_pb2_grpc.SimulationStub(chan) resp = stub.simulateMeasurements(build_settings(config)) simdata = convert_measurements(resp.array) if (output_file): write_output_file(output_file, simdata) return (simdata)