Passed
Pull Request — main (#21)
by
unknown
01:55
created

mutis.correlation.Correlation.plot_signals()   A

Complexity

Conditions 2

Size

Total Lines 27
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
rs 9.9
c 0
b 0
f 0
cc 2
nop 2
1
# Licensed under a 3-clause BSD style license - see LICENSE
2
"""Analysis of correlation of light curves."""
3
4
import logging
5
6
import matplotlib.pyplot as plt
0 ignored issues
show
introduced by
Unable to import 'matplotlib.pyplot'
Loading history...
7
import numpy as np
0 ignored issues
show
introduced by
Unable to import 'numpy'
Loading history...
8
9
from mutis.lib.correlation import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like mutis.lib.correlation should generally be avoided.
Loading history...
Unused Code introduced by
kroedel_ab_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
welsh_ab_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
fkroedel was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
fwelsh was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
kroedel was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
welsh was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ndcf was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
get_grid was imported with wildcard, but is not used.
Loading history...
10
11
__all__ = ["Correlation"]
12
13
log = logging.getLogger(__name__)
14
15
16
class Correlation:
0 ignored issues
show
best-practice introduced by
Too many instance attributes (21/7)
Loading history...
17
    """Analysis of the correlation of two signals.
18
19
    Parameters
20
    ----------
21
    signal1 : :class:`~mutis.signal.Signal`
22
        Values of the time axis.
23
    signal2 : :class:`~mutis.signal.Signal`
24
        Values of the signal axis.
25
    fcorr : :py:class:`~str`
26
        Method used to correlate the signals.
27
    """
28
29
    def __init__(self, signal1, signal2, fcorr):
30
        self.signal1 = signal1
31
        self.signal2 = signal2
32
        self.fcorr = fcorr
33
34
        self.times = np.array([])
35
        self.dts = np.array([])
36
        self.nb = np.array([])
0 ignored issues
show
Coding Style Naming introduced by
Attribute name "nb" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
37
38
        self.values = None
39
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
40
        # TODO: have a much smaller set of attributes
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
41
        self.samples = None
42
        # storage of the significance limits of the correlation
43
        self.l1s = None
44
        self.l2s = None
45
        self.l3s = None
46
        # storage of the uncertainties of the correlation
47
        self.s1s = None
48
        self.s2s = None
49
        self.s3s = None
50
51
        # attributes indicating the ranges where the correlations are defined
52
        t1, t2 = self.signal1.times, self.signal2.times
0 ignored issues
show
Coding Style Naming introduced by
Variable name "t2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "t1" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
53
        self.tmin_full = t2.min() - t1.max()
54
        self.tmax_full = t2.max() - t1.min()
55
        self.t0_full = (self.tmax_full + self.tmin_full) / 2
56
        self.tmin_same = -(np.max([t1.max() - t1.min(), t2.max() - t2.min()])) / 2 + self.t0_full
57
        self.tmax_same = (np.max([t1.max() - t1.min(), t2.max() - t2.min()])) / 2 + self.t0_full
58
        self.tmin_valid = (
59
            -(np.max([t1.max() - t1.min(), t2.max() - t2.min()]) - np.min([t1.max() - t1.min(), t2.max() - t2.min()]))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (118/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
60
            / 2
61
            + self.t0_full
62
        )
63
        self.tmax_valid = (
64
            +(np.max([t1.max() - t1.min(), t2.max() - t2.min()]) - np.min([t1.max() - t1.min(), t2.max() - t2.min()]))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (118/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
65
            / 2
66
            + self.t0_full
67
        )
68
69
    def gen_synth(self, samples):
70
        """Generates the synthetic light curves.
71
72
        Generates the specified number `samples` of synthetic light
73
        curves for each signal, to be used to compute the significance
74
        the correlation.
75
76
        Parameters
77
        ----------
78
        samples : :py:class:`~int`
79
            Number of synthetic light curves to be generated for each signal.
80
        """
81
82
        self.samples = samples
83
        self.signal1.gen_synth(samples)
84
        self.signal2.gen_synth(samples)
85
86
    def gen_corr(self, uncert=True, dsamples=500):
87
        """Generates the correlation of the signals.
88
89
        Generates the correlation of the signals, and computes their
90
        confidence level from the synthetic light curves, which must
91
        have been generated before.
92
        """
93
94
        if uncert and self.signal1.dvalues is None:
95
            log.error("uncert is True but no uncertainties for Signal 1 were specified")
96
            uncert = False
97
        if uncert and self.signal2.dvalues is None:
98
            log.error("uncert is True but no uncertainties for Signal 2 were specified")
99
            uncert = False
100
101
        if len(self.times) == 0 or len(self.dts) == 0:
102
            raise Exception(
103
                "You need to define the times on which to calculate the correlation."
104
                "Please use gen_times() or manually set them."
105
            )
106
107
        # TODO: refactor if/elif with a helper function
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
108
        mc_corr = np.empty((self.samples, self.times.size))
109
        if uncert:
110
            mc_sig = np.empty((dsamples, self.times.size))
111
112
        if self.fcorr == "welsh_ab":
113
            for n in range(self.samples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
114
                mc_corr[n] = welsh_ab(
115
                    self.signal1.times,
116
                    self.signal1.synth[n],
117
                    self.signal2.times,
118
                    self.signal2.synth[n],
119
                    self.times,
120
                    self.dts,
121
                )
122
            if uncert:
123
                for n in range(dsamples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
124
                    mc_sig[n] = welsh_ab(
125
                        self.signal1.times,
126
                        self.signal1.values + self.signal1.dvalues * np.random.randn(self.signal1.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
127
                        self.signal2.times,
128
                        self.signal2.values + self.signal2.dvalues * np.random.randn(self.signal2.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
129
                        self.times,
130
                        self.dts,
131
                    )
132
            self.values = welsh_ab(
133
                self.signal1.times,
134
                self.signal1.values,
135
                self.signal2.times,
136
                self.signal2.values,
137
                self.times,
138
                self.dts,
139
            )
140
        elif self.fcorr == "kroedel_ab":
141
            for n in range(self.samples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
142
                mc_corr[n] = kroedel_ab(
143
                    self.signal1.times,
144
                    self.signal1.synth[n],
145
                    self.signal2.times,
146
                    self.signal2.synth[n],
147
                    self.times,
148
                    self.dts,
149
                )
150
            if uncert:
151
                for n in range(dsamples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
152
                    mc_sig[n] = kroedel_ab(
153
                        self.signal1.times,
154
                        self.signal1.values + self.signal1.dvalues * np.random.randn(self.signal1.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
155
                        self.signal2.times,
156
                        self.signal2.values + self.signal2.dvalues * np.random.randn(self.signal2.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
157
                        self.times,
158
                        self.dts,
159
                    )
160
            self.values = kroedel_ab(
161
                self.signal1.times,
162
                self.signal1.values,
163
                self.signal2.times,
164
                self.signal2.values,
165
                self.times,
166
                self.dts,
167
            )
168
        elif self.fcorr == "numpy":
169
            for n in range(self.samples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
170
                mc_corr[n] = nindcf(
171
                    self.signal1.times,
172
                    self.signal1.synth[n],
173
                    self.signal2.times,
174
                    self.signal2.synth[n],
175
                )
176
            if uncert:
177
                for n in range(dsamples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
178
                    mc_sig[n] = nindcf(
179
                        self.signal1.times,
180
                        self.signal1.values + self.signal1.dvalues * np.random.randn(self.signal1.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
181
                        self.signal2.times,
182
                        self.signal2.values + self.signal2.dvalues * np.random.randn(self.signal2.values.size),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
183
                    )
184
            self.values = nindcf(
185
                self.signal1.times,
186
                self.signal1.values,
187
                self.signal2.times,
188
                self.signal2.values,
189
            )
190
        else:
191
            raise Exception("Unknown method " + self.fcorr + " for correlation.")
192
193
        self.l3s = np.percentile(mc_corr, [0.135, 99.865], axis=0)
194
        self.l2s = np.percentile(mc_corr, [2.28, 97.73], axis=0)
195
        self.l1s = np.percentile(mc_corr, [15.865, 84.135], axis=0)
196
197
        if uncert is True:
198
            self.s3s = np.percentile(mc_sig, [0.135, 99.865], axis=0)
0 ignored issues
show
introduced by
The variable mc_sig does not seem to be defined in case uncert on line 109 is False. Are you sure this can never be the case?
Loading history...
199
            self.s2s = np.percentile(mc_sig, [2.28, 97.73], axis=0)
200
            self.s1s = np.percentile(mc_sig, [15.865, 84.135], axis=0)
201
202
    def gen_times(self, ftimes="canopy", *args, **kwargs):
0 ignored issues
show
introduced by
Keyword argument before variable positional arguments list in the definition of gen_times function
Loading history...
203
        """Sets times and bins using the method defined by ftimes parameter.
204
205
        Parameters
206
        ----------
207
        ftimes : :py:class:`~str`
208
            Method used to bin the time interval of the correlation.
209
            Possible values are:
210
            - "canopy": Computes a binning as dense as possible, with
211
            variable bin width and (with a minimum and a maximum
212
            resolution) and a minimum statistic.
213
            - "rawab": Computes a binning with variable bin width,
214
            a given step, maximum bin size and a minimum statistic.
215
            - "uniform": Computes a binning with uniform bin width
216
            and a minimum statistic.
217
            - "numpy": Computes a binning suitable for method='numpy'.
218
        """
219
        if ftimes == "canopy":
220
            self.times, self.dts, self.nb = gen_times_canopy(self.signal1.times, self.signal2.times, *args, **kwargs)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
221
        elif ftimes == "rawab":
222
            self.times, self.dts, self.nb = gen_times_rawab(self.signal1.times, self.signal2.times, *args, **kwargs)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (116/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
223
        elif ftimes == "uniform":
224
            self.times, self.dts, self.nb = gen_times_uniform(self.signal1.times, self.signal2.times, *args, **kwargs)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (118/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
225
        elif ftimes == "numpy":
226
            t1, t2 = self.signal1.times, self.signal1.times
0 ignored issues
show
Coding Style Naming introduced by
Variable name "t2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "t1" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
227
            dt = np.max([(t1.max() - t1.min()) / t1.size, (t2.max() - t2.min()) / t2.size])
0 ignored issues
show
Coding Style Naming introduced by
Variable name "dt" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
228
            n1 = int(np.ptp(t1) / dt * 10.0)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n1" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
229
            n2 = int(np.ptp(t1) / dt * 10.0)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
230
            self.times = np.linspace(self.tmin_full, self.tmax_full, n1 + n2 - 1)
231
            self.dts = np.full(self.times.size, (self.tmax_full - self.tmin_full) / (n1 + n2))
232
        else:
233
            raise Exception("Unknown method " + ftimes + ", please indicate how to generate times.")
234
235
    def plot_corr(self, uncert=True, ax=None, legend=False):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
236
        """Plots the correlation of the signals.
237
238
        Plots the correlation of the signal, and the confidence limits
239
        computed from the synthetic curves.
240
241
        Parameters
242
        ----------
243
        ax : :class:`matplotlib.axes.Axes`
244
            Axes to be used (default None, it creates a new axes).
245
        legend : :py:class:`~bool`
246
            Whether to add a legend indicating the confidence levels.
247
        """
248
249
        # TODO: develop a plotting object for plots
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
250
        #       this will considerably shorten the
251
        #       number of attributes of this class
252
253
        # plt.figure()
254
        if ax is None:
255
            ax = plt.gca()
256
257
        ax.plot(self.times, self.l1s[0], "c-.")
258
        ax.plot(self.times, self.l1s[1], "c-.", label=r"$1\sigma$")
259
        ax.plot(self.times, self.l2s[0], "k--")
260
        ax.plot(self.times, self.l2s[1], "k--", label=r"$2\sigma$")
261
        ax.plot(self.times, self.l3s[0], "r-")
262
        ax.plot(self.times, self.l3s[1], "r-", label=r"$3\sigma$")
263
        ax.plot(self.times, self.values, "b.--", lw=1)
264
265
        # full limit
266
        ax.axvline(x=self.tmin_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
267
        ax.axvline(x=self.tmax_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
268
        # same limit
269
        ax.axvline(x=self.tmin_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
270
        ax.axvline(x=self.tmax_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
271
        # valid limit
272
        ax.axvline(x=self.tmin_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
273
        ax.axvline(x=self.tmax_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
274
275
276
        if uncert is True:
277
            ax.fill_between(x=self.times, y1=self.s1s[0], y2=self.s1s[1], color="b", alpha=0.5)
278
            ax.fill_between(x=self.times, y1=self.s2s[0], y2=self.s2s[1], color="b", alpha=0.3)
279
            ax.fill_between(x=self.times, y1=self.s3s[0], y2=self.s3s[1], color="b", alpha=0.1)
280
281
        if legend:
282
            ax.legend()
283
284
        # plt.show()
285
        return ax
286
287
    def plot_times(self, rug=False):
288
        """Plots the time binning generated previously.
289
290
        Plots the number of total bins, their distribution and the
291
        number of points in each bin for the generated time binning,
292
        previously generated with Correlation().gen_times(...).
293
294
        Parameters
295
        ----------
296
        rug : :py:class:`~bool`
297
            Whether to make a rug plot just below the binning, to make
298
            it easier to visually understand the density and distribution
299
            of the generated bins.
300
301
        """
302
303
        # TODO: develop a plotting object for plots
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
304
        #       this will considerably shorten the
305
        #       number of attributes of this class
306
307
        fig, ax = plt.subplots(nrows=2, ncols=1, sharex=True)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
308
        tab, dtab, nab = self.times, self.dts, self.nb
309
310
        fig.suptitle("Total bins: {:d}".format(self.times.size))
311
        ax[0].plot(tab, nab, "b.")
312
        ax[0].errorbar(x=tab, y=nab, xerr=dtab / 2, fmt="none")
313
        ax[0].set_ylabel("$n_i$")
314
        ax[0].grid()
315
        ax[0].axvline(x=self.tmin_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
316
        ax[0].axvline(x=self.tmax_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
317
        ax[0].axvline(x=self.tmin_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
318
        ax[0].axvline(x=self.tmax_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
319
        ax[0].axvline(x=self.tmin_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
320
        ax[0].axvline(x=self.tmax_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
321
        ax[1].plot(tab, dtab, "b.")
322
        ax[1].set_ylabel("$dt_i$")
323
        # ax[1].grid()
324
        ax[1].axvline(x=self.tmin_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
325
        ax[1].axvline(x=self.tmax_full, ymin=-1, ymax=+1, color="red", linewidth=4, alpha=0.5)
326
        ax[1].axvline(x=self.tmin_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
327
        ax[1].axvline(x=self.tmax_same, ymin=-1, ymax=+1, color="black", linewidth=2, alpha=0.5)
328
        ax[1].axvline(x=self.tmin_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
329
        ax[1].axvline(x=self.tmax_valid, ymin=-1, ymax=+1, color="cyan", linewidth=1, alpha=0.5)
330
331
        if rug is True:
332
            for t in self.times:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "t" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
333
                ax[1].axvline(x=t, ymin=0, ymax=0.2, color="black", linewidth=0.8, alpha=1.0)
334
            # ax[1].plot(self.t, ax[1].get_ylim()[0]+np.zeros(self.t.size), 'k|', alpha=0.8, lw=1)
335
336
        ax[1].grid()
337
        # fig.show()
338
339
    def plot_signals(self, ax=None):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
340
        """Plots the signals involved in this correlation.
341
342
        Plots the signals involved in this correlation, in the same window
343
        but with different twin y-axes and different colors.
344
345
        Parameters
346
        ----------
347
        ax : :py:class:`~matplotlib.axes.Axes`
348
            Axes to be used for plotting.
349
        """
350
351
        # TODO: develop a plotting object for plots
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
352
        #       this will considerably shorten the
353
        #       number of attributes of this class
354
355
        if ax is None:
356
            ax = plt.gca()
357
358
        ax.plot(self.signal1.times, self.signal1.values, "b.-", lw=1, alpha=0.4)
359
        ax.tick_params(axis="y", labelcolor="b")
360
        ax.set_ylabel("sig 1", color="b")
361
362
        ax2 = ax.twinx()
363
        ax2.plot(self.signal2.times, self.signal2.values, "r.-", lw=1, alpha=0.4)
364
        ax2.tick_params(axis="y", labelcolor="r")
365
        ax2.set_ylabel("sig 2", color="r")
366