Skip to content

Commit d843736

Browse files
authored
fix_flip_docstring (#560)
* fix_flip_docstring * more doc update
1 parent 2cb70d6 commit d843736

File tree

13 files changed

+45
-72
lines changed

13 files changed

+45
-72
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ Thanks for contributing to DASCore, community contributions are most welcomed!
33
44
Before contributing, please read through the [contributors doc](https://dascore.org/contributing/contributing.html)
55
6-
Before making big changes to the code or adding large complex features, it is a good idea to
7-
[open a discussion](https://github.com/DASDAE/dascore/discussions). Don't hesitate to ask a question or for
6+
Before making big changes to the code or adding large complex features, it is a good idea to [open a discussion](https://github.com/DASDAE/dascore/discussions). Don't hesitate to ask a question or for
87
help if something isn't clear.
98
-->
109

@@ -22,7 +21,6 @@ pound sign, e.g. `#12` without the backticks)
2221
I have (if applicable):
2322

2423
- [ ] referenced the GitHub issue this PR closes.
25-
- [ ] documented the new feature with docstrings or appropriate doc page.
26-
- [ ] included a test. See [testing guidelines](https://dascore.org/contributing/testing.html).
27-
- [ ] your name has been added to the contributors page (docs/contributors.md).
24+
- [ ] documented the new feature with docstrings and/or appropriate doc page.
25+
- [ ] included tests. See [testing guidelines](https://dascore.org/contributing/testing.html).
2826
- [ ] added the "ready_for_review" tag once the PR is ready to be reviewed.

dascore/proc/basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ def flip(patch, *dims, flip_coords=True):
773773
Examples
774774
--------
775775
>>> import dascore as dc
776+
>>> import numpy as np
776777
>>> patch = dc.get_example_patch()
777778
>>>
778779
>>> # Flip patch over time axis

docs/contributing/contributing.qmd

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ please be aware of our [code of conduct](code_of_conduct.qmd).
1010
To start, clone DASCore and [install it in development mode](dev_install.qmd). If you are new to contributing to open-source projects, this [recipe](../recipes/how_to_contribute.qmd) provides step-by-step instructions.
1111

1212
Review how [DASCore's testing](testing.qmd) works, [how DASCore is documented](documentation.qmd),
13-
[DAScore style and linting](style_and_linting.qmd), and the [general guidelines](general_guidelines.qmd).
13+
[DASCore style and linting](style_and_linting.qmd), and the [general guidelines](general_guidelines.qmd).
1414

1515

1616

@@ -20,38 +20,12 @@ Development planning and prioritization takes place [here](https://github.com/or
2020

2121
# DASCore or other DASDAE packages
2222

23-
You may wonder whether a new feature you'd like to add belongs in DASCore, or if it should be
24-
part of another [DASDAE](https://github.com/DASDAE) package. The guiding principle is that
25-
if it does not require additional dependencies and is not particularly specialized to
26-
one sub-area of applied seismology, then it can be part of DASCore. What if the feature
27-
you're interested in adding is generally applicable for many kinds of DAS data analysis, but
28-
requires some additional package dependency? If this is the case, open a discussion describing
29-
the feature, the additional dependency, and (optional but encouraged) other future
30-
features that may also share this dependency. Typically we'll try to come to a clear consensus, then you can
31-
move ahead with development. If the proposed DASCore dependency addition appears to be controversial, then you will
32-
deliver a short presentation at one of the bi-weekly DASDAE developer team check-ins that should
33-
describe the feature, the additional dependency (including the approximate size of the additional
34-
software to be installed), and ideas for other features this dependency could enable.
35-
Then the developer community in attendance will discuss the proposed change and take a vote (majority
36-
approval required).
37-
38-
If you are interested in creating a new [DASDAE](https://github.com/DASDAE) package which uses
39-
DASCore as a dependency, you are not required to hold it to the same style and testing guidelines
40-
as DASCore, but you are encouraged to do so, and can use DASCore's setup as an example. Following
41-
a common set of style and contributor workflows will make it easier for us to develop a
42-
community of DASDAE developers who can easily move between using and developing any of the
43-
DASDAE packages.
23+
You may wonder whether a new feature you'd like to add belongs in DASCore, or if it should be part of another [DASDAE](https://github.com/DASDAE) package. The guiding principle is that if it does not require additional dependencies and is not particularly specialized to one sub-area of applied seismology, then it can be part of DASCore. What if the feature you're interested in adding is generally applicable for many kinds of DAS data analysis, but requires some additional package dependency? If this is the case, open a discussion describing the feature, the additional dependency, and (optional but encouraged) other future features that may also share this dependency. Typically we'll try to come to a clear consensus, then you can move ahead with development. If the proposed DASCore dependency addition appears to be controversial, then you will deliver a short presentation at one of the bi-weekly DASDAE developer team check-ins that should describe the feature, the additional dependency (including the approximate size of the additional software to be installed), and ideas for other features this dependency could enable. Then the developer community in attendance will discuss the proposed change and take a vote (majority approval required).
24+
25+
If you are interested in creating a new [DASDAE](https://github.com/DASDAE) package which uses DASCore as a dependency, you are not required to hold it to the same style and testing guidelines as DASCore, but you are encouraged to do so, and can use DASCore's setup as an example. Following a common set of style and contributor workflows will make it easier for us to develop a community of DASDAE developers who can easily move between using and developing any of the DASDAE packages.
4426

4527
# Leadership
4628

47-
Currently DASCore operates in BDFL mode during its initial construction phase,
48-
with Derrick Chambers leading the oversight of the master branch, but this is
49-
not intended to be the mode of operation in the future. At a DASDAE developer team check-in (currently biweekly), the team reviews contributions and nominates a leadership team for the next cycle based on contribution history.
50-
51-
Currently Eileen Martin and Ge Jin lead organizational activities (e.g. organize
52-
team meetings, coordinate logistics of training and tutorial activities, enforcement
53-
of community standards, approving travel and research assistantships for some contributors
54-
at Colorado School of Mines) as PI and co-PI of the NSF Geoinformatics grant that is
55-
supporting initial development of DASDAE packages. However, as the contributor
56-
community grows beyond Colorado School of Mines, after the life of the grant, these
57-
roles are intended to be rotating among community members.
29+
Currently DASCore operates in BDFL mode during its initial construction phase, with Derrick Chambers leading the oversight of the master branch, but this is not intended to be the mode of operation in the future. At a DASDAE developer team check-in (currently biweekly), the team reviews contributions and nominates a leadership team for the next cycle based on contribution history.
30+
31+
Currently Eileen Martin and Ge Jin lead organizational activities (e.g. organize team meetings, coordinate logistics of training and tutorial activities, enforcement of community standards, approving travel and research assistantships for some contributors at Colorado School of Mines) as PI and co-PI of the NSF Geoinformatics grant that is supporting initial development of DASDAE packages. However, as the contributor community grows beyond Colorado School of Mines, after the life of the grant, these roles are intended to be rotating among community members.

docs/contributing/new_format.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To demonstrate this process, imagine adding support for a format called `jingle`
1818

1919
## Adding a New IO Module
2020

21-
First, we create a new io module called 'jingle' in DASCore's io module (dascore/io/jingle). Make sure there is a \__init__.py file in this module whose docstring describes basic use of the format and lists any non-obvious implementation details that might debug/improve the parser.
21+
First, we create a new io module called 'jingle' in DASCore's io module (dascore/io/jingle). Make sure there is a \__init__.py file in this module whose docstring describes basic use of the format and lists any non-obvious implementation details that might help debug/improve the parser.
2222

2323
contents of `dascore/io/jingle/__init__.py`
2424
```{python}
@@ -37,7 +37,7 @@ jingle = dc.spool('path_to_file.jgl')
3737
"""
3838
```
3939

40-
Next, create a `core.py` file in the new module (dascore/io/jingle/core.py). Start by creating a class called `JingleIOV1` which subclasses (`dascore.io.core.FiberIO`)[`dascore.io.core.FiberIO`]. Now, on your subclass, you need to implement the supported methods.
40+
Next, create a `core.py` file in the new module (dascore/io/jingle/core.py). Start by creating a class called `JingleIOV1` which subclasses [`dascore.io.core.FiberIO`](`dascore.io.core.FiberIO`). Now, on your subclass, you need to implement the supported methods.
4141

4242
Contents of `dascore/io/jingle/core.py`:
4343

docs/contributing/profiling_benchmarks.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you find a significant issue, you can profile the problematic benchmark(s) to
2121
For example, suppose you notice a large increase in runtime for the pass_filter benchmark in the patch_benchmarks' TestProcessingBenchmarks class. Run the benchmark again under profiling:
2222

2323
```bash
24-
pytest benchmarks/test_patch_benchmarks.py::TestProcessingBenchmarks::test_pass_filter_performance --profile
24+
pytest benchmarks/test_patch_benchmarks.py::TestProcessingBenchmarks::test_pass_filter --profile
2525
```
2626
This will create a new `prof` folder with `test_pass_filter_performance.prof` as one of the files. You can view these with a variety of tools, such as [snakeviz](https://jiffyclub.github.io/snakeviz/) (assuming you installed snakeviz with `pip install snakeviz`).
2727

docs/contributing/publish_a_new_release.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: "Publish a new release"
33
---
44

5-
On this page, we provide a step-by-step guidance on how to publish a new release for DASCore.
5+
On this page, we provide step-by-step guidance on how to publish a new release for DASCore.
66

77
## Step 1: Draft a new release and publish
88

9-
On DASCore GitHub page, you should go to [Releases](https://github.com/DASDAE/dascore/releases), draft a new release. On the draft, choose a new tag a release title (e.g. 0.0.14). Finally, generate release notes and publish the relase.
9+
On DASCore GitHub page, you should go to [Releases](https://github.com/DASDAE/dascore/releases), draft a new release. On the draft, choose a new tag and a release title (e.g. 0.0.14). Finally, generate release notes and publish the release.
1010

1111
## Step 2: Check the release status
1212

docs/contributing/style_and_linting.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "Style and Linting"
55
# Linting
66

77
DASCore uses [Black](https://github.com/ambv/black) and [flake8](http://flake8.pycqa.org/en/latest/) for code linting.
8-
If you have [properly installed DASCore' pre-commit hooks](dev_install.qmd#setup-pre-commit-hooks) they will be
8+
If you have [properly installed DASCore's pre-commit hooks](dev_install.qmd#setup-pre-commit-hooks) they will be
99
invoked automatically when you make a git commit. If any complaints are raised simply address them and try again.
1010

1111
Alternatively, before making a commit, you can run all the hooks on all the code like so:
@@ -20,5 +20,5 @@ will automatically fix the issue they raise on the first run.
2020
# Type Hints
2121

2222
DASCore makes extensive use of Python 3's [type hints](https://docs.python.org/3/library/typing.html).
23-
Use them to annotate any public functions/methods. See the docstring section of the [documentation page](documentation.qml)
23+
Use them to annotate any public functions/methods. See the docstring section of the [documentation page](documentation.qmd)
2424
for more information and some examples.

docs/notes/dft_notes.qmd

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ These notes provide the reasoning for DASCore's [fourier](`dascore.transform.fou
44

55
## Summary {#sec-summary}
66

7-
- When performing discrete fourier transforms, DACore multiplies numpy's fft output by the coordinate spacing in order to:
7+
- When performing discrete fourier transforms, DASCore multiplies numpy's fft output by the coordinate spacing in order to:
88

99
- Produce the same units as the continuous fourier transform
1010
- Preserve energy between the initial and transformed signals
@@ -55,7 +55,7 @@ Before defining the Discrete Fourier Transform (DFT), let's first consider how w
5555
5656
2. Energy Preservation: From @eq-3, integrating the square of the untransformed data should yield the same value as integrating the square of the amplitude spectra.
5757
58-
3. The amplitude of the zero frequency should be equal to the integral of the time series.
58+
3. The amplitude of the zero frequency should be equal to the integral of the signal.
5959
6060
Now, let's look at Numpy's DFT, which is defined as:
6161
@@ -65,11 +65,11 @@ $${#eq-4}
6565
6666
where $a$ is the untransformed series of length $n$, $A$ is the transformed discrete series with elements corresponding to frequency bins ($k$, $k=0, ..., n-1$)
6767
68-
Right away you might notice some reasons @eq-4 can't meet our expectations. First, nowhere are the units of $a$'s axis multiplied by the summation. Since the exponential term must be unit-less, $a$ must have the same units as $A$. Next, the energy can't be preserved since the number of elements in the summation increases as $n$ increases. Lastly, $A(0) = \sum_{m=0}^{n-1} a_m$ which is not the integral, but the sum, of $a$ (it doesn't consider sample spacing).
68+
Right away you might notice some reasons @eq-4 can't meet our expectations. First, nowhere are the units of $a$'s axis multiplied in the summation. Since the exponential term must be unit-less, $a$ must have the same units as $A$. Next, the energy can't be preserved since the number of elements in the summation increases as $n$ increases. Lastly, $A(0) = \sum_{m=0}^{n-1} a_m$ which is not the integral, but the sum, of $a$ (it doesn't consider sample spacing).
6969
7070
## Two Sine Waves
7171
72-
To illustrate some of these issues, consider a sine waves with amplitude of $\pm$ $b_0$ and dominant frequency of $f_0$ Hz.
72+
To illustrate some of these issues, consider a sine wave with amplitude of $\pm$ $b_0$ and dominant frequency of $f_0$ Hz.
7373
7474
$$
7575
f(x) = b_0 sin(2 \pi\ f_0 x)
@@ -83,11 +83,11 @@ $${#eq-6}
8383
8484
Where $\delta$ is the Dirac delta distribution.
8585
86-
To discretize @eq-5, let $f_0 = 2$, the total signal duration ($T$) = 5 seconds, and $b_0$ = 1. We create two sine waves, one with 500 samples and one with 1000 samples. When we naively perform the dft, [shift the zero frequency to the center](https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshift.html), and plot the amplitude spectra get the following:
86+
To discretize @eq-5, let $f_0 = 2$, the total signal duration ($T$) = 5 seconds, and $b_0$ = 1. We create two sine waves, one with 500 samples and one with 1000 samples. When we naively perform the dft, [shift the zero frequency to the center](https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshift.html), and plot the amplitude spectra we get the following:
8787
8888
```{python}
8989
#| code-fold: true
90-
#| label: fig-unscalled-plot
90+
#| label: fig-unscaled-plot
9191
#| fig-cap: "Sine amplitude spectrum"
9292
import matplotlib.pyplot as plt
9393
@@ -109,7 +109,7 @@ def get_fft_and_freqs(time, signal):
109109
return np.fft.fftshift(freqs), np.fft.fftshift(fft)
110110
111111
112-
def plot_amplitude_spectras(freqs1, fft1, freqs2, fft2, lims=(-5, 5)):
112+
def plot_amplitude_spectra(freqs1, fft1, freqs2, fft2, lims=(-5, 5)):
113113
"""plot amplitude spectra without normalization"""
114114
plt.plot(freqs1, np.abs(fft1), label=f"n={len(freqs1)}", alpha=0.8)
115115
plt.plot(freqs2, np.abs(fft2), label=f"n={len(freqs2)}", alpha=0.8)
@@ -133,23 +133,23 @@ freqs1, fft1 = get_fft_and_freqs(t1, sin1)
133133
freqs2, fft2 = get_fft_and_freqs(t2, sin2)
134134
135135
# and plot
136-
ax = plot_amplitude_spectras(freqs1, fft1, freqs2, fft2)
136+
ax = plot_amplitude_spectra(freqs1, fft1, freqs2, fft2)
137137
plt.show()
138138
```
139139
140-
As expected, both outputs have spikes at $\pm f_0$ (5Hz), but the amplitude of the 1000 sample function 2X larger than the 500 sample function. This isn't entirely surprising; from @eq-6 we expect the amplitude to tend toward infinity as the signal moves from discrete to continuous ($n \rightarrow \infty$). However, this scaling is typically not useful. Certainly, it won't meet our expectations stated above.
140+
As expected, both outputs have spikes at $\pm f_0$ (2Hz), but the amplitude of the 1000 sample function is 2X larger than the 500 sample function. This isn't entirely surprising; from @eq-6 we expect the amplitude to tend toward infinity as the signal moves from discrete to continuous ($n \rightarrow \infty$). However, this scaling is typically not useful. Certainly, it won't meet our expectations stated above.
141141
142142
## Scaling
143143
144144
One approach to fix scaling discrepancy is to divide each amplitude spectrum by the number of samples. After which, they have nearly identical spectral amplitudes.
145145
146146
```{python}
147147
#| code-fold: true
148-
#| label: fig-n-scalled-plot
148+
#| label: fig-n-scaled-plot
149149
#| fig-cap: "Sine amplitude spectrum scaled by n"
150150
n_scaled_fft1 = fft1 / len(freqs1)
151151
n_scaled_fft2 = fft2 / len(freqs2)
152-
ax = plot_amplitude_spectras(freqs1, n_scaled_fft1, freqs2, n_scaled_fft2)
152+
ax = plot_amplitude_spectra(freqs1, n_scaled_fft1, freqs2, n_scaled_fft2)
153153
plt.show()
154154
```
155155
@@ -182,7 +182,7 @@ print(f"fft n-scaled (n={len(t2)}) energy {fft2_energy:.02f}")
182182
183183
It doesn't. And what about the units? As we saw above, $A$ in @eq-4 would have the same units as $a$.
184184
185-
What if, drawing inspiration from @eq-1, we simply scale the output units by the function's sample spacing ($dx$)? After all, the spacing and the number of samples is directly related by
185+
What if, drawing inspiration from @eq-1, we simply scale the output by the function's sample spacing ($dx$)? After all, the spacing and the number of samples is directly related by
186186
187187
$$
188188
\frac{T}{n} = dx
@@ -191,16 +191,16 @@ $${#eq-7}
191191
192192
```{python}
193193
#| code-fold: true
194-
#| label: fig-dt-scalled-plot
195-
#| fig-cap: "Sine amplitude spectrum scalled by dx"
194+
#| label: fig-dt-scaled-plot
195+
#| fig-cap: "Sine amplitude spectrum scaled by dx"
196196
dt1, dt2 = t1[1] - t1[0], t2[1] - t2[0]
197197
dt_scaled_fft1 = fft1 * dt1
198198
dt_scaled_fft2 = fft2 * dt2
199-
ax = plot_amplitude_spectras(freqs1, dt_scaled_fft1, freqs2, dt_scaled_fft2)
199+
ax = plot_amplitude_spectra(freqs1, dt_scaled_fft1, freqs2, dt_scaled_fft2)
200200
plt.show()
201201
```
202202
203-
As expected, The transforms with different numbers of points still have the same magnitude at $\pm f_0$. Checking their energy conservation:
203+
As expected, the transforms with different numbers of points still have the same magnitude at $\pm f_0$. Checking their energy conservation:
204204
205205
```{python}
206206
#| code-fold: true
@@ -242,7 +242,7 @@ tri_fft1_scaled = tri_fft1 * dt1
242242
tri_fft2_scaled = tri_fft2 * dt2
243243
244244
245-
ax = plot_amplitude_spectras(tri_freq1, tri_fft1_scaled, tri_freq2, tri_fft2_scaled)
245+
ax = plot_amplitude_spectra(tri_freq1, tri_fft1_scaled, tri_freq2, tri_fft2_scaled)
246246
247247
value = np.abs(tri_fft2_scaled).max()
248248

docs/notes/velocity_to_strain_rate.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ plt.tight_layout()
7777

7878
Notice how the noisy channels around distance 2600m and 3400m have lower amplitude but occur along more channels when the `step_multiple` is increased.
7979

80-
Using the first function, the smallest `step_multiple` is 2. Despite treating the edges differently, the outputs of function 2 are nearly tha same as function 1 and no significant edge effects are observable.
80+
Using the first function, the smallest `step_multiple` is 2. Despite treating the edges differently, the outputs of function 2 are nearly the same as function 1 and no significant edge effects are observable.
8181

8282
```{python}
8383
#| code-fold: true

0 commit comments

Comments
 (0)