def parse_resistivity(model): """ Given a Boteler resitivity specification *model* (list of depth [m] / resistivity [Ohm/m] tuples), return a conductivity map suitable for func:`conductivity.surface_impedance_1D`. """ conductivity_model = OrderedDict() last_depth = 0 for depth_i, r in model: bound = FloatInterval.closed_open(last_depth, last_depth + depth_i) conductivity_model[bound] = 1 / r last_depth += depth_i return conductivity_model
def parse_conductivity(fid): """ Parse a USGS model conductivity file-like object *fid*. Return an ordered mapping between layer depth interval, [upper depth, lower_depth) in [m], and the conductivity [(Ohm-m)^{-1}] """ for line in fid: if line.startswith('*/'): if 'thicknesses' in line.split('!')[1].lower(): thicknesses = map(float, line[1:].split('/')[1].split(',')[:-1]) elif 'resistivities' in line.split('!')[1].lower(): resistivites = map(float, line[1:].split('/')[1].split(',')[:-1]) else: break last_depth = 0 bounds = [] for depth in thicknesses: bounds.append(FloatInterval.closed_open(last_depth, last_depth + depth)) last_depth += depth return OrderedDict(zip(bounds, 1 / NP.array(resistivites)))
def parse_conductivity(fid): """ Parse a USGS model conductivity file-like object *fid*. Return an ordered mapping between layer depth interval, [upper depth, lower_depth) in [m], and the conductivity [(Ohm-m)^{-1}] """ for line in fid: if line.startswith('*/'): if 'thicknesses' in line.split('!')[1].lower(): thicknesses = map(float, line[1:].split('/')[1].split(',')[:-1]) elif 'resistivities' in line.split('!')[1].lower(): resistivites = map(float, line[1:].split('/')[1].split(',')[:-1]) else: break last_depth = 0 bounds = [] for depth in thicknesses: bounds.append(FloatInterval.closed_open(last_depth, last_depth + depth)) last_depth += depth return OrderedDict(zip(bounds, 1 / NP.array(resistivites)))