Skip to content

Variography🍋

plot_semivariogram(variograms, model=None, model_angles=None, display_npairs=False, method=<VariographyMethod.SEMIVARIOGRAM: 'SEMIVARIOGRAM'>, save_file=None) 🍋

Semivariogram plot.

Parameters:

Name Type Description Default
variograms List

A pandas DataFrame with at least "vario" column in it.

required
model Optional[geolime.geostats.models.covariance.Covariance]

Covariance model to be applied. Defaults to None.

None
model_angles Optional[List[Dict[str, float]]]

Display variogram model along other orientations. {azi: float, dip: float, pitch: float, label: str}. Defaults to None.

None
display_npairs Optional[bool]

Display barplot with number of pairs if True. Defaults to False.

False
method VariographyMethod

"COVARIOGRAM" or "SEMIVARIOGRAM". Defaults to "SEMIVARIOGRAM".

<VariographyMethod.SEMIVARIOGRAM: 'SEMIVARIOGRAM'>
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

1D plot of variograms and models.

Source code in geolime/plotting/vario_plot.py
def plot_semivariogram(
    variograms: List,
    model: Optional[Covariance] = None,
    model_angles: Optional[List[Dict[str, float]]] = None,
    display_npairs: Optional[bool] = False,
    method: VariographyMethod = VariographyMethod.SEMIVARIOGRAM,
    save_file: str = None
) -> None:
    """
    Semivariogram plot.

    Args:
        variograms:
            A pandas DataFrame with at least "vario" column in it.
        model:
            Covariance model to be applied. Defaults to None.
        model_angles:
            Display variogram model along other orientations.
            {azi: float, dip: float, pitch: float, label: str}. Defaults to None.
        display_npairs:
            Display barplot with number of pairs if True. Defaults to False.
        method:
            "COVARIOGRAM" or "SEMIVARIOGRAM". Defaults to "SEMIVARIOGRAM".
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        1D plot of variograms and models.

    """
    fig, ax = plt.subplots()

    colors = plt.cm.jet(np.linspace(0, 1, len(variograms)))

    svmax = 0

    for i, v in enumerate(variograms):
        legend_str = strip_extra_ws(f"""
            A: {v.attrs["geographic_azimuth"]},
            D: {v.attrs["dip"]},
            P: {v.attrs["pitch"]}
        """)
        ax.plot(v["avgdist"], v["vario"], color=colors[i], marker="o", label=legend_str)
        ax.set_ylabel("Semivariance")
        ax.set_xlabel("Average distance")
        ax.yaxis.tick_left()

        # retrieve max value for setting y limit later on
        if svmax < v["vario"].max():
            svmax = v["vario"].max()

        if display_npairs:
            # add variogram value to points
            for j, value in enumerate(v["npairs"]):
                ax.annotate(value, (v["lag"][j], v["vario"][j] + v["vario"][j] * 0.05))

    ax.legend(loc="upper left", bbox_to_anchor=(1.05, 1))
    ax.set_ylim(bottom=0, top=svmax + 0.15 * svmax)
    ax.set_xlim(left=0)

    if model:

        # Compute max_lag to strip model
        max_lag = np.max([vario["lag"].max() for vario in variograms])

        # store default vdir
        if model_angles:
            original_vdir = v.attrs["directional_vector"]
            for angle in model_angles:
                vdir, _, _ = directional_vector(
                    angle["azi"],
                    angle["dip"],
                    angle["pitch"]
                )
                vdir = vdir[:v.attrs["dim"]]
                v.attrs["directional_vector"] = vdir
                distance, results = model._compute_model(
                    angles=[angle["azi"], angle["dip"], angle["pitch"]],
                    method=method
                )
                bool_array = distance <= max_lag
                distance = distance[bool_array]
                results = results[bool_array]
                legend_str = strip_extra_ws(f"""
                    A: {angle["azi"]},
                    D: {angle["dip"]},
                    P: {angle["pitch"]}
                """)
                ax.plot(distance, results, label=legend_str)

            v.attrs["directional_vector"] = original_vdir
        else:
            distance, results = model._compute_model([0., 0., 0.], method, max_lag)
            bool_array = distance <= max_lag
            distance = distance[bool_array]
            results = results[bool_array]
            ax.plot(distance, results, label="A: 0, D:0, P:0")

    ax.legend(loc="upper left", bbox_to_anchor=(1.05, 1))

    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_azimuth(object, attribute, region, lags, tol, n_az, atol) 🍋

Compute VarioContour as Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
n_az int

Number of azimuth to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required

Returns:

Type Description
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Computed values of azimuthal variomap.

Source code in geolime/plotting/vario_plot.py
def vario_azimuth(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    n_az: int,
    atol: float,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
    """
    Compute VarioContour as Pie Chart. Angle of slice equals angular tolerance
    and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        n_az:
            Number of azimuth to compute variogram.
        atol:
            Angular tolerance for variogram computation.

    Returns:
        Computed values of azimuthal variomap.

    """
    # Convert number of azimuth to even number
    n_az = ceil(n_az / 2) * 2

    # Compute azimuth list in degrees and radians
    # Degree list is for computing : only needs half of the circle
    azm_deg = np.linspace(0, 180 * ((n_az - 2) / n_az), n_az // 2)

    # Radian list is for plotting : needs all the circle
    azm_rad = np.linspace(0, 2 * np.pi * ((n_az - 1) / n_az), n_az)

    # Pcontourf and pcolomesh use nodes values : needs to close circle
    azm_rad = np.append(azm_rad, 2 * np.pi)

    r, th = np.meshgrid(lags, azm_rad)
    z = np.ones_like(r, dtype=np.float64)

    # Compute value for halph circle and apply it to symmetric
    for j, az in enumerate(azm_deg):
        t = variogram(
            object=object,
            attribute=attribute,
            region=region,
            geographic_azimuth=az,
            dip=0,
            pitch=0,
            lags=lags,
            tol=tol,
            atol=atol
        )['vario']
        z[j, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))

        z[j + n_az // 2, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))

    # Last value is first value : 0 degrees value == 360 degrees value
    z[-1, :] = z[0, :]

    return r, th, z

vario_contour(object, attribute, region, lags, tol, n_az, atol, user_azimuth=None, c_step=None, save_file=None) 🍋

Plot Azimuth VarioContour as Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
n_az int

Number of azimuth to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required
user_azimuth Optional[float]

Azimuth value to be displayed. Defaults to None.

None
c_step Optional[int]

Number of discretization steps of iso-values. Defaults to None.

None
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

Plot Azimuth variocontour.

Source code in geolime/plotting/vario_plot.py
def vario_contour(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    n_az: int,
    atol: float,
    user_azimuth: Optional[float] = None,
    c_step: Optional[int] = None,
    save_file: str = None
) -> None:
    """
    Plot Azimuth VarioContour as Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        n_az:
            Number of azimuth to compute variogram.
        atol:
            Angular tolerance for variogram computation.
        user_azimuth:
            Azimuth value to be displayed. Defaults to None.
        c_step:
            Number of discretization steps of iso-values. Defaults to None.
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        Plot Azimuth variocontour.

    """
    r, th, z = vario_azimuth(
        object,
        attribute,
        region,
        lags,
        tol,
        n_az,
        atol
    )

    # O means no data, misleading in plot
    z = np.where(z == 0, np.nan, z)

    # Plotting
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="polar")
    ax.set_theta_zero_location("N")
    ax.set_theta_direction(-1)
    my_cmap = plt.cm.get_cmap("viridis")
    ax.contourf(th, r, z, cmap=my_cmap, levels=c_step)
    ax.grid()
    sm = ScalarMappable(cmap=my_cmap, norm=plt.Normalize(np.nanmin(z), np.nanmax(z)))
    sm.set_array([])
    cbar = fig.colorbar(sm)
    cbar.set_label("Semivariance", rotation=270, labelpad=25)
    if user_azimuth is not None:
        R1 = np.linspace(0, np.nanmax(r), 100)
        theta = np.ones(100) * user_azimuth * (np.pi / 180.0)
        ax.plot(theta, R1, lw=2.5)
    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_contour_dip(object, attribute, region, lags, tol, azimuth, n_dip, atol, user_dip=None, c_step=None, save_file=None) 🍋

Plot VarioContour for a given azimuth as a semi Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
azimuth float

Azimuth value along which dip is searched.

required
n_dip int

Number of dip to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required
user_dip Optional[float]

Dip value to be displayed. Defaults to None.

None
c_step Optional[int]

Number of discretization steps of iso-values. Defaults to None.

None
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

2D plot of dip variomap along a given azimuth.

Source code in geolime/plotting/vario_plot.py
def vario_contour_dip(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    azimuth: float,
    n_dip: int,
    atol: float,
    user_dip: Optional[float] = None,
    c_step: Optional[int] = None,
    save_file: str = None
) -> None:
    """
    Plot VarioContour for a given azimuth as a semi Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        azimuth:
            Azimuth value along which dip is searched.
        n_dip:
            Number of dip to compute variogram.
        atol:
            Angular tolerance for variogram computation.
        user_dip:
            Dip value to be displayed. Defaults to None.
        c_step:
            Number of discretization steps of iso-values. Defaults to None.
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        2D plot of dip variomap along a given azimuth.

    """
    r, th, z = vario_dip(
        object,
        attribute,
        region,
        lags,
        tol,
        azimuth,
        n_dip,
        atol
    )

    # O means no data, misleading in plot
    z = np.where(z == 0, np.nan, z)

    # Plotting
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="polar")
    ax.set_theta_zero_location("E")
    ax.set_theta_direction(-1)
    ax.set_thetalim(-np.pi / 2, 3 * np.pi / 2)
    my_cmap = plt.cm.get_cmap("viridis")
    ax.contourf(th, r, z, cmap=my_cmap, levels=c_step)
    ax.grid()
    sm = ScalarMappable(cmap=my_cmap, norm=plt.Normalize(np.nanmin(z), np.nanmax(z)))
    sm.set_array([])
    cbar = fig.colorbar(sm)
    cbar.set_label("Semivariance", rotation=270, labelpad=25)
    if user_dip is not None:
        R1 = np.linspace(0, np.nanmax(r), 100)
        theta = np.ones(100) * user_dip * (np.pi / 180.0)
        ax.plot(theta, R1, lw=2.5)
    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_contour_pitch(object, attribute, region, lags, tol, azimuth, dip, n_pitch, atol, user_pitch=None, c_step=None, save_file=None) 🍋

Plot VarioContour for given azimuth and pitch as a semi Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
azimuth float

Azimuth along which pitch is searched.

required
dip float

Dip along which pitch is searched.

required
n_pitch int

Number of dip to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required
user_pitch Optional[float]

Pitch value to be displayed. Defaults to None.

None
c_step Optional[int]

Number of discretization steps of iso-values. Defaults to None.

None
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

2D plot of pitch variomap along given azimuth and dip.

Source code in geolime/plotting/vario_plot.py
def vario_contour_pitch(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    azimuth: float,
    dip: float,
    n_pitch: int,
    atol: float,
    user_pitch: Optional[float] = None,
    c_step: Optional[int] = None,
    save_file: str = None
) -> None:
    """
    Plot VarioContour for given azimuth and pitch as a semi Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        azimuth:
            Azimuth along which pitch is searched.
        dip:
            Dip along which pitch is searched.
        n_pitch:
            Number of dip to compute variogram.
        atol:
            Angular tolerance for variogram computation.
        user_pitch:
            Pitch value to be displayed. Defaults to None.
        c_step:
            Number of discretization steps of iso-values. Defaults to None.
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        2D plot of pitch variomap along given azimuth and dip.

    """
    r, th, z = vario_pitch(
        object,
        attribute,
        region,
        lags,
        tol,
        azimuth,
        dip,
        n_pitch,
        atol
    )

    # O means no data, misleading in plot
    z = np.where(z == 0, np.nan, z)

    # Plotting
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="polar")
    ax.set_theta_zero_location("N")
    ax.set_theta_direction(-1)
    ax.set_thetalim(-np.pi / 2, 3 * np.pi / 2)
    my_cmap = plt.cm.get_cmap("viridis")
    ax.contourf(th, r, z, cmap=my_cmap, levels=c_step)
    ax.grid()
    sm = ScalarMappable(cmap=my_cmap, norm=plt.Normalize(np.nanmin(z), np.nanmax(z)))
    sm.set_array([])
    cbar = fig.colorbar(sm)
    cbar.set_label("Semivariance", rotation=270, labelpad=25)
    if user_pitch is not None:
        R1 = np.linspace(0, np.nanmax(r), 100)
        theta = np.ones(100) * user_pitch * (np.pi / 180.0)
        ax.plot(theta, R1, lw=2.5)
    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_dip(object, attribute, region, lags, tol, azimuth, n_dip, atol) 🍋

Compute VarioContour for a given azimuth as a semi Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
azimuth float

Azimuth value along which dip is searched.

required
n_dip int

Number of dip to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required

Returns:

Type Description
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Computed values of dip variomap along a given azimuth.

Source code in geolime/plotting/vario_plot.py
def vario_dip(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    azimuth: float,
    n_dip: int,
    atol: float
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
    """
    Compute VarioContour for a given azimuth as a semi Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        azimuth:
            Azimuth value along which dip is searched.
        n_dip:
            Number of dip to compute variogram.
        atol:
            Angular tolerance for variogram computation.

    Returns:
        Computed values of dip variomap along a given azimuth.

    """
    # Convert number of dip to even number
    n_dip = ceil(n_dip / 2) * 2

    # Compute dip list in degrees and radians
    # Degree list is for computing : only needs half of the circle
    dip_deg = np.linspace(-90, 90 * ((n_dip - 2) / n_dip), n_dip // 2)

    # Radian list is for plotting : needs half circle
    dip_rad = np.linspace(-np.pi / 2, 3 * np.pi / 2 * ((n_dip - 1) / n_dip), n_dip)

    # Pcontourf and pcolomesh use nodes values : needs to close circle
    dip_rad = np.append(dip_rad, 3 * np.pi / 2)

    r, th = np.meshgrid(lags, dip_rad)
    z = np.ones_like(r, dtype=np.float64)

    for j, dip in enumerate(dip_deg):
        if dip < 0:
            dip = - dip
            azimuth = azimuth + 180 if azimuth <= 180 else azimuth - 180

        t = variogram(
            object=object,
            attribute=attribute,
            region=region,
            geographic_azimuth=azimuth,
            dip=dip,
            pitch=90,
            lags=lags,
            tol=tol,
            atol=atol
        )["vario"]
        z[j, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))
        z[j + n_dip // 2, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))

    # Last value is first value : 0 degrees value == 360 degrees value
    z[-1, :] = z[0, :]

    return r, th, z

vario_map(object, attribute, region, lags, tol, n_az, atol, user_azimuth=None, save_file=None) 🍋

Plot Azimuth VarioMap as Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
n_az int

Number of azimuth to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required
user_azimuth Optional[float]

Azimuth value to be displayed. Defaults to None.

None
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

Plot Azimuth variomap.

Source code in geolime/plotting/vario_plot.py
def vario_map(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    n_az: int,
    atol: float,
    user_azimuth: Optional[float] = None,
    save_file: str = None
) -> None:
    """
    Plot Azimuth VarioMap as Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        n_az:
            Number of azimuth to compute variogram.
        atol:
            Angular tolerance for variogram computation.
        user_azimuth:
            Azimuth value to be displayed. Defaults to None.
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        Plot Azimuth variomap.

    """
    # Convert number of azimuth to even number
    n_az = ceil(n_az / 2) * 2

    # Compute azimuth list in degrees and radians
    # Degree list is for computing : only needs half of the circle
    azm_deg = np.arange(0, 180, 180 / (n_az // 2))

    # Radian list is for plotting : needs all the circle
    azm_rad = np.arange(0, 2 * np.pi, 2 * np.pi / n_az)
    r, th = np.meshgrid(lags, azm_rad)
    z = np.ones_like(r, dtype=np.float64)

    # Compute value for halph circle and apply it to symmetric
    for j, az in enumerate(azm_deg):
        t = variogram(
            object=object,
            attribute=attribute,
            region=region,
            geographic_azimuth=az,
            dip=0,
            pitch=0,
            lags=lags,
            tol=tol,
            atol=atol
        )["vario"]

        z[j, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))

        z[j + n_az // 2, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))

    # O means no data, misleading in plot
    z = np.where(z == 0, np.nan, z)

    # Plotting
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="polar")
    ax.set_theta_zero_location("N")
    ax.set_theta_direction(-1)
    my_cmap = plt.cm.get_cmap("viridis")
    for j in range(len(azm_rad)):
        ax.bar(
            np.ones(len(lags)) * azm_rad[j],
            lags,
            width=np.ones(len(lags)) * np.deg2rad(360 / n_az),
            color=[plt.cm.viridis(z[j, i] / np.nanmax(z)) for i in range(z.shape[1])],
            bottom=shift(lags, 1, cval=0)
        )

    ax.grid()
    ax.set_ylim(0, lags[-1])
    sm = ScalarMappable(cmap=my_cmap, norm=plt.Normalize(np.nanmin(z), np.nanmax(z)))

    sm.set_array([])
    cbar = fig.colorbar(sm)
    cbar.set_label("Semivariance", rotation=270, labelpad=25)
    if user_azimuth is not None:
        R1 = np.linspace(0, np.nanmax(z), 100)
        theta = np.ones(100) * user_azimuth * (np.pi / 180.0)
        ax.plot(theta, R1, lw=2.5)
    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_map_summary(object, attribute, region, lags, tol, azimuth, dip, pitch, n_step, atol, c_step=None, save_file=None) 🍋

Plot VarioContour for a given azimuth, dip and pitch as Pie Charts. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
azimuth float

Azimuth value along which dip is searched.

required
dip float

Dip value along which dip is searched.

required
pitch float

Pitch value along which dip is searched.

required
n_step int

Number of step to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required
c_step Optional[int]

Number of discretization steps of iso-values. Defaults to None.

None
save_file str

Filename of saved figure. Defaults to None.

None

Returns:

Type Description
None

Summary of 3 2D subplots variomaps of azimuth, dip and pitch.

Source code in geolime/plotting/vario_plot.py
def vario_map_summary(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    azimuth: float,
    dip: float,
    pitch: float,
    n_step: int,
    atol: float,
    c_step: Optional[int] = None,
    save_file: str = None
) -> None:
    """
    Plot VarioContour for a given azimuth, dip and pitch as Pie Charts.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        azimuth:
            Azimuth value along which dip is searched.
        dip:
            Dip value along which dip is searched.
        pitch:
            Pitch value along which dip is searched.
        n_step:
            Number of step to compute variogram.
        atol:
            Angular tolerance for variogram computation.
        c_step:
            Number of discretization steps of iso-values. Defaults to None.
        save_file:
            Filename of saved figure. Defaults to None.

    Returns:
        Summary of 3 2D subplots variomaps of azimuth, dip and pitch.

    """
    r_az, th_az, z_az = vario_azimuth(
        object,
        attribute,
        region,
        lags,
        tol,
        n_step,
        atol
    )

    # O means no data, misleading in plot
    z_az = np.where(z_az == 0, np.nan, z_az)

    r_dip, th_dip, z_dip = vario_dip(
        object,
        attribute,
        region,
        lags,
        tol,
        azimuth,
        n_step,
        atol
    )
    # O means no data, misleading in plot
    z_dip = np.where(z_dip == 0, np.nan, z_dip)

    r_pitch, th_pitch, z_pitch = vario_pitch(
        object,
        attribute,
        region,
        lags,
        tol,
        azimuth,
        dip,
        n_step,
        atol
    )

    # O means no data, misleading in plot
    z_pitch = np.where(z_pitch == 0, np.nan, z_pitch)

    # Figure Creation
    fig, (ax0, ax1, ax2) = plt.subplots(ncols=3, subplot_kw=dict(projection="polar"))
    cmap = 'viridis'

    # Plot Azimuth VarioContour
    azi_plot = ax0.contourf(th_az, r_az, z_az, cmap=cmap, levels=c_step)
    R1 = np.linspace(0, np.nanmax(r_az), 100)
    theta = np.ones(100) * azimuth * (np.pi / 180.0)
    ax0.plot(theta, R1, lw=2.5)
    ax0.set_theta_zero_location("N")
    ax0.set_theta_direction(-1)
    fig.colorbar(azi_plot, ax=ax0, fraction=0.046, pad=0.04, label="Semivariance")
    ax0.set_title("Azimuth Vario Map")

    # Plot Dip VarioContour
    dip_plot = ax1.contourf(th_dip, r_dip, z_dip, cmap=cmap, levels=c_step)
    R2 = np.linspace(0, np.nanmax(r_dip), 100)
    theta2 = np.ones(100) * dip * (np.pi / 180.0)
    ax1.plot(theta2, R2, lw=2.5)
    ax1.set_theta_zero_location("E")
    ax1.set_theta_direction(-1)
    ax1.set_thetalim(-np.pi / 2, 3 * np.pi / 2)
    fig.colorbar(dip_plot, ax=ax1, fraction=0.046, pad=0.04, label="Semivariance")
    ax1.set_title(f"Dip Vario Map with Azimuth = {azimuth}")

    # Plot pitch VarioContour
    pitch_plot = ax2.contourf(th_pitch, r_pitch, z_pitch, cmap=cmap, levels=c_step)
    R3 = np.linspace(0, np.nanmax(r_pitch), 100)
    theta3 = np.ones(100) * pitch * (np.pi / 180.0)
    ax2.plot(theta3, R3, lw=2.5)
    ax2.set_theta_zero_location("N")
    ax2.set_theta_direction(-1)
    ax2.set_thetalim(-np.pi / 2, 3 * np.pi / 2)
    fig.colorbar(pitch_plot, ax=ax2, fraction=0.046, pad=0.04, label="Semivariance")
    ax2.set_title(f"Pitch Vario Map with Azimuth = {azimuth} and Dip = {dip}")

    if save_file is not None:
        fig.savefig(save_file, bbox_inches='tight')
        plt.close()
    else:
        plt.show()

vario_pitch(object, attribute, region, lags, tol, azimuth, dip, n_pitch, atol) 🍋

Compute VarioContour for given azimuth and pitch as a semi Pie Chart. Angle of slice equals angular tolerance and slice radius equals lag distance.

Parameters:

Name Type Description Default
object GeoRefObject

Geo-ref Object.

required
attribute str

Object attribute to compute variography on.

required
region Optional[str]

Object region to select data from.

required
lags List[float]

List of lags, in meters.

required
tol float

Lag tolerance, in percent.

required
azimuth float

Azimuth along which pitch is searched.

required
dip float

Dip along which pitch is searched.

required
n_pitch int

Number of dip to compute variogram.

required
atol float

Angular tolerance for variogram computation.

required

Returns:

Type Description
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Computed values of pitch variomap along given azimuth and dip.

Source code in geolime/plotting/vario_plot.py
def vario_pitch(
    object: GeoRefObject,
    attribute: str,
    region: Optional[str],
    lags: List[float],
    tol: float,
    azimuth: float,
    dip: float,
    n_pitch: int,
    atol: float
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
    """
    Compute VarioContour for given azimuth and pitch as a semi Pie Chart.
    Angle of slice equals angular tolerance and slice radius equals lag distance.

    Args:
        object:
            Geo-ref Object.
        attribute:
            Object attribute to compute variography on.
        region:
            Object region to select data from.
        lags:
            List of lags, in meters.
        tol:
            Lag tolerance, in percent.
        azimuth:
            Azimuth along which pitch is searched.
        dip:
            Dip along which pitch is searched.
        n_pitch:
            Number of dip to compute variogram.
        atol:
            Angular tolerance for variogram computation.

    Returns:
        Computed values of pitch variomap along given azimuth and dip.

    """
    # Convert number of pitch to even number
    n_pitch = ceil(n_pitch / 2) * 2

    # Compute pitch list in degrees and radians
    # Degree list is for computing : only needs half of the circle
    pitch_deg = np.linspace(-90, 90 * ((n_pitch - 2) / n_pitch), n_pitch // 2)

    # Radian list is for plotting : needs half circle
    pitch_rad = np.linspace(-np.pi / 2, 3 * np.pi / 2 * ((n_pitch - 1) / n_pitch), n_pitch)

    # Pcontourf and pcolomesh use nodes values : needs to close circle
    pitch_rad = np.append(pitch_rad, 3 * np.pi / 2)

    r, th = np.meshgrid(lags, pitch_rad)
    z = np.ones_like(r, dtype=np.float64)

    for j, pitch in enumerate(pitch_deg):
        t = variogram(
            object=object,
            attribute=attribute,
            region=region,
            geographic_azimuth=azimuth,
            dip=dip,
            pitch=pitch,
            lags=lags,
            tol=tol,
            atol=atol
        )["vario"]
        z[j, :] = np.concatenate((t.values, np.zeros(z.shape[1] - t.values.shape[0])))
        z[j + n_pitch // 2, :] = np.concatenate(
            (t.values, np.zeros(z.shape[1] - t.values.shape[0]))
        )

    # Last value is first value : 0 degrees value == 360 degrees value
    z[-1, :] = z[0, :]

    return r, th, z
Back to top