crtomopy package

class tomopal.crtomopy.crtomo.crc.Crtomo(working_dir='\\', data_dir='\\', mesh_dir='\\', iso_dir='\\', ref_dir='\\', start_dir='\\', results_dir='\\', crtomo_exe='crtomo.exe', mesh_exe='mesh.exe')[source]

Bases: object

__init__(working_dir='\\', data_dir='\\', mesh_dir='\\', iso_dir='\\', ref_dir='\\', start_dir='\\', results_dir='\\', crtomo_exe='crtomo.exe', mesh_exe='mesh.exe')[source]

Initialize self. See help(type(self)) for accurate signature.

meshmaker(abmn=None, electrode_spacing=5, elevation_data=None)[source]

Generates crtomo-readable mesh files. :param abmn: np.array containing x-coordinates of electrodes in METERS :param electrode_spacing: :param elevation_data: np.array containing [[x_i, elev_i]…[x_f, elev_f]] :return:

run()[source]

Copies all the input files to a ‘param’ folder within the inversion results folder and run the exe.

Returns

write_config(erase=0, mesh_file='Mesh.dat', elec_file='elec.dat', data_file='dataset.dat', result_folder='results', difference_inversion=0, fdi1=None, reference_model_file=None, fdi3=None, reference_model=0, data_difference=0, stochastic_inversion=0, prior_si=0, reference_weights_file=None, fincr=1, grid_type=1, arbitrary=5, vario=1, smoothing_x=1, smoothing_y=1, iso_file1='iso.dat', iso_file2='iso.dat', variogram_regularization=0, iterations=20, rms=1.0, dc=1, robust=1, check_polarity=1, final_phase_improvement=0, individual_error=0, error_level=1, min_abs_error=0.00015, phase_error=0.15, hom_bkg_res=0, bkg_mag=160, bkg_pha=0, resolution_mtx=0, mgs=0, beta=0.0001, starting_model=0, starting_model_file='startmodel.dat', fwd_only=0, sink_node=0, node_bumber=3348, next_dset=0)[source]

Writes the crtomo configuration file crtritime.cfg.

Parameters
  • erase – flag for erasing the content of a result folder (0/1)

  • result_folder

  • mesh_file – Mesh data file

  • elec_file – Elec data file

  • data_file – Data file

  • difference_inversion

  • fdi1

  • reference_model_file – Reference model file

  • fdi3

  • reference_model

  • data_difference

  • stochastic_inversion

  • prior_si

  • reference_weights_file

  • fincr

  • grid_type

  • arbitrary

  • vario

  • smoothing_x

  • smoothing_y

  • iso_file1

  • iso_file2

  • variogram_regularization

  • iterations

  • rms

  • dc

  • robust

  • check_polarity

  • final_phase_improvement

  • individual_error

  • error_level

  • min_abs_error

  • phase_error

  • hom_bkg_res

  • bkg_mag

  • bkg_pha

  • resolution_mtx

  • mgs

  • beta

  • starting_model – If doing forward modeling only, select 1

  • starting_model_file – If doing forward modeling only, input here the model

  • fwd_only

  • sink_node

  • node_bumber

  • next_dset

Returns

tomopal.crtomopy.crtomo.crc.chunks(l, n)[source]

Yield successive n-sized chunks from l.

tomopal.crtomopy.crtomo.crc.crtomo_file_shortener(f1, f2)[source]

CRTOMO cannot deal with long folder path, especially not with spaces within it…

tomopal.crtomopy.crtomo.crc.datread(file=None, start=0, end=None)[source]

Reads space separated dat file

tomopal.crtomopy.crtomo.crc.deldir(dirp)[source]

Used to delete the contents of the folder :param dirp: path to the folder to be emptied :return:

tomopal.crtomopy.crtomo.crc.dirmaker(dirp)[source]

Given a folder path, check if it exists, and if not, creates it :param dirp: path :return:

tomopal.crtomopy.crtomo.crc.flag(n)[source]

Used to build configuration file :param n: 0 or 1 :return: F or T

tomopal.crtomopy.crtomo.crc.import_res(result_folder, iteration=0, return_file=0)[source]
Parameters
  • return_file – bool: if True, returns the path of the created file

  • result_folder – str: FOLDER containing results files .rho .pha

  • iteration – int: Iteration number, by default the last one is selected

Returns

r_array, p_array if the case

tomopal.crtomopy.crtomo.crc.mesh_geometry(mesh_file)[source]

Extracts the mesh properties from the mesh.dat file.

Parameters

mesh_file – mesh.dat file

Returns

ncol, nlin, nelem, blocks, centerxy

tomopal.crtomopy.crtomo.crc.mtophase(ncycles=0, pulse_l=0, tmin=0, tmax=0, mpath=None)[source]

Run mtophase.exe and loads return the conversion factor. :param ncycles: number of cycles of injected square wave (with 50% duty cycle) :param pulse_l: pulse length (in sec) :param tmin: t_min of chargeability time window (in sec) :param tmax: t_max of chargeability time window (in sec) :param mpath: str: Path to the folder containing IP exe and config files :return: m2p factor

tomopal.crtomopy.crtomo.crc.neighbor(abcd, h)[source]

Function to fill the final mesh file.

Parameters
  • abcd – adj [4 cols]

  • h – int:

Returns

[el1, el2, el3, el4]

tomopal.crtomopy.crtomo.crc.path_leaf(path)[source]

Extracts file name from a path name

tomopal.crtomopy.crtomo.crc.res2mod(file, processing_function=None)[source]

Converts a crtomo result txt file to a starting/reference model dat file

tomopal.crtomopy.crtomo.crc.write_data(nelem=0, electrode_spacing=1, data=None, data_op_file=None, m2p=1)[source]

Given the arguments below, writes crtomo-readable file.

Parameters
  • nelem – number of cells

  • electrode_spacing – electrode spacing

  • data – np.array containing A B M N locations in METERS, RESISTANCE, and IP (mrad)

  • data_op_file – name of the output data file

:param m2p Factor to convert IP data to mrad :return: nothing

Module contents