• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GeoStat-Framework / welltestpy / 10691143420

03 Sep 2024 09:48PM UTC coverage: 76.813% (+0.8%) from 76.01%
10691143420

Pull #35

github

web-flow
Merge 1ebfe99fb into 81a2299af
Pull Request #35: Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows

1928 of 2510 relevant lines covered (76.81%)

10.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.36
/src/welltestpy/tools/diagnostic_plots.py
1
"""welltestpy subpackage to make diagnostic plots."""
2
# pylint: disable=C0103
3
import matplotlib.pyplot as plt
14✔
4
import numpy as np
14✔
5

6
from ..process import processlib
14✔
7
from . import plotter
14✔
8

9

10
def diagnostic_plot_pump_test(
14✔
11
    observation,
12
    rate,
13
    method="bourdet",
14
    linthresh_time=1.0,
15
    linthresh_head=1e-5,
16
    fig=None,
17
    ax=None,
18
    plotname=None,
19
    style="WTP",
20
):
21
    """
22
    Plot the derivative with the original data.
23

24
    Parameters
25
    ----------
26
    observation : :class:`welltestpy.data.Observation`
27
        The observation to calculate the derivative.
28
    rate : :class:`float`
29
        Pumping rate.
30
    method : :class:`str`, optional
31
        Method to calculate the time derivative.
32
        Default: "bourdet"
33
    linthresh_time : :class: 'float'
34
        Range of time around 0 that behaves linear.
35
        Default: 1
36
    linthresh_head : :class: 'float'
37
        Range of head values around 0 that behaves linear.
38
        Default: 1e-5
39
    fig : Figure, optional
40
        Matplotlib figure to plot on.
41
        Default: None.
42
    ax : :class:`Axes`
43
        Matplotlib axes to plot on.
44
        Default: None.
45
    plotname : str, optional
46
        Plot name if the result should be saved.
47
        Default: None.
48
    style : str, optional
49
        Plot style.
50
        Default: "WTP".
51

52
    Returns
53
    -------
54
    Diagnostic plot
55
    """
56
    head, time = observation()
×
57
    head = np.array(head, dtype=float).reshape(-1)
×
58
    time = np.array(time, dtype=float).reshape(-1)
×
59
    if rate < 0:
×
60
        head = head * -1
×
61
    derivative = processlib.smoothing_derivative(
×
62
        head=head, time=time, method=method
63
    )
64
    # setting variables
65
    dx = time[1:-1]
×
66
    dy = derivative[1:-1]
×
67

68
    # plotting
69
    if style == "WTP":
×
70
        style = "ggplot"
×
71
        font_size = plt.rcParams.get("font.size", 10.0)
×
72
        keep_fs = True
×
73
    with plt.style.context(style):
×
74
        if keep_fs:
×
75
            plt.rcParams.update({"font.size": font_size})
×
76
        fig, ax = plotter._get_fig_ax(fig, ax)
×
77
        ax.scatter(time, head, color="C0", label="drawdown")
×
78
        ax.plot(dx, dy, color="C1", label="time derivative")
×
79
        ax.set_xscale("symlog", linthresh=linthresh_time)
×
80
        ax.set_yscale("symlog", linthresh=linthresh_head)
×
81
        ax.set_xlabel("$t$ in [s]", fontsize=16)
×
82
        ax.set_ylabel("$h$ and $dh/dx$ in [m]", fontsize=16)
×
83
        lgd = ax.legend(loc="upper left", facecolor="w")
×
84
        min_v = min(np.min(head), np.min(dy))
×
85
        max_v = max(np.max(head), np.max(dy))
×
86
        max_e = int(np.ceil(np.log10(max_v)))
×
87
        if min_v < linthresh_head:
×
88
            min_e = -np.inf
×
89
        else:
90
            min_e = int(np.floor(np.log10(min_v)))
×
91
        ax.set_ylim(10.0**min_e, 10.0**max_e)
×
92
        yticks = [0 if min_v < linthresh_head else 10.0**min_e]
×
93
        thresh_e = int(np.floor(np.log10(linthresh_head)))
×
94
        first_e = thresh_e if min_v < linthresh_head else (min_e + 1)
×
95
        yticks += list(10.0 ** np.arange(first_e, max_e + 1))
×
96
        ax.set_yticks(yticks)
×
97
        fig.tight_layout()
×
98
        if plotname is not None:
×
99
            fig.savefig(
×
100
                plotname,
101
                format="pdf",
102
                bbox_extra_artists=(lgd,),
103
                bbox_inches="tight",
104
            )
105
    return ax
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc