Function to add or substract the temperature effect to given data. The
    function can be called in python scripts. For application via command line
    in a file system use the script td_correct_temperature.py. The data is
    taken and given in Ohmm.

    rho_std_i = (m * (T_i - 25°) + 1) / (m * (T_std - 25°) + 1) * rho_i
    rho_i = (m * (T_std - 25°) + 1) / (m * (T_i - 25°) + 1) * rho_std_i

    Hayley (2007)

    Parameters:
        temp: temperature values corresponding to the individual resistivity
              values
        mag: resistivity values to be corrected
        add: switch for adding instead of substracting the effect
        T_std: standard temperature t or from which to correct (default=10°)
        m:coeffcient (default=0.021)

def calc_correction(temp, mag, add=False, T_std=10, m=0.021):
    """Function to add or substract the temperature effect to given data. The
    function can be called in python scripts. For application via command line
    in a file system use the script td_correct_temperature.py. The data is
    taken and given in Ohmm.

    rho_std_i = (m * (T_i - 25°) + 1) / (m * (T_std - 25°) + 1) * rho_i
    rho_i = (m * (T_std - 25°) + 1) / (m * (T_i - 25°) + 1) * rho_std_i

    Hayley (2007)

    Parameters:
        temp: temperature values corresponding to the individual resistivity
              values
        mag: resistivity values to be corrected
        add: switch for adding instead of substracting the effect
        T_std: standard temperature t or from which to correct (default=10°)
        m:coeffcient (default=0.021)
    """
    if mag.shape[1] == 3:
        if add:
            data_x = (m * (T_std - 25) + 1) / (m * (temp - 25) + 1) * mag[:, 0]
            data_y = (m * (T_std - 25) + 1) / (m * (temp - 25) + 1) * mag[:, 1]
            data_z = (m * (T_std - 25) + 1) / (m * (temp - 25) + 1) * mag[:, 2]
            return np.column_stack((data_x, data_y, data_z))
        else:
            data_x = (m * (temp - 25) + 1) / (m * (T_std - 25) + 1) * mag[:, 0]
            data_y = (m * (temp - 25) + 1) / (m * (T_std - 25) + 1) * mag[:, 1]
            data_z = (m * (temp - 25) + 1) / (m * (T_std - 25) + 1) * mag[:, 2]
            return np.column_stack((data_x, data_y, data_z))
    else:
        if add:
            data_i = (m * (T_std - 25) + 1) / (m * (temp - 25) + 1) * mag
            return data_i
        else:
            data_std = (m * (temp - 25) + 1) / (m * (T_std - 25) + 1) * mag
            return data_std