Ejemplo n.º 1
0
def main():
    # If a model file is not specified, a uniformly spaced model should be generated based on the data.the
    # i.e., use sites as bounds, and use smallest period as a starting point for cell sizes.
    files = sys.argv[1:]
    for file in files:
        if not utils.check_file(file):
            print('File {} not found.'.format(file))
            return
    files = utils.sort_files(files=files)
    try:
        data = WSDS.Data(datafile=files['dat'])
    except KeyError:
        print('No data file given. Site locations will not be available.')
        data = None
    try:
        model = WSDS.Model(files['model'])
    except KeyError:
        if data is None:
            print('One or more of <model_file> and <data_file> must be given!')
            return
        else:
            print('Generating initial model...')
            model = WSDS.Model(data=data)
            print([model.vals.shape, model.nx, model.ny, model.nz])

    app = QtWidgets.QApplication(sys.argv)
    viewer = model_viewer_2d(model=model, data=data)
    viewer.show()
    ret = app.exec_()
    sys.exit(ret)
    viewer.disconnect_mpl_events()
Ejemplo n.º 2
0
def to_vtk(outfile,
           datafile=None,
           listfile=None,
           modelfile=None,
           datpath=None,
           origin=None,
           UTM=None,
           sea_level=0,
           resolutionfile=None,
           transform_coords=None):
    if not outfile:
        print('Output file required!')
        return
    if listfile or datafile:
        dataset = WSDS.Dataset(modelfile=modelfile,
                               datafile=datafile,
                               listfile=listfile,
                               datpath=datpath)
    model = WSDS.Model(modelfile=modelfile)
    if not UTM:
        print('Using dummy UTM zone')
        UTM = '999'
    if transform_coords == 'y':
        print('Transforming locations to UTM {}'.format(UTM))
        transform_locations(dataset, UTM)

    if not origin and not listfile:
        print(
            'You must either specify the origin, or the list file to calculate it from.'
        )
        return
    elif (not origin and listfile) or transform_coords == 'y':
        origin = dataset.raw_data.origin
        print('Setting origin as {}'.format(origin))
    if modelfile:
        model.origin = origin
        model.UTM_zone = UTM
        print('Writing model to {}'.format('_'.join([outfile, 'model.vtk'])))
        if resolutionfile:
            print('Adding resolution')
            resolution = WSDS.Model(modelfile=resolutionfile)
            model.resolution = resolution.vals
        model.to_vtk(outfile, sea_level=sea_level)
    if listfile:
        print('Writing model to {}'.format('_'.join([outfile, 'sites.vtk'])))
        # dataset.raw_data.locations = dataset.raw_data.get_locs(mode='centered')
        dataset.raw_data.locations -= (origin[1], origin[0])
        dataset.raw_data.to_vtk(origin=origin,
                                UTM=UTM,
                                outfile=outfile,
                                sea_level=sea_level)
    elif datafile:
        print('Writing model to {}'.format('_'.join([outfile, 'sites.vtk'])))
        dataset.data.to_vtk(origin=origin,
                            UTM=UTM,
                            outfile=outfile,
                            sea_level=sea_level)
Ejemplo n.º 3
0
def main():
    files = sys.argv[1:]
    for file in files:
        if not check_file(file):
            print('File {} not found.'.format(file))
            return
    files = sort_files(files=files)
    try:
        data = WSDS.Data(datafile=files['dat'])
    except KeyError:
        print('No data file given. Site locations will not be available.')
        data = None
    try:
        model = WSDS.Model(files['model'])
    except KeyError:
        print('Model must be specified')
        return
    app = Qt.QApplication(sys.argv)
    viewer = ModelWindow(files)
    viewer.show()
    ret = app.exec_()
    sys.exit(ret)
Ejemplo n.º 4
0
# main_transect = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/rouyn/j2/main_transect_more.lst')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/abi-gren/j2/center_fewer3.lst')
# backup_data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/abi-gren/j2/center_fewer3.lst')
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/abi-gren/centerMore_ModEM/NLCG_NLCG_120.rho')
# seismic = pd.read_table('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/rouyn/rou_seismic_traces.txt',
#                         header=0, names=('trace', 'x', 'y'), sep='\s+')
#########################################################
# MATHESON
# main_transect = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/mat_westLine.lst')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/mat_bb_cull1.lst')
# backup_data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/mat_bb_cull1.lst')
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/matheson/mat3/mat3_lastIter.rho')
main_transect = WSDS.RawData(local_path + '/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/MATBB.lst')
data = WSDS.RawData(local_path + '/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/MATall.lst')
backup_data = WSDS.RawData(local_path + '/phd/ownCloud/data/Regions/MetalEarth/matheson/j2/MATall.lst')
mod = WSDS.Model(local_path + '/phd/ownCloud/data/Regions/MetalEarth/matheson/Hex2Mod/HexMat_all.model')
#########################################################
# AFTON
# main_transect = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/afton/j2/l0.lst')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/afton/j2/afton_cull1.lst')
# backup_data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/afton/j2/afton_cull1.lst')
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/afton/afton1/afton2_lastIter.rho')
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/afton/afton_rot/aftonrot_NLCG_069.rho')
#########################################################
# GERALDTON
# main_transect = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/geraldton/j2/main_transect.lst')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/geraldton/j2/ger_cull4.lst')
# backup_data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/geraldton/j2/ger_cull4.lst')
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/geraldton/ger_cull4/ger_NLCG_155.rho')
# seismic = pd.read_table(r'C:/Users/eroots/phd/ownCloud/Metal Earth/Data/Seismic/ME_Seismic_PostStack_Migrated_sections/' + 
#                         r'GERALDTON_LN301_R1_KMIG/GERALDTON_LN301_R1_KMIG_SUGETHW_UTM.txt',
Ejemplo n.º 5
0
# data = WSDS.Data(r'C:\Users\eroots\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\swz_cull1i_Z.dat')
# reso = WSDS.Model(r'C:\Users\eroots\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\Resolution.model')
# mod = WSDS.Model(r'C:\Users\eric\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\swz_finish.model')
# data = WSDS.Data(r'C:\Users\eric\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\swz_cull1i_Z.dat')
# reso = WSDS.Model(r'C:\Users\eric\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\Resolution.model')
# mod = WSDS.Model(r'C:\Users\eroots\phd\ownCloud\data\Regions\MetalEarth\swayze\swz_cull1\finish\Resolution.model')
# mod = WSDS.Model(r'C:\Users\eric\Documents\MATLAB\MATLAB\Inversion\Regions\MetalEarth\swayze\R1South_2\bb\R1South_2e_smooth.model')
# data = WSDS.Data(r'C:\Users\eric\Documents\MATLAB\MATLAB\Inversion\Regions\MetalEarth\swayze\R1South_2\bb\R1South_2f_bb_Z.dat')
# data = WSDS.Data(datafile='C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/dry53.data',
#                  listfile='C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/j2/dry5_3.lst')
#####################################################################
# MALARTIC
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/malartic/mal1/mal3_lastIter.rho')
# data = WSDS.Data('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/malartic/mal1/mal3_lastIter.dat')
mod = WSDS.Model(
    local_path +
    'phd/ownCloud/data/Regions/MetalEarth/malartic/Hex2Mod/HexMal_Z.model')
data = WSDS.RawData(
    local_path +
    'phd/ownCloud/data/Regions/MetalEarth/malartic/j2/mal_hex.lst')
#####################################################################
# DRYDEN
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/norot/dry5norot_lastIter.rho')
# data = WSDS.Data('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/norot/dry5norot_lastIter.dat')
#####################################################################
# AFTON
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/regions/afton/afton1/afton2_lastIter.rho')
# data = WSDS.Data('C:/Users/eroots/phd/ownCloud/data/regions/afton/afton1/afton2_lastIter.dat')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/regions/afton/j2/afton_cull1.lst')
#####################################################################
# LARDER
Ejemplo n.º 6
0
# data_out = r'C:\Users\eroots\phd\ownCloud\data\Regions\MetalEarth\swayze\R1South_4\R1South_4_placed.data'
########################################
# WESTERN SUPERIOR - DRYDEN
# model_file = r'C:\Users\eric\phd\ownCloud\data\Regions\wst\wsSC1\wsSC_final.model'
# base_data = r'C:\Users\eric\phd\ownCloud\data\Regions\wst\wsSC1\wsSC_final.dat'
# data_file = 'C:/Users/eric/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/dry53.data'
# list_file = 'C:/Users/eric/phd/ownCloud/data/Regions/MetalEarth/dryden/j2/dry5_3.lst'
# base_list = r'C:\Users\eric\phd\ownCloud\data\Regions\wst\j2\southcentral.lst'
# model_out = r'C:\Users\eric\phd\ownCloud\data\Regions\MetalEarth\dryden\wst2dry\wst2dry.model'
# data_out = r'C:\Users\eric\phd\ownCloud\data\Regions\MetalEarth\dryden\wst2dry.dat'
########################################
plot_it = 0
write_it = 1
azi = -0  # Rotate the non-base data back

mod = WSDS.Model(model_file)
data = WSDS.Data(datafile=data_file, listfile=list_file)
data.locations = data.get_locs(azi=-azi)
data.set_locs()
base_data = WSDS.Data(datafile=base_data, listfile=base_list)
for site in base_data.site_names:
    if site in data.site_names:
        x_diff = data.sites[site].locations['X'] - base_data.sites[
            site].locations['X']
        y_diff = data.sites[site].locations['Y'] - base_data.sites[
            site].locations['Y']
        break
data.locations[:, 0] -= x_diff
data.locations[:, 1] -= y_diff
file_format = 'wsinv3dmt'
depths_per_decade = (8, 10, 12, 14, 10)
Ejemplo n.º 7
0
#####################################################################
# DRYDEN
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/norot/dry5norot_lastIter.rho')
# data = WSDS.Data('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/norot/dry5norot_lastIter.dat')
#####################################################################
# AFTON
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/regions/afton/afton1/afton2_lastIter.rho')
# data = WSDS.Data('C:/Users/eroots/phd/ownCloud/data/regions/afton/afton1/afton2_lastIter.dat')
# data = WSDS.RawData('C:/Users/eroots/phd/ownCloud/data/regions/afton/j2/afton_cull1.lst')
#####################################################################
# LARDER
data = WSDS.RawData(local_path +
                    'phd/ownCloud/data/Regions/MetalEarth/larder/j2/test.lst')
# mod = WSDS.Model(local_path + 'phd/ownCloud/data/Regions/MetalEarth/larder/Hex2Mod/Hex2Mod_all.model')
mod = WSDS.Model(
    local_path +
    'phd/ownCloud/data/Regions/MetalEarth/larder/Hex2Mod/Hex2Mod_Z_static.model'
)
# reso = []
# mod = WSDS.Model('C:/Users/eroots/phd/ownCloud/data/Regions/MetalEarth/dryden/dry5/dry53.rho')
# kimberlines = [5.341140e+006, 5.348097e+006,
#                5.330197e+006, 5.348247e+006,
#                5.369642e+006]
kimberlines = []
mod.origin = data.origin
# data.locations = np.array([[0 for ii in range(17)],
#                            [0.000000000E+00, 0.501143799E+04, 0.104698379E+05,
#                             0.136017852E+05, 0.178389980E+05, 0.208527168E+05,
#                             0.247133633E+05, 0.279987383E+05, 0.328820195E+05,
#                             0.345390352E+05, 0.372428438E+05, 0.394137422E+05,
#                             0.433482109E+05, 0.467561680E+05, 0.507770469E+05,
#                             0.534360625E+05, 0.653211367E+05]]) / 1000
Ejemplo n.º 8
0
    ax.images.append(img)
    ax.set_xlim(left=x[0], right=x[-1])
    ax.set_ylim(bottom=y[0], top=y[-1])
    ax.autoscale_view(tight=True)
    return img


def interpolate_slice(x, y, Z, NP):
    mod_interp = RBS(x, y, Z)
    interp_vals = mod_interp(np.linspace(x[0], x[-1], NP),
                             np.linspace(y[0], y[-1], NP))
    return interp_vals


mod = WSDS.Model(r'C:\Users\eric\Documents' +
                 r'\MATLAB\MATLAB\Inversion\Regions' +
                 r'\abi-gren\New\abi0_sens\outSens_model.00')
reso = WSDS.Model(r'C:\Users\eric\Documents' +
                  r'\MATLAB\MATLAB\Inversion\Regions' +
                  r'\abi-gren\New\abi0_sens\Resolution0_inverted.model')
data = WSDS.RawData(
    r'C:\Users\eric\Documents' + r'\MATLAB\MATLAB\Inversion\Regions' +
    r'\abi-gren\New\abi0_sens\bigabi_2.lst',
    datpath=r'C:\Users\eric\Documents' + r'\MATLAB\MATLAB\Inversion\Regions' +
    r'\abi-gren\New\j2')
mod.origin = data.origin
mod.to_UTM()
cax = [1, 5]
modes = {1: 'pcolor', 2: 'imshow', 3: 'pcolorimage'}
mode = 3
use_alpha = 0
Ejemplo n.º 9
0
def main_mesh(args, data=None):
    if data is None:
        datafile = WSIO.verify_input('Data file to use?', expected='read')
        data = WSDS.Data(datafile=datafile)
    avg_rho = np.mean([
        utils.compute_rho(site, calc_comp='det', errtype='none')
        for site in data.sites.values()
    ])
    print('Average determinant apparent resistivity is {}'.format(avg_rho))
    bg_resistivity = WSIO.verify_input('Background resistivity?',
                                       expected=float,
                                       default=avg_rho)
    xmesh = utils.generate_lateral_mesh(site_locs=data.locations[:, 0])
    ymesh = utils.generate_lateral_mesh(site_locs=data.locations[:, 1])
    max_depth = min([500, utils.skin_depth(bg_resistivity, data.periods[-1])])
    min_depth = min([1, utils.skin_depth(bg_resistivity, data.periods[0])])
    print(
        'Note: Default min and max depths are based on skin depth of lowest and highest periods.'
    )
    min_depth = WSIO.verify_input('Depth of first layer?',
                                  expected=float,
                                  default=min_depth)
    max_depth = WSIO.verify_input('Depth of last layer?',
                                  expected=float,
                                  default=max_depth)
    NZ = WSIO.verify_input('Total # of layers or # of layers per decade?',
                           expected='numtuple',
                           default=60)
    zmesh = utils.generate_zmesh(min_depth=min_depth,
                                 max_depth=max_depth,
                                 NZ=NZ)
    model = WSDS.Model()
    model.dx = xmesh
    model.dy = ymesh
    model.dz = zmesh
    model.vals = bg_resistivity * np.ones((model.nx, model.ny, model.nz))
    if '-i' in args:
        viewer = meshview(model, data)
        viewer.show()
    else:
        nxpads = WSIO.verify_input('Number of pads in X direction',
                                   expected=int,
                                   default=5)
        nypads = WSIO.verify_input('Number of pads in y direction',
                                   expected=int,
                                   default=5)
        xpads = [model.xCS[0]]
        ypads = [model.yCS[0]]
        for ii in range(nxpads):
            xpads.append(
                WSIO.verify_input('Pad size',
                                  expected=float,
                                  default=xpads[ii] * 1.2))
            xpads = xpads[1:]
        for ii in range(nypads):
            ypads.append(
                WSIO.verify_input('Pad size',
                                  expected=float,
                                  default=ypads[ii] * 1.2))
            ypads = ypads[:1]
        model.dx = xpads[-1::-1] + model.dx + xpads
        model.dy = ypads[-1::-1] + model.dy + ypads
        modelname = WSIO.verify_input('Model name',
                                      expected='write',
                                      default='mod')
        if '.model' not in modelname:
            modelname = ''.join([modelname, '.model'])
        model.write(modelname)
    return