def test_from_csv(): lexicon = Lexicon.default() csv_string = """ 200.000, 230.329, Anhydrite 230.329, 233.269, Grey vf-f sandstone 233.269, 234.700, Anhydrite 234.700, 236.596, Dolomite 236.596, 237.911, Red siltstone 237.911, 238.723, Anhydrite 238.723, 239.807, Grey vf-f sandstone 239.807, 240.774, Red siltstone 240.774, 241.122, Dolomite 241.122, 241.702, Grey siltstone 241.702, 243.095, Dolomite 243.095, 246.654, Grey vf-f sandstone 246.654, 247.234, Dolomite 247.234, 255.435, Grey vf-f sandstone 255.435, 258.723, Grey siltstone 258.723, 259.729, Dolomite 259.729, 260.967, Grey siltstone 260.967, 261.354, Dolomite 261.354, 267.041, Grey siltstone 267.041, 267.350, Dolomite 267.350, 274.004, Grey siltstone 274.004, 274.313, Dolomite 274.313, 294.816, Grey siltstone 294.816, 295.397, Dolomite 295.397, 296.286, Limestone 296.286, 300.000, Volcanic """ strip2 = Striplog.from_csv(csv_string, lexicon=lexicon) assert len(strip2.top) == 7
def update_cross_section(tops_storage, well_uwi): """ top_storage_json to striplogs to project. to return encoded str (image) """ wells_tops = pd.read_json(tops_storage) well_tops = wells_tops[wells_tops.UWI == well_uwi] csv_txt = df_to_csvtxt(well_tops) p.get_well(well_uwi).data['tops'] = Striplog.from_csv(text=csv_txt) return encode_xsection(p, legend)
def test_canstrat(): """ Test basic stuff. """ w = Well.from_las('tests/P-129_out.LAS') s = Striplog.from_csv('tests/K90_strip_pred.csv') w.data['test'] = s dat = w.to_canstrat(key='test', log='K 90', as_text=True) s7 = "K 907 3960 3966L0 " assert s7 in dat
def make_well_project(laspath='data/las/', stripath='data/tops/'): """ Return a dictionary of wells and striplogs where the key is the base filename """ wells = {} lasfiles = glob(laspath + '*.LAS') stripfiles = glob(stripath + '*.csv') for fname, sname in zip(lasfiles, stripfiles): name = fname.split('/')[-1].split('.')[0] wells[name] = Well.from_las(fname) wells[name].data['tops'] = Striplog.from_csv(sname) proj = Project(list(wells.values())) return proj
def make_well_project(laspath='data/las/', stripath='data/tops/'): """ Return a dictionary of wells and striplogs where the key is the base filename This assumes that the las file and tops files have the same name """ wells = {} lasfiles = glob(laspath + '*.LAS') stripfiles = glob(stripath + '*.csv') for fname, sname in zip(lasfiles, stripfiles): name = Path(fname).stem wells[name] = Well.from_las(fname) wells[name].data['tops'] = Striplog.from_csv(sname) proj = Project(list(wells.values())) return proj
def test_striplog_top_plot(): """ Tests mpl image of striplog with the tops option. """ tops_csv = """top, Comp formation 25, Escanilla Fm. 35, San Vicente Fm. 20, Sobrarbe Fm. 50, Cretaceous""" tops = Striplog.from_csv(text=tops_csv) fig = tops.plot(style='tops', field='formation', aspect=1.5, return_fig=True) return fig
stripfiles = glob(path2 + '*.csv') legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv' ) # direct link to specific data p = Project.from_las( 'data/Poseidon_data/las/*.LAS') # direct link to specific data well_uwi = [w.uwi for w in p ] ##gets the well uwi data for use in the well-selector tool # Add striplogs to Project # Striplog must have the same name as LAS file. # e.g. Torosa-1.LAS and Torosa-1.csv for w in p: name = Path(w.fname).stem strip = Striplog.from_csv( f'data/Poseidon_data/tops/{name}.csv') # direct link to specific data w.data['tops'] = strip well = p[0] ##gets data from the first well in the Welly Project curve_list = get_curves( p) ##gets the column names for later use in the curve-selector tool curve = get_first_curve(curve_list) surface_picks_df = get_tops_df(p) #well dropdown selector well_dropdown_options = [{ 'label': k, 'value': k } for k in sorted(well_uwi)] ##list of wells to the dropdown #tops dropdown options """we need to have a stratigraphic column at some point"""
def test_from_csv(): lexicon = Lexicon.default() strip2 = Striplog.from_csv(csv_string, lexicon=lexicon) assert len(strip2.top) == 7
def test_points(): """Test a striplog of points. """ points = Striplog.from_csv(text=csv_points, points=True) assert len(points) == 6 assert points.order == 'none'
helper.update_picks_on_plot(fig, picks_selected) return fig base_dir = "./data/Poseidon_data" # # load well data """Need to add a method for the user to point to the directory or add additional las files later""" fpath = Path(base_dir + "/las/*.LAS") p = Project.from_las(str(fpath)) well_uwi = [w.uwi for w in p] for w in p: name = w.fname.split('/')[-1].split('.')[0] strip = Striplog.from_csv(base_dir + f'/tops/{name}.csv') w.data['tops'] = strip well_uwi = [w.uwi for w in p] well_uwi = st.sidebar.selectbox("Well Names", well_uwi) df = p[0].df() ##gets data from the first well in the Welly Project curve_list = df.columns.tolist( ) ##gets the column names for later use in the curve-selector tool curve_dropdown_options = [{ 'label': k, 'value': k } for k in sorted(curve_list)] ##list of well log curves to the dropdown curve = st.sidebar.selectbox( "Well Names", [item['value'] for item in curve_dropdown_options])
def test_striplog(): s = Striplog.from_csv( data_path.joinpath('striplog_integration/alpha_strip.tops')) s.plot() plt.show() print(s)
else: data_path = cwd + '/..' print(data_path + '/data/input_data/striplog_integration/*.tops') topsfiles = glob.glob(data_path + '/data/input_data/striplog_integration/*.tops') topsfiles # %% # Creating striplog object my_striplogs = [] for file in topsfiles: with open(file) as f: text = f.read() striplog = Striplog.from_csv(text=text) my_striplogs.append(striplog) striplog_dict = { 'alpha': my_striplogs[1], 'beta': my_striplogs[2], 'gamma': my_striplogs[3], 'epsilon': my_striplogs[0] } striplog_dict['alpha'][0] # %% # Plot striplog f, a = plt.subplots(ncols=4, sharey=True)
print(' '*5, fname) print('\n') tops_legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv') p = Project.from_las('data/Poseidon_data/las/*.LAS') well_uwi = [w.uwi for w in p] ##gets the well uwi data for use in the well-selector tool # Add striplogs to Project # Striplog must have the same name as LAS file. # e.g. Torosa-1.LAS and Torosa-1.csv for w in p: name = Path(w.fname).name.split('.')[0] new_path = f'data/Poseidon_data/tops/{name}.csv' print(name, new_path) strip = Striplog.from_csv(f'data/Poseidon_data/tops/{name}.csv') w.data['tops'] = strip # Make the well correlation panel def encode_xsection(p): """ Takes the project and saves a xsec PNG a disk and encodes it for dash """ section_plot(p, tops_legend) image_filename = 'cross_section.png' # replace with your own image encoded_image = base64.b64encode(open(image_filename, 'rb').read()) return 'data:image/png;base64,{}'.format(encoded_image.decode()) # Initialize Cross-section
def test_from_csv(): """Test the CSV route. """ lexicon = Lexicon.default() strip2 = Striplog.from_csv(csv_intervals, lexicon=lexicon) assert len(strip2.top) == 7