SeisCM 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seiscm/__init__.py +6 -0
- seiscm/_version.py +24 -0
- seiscm/py.typed +0 -0
- seiscm/seiscm.py +231 -0
- seiscm-0.1.3.dist-info/METADATA +121 -0
- seiscm-0.1.3.dist-info/RECORD +9 -0
- seiscm-0.1.3.dist-info/WHEEL +5 -0
- seiscm-0.1.3.dist-info/licenses/LICENSE +21 -0
- seiscm-0.1.3.dist-info/top_level.txt +1 -0
seiscm/__init__.py
ADDED
seiscm/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.3'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 3)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
seiscm/py.typed
ADDED
|
File without changes
|
seiscm/seiscm.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"""Seismic colormaps for geophysical data visualization."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from typing import Literal, TypeAlias
|
|
7
|
+
|
|
8
|
+
import matplotlib.pyplot as plt
|
|
9
|
+
import numpy as np
|
|
10
|
+
from matplotlib.colors import LinearSegmentedColormap
|
|
11
|
+
|
|
12
|
+
_Segments: TypeAlias = Sequence[tuple[float, ...]]
|
|
13
|
+
_CDict: TypeAlias = dict[Literal["red", "green", "blue", "alpha"], _Segments]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _make_cmap(name: str, cdict: _CDict) -> LinearSegmentedColormap:
|
|
17
|
+
"""Thin wrapper around ``LinearSegmentedColormap`` for DRY construction."""
|
|
18
|
+
return LinearSegmentedColormap(name, cdict)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# ---------------------------------------------------------------------------
|
|
22
|
+
# Public colormaps
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def bwr(alpha: float = 0) -> LinearSegmentedColormap:
|
|
27
|
+
"""Blue-White-Red colormap with configurable mid-point transparency.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
alpha : float
|
|
32
|
+
Transparency at the centre of the map, in ``[0, 1]``.
|
|
33
|
+
``0`` (default) gives a fully transparent midpoint suitable for
|
|
34
|
+
overlaying seismic amplitudes on other imagery.
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
LinearSegmentedColormap
|
|
39
|
+
"""
|
|
40
|
+
if not 0 <= alpha <= 1:
|
|
41
|
+
raise ValueError("alpha must be between 0 and 1.")
|
|
42
|
+
|
|
43
|
+
cdict: _CDict = {
|
|
44
|
+
"red": (
|
|
45
|
+
(0, 0, 0),
|
|
46
|
+
(0.25, 0, 0),
|
|
47
|
+
(0.5, 1, 1),
|
|
48
|
+
(0.75, 0.8314, 0.8314),
|
|
49
|
+
(1, 0.5, 0.5),
|
|
50
|
+
),
|
|
51
|
+
"green": (
|
|
52
|
+
(0, 0, 0),
|
|
53
|
+
(0.25, 0.375, 0.375),
|
|
54
|
+
(0.5, 1, 1),
|
|
55
|
+
(0.75, 0.375, 0.375),
|
|
56
|
+
(1, 0, 0),
|
|
57
|
+
),
|
|
58
|
+
"blue": (
|
|
59
|
+
(0, 0.5, 0.5),
|
|
60
|
+
(0.25, 0.8314, 0.8314),
|
|
61
|
+
(0.5, 1, 1),
|
|
62
|
+
(0.75, 0, 0),
|
|
63
|
+
(1, 0, 0),
|
|
64
|
+
),
|
|
65
|
+
"alpha": (
|
|
66
|
+
(0, 1, 1),
|
|
67
|
+
(0.5, alpha, alpha),
|
|
68
|
+
(1, 1, 1),
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
return _make_cmap("BlueWhiteRed", cdict)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def seismic() -> LinearSegmentedColormap:
|
|
75
|
+
"""Seismic colormap.
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
LinearSegmentedColormap
|
|
80
|
+
"""
|
|
81
|
+
cdict: _CDict = {
|
|
82
|
+
"red": (
|
|
83
|
+
(0, 0.6314, 0.6314),
|
|
84
|
+
(0.33, 0, 0),
|
|
85
|
+
(0.4, 0.302, 0.302),
|
|
86
|
+
(0.5, 0.8, 0.8),
|
|
87
|
+
(0.6, 0.3804, 0.3804),
|
|
88
|
+
(0.667, 0.749, 0.749),
|
|
89
|
+
(1, 1, 1),
|
|
90
|
+
),
|
|
91
|
+
"green": (
|
|
92
|
+
(0, 1, 1),
|
|
93
|
+
(0.33, 0, 0),
|
|
94
|
+
(0.4, 0.302, 0.302),
|
|
95
|
+
(0.5, 0.8, 0.8),
|
|
96
|
+
(0.6, 0.2706, 0.2706),
|
|
97
|
+
(0.667, 0, 0),
|
|
98
|
+
(1, 1, 1),
|
|
99
|
+
),
|
|
100
|
+
"blue": (
|
|
101
|
+
(0, 1, 1),
|
|
102
|
+
(0.33, 0.749, 0.749),
|
|
103
|
+
(0.4, 0.302, 0.302),
|
|
104
|
+
(0.5, 0.8, 0.8),
|
|
105
|
+
(0.6, 0, 0),
|
|
106
|
+
(0.667, 0, 0),
|
|
107
|
+
(1, 0, 0),
|
|
108
|
+
),
|
|
109
|
+
}
|
|
110
|
+
return _make_cmap("Seismic", cdict)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def phase() -> LinearSegmentedColormap:
|
|
114
|
+
"""Phase colormap.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
LinearSegmentedColormap
|
|
119
|
+
"""
|
|
120
|
+
cdict: _CDict = {
|
|
121
|
+
"red": (
|
|
122
|
+
(0, 1, 1),
|
|
123
|
+
(0.1, 1, 1),
|
|
124
|
+
(0.2, 1, 1),
|
|
125
|
+
(0.3, 1, 1),
|
|
126
|
+
(0.4, 0.7765, 0.7765),
|
|
127
|
+
(0.5, 0, 0),
|
|
128
|
+
(0.6, 0, 0),
|
|
129
|
+
(0.7, 0, 0),
|
|
130
|
+
(0.8, 0, 0),
|
|
131
|
+
(0.9, 0.6314, 0.6314),
|
|
132
|
+
(1, 1, 1),
|
|
133
|
+
),
|
|
134
|
+
"green": (
|
|
135
|
+
(0, 0, 0),
|
|
136
|
+
(0.1, 0, 0),
|
|
137
|
+
(0.2, 0.4471, 0.4471),
|
|
138
|
+
(0.3, 0.8941, 0.8941),
|
|
139
|
+
(0.4, 1, 1),
|
|
140
|
+
(0.5, 1, 1),
|
|
141
|
+
(0.6, 1, 1),
|
|
142
|
+
(0.7, 0.8941, 0.8941),
|
|
143
|
+
(0.8, 0.4471, 0.4471),
|
|
144
|
+
(0.9, 0, 0),
|
|
145
|
+
(1, 0, 0),
|
|
146
|
+
),
|
|
147
|
+
"blue": (
|
|
148
|
+
(0, 1, 1),
|
|
149
|
+
(0.1, 0.6314, 0.6314),
|
|
150
|
+
(0.2, 0, 0),
|
|
151
|
+
(0.3, 0, 0),
|
|
152
|
+
(0.4, 0, 0),
|
|
153
|
+
(0.5, 0, 0),
|
|
154
|
+
(0.6, 0.7765, 0.7765),
|
|
155
|
+
(0.7, 1, 1),
|
|
156
|
+
(0.8, 1, 1),
|
|
157
|
+
(0.9, 1, 1),
|
|
158
|
+
(1, 1, 1),
|
|
159
|
+
),
|
|
160
|
+
}
|
|
161
|
+
return _make_cmap("Phase", cdict)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def frequency() -> LinearSegmentedColormap:
|
|
165
|
+
"""Frequency colormap.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
LinearSegmentedColormap
|
|
170
|
+
"""
|
|
171
|
+
cdict: _CDict = {
|
|
172
|
+
"red": (
|
|
173
|
+
(0, 0, 0),
|
|
174
|
+
(0.1, 1, 1),
|
|
175
|
+
(0.2, 1, 1),
|
|
176
|
+
(0.3, 0.9412, 0.9412),
|
|
177
|
+
(0.4, 0.5765, 0.5765),
|
|
178
|
+
(0.5, 0, 0),
|
|
179
|
+
(0.6, 0, 0),
|
|
180
|
+
(0.7, 0, 0),
|
|
181
|
+
(0.8, 0, 0),
|
|
182
|
+
(0.9, 0.6667, 0.6667),
|
|
183
|
+
(1, 1, 1),
|
|
184
|
+
),
|
|
185
|
+
"green": (
|
|
186
|
+
(0, 0, 0),
|
|
187
|
+
(0.1, 0, 0),
|
|
188
|
+
(0.2, 0.7451, 0.7451),
|
|
189
|
+
(0.3, 1, 1),
|
|
190
|
+
(0.4, 1, 1),
|
|
191
|
+
(0.5, 1, 1),
|
|
192
|
+
(0.6, 1, 1),
|
|
193
|
+
(0.7, 0.8157, 0.8157),
|
|
194
|
+
(0.8, 0.3333, 0.3333),
|
|
195
|
+
(0.9, 0, 0),
|
|
196
|
+
(1, 0, 0),
|
|
197
|
+
),
|
|
198
|
+
"blue": (
|
|
199
|
+
(0, 0, 0),
|
|
200
|
+
(0.1, 0, 0),
|
|
201
|
+
(0.2, 0, 0),
|
|
202
|
+
(0.3, 0, 0),
|
|
203
|
+
(0.4, 0, 0),
|
|
204
|
+
(0.5, 0.4706, 0.4706),
|
|
205
|
+
(0.6, 0.8824, 0.8824),
|
|
206
|
+
(0.7, 1, 1),
|
|
207
|
+
(0.8, 1, 1),
|
|
208
|
+
(0.9, 1, 1),
|
|
209
|
+
(1, 1, 1),
|
|
210
|
+
),
|
|
211
|
+
}
|
|
212
|
+
return _make_cmap("Frequency", cdict)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if __name__ == "__main__":
|
|
216
|
+
gradient = np.linspace(0, 1, 256)
|
|
217
|
+
gradient = np.vstack((gradient, gradient))
|
|
218
|
+
|
|
219
|
+
fig, axes = plt.subplots(4, 1)
|
|
220
|
+
cmaps = [
|
|
221
|
+
("bwr", bwr),
|
|
222
|
+
("seismic", seismic),
|
|
223
|
+
("phase", phase),
|
|
224
|
+
("frequency", frequency),
|
|
225
|
+
]
|
|
226
|
+
for ax, (name, cmap_fn) in zip(axes, cmaps, strict=True):
|
|
227
|
+
ax.imshow(gradient, interpolation="none", aspect="auto", cmap=cmap_fn())
|
|
228
|
+
ax.set_axis_off()
|
|
229
|
+
ax.set_title(name)
|
|
230
|
+
|
|
231
|
+
plt.show()
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SeisCM
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Seismic Colormap Generator
|
|
5
|
+
Author-email: Lijun Zhu <gatechzhu@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lijunzh/SeisCM
|
|
8
|
+
Project-URL: Documentation, https://github.com/lijunzh/SeisCM#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/lijunzh/SeisCM/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/lijunzh/SeisCM/blob/master/CHANGELOG.md
|
|
11
|
+
Keywords: seismic,geophysics,colormap,matplotlib,visualization
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.24
|
|
27
|
+
Requires-Dist: matplotlib>=3.7
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Seismic Colormaps (SeisCM)
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/SeisCM/)
|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
[](https://github.com/astral-sh/ruff)
|
|
36
|
+
[](https://github.com/lijunzh/seiscm/actions/workflows/cicd.yml)
|
|
37
|
+
|
|
38
|
+
## Introduction
|
|
39
|
+
|
|
40
|
+
Geophysicists can never agree on a standard colormap — so here's a package
|
|
41
|
+
with the most common ones, ready to import. SeisCM provides
|
|
42
|
+
[matplotlib](https://matplotlib.org/)-compatible colormaps designed
|
|
43
|
+
specifically for seismic and geophysical data visualization.
|
|
44
|
+
|
|
45
|
+
Pull requests for new colormaps are welcome!
|
|
46
|
+
|
|
47
|
+
## Available Colormaps
|
|
48
|
+
|
|
49
|
+
| Name | Description |
|
|
50
|
+
|------|-------------|
|
|
51
|
+
| `bwr` | Blue-White-Red with configurable mid-point transparency |
|
|
52
|
+
| `seismic` | Classic seismic amplitude display |
|
|
53
|
+
| `phase` | Phase attribute visualisation |
|
|
54
|
+
| `frequency` | Frequency attribute visualisation |
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### From PyPI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install seiscm
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### From source (development)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/lijunzh/seiscm.git
|
|
70
|
+
cd seiscm
|
|
71
|
+
uv sync --dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Quick Start
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from seiscm import bwr
|
|
78
|
+
import matplotlib.pyplot as plt
|
|
79
|
+
import numpy as np
|
|
80
|
+
|
|
81
|
+
data = np.random.default_rng(42).standard_normal((100, 100))
|
|
82
|
+
plt.imshow(data, cmap=bwr())
|
|
83
|
+
plt.colorbar()
|
|
84
|
+
plt.show()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Dependencies
|
|
88
|
+
|
|
89
|
+
- [NumPy](https://numpy.org/)
|
|
90
|
+
- [Matplotlib](https://matplotlib.org/)
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv run ruff check src tests # lint
|
|
96
|
+
uv run ruff format src tests # format
|
|
97
|
+
uv run mypy # type-check
|
|
98
|
+
uv run pytest --cov # test with coverage
|
|
99
|
+
uv run pre-commit install # set up git hooks
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Contributing
|
|
103
|
+
|
|
104
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and the
|
|
105
|
+
[Code of Conduct](CODE_OF_CONDUCT.md). Security issues: see
|
|
106
|
+
[SECURITY.md](SECURITY.md).
|
|
107
|
+
|
|
108
|
+
## Citing
|
|
109
|
+
|
|
110
|
+
A [`CITATION.cff`](CITATION.cff) file is provided; GitHub's
|
|
111
|
+
"Cite this repository" button uses it.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
[MIT](LICENSE)
|
|
116
|
+
|
|
117
|
+
## Contact
|
|
118
|
+
|
|
119
|
+
For issues, please open a
|
|
120
|
+
[GitHub issue](https://github.com/lijunzh/seiscm/issues) or contact
|
|
121
|
+
*gatechzhu@gmail.com*.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
seiscm/__init__.py,sha256=Y5Lkwxv0HdP_W19P-V9ex4UCySNBzyHRm7o23xtIuMs,187
|
|
2
|
+
seiscm/_version.py,sha256=viarq5ZcPE6m7M15YjEVsiRlL7HdWBz-44nt_tqueY8,520
|
|
3
|
+
seiscm/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
seiscm/seiscm.py,sha256=Z5Z6MRujy-sgQMRHNi3qPanoESzXgfaqxb5CWz403_c,5722
|
|
5
|
+
seiscm-0.1.3.dist-info/licenses/LICENSE,sha256=c4IqQsx128mkthGi1xD9_M5Nl_WfPpaJylZcGrSmJ2k,1066
|
|
6
|
+
seiscm-0.1.3.dist-info/METADATA,sha256=Vrj__-3z_rIwwgWV2KSDC9UwbCcBsSrnMhBmPiGYFrU,3512
|
|
7
|
+
seiscm-0.1.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
+
seiscm-0.1.3.dist-info/top_level.txt,sha256=ivke2vYaryxUBvsfzPSwG3EYHSuY_ybldzSvjbTdCWM,7
|
|
9
|
+
seiscm-0.1.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 gatechzhu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
seiscm
|