Skip to content

Commit

Permalink
Add measure to ignore specific value when running remove_baseline() i…
Browse files Browse the repository at this point in the history
…n the DynamicSpectrum class
  • Loading branch information
mtlam committed Mar 29, 2022
1 parent 477908e commit 58637bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -17,13 +17,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default behavior of `DynamicSpectrum`'s `getData()` now has `remove_baseline=False` and the internal data array is returned as is.
- Improved error handling on loading a PSRFITS file. PyPulse first checks to see if the file exists, then if it fails in `pyfits.open()`, raises an exception noting the problem lies internally there.


### Added

- In `Archive`'s `imshow()`, the y-axis can now be flipped with the `flip=True` argument. This allows inverted frequency axes to be turned right-side up. A `title` argument can now be supplied as well.
- `Archive`'s `plot()` now takes arguments of `subint`, `pol`, and `chan` to specifically select individual profile rather than requiring the data be 1D. By default, these arguments are `0`.
- `SinglePulse.getOffpulseRMS()` convenience function added, which calls `SinglePulse.getOffpulseNoise()`
- Individual phase plot implemented in Calibrator class as `phaseplot()`. This can also be called with `plot(mode="phase")`.
- `SinglePulse.component_fitting()` now offers the ability to output to PSRCHIVE's paas text file format for von Mises components.
- In `DynamicSpectrum`'s `remove_baseline()` command, two flags have been added. By default, `ignorezapped=True` and so data with a value of `zapvalue` are ignored. Such dynamic spectra can result from the less-robust generation methods, i.e., not specifying a template shape, thus resulting in a spike of 0.0 values for zapped data. This should be overhauled in the future.


## [0.1.1] - 2021-06-15

Expand Down
6 changes: 5 additions & 1 deletion pypulse/dynamicspectrum.py
Expand Up @@ -102,7 +102,7 @@ def getValue(self, f, t, df=1, dt=1, err=False, index=False):
N += 1
return total/float(N)

def remove_baseline(self, function="gaussian", redo=False):
def remove_baseline(self, function="gaussian", redo=False, ignorezapped=True, zapvalue=0.0):
"""
Attempts to remove the baseline amplitude from the dynamic spectrum
"""
Expand All @@ -113,6 +113,10 @@ def remove_baseline(self, function="gaussian", redo=False):
self.data -= np.median(flatdata)
self.baseline_removed = True
return self

# Remove zap
if ignorezapped:
flatdata = flatdata[np.where(flatdata!=zapvalue)[0]]
#~100 divisions, but bins to an even power of 10
interval = np.power(10, np.floor(np.log10(np.ptp(flatdata/100))))
center, hist = u.histogram(flatdata, interval=interval)
Expand Down

0 comments on commit 58637bd

Please sign in to comment.