# Argname, description, dtype, default ARGS = [ ('cube-path', 'path to the seismic cube in HDF5 format', str, None), ('savedir', 'path to save files to', str, '_placeholder_'), ('metrics', 'metrics to compute for quality map creation', str, ['support_hellinger']), ('add-prefix', 'whether to prepend cube name to the saved file names', str2bool, True), ('save-txt', 'whether to save point cloud of quality map to disk', str2bool, False), ] if __name__ == '__main__': config = make_config(MSG, ARGS, os.path.basename(__file__).split('.')[0]) if config['savedir'] == '_placeholder_': config['savedir'] = os.path.dirname(config['cube-path']) geometry = SeismicGeometry(config['cube-path']) geometry.make_quality_map([0.1, 0.15, 0.2, 0.4, 0.5], config['metrics']) prefix = '' if config['add-prefix'] is False else geometry.short_name + '_' safe_mkdir(config['savedir']) plot_image(geometry.quality_map, cmap='Reds', xlabel='INLINE_3D', ylabel='CROSSLINE_3D', title='', savepath=os.path.join(config['savedir'], f'{prefix}quality_map.png')) if config['save-txt']: save_point_cloud(geometry.quality_map, os.path.join(config['savedir'], f'{prefix}quality_map.txt'), geometry)
cm = HorizonMetrics(carcass) for metric_name in config['metrics']: kwargs = copy(LOCAL_KWARGS) if metric_name.startswith( 'local') else copy(SUPPORT_KWARGS) kwargs = {} if metric_name.startswith('insta') else kwargs savepath = os.path.join(config['savedir'], f'{prefix}carcass_{metric_name}') metric = cm.evaluate(metric_name, **kwargs) metric = metric if len(carcass) > ( len(horizon) // 10) else enlarge_carcass_metric( metric, geometry) plot_image(metric, figsize=(20, 20), cmap=METRIC_CMAP, zmin=-1, zmax=1, fill_color='black', savepath=savepath + '.png') row_dict[f'carcass_{metric_name}'] = np.nanmean(metric) if config['save-files']: horizon.dump(os.path.join(config['savedir'], f'{horizon.name}_carcass'), add_height=False) else: row_dict = { **row_dict, 'carcass_name': '', 'carcass_path': '', **{metric_name: 0
kwargs = copy(LOCAL_KWARGS) if metric_name.startswith( 'local') else copy(SUPPORT_KWARGS) kwargs = {} if metric_name.startswith('insta') else kwargs savepath = os.path.join( config['savedir'], f'{prefix}{other_prefix}_{metric_name}') metric = om.evaluate(metric_name, **kwargs) if other.is_carcass: metric = enlarge_carcass_metric(metric, geometry) plot_image(metric, figsize=(20, 20), cmap=METRIC_CMAP, zmin=-1, zmax=1, fill_color='black', xlabel='INLINE_3D', ylabel='CROSSLINE_3D', savepath=savepath + '.png') row_dict[f'{other_prefix}_{metric_name}'] = np.nanmean( metric) if config['save-files']: shutil.copy2( other.path, os.path.join(config['savedir'], f'{horizon.name}_{other_prefix}')) else: row_dict = { **row_dict,
row_dict = { **row_dict, 'carcass_name': carcass.name, 'carcass_path': os.path.join(*carcass.path.split('/')[-2:]), } cm = HorizonMetrics(carcass) for metric_name in config['metrics']: kwargs = copy(LOCAL_KWARGS) if metric_name.startswith('local') else copy(SUPPORT_KWARGS) kwargs = {} if metric_name.startswith('insta') else kwargs savepath = os.path.join(config['savedir'], f'{prefix}carcass_{metric_name}') metric = cm.evaluate(metric_name, **kwargs) plot_image(enlarge_carcass_metric(metric, geometry), figsize=(20, 20), cmap=METRIC_CMAP, zmin=-1, zmax=1, fill_color='black', savepath=savepath + '.png') row_dict[f'carcass_{metric_name}'] = np.nanmean(metric) if config['save-files']: horizon.dump(os.path.join(config['savedir'], f'{horizon.name}_carcass'), add_height=False) else: row_dict = { **row_dict, 'carcass_name': '', 'carcass_path': '', **{metric_name: 0 for metric_name in config['metrics']}, } dataframe.append(row_dict) pd.DataFrame(dataframe).to_csv(os.path.join(config['savedir'], 'report.csv'), sep=',', index=False)