Coverage for waveqc/utils.py: 0%
15 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-05-15 08:47 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-05-15 08:47 +0000
1import platform
3from obspy import __version__ as obspy_version
4from obspy.clients.fdsn import Client
5from obspy.clients.fdsn.header import platform_
7from .config import settings
8from .models import (
9 RESULT_DECONVOLUTION_FAILS,
10 RESULT_DECONVOLUTION_PASS,
11 RESULT_NO_DATA,
12 RESULT_NOT_READABLE,
13 RESULT_PONDERATION,
14)
16ZMAX = 355
18HEATMAP_LAYOUT_NETWORK = {
19 "colorbar": {
20 "title_text": "Data Quality and Completeness",
21 "title_side": "top",
22 "tickvals": [25, 75, 125, 200, 255, 305, 345],
23 "ticktext": [
24 "Channel closed",
25 "No data",
26 "Not readable",
27 "Deconvolution fails",
28 "0%",
29 "Deconvolution pass",
30 "100%",
31 ],
32 "lenmode": "pixels",
33 "len": 300,
34 "yanchor": "top",
35 "y": 1,
36 },
37 "hovertemplate": (
38 "<b>%{y}</b><br>"
39 "%{x}<br>"
40 "Completeness : %{customdata[0]}%<br>"
41 "Traces : %{customdata[2]}<br>"
42 "Shortest trace : %{customdata[3]} seconds"
43 "<extra></extra>"
44 ),
45 "colorscale": [
46 [0, "black"],
47 [RESULT_PONDERATION[RESULT_NO_DATA] / ZMAX - 0.001, "black"],
48 [RESULT_PONDERATION[RESULT_NO_DATA] / ZMAX, "whitesmoke"],
49 [RESULT_PONDERATION[RESULT_NOT_READABLE] / ZMAX - 0.001, "whitesmoke"],
50 [RESULT_PONDERATION[RESULT_NOT_READABLE] / ZMAX, "#a50026"],
51 [RESULT_PONDERATION[RESULT_DECONVOLUTION_FAILS] / ZMAX - 0.001, "#a50026"],
52 [RESULT_PONDERATION[RESULT_DECONVOLUTION_FAILS] / ZMAX, "#f46d43"],
53 [(RESULT_PONDERATION[RESULT_DECONVOLUTION_PASS] - 5) / ZMAX, "#f46d43"],
54 [(RESULT_PONDERATION[RESULT_DECONVOLUTION_PASS] - 4) / ZMAX, "#e0f3f8"],
55 [0.99, "#4575b4"],
56 [1, "#313695"],
57 # [RESULT_PONDERATION[RESULT_DECONVOLUTION_PASS/ZMAX, "#d9ef8b"],
58 # [0.99, "#1a9850"],
59 # [1, "#006837"],
60 ],
61 "xgap": 1,
62 "ygap": 1,
63 "zmin": 0,
64 "zmax": ZMAX,
65}
66HEATMAP_LAYOUT_QUALITY = HEATMAP_LAYOUT_NETWORK | {
67 "colorbar_len": 0.5,
68 "colorbar_lenmode": "fraction",
69 "colorbar_y": 1.05,
70}
71HEATMAP_LAYOUT_STATION = {
72 "colorbar": {"title_text": "Number of traces", "len": 0.5, "y": 0.25},
73 "colorscale": list(
74 reversed(
75 [
76 [1, "rgb(165,0,38)"],
77 [0.9, "rgb(215,48,39)"],
78 [0.8, "rgb(244,109,67)"],
79 [0.7, "rgb(253,174,97)"],
80 [0.6, "rgb(254,224,139)"],
81 [0.5, "rgb(255,255,191)"],
82 [0.4, "rgb(217,239,139)"],
83 [0.3, "rgb(166,217,106)"],
84 [0.2, "rgb(102,189,99)"],
85 [0.1, "rgb(26,152,80)"],
86 [0.001, "rgb(0,104,55)"],
87 [0, "whitesmoke"],
88 ]
89 )
90 ),
91 "hovertemplate": ("<b>%{y}</b><br>%{x}<br>Traces : %{z}<extra></extra>"),
92 "xgap": 1,
93 "ygap": 1,
94 "zmin": 0,
95}
96HEATMAP_LAYOUT_COMPLETENESS = {
97 "x": [""],
98 "showscale": False,
99 "ygap": 1,
100}
102MONITORED_NETWORKS = ["RA"] if settings.ENV == "local" else ["RA", "FR"]
105def get_obspy_client() -> Client:
106 user_agent = (
107 f"WaveQC (ObsPy/{obspy_version}, {platform_}, "
108 f"Python {platform.python_version()})"
109 )
110 return Client(settings.FDSN_CLIENT, user_agent=user_agent)