Pyriod 0.3.2__tar.gz → 0.3.4__tar.gz

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.
Files changed (36) hide show
  1. {pyriod-0.3.2 → pyriod-0.3.4}/PKG-INFO +1 -1
  2. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/Pyriod.py +48 -15
  3. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod.egg-info/PKG-INFO +1 -1
  4. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod.egg-info/SOURCES.txt +0 -1
  5. pyriod-0.3.4/docs/img/Log.png +0 -0
  6. pyriod-0.3.4/docs/img/Periodogram.png +0 -0
  7. pyriod-0.3.4/docs/img/Pyriod.png +0 -0
  8. pyriod-0.3.4/docs/img/Signals.png +0 -0
  9. pyriod-0.3.4/docs/img/TimeSeries.png +0 -0
  10. pyriod-0.3.4/docs/index.md +39 -0
  11. pyriod-0.3.4/examples/TESS_DBV_example.ipynb +272 -0
  12. {pyriod-0.3.2 → pyriod-0.3.4}/examples/TSC2_Demo.ipynb +94 -29
  13. {pyriod-0.3.2 → pyriod-0.3.4}/mkdocs.yml +1 -1
  14. {pyriod-0.3.2 → pyriod-0.3.4}/setup.py +1 -1
  15. pyriod-0.3.2/docs/img/Log.png +0 -0
  16. pyriod-0.3.2/docs/img/Periodogram.png +0 -0
  17. pyriod-0.3.2/docs/img/Pyriod.png +0 -0
  18. pyriod-0.3.2/docs/img/Signals.png +0 -0
  19. pyriod-0.3.2/docs/img/TimeSeries.png +0 -0
  20. pyriod-0.3.2/docs/index.md +0 -40
  21. pyriod-0.3.2/docs/tutorial.md +0 -76
  22. pyriod-0.3.2/examples/TESS_DBV_example.ipynb +0 -218
  23. {pyriod-0.3.2 → pyriod-0.3.4}/LICENSE +0 -0
  24. {pyriod-0.3.2 → pyriod-0.3.4}/MANIFEST.in +0 -0
  25. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/__init__.py +0 -0
  26. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/docs/Periodogram.md +0 -0
  27. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/docs/Signals.md +0 -0
  28. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/docs/TimeSeries.md +0 -0
  29. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod/pyquist.py +0 -0
  30. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod.egg-info/dependency_links.txt +0 -0
  31. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod.egg-info/requires.txt +0 -0
  32. {pyriod-0.3.2 → pyriod-0.3.4}/Pyriod.egg-info/top_level.txt +0 -0
  33. {pyriod-0.3.2 → pyriod-0.3.4}/README.md +0 -0
  34. {pyriod-0.3.2 → pyriod-0.3.4}/docs/examples.md +0 -0
  35. {pyriod-0.3.2 → pyriod-0.3.4}/requirements.txt +0 -0
  36. {pyriod-0.3.2 → pyriod-0.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Pyriod
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Basic period detection and fitting routines for astronomical time series.
5
5
  Home-page: https://github.com/keatonb/Pyriod
6
6
  Author: Keaton Bell
@@ -61,7 +61,7 @@ warnings.filterwarnings(action='ignore', category=XMLParsedAsHTMLWarning,
61
61
 
62
62
  # Definition of the basic model we fit
63
63
  def sin(x, freq, amp, phase):
64
- """Model fit to time series."""
64
+ """Sinusoidal time series model."""
65
65
  return amp*np.sin(2.*np.pi*(freq*x+phase))
66
66
 
67
67
 
@@ -86,7 +86,7 @@ class Capturing(list):
86
86
  class lasso_selector(object):
87
87
  """Select indices from a matplotlib collection using `LassoSelector`.
88
88
 
89
- Outline selected points with given color, otherwise don't outline
89
+ Highlight selected points with gold outline.
90
90
 
91
91
  Based on Lasso Selector Demo
92
92
  https://matplotlib.org/3.1.1/gallery/widgets/lasso_selector_demo_sgskip.html
@@ -142,6 +142,26 @@ class Pyriod(object):
142
142
  rescale_covar: (bool)
143
143
  Rescale covariance matrix when estimating uncertainties? The
144
144
  default is False.
145
+ **kwargs are passed to set_frequency_sampling() method, which takes arguments
146
+ ----------
147
+ frequency : array, optional
148
+ Explicit set of frequencies to compute periodogram at. The default
149
+ is None.
150
+ oversample_factor : FLOAT, optional
151
+ How many times more densely than the natural frequency resolution
152
+ of 1/duration to sample frequencies. The default is 5.
153
+ nyquist_factor : FLOAT, optional
154
+ How many time beyond the approximate Nyquist frequency to sample
155
+ periodograms. The default is 1. Overridden by maxfreq, if provided.
156
+ Note that the Nyquist frequency is estimated to equal 1/(2*dt),
157
+ where dt is the median time separation between adjacent samples.
158
+ This is only valid for evenly sampled data, and may be a very poor
159
+ approximation for unevenly sampled data.
160
+ minfreq : FLOAT
161
+ Minimum frequency of range to use. The default is 1/duration.
162
+ maxfreq : FLOAT
163
+ Maximum frequency of range to use. The default is based off of
164
+ nyquist_factor.
145
165
 
146
166
  Attributes
147
167
  ----------
@@ -278,6 +298,10 @@ class Pyriod(object):
278
298
  # Display toggle widget _perplot_orig_display
279
299
  # TODO: Add color picker _perplot_orig_color
280
300
 
301
+ # If gui, set up widgets (need checkbox for recalculating periodogram)
302
+ if self.gui:
303
+ self._init_periodogram_widgets()
304
+
281
305
  # Compute original periodogram
282
306
  self.compute_pers(orig=True)
283
307
 
@@ -290,10 +314,8 @@ class Pyriod(object):
290
314
  # Make interpolator for residual periodogram
291
315
  self.interpls = interp1d(self.freqs, self.per_resid.power.value)
292
316
 
293
- # Initialize widgets and plot
317
+ # Initialize periodogram plot
294
318
  if self.gui:
295
- self._init_periodogram_widgets()
296
-
297
319
  # Set up figs/axes for periodogram plots
298
320
  self.perfig, self.perax = plt.subplots(
299
321
  figsize=(7, 3), num='Periodogram ({:d})'.format(self.id))
@@ -625,9 +647,16 @@ class Pyriod(object):
625
647
  # Whether to extrapolate
626
648
  self._sig_extrapolate_widget = widgets.Checkbox(
627
649
  value = False,
628
- description='Extrapolate?',
650
+ description='Extrapolate',
629
651
  style={'description_width': 'initial'}
630
652
  )
653
+ # Automatically recalculate sig threshold?
654
+ self._sig_auto_recalculate = widgets.Checkbox(
655
+ value = False,
656
+ description='Auto-recalculate',
657
+ style={'description_width': 'initial'},
658
+ layout=widgets.Layout(width='100%')
659
+ )
631
660
  # Calulate sig threshold button
632
661
  self._sig_calculate_button = widgets.Button(
633
662
  description='Calculate',
@@ -1040,7 +1069,7 @@ class Pyriod(object):
1040
1069
 
1041
1070
  def _valid_combo(self, combostr):
1042
1071
  """Check that provided combination string is a valid expression."""
1043
- parts = re.split('\+|\-|\*|\/', combostr.replace(" ", "").lower())
1072
+ parts = re.split(r'\+|\-|\*|\/', combostr.replace(" ", "").lower())
1044
1073
  allvalid = np.all([(part in self.stagedvalues.index)
1045
1074
  or part.replace('.', '', 1).isdigit()
1046
1075
  for part in parts])
@@ -1095,11 +1124,11 @@ class Pyriod(object):
1095
1124
  for i in range(len(combostr)):
1096
1125
  combostr[i] = combostr[i].replace(" ", "").lower()
1097
1126
  # Evaluate combostring, replacing keys with values.
1098
- parts = re.split('\+|\-|\*|\/',
1127
+ parts = re.split(r'\+|\-|\*|\/',
1099
1128
  combostr[i].replace(" ", "").lower())
1100
1129
  keys = set([part for part in parts if part
1101
1130
  in self.stagedvalues.index])
1102
- exploded = re.split('(\+|\-|\*|\/)',
1131
+ exploded = re.split(r'(\+|\-|\*|\/)',
1103
1132
  combostr[i].replace(" ", "").lower())
1104
1133
  expression = "".join([str(self.stagedvalues.loc[val, 'freq'])
1105
1134
  if val in keys else val for val in exploded])
@@ -1196,7 +1225,7 @@ class Pyriod(object):
1196
1225
  # Correct phase for tdiff
1197
1226
  thisphase = (self.stagedvalues.phase[prefix]
1198
1227
  - (self.tshift * self.freq_conversion
1199
- * self.stagedvalues.freq[prefix]))
1228
+ * self.stagedvalues.freq[prefix])) % 1
1200
1229
 
1201
1230
  # Estimate phase for new signals with _brute_phase_est
1202
1231
  # (or those with brute = True)
@@ -1213,10 +1242,10 @@ class Pyriod(object):
1213
1242
  useprefix = 'c{}'.format(cnum)
1214
1243
  signals[useprefix] = Model(sin, prefix=useprefix)
1215
1244
  params.update(signals[useprefix].make_params())
1216
- parts = re.split('\+|\-|\*|\/', prefix)
1245
+ parts = re.split(r'\+|\-|\*|\/', prefix)
1217
1246
  keys = set([part for part in parts
1218
1247
  if part in self.stagedvalues.index])
1219
- exploded = re.split('(\+|\-|\*|\/)', prefix)
1248
+ exploded = re.split(r'(\+|\-|\*|\/)', prefix)
1220
1249
  expression = "".join([val+'freq' if val in keys else val
1221
1250
  for val in exploded])
1222
1251
  params[useprefix+'freq'].set(expr=expression)
@@ -1226,7 +1255,7 @@ class Pyriod(object):
1226
1255
  # Correct phase for tdiff
1227
1256
  thisphase = (self.stagedvalues.phase[prefix]
1228
1257
  - (self.tshift * self.freq_conversion
1229
- * self.stagedvalues.freq[prefix]))
1258
+ * self.stagedvalues.freq[prefix])) % 1
1230
1259
  if np.isnan(thisphase): # If new signal to fit
1231
1260
  thisphase = self._brute_phase_est(
1232
1261
  self.stagedvalues.freq[prefix],
@@ -1489,7 +1518,7 @@ class Pyriod(object):
1489
1518
  def _update_freq_dropdown(self):
1490
1519
  # Add new frequencies to dropdown options
1491
1520
  labels = [self.fitvalues.index[i]
1492
- + ': {:.8f} '.format(self.fitvalues.freq[i])
1521
+ + ': {:.8f} '.format(self.fitvalues.freq.iloc[i])
1493
1522
  + self.per_orig.frequency.unit.to_string()
1494
1523
  for i in range(len(self.fitvalues))]
1495
1524
  currentind = self._select_fold_freq.index
@@ -1638,6 +1667,10 @@ class Pyriod(object):
1638
1667
  bounds_error=False,
1639
1668
  fill_value=self.per_resid.max_power.value)
1640
1669
  self._log_per_properties()
1670
+ # If auto-recalculate set for significance threshold:
1671
+ if self.gui:
1672
+ if self._sig_auto_recalculate.value:
1673
+ self._sigthreshfromgui()
1641
1674
  self._update_status(False) # Calculation complete
1642
1675
 
1643
1676
  def _update_per_plots(self):
@@ -1833,7 +1866,7 @@ class Pyriod(object):
1833
1866
  self._sig_freqstep_widget,
1834
1867
  self._sig_winwidth_widget,
1835
1868
  self._sig_avgtype_widget,
1836
- self._sig_extrapolate_widget,
1869
+ HBox([self._sig_extrapolate_widget,self._sig_auto_recalculate]),
1837
1870
  self._sig_calculate_button],
1838
1871
  layout=widgets.Layout(border='solid 1px'))
1839
1872
  options = HBox([displayconfig, thresholdconfig])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Pyriod
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Basic period detection and fitting routines for astronomical time series.
5
5
  Home-page: https://github.com/keatonb/Pyriod
6
6
  Author: Keaton Bell
@@ -17,7 +17,6 @@ Pyriod/docs/Signals.md
17
17
  Pyriod/docs/TimeSeries.md
18
18
  docs/examples.md
19
19
  docs/index.md
20
- docs/tutorial.md
21
20
  docs/img/Log.png
22
21
  docs/img/Periodogram.png
23
22
  docs/img/Pyriod.png
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,39 @@
1
+ # Pyriod
2
+
3
+ Python implementation of basic pre-whitening period detection and fitting routines for astronomical time series data.
4
+
5
+ Pyriod aims to provide most of the functionality of the wonderful program [Period04](https://www.period04.net/) in the Python environment for the modern astronomy workflow.
6
+
7
+ The interactive GUI runs in a Jupyter Notebook environment.
8
+
9
+ Please report any new bugs or request new features on the issues page on [GitHub](https://github.com/keatonb/Pyriod/issues).
10
+
11
+ Pyriod is written and maintained by [Keaton Bell](https://keaton.commons.gc.cuny.edu/).
12
+
13
+ Additional documentation and tutorials are under development.
14
+
15
+ ## Installation
16
+
17
+ To install, use
18
+
19
+ ```pip install Pyriod```
20
+
21
+ or download the latest (possibly unstable) version from [GitHub](https://github.com/keatonb/Pyriod) and run
22
+
23
+ ```python setup.py install```.
24
+
25
+ ## Dependencies
26
+
27
+ Pyriod requires Python 3.
28
+
29
+ You can view a list of package requirements [here](https://github.com/keatonb/Pyriod/blob/master/requirements.txt). Beyond fairly standard packages of astronomy research and plotting (Astropy, Pandas, ipywidgets, etc.), these few specific projects really made Pyriod possible, and are worth looking into if you want to understand or extend the code:
30
+
31
+ * [lightkurve](https://docs.lightkurve.org/) -- A friendly package for Kepler & TESS time series analysis in Python.
32
+ * [Lmfit](https://lmfit.github.io/lmfit-py/) -- Non-linear least-squares minimization and curve-fitting for Python.
33
+ * [qgrid](https://github.com/quantopian/qgrid) -- An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks. Huge thanks to [qgridnext](https://github.com/zhihanyue/qgridnext/) for keeping the functionality alive and compatible with modern python/dependencies.
34
+
35
+ ## Acknowledgement
36
+
37
+ This material is based upon work supported by the National
38
+ Science Foundation under Grant No. AST-2406917.
39
+