def test_segy2ncdf_3D_cropZ(temp_dir, temp_segy, cropping_limits): temp_seisnc = temp_segy.with_suffix('.SEISNC') _, cropz = cropping_limits min_z, max_z = cropz segy2ncdf(temp_segy, temp_seisnc, silent=True, zcrop=[min_z, max_z]) ds = xr.open_dataset(temp_seisnc) assert tuple(ds.dims.values())[2] == max_z - min_z + 1
def test_segy2ncdf_3D_crop(temp_dir, temp_segy, cropping_limits): temp_seisnc = temp_segy.with_suffix('.SEISNC') crop, cropz = cropping_limits min_il, max_il, min_xl, max_xl = crop min_z, max_z = cropz segy2ncdf(temp_segy, temp_seisnc, silent=True, crop=crop, zcrop=cropz) ds = xr.open_dataset(temp_seisnc) assert tuple(ds.dims.values()) == (max_il - min_il + 1, max_xl - min_xl + 1, max_z - min_z + 1)
def test_segy2ncdf_3D_cropH(temp_dir, temp_segy, cropping_limits): temp_seisnc = temp_segy.with_suffix('.SEISNC') crop, _ = cropping_limits min_il, max_il, min_xl, max_xl = crop segy2ncdf(temp_segy, temp_seisnc, silent=True, crop=crop) ds = xr.open_dataset(temp_seisnc) assert tuple(ds.dims.values()) == (max_il - min_il + 1, max_xl - min_xl + 1, TEST_SEGY_SIZE)
def main(): # how to track down warnings #import warnings #warnings.filterwarnings('error', category=UnicodeWarning) #warnings.filterwarnings('error', category=DeprecationWarning, module='numpy') #parse args sys_parser = segysakArgsParser() args = sys_parser.parse_args() # gaffe print(f'SEGY-SAK - v{version}') # initialise logging LOGGER.info(f'segysak v{version}') # check inputs checked_files = check_file(args.files) # Generate or Load Configuration File for input_file in checked_files: print(input_file.name) # Print EBCIDC header if args.ebcidc: try: print(get_segy_texthead(input_file)) except IOError: LOGGER.error( "Input SEGY file was not found - check name and path") if args.scan > 0: hscan, nscan = segy_header_scan(input_file, max_traces_scan=args.scan) width = 10 print(f'Traces scanned: {nscan}') print("{:>40s} {:>8s} {:>10s} {:>10s}".format( 'Item', 'Byte Loc', 'Min', 'Max')) for key, item in hscan.items(): print("{:>40s} {:>8d} {:>10.0f} {:>10.0f}".format( key, item[0], item[1], item[2])) iline = args.iline xline = args.xline if args.netCDF is None or args.netCDF is not False: if args.netCDF is None: outfile = input_file.stem + '.SEISNC' else: outfile = args.netCDF segy2ncdf(input_file, outfile, iline=iline, xline=xline, crop=args.crop) LOGGER.info(f"NetCDF output written to {outfile}") if args.SEGY is None or args.SEGY is not False: if args.SEGY is None: outfile = input_file.stem + '.segy' else: outfile = args.SEGY ncdf2segy(input_file, outfile, iline=iline, xline=xline) #, crop=args.crop) LOGGER.info(f"SEGY output written to {outfile}")
def test_segy2ncdf_3D(temp_dir, temp_segy): temp_seisnc = temp_segy.with_suffix('.SEISNC') segy2ncdf(temp_segy, temp_seisnc, silent=True)