def test_non_existing_file(): with pytest.raises(argparse.ArgumentTypeError) as err_context: Trajectory.load_from_file("non_existing") assert ("Warning: Trajectory file non_existing not found!" == err_context.value.args[0])
def test_load(initdir, fname): expected_utmxs = [0, 4] trajectory = Trajectory.load_from_file(fname) for expected_utmx, trajectorypoint in zip(expected_utmxs, trajectory.trajectory_points): assert trajectorypoint.utm_x == expected_utmx
def main_entry_point(args=None): arg_parser = _build_parser() options = arg_parser.parse_args(args) logger.setLevel(options.log_level) well_names = [w_info[0] for w_info in options.well_and_time_file] trajectories = { wname: Trajectory.load_from_file( filepath=os.path.join(options.trajectory_path, wname + ".txt")) for wname in well_names } logger.info("All files loaded\nRetrieving RFT data...") gendata_rft.run( well_times=options.well_and_time_file, trajectories=trajectories, ecl_grid=options.eclbase[0], ecl_rft=options.eclbase[1], zonemap=options.zonemap, csvfile=options.csvfile, ) logger.info("Completed!")
def main_entry_point(args=None): arg_parser = _build_parser() options = arg_parser.parse_args(args) logger.setLevel(options.log_level) well_names = [w_info[0] for w_info in options.well_and_time_file] trajectories = { wname: Trajectory.load_from_file( filepath=os.path.join(options.trajectory_path, wname + ".txt")) for wname in well_names } logger.info("All files loaded\nRetrieving RFT data...") try: gendata_rft.run( well_times=options.well_and_time_file, trajectories=trajectories, ecl_grid=options.eclbase[0], ecl_rft=options.eclbase[1], zonemap=options.zonemap, csvfile=options.csvfile, outputdirectory=options.outputdirectory, ) with open("GENDATA_RFT.OK", "w") as fh: fh.write("GENDATA RFT completed OK") logger.info("Completed!") except ValueError as exception: logger.error("Failed with error message: {}".format(exception))
def test_dframe_trajectory(initdir, fname): """Test dataframe representation of a trajectory not having any attached Eclipse simulation results""" dframe = Trajectory.load_from_file(fname).to_dataframe() assert isinstance(dframe, pd.DataFrame) # Dataframe lengths should be the same as number of non-empty lines # in txt input: assert len(dframe) == len([ line for line in open(fname).readlines() if line.strip() and not line.strip().startswith("--") ], ) # Check that we have the input columns which defines the trajectory: assert {"utm_x", "utm_y", "measured_depth", "true_vertical_depth", "zone"}.issubset(set(dframe.columns)) # grid_ijk is a temp column, never to be present in output assert "grid_ijk" not in dframe # and since there is no Eclipse results attached, we can't have these either: assert "i" not in dframe assert "j" not in dframe assert "k" not in dframe # Check casing for column names, ensuring consistency in this particular # dataframe: assert list( dframe.columns) == [colname.lower() for colname in dframe.columns] # pressure should not be there when there is no data for it # (no Eclipse simulation results attached in this particular test function) assert "pressure" not in dframe # These columns should be in place, to signify there is not data for them. # (Eclipse simulation results would be needed for any of these to be True) assert set(dframe["valid_zone"]) == {False} assert set(dframe["is_active"]) == {False} # Check dataframe sorting: assert (dframe.sort_values("measured_depth")["measured_depth"] == dframe["measured_depth"]).all()
def main_entry_point(): arg_parser = _build_parser() options = arg_parser.parse_args() logger.setLevel(options.log_level) context_errors = [] trajectories = {} for well_name, *_ in options.well_and_time_file: try: trajectories[well_name] = Trajectory.load_from_file( filepath=os.path.join(options.trajectory_path, well_name + ".txt")) except (IOError, ValueError) as err: context_errors.append(str(err)) if context_errors: raise SystemExit("\n".join(context_errors)) logger.info("All files loaded\nRetrieving RFT data...") try: gendata_rft.run( well_times=options.well_and_time_file, trajectories=trajectories, ecl_grid=options.eclbase[0], ecl_rft=options.eclbase[1], zonemap=options.zonemap, csvfile=options.csvfile, outputdirectory=options.outputdirectory, ) with open("GENDATA_RFT.OK", "w") as fh: fh.write("GENDATA RFT completed OK") logger.info("Completed!") except ValueError as exception: logger.error(str(exception)) sys.exit(1)
def test_non_existing_file(): with pytest.raises(IOError, match="Trajectory file non_existing not found!"): Trajectory.load_from_file("non_existing")