Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/687.attribution.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lucien Mauviard
3 changes: 3 additions & 0 deletions changelog.d/687.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Removed the old synthesise method from `synthesise.pyx`.

Fixed the Signal synthesize to handle better the background
133 changes: 74 additions & 59 deletions docs/source/Synthetic_data.ipynb

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions xpsi/Signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,10 @@ def synthesise(self,
if (format == 'TXT') and (backscal_ratio != 1.0):
raise ValueError('TXT format not supported for backscal_ratio != 1.')

# In the other case, if phase-averaged background was provided, use it
elif len( data_BKG.shape ) == 1:
BKG = BKG.sum( axis = 1 )

# Write expected background
kwargs = {'channels':self._data.channels,
'counts':BKG,
Expand All @@ -911,8 +915,15 @@ def _write(self, format, **kwargs):
if format == 'TXT':
self._write_TXT(**kwargs)
elif format == 'FITS':
if len(self._data.phases) > 2:
self._write_EVT(**kwargs)
# Case of 2D counts
if (len(kwargs['counts'].shape) == 2):
# If counts is phase-resolved
if kwargs['counts'].shape[1] > 1:
self._write_EVT(**kwargs)
# If counts is phase-averaged
else:
kwargs['counts'] = kwargs['counts'][:,0]
self._write_PHA(**kwargs)
else:
self._write_PHA(**kwargs)
else:
Expand Down
Loading
Loading