resistics.transfunc.io module

class resistics.transfunc.io.TransferFunctionReader(filepath: str = '')[source]

Bases: resistics.common.base.ResisticsBase

Class for reading and writing maskData

Transfer function files are located in: project -> transFuncData -> site -> filepath

Attributes
filepathstr

Transfer function file

headersOrderedDict()

Transfer function file header information

Methods

__init__(filepath=””)

Initialise the transferFunctionReader file read(filepath) Set and read a new transfer function file

readFile()

Read the transfer function file

readInternal()

Read internally formatted transfer function files

formatHeaders()

Format header values for internally formatted transfer function files

readEdi()

Read Edi formatted tranfer function files

readNumericBlock(lines)

Read a numeric block for Edi transfer function files

constructComplex(real, imag)

Construct a complex valued array from arrays of the real and imaginary values of the complex numbers

printList()

Class status returned as list of strings

constructComplex(self, real, imag)[source]

Construct a complex array from separate real and imaginary arrays

Parameters
realnp.ndarray

An array of the real part of the complex data

imagnp.ndarray

An array of the complex part of the complex data

Returns
np.ndarray

Numpy array of complex data

formatHeaders(self) → None[source]

Format header values for the internal transfer function file format

printList(self) → List[str][source]

Class information as a list of strings

Returns
outList[str]

List of strings with information

read(self, filepath: str) → None[source]

Read a new file

Parameters
filepathstr

Filepath to transfer function file

readEdi(self) → None[source]

Read an EDI transfer function file

EDI files have an >END that signifies the end of the file. This works quite nicely to our advantage when reading an EDI file.

Returns
TransferFunctionData

Tranfser function data object

readFile(self) → resistics.transfunc.data.TransferFunctionData[source]

Read a transfer function file

Returns
TransferFunctionData

Tranfser function data object

readInternal(self) → None[source]

Read an internally formatted transfer function file

Returns
TransferFunctionData

Tranfser function data object

readNumericBlock(self, lines: List[str])[source]

Read an EDI numeric block

Parameters
linesList[str]

List of strings (or the lines in the file) that are a numeric block

Returns
np.ndarray

Numeric data as a numpy array

class resistics.transfunc.io.TransferFunctionWriter(filepath: str, tfData: resistics.transfunc.data.TransferFunctionData, **kwargs)[source]

Bases: resistics.common.base.ResisticsBase

Class for reading and writing maskData

Transfer function files are located in: project -> transFuncData -> site -> filepath

Attributes
filepathstr

Transfer function file

headersOrderedDict()

Transfer function file header information

Methods

__init__(filepath, tfData)

Initialise the transferFunctionWriter defaultHeaders() Get a dictionary of default header values

setHeaders(**kwargs)

Set header values

addHeader(header, val)

Add a new header or update an existing one

setPathAndData(filepath, tfData)

Set a new filepath for writing and new transfer function data

write()

Write transfer function data to internal format transfer function file

writeEdi()

Write transfer function data to Edi file

writeNumericBlock(lines)

Write a numeric block for Edi files

printList()

Class status returned as list of strings

addHeader(self, header: str, value: Any) → None[source]

Add a header value for writing out

Parameters
headerstr

The name of the header

valueAny

The value for the header

defaultHeaders(self) → Dict[str, Any][source]

Get the default header values

Returns
defaultDict

A dictionary with default header keys and values

printList(self) → List[str][source]

Class information as a list of strings

Returns
outList[str]

List of strings with information

setHeaders(self, **kwargs)[source]

Set header values

Parameters
sampleFreqfloat, optional

The sampling frequency of the original time data

insitestr

The input site

inchansList[str]

The input channels

outsitestr

The output site

outchansList[str]

The output channels

remotesitestr

The remote reference site

remotechansList[str]

The remote reference chans used

setPathAndData(self, filepath: str, tfData: resistics.transfunc.data.TransferFunctionData) → None[source]

Add a header value for writing out

Parameters
filepathstr

The filepath to write out to

tfDataTransferFunctionData

Transfer function data object

write(self)[source]

Write transfer function data in internal format file

writeEdi(self) → None[source]

Write transfer function data in Edi file

writeNumericBlock(self, outF: IO[str], vals: numpy.ndarray) → None[source]

Write numeric blocks for edi files

The format is: 5 values on a line Each value has 5 decimal places and is in scientific notation

Parameters
outFfile object

Output file

valsnp.ndarray

Numeric files to write out