Skip to content

Commit

Permalink
Fix for PINT-style dmx files with no F1/F2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlam committed Aug 30, 2023
1 parent d2d668e commit 0c94807
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow `DynamicSpectrum`'s `imshow()` to take `**kwargs` now.
- `Par`'s `getPM()` function (also used to get the transverse velocity) parses `PMELONG` and `PMELAT`.

### Fixed

- The `DMX` class now correctly parses PINT-style `.dmx` files with no `F1` or `F2` columns.

## [0.1.1] - 2021-06-15

### Added
Expand Down
16 changes: 9 additions & 7 deletions pypulse/dmx.py
Expand Up @@ -17,7 +17,7 @@ class DM(object):
def __init__(self, epoch, value=None, err=None, R1=None, R2=None,
F1=None, F2=None, dmxbin=None):
if (value is not None and err is not None and R1 is not None and
R2 is not None and F1 is not None and F2 is not None and dmxbin is not None):
R2 is not None and dmxbin is not None): #F1, F2 not required
self.epoch = epoch
self.value = value
self.err = err
Expand All @@ -34,9 +34,12 @@ def __init__(self, epoch, value=None, err=None, R1=None, R2=None,
self.err = float(splitstring[2])
self.R1 = float(splitstring[3])
self.R2 = float(splitstring[4])
self.F1 = float(splitstring[5])
self.F2 = float(splitstring[6])
self.dmxbin = splitstring[7]
if "DMX" in splitstring[5]:
self.dmxbin = splitstring[5]
else:
self.F1 = float(splitstring[5])
self.F2 = float(splitstring[6])
self.dmxbin = splitstring[7]

def __str__(self):
pass
Expand Down Expand Up @@ -124,7 +127,7 @@ def __init__(self, filename):

self.DMs = []
self.comment_dict = dict()

for i, line in enumerate(lines):
if line[0] == "#":
self.comment_dict[i] = line
Expand All @@ -150,7 +153,7 @@ def plot(self, filename=None, ax=None, show=True, fmt='k.', **kwargs):
if show:
plt.show()
return ax


def save(self, filename=None):
""" Save DMX file """
Expand Down Expand Up @@ -234,4 +237,3 @@ def subtractMean(self, save=True):
return self.getValues()
else:
return dmxs - wmean

0 comments on commit 0c94807

Please sign in to comment.