Skip to content

Commit

Permalink
Merge pull request #498 from xpsi-group/497-instrument-init-may-break…
Browse files Browse the repository at this point in the history
…-merging-of-scaling-factor

Removed name from instrument and its dependencies
  • Loading branch information
lmauviard authored Dec 16, 2024
2 parents f3a7e81 f5de551 commit acca794
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
25 changes: 12 additions & 13 deletions docs/source/Instrument_synergy.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions xpsi/Instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 84,12 @@ class Instrument(ParameterSubspace):
find its way to the base class.
"""
def __init__(self, matrix, energy_edges, channels, channel_edges=None, name=None,
def __init__(self, matrix, energy_edges, channels, channel_edges=None,
*args, **kwargs):

self.matrix = matrix
self.energy_edges = energy_edges
self.channels = channels
self.name = name
if channel_edges is not None:
self.channel_edges = channel_edges

Expand Down
14 changes: 9 additions & 5 deletions xpsi/utilities/PlottingLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 199,7 @@ def plot_instruments(instruments, xlabel="Energy interval", ylabel="Channel"):
matrixplot = ax1.imshow(inst.matrix,
cmap=cm.viridis,
rasterized=True)
ax1.set_xlabel('Energy interval')
ax1.set_xlabel(xlabel)
ax1.set_ylabel(ylabel)

cbar = fig.colorbar(matrixplot, ax=ax1, shrink=1 / nb_instru, pad=0.01)
Expand All @@ -210,9 210,11 @@ def plot_instruments(instruments, xlabel="Energy interval", ylabel="Channel"):
veneer((0.1, 0.5), (50, 250), ax2)

for inst in instruments:
label = inst.name if hasattr(inst,'name') else None
ax2.plot((inst.energy_edges[:-1] inst.energy_edges[1:]) / 2.0,
np.sum(inst.matrix, axis=0), label='NICER') ## TODO: change NICER by instrument.name
ax2.legend()
np.sum(inst.matrix, axis=0), label=label)
if not label is None:
ax2.legend()
ax2.set_ylabel(r'Effective area [cm$^{2}$]')
ax2.set_xlabel('Energy [keV]')

Expand Down Expand Up @@ -244,12 246,14 @@ def plot_arf(instruments,
ax = fig.add_subplot(111)

for i, inst in enumerate(instruments):
label = inst.name if hasattr(inst,'name') else None
ax.plot((inst.energy_edges[:-1] inst.energy_edges[1:]) / 2.0,
np.sum(inst.matrix, axis=0), label=inst.name) ## TODO: change NICER by instrument.name
np.sum(inst.matrix, axis=0), label=label)

ax.set_ylabel('Effective area [cm$^{2}$]')
ax.set_xlabel('Energy [keV]')
ax.legend(loc='best')
if not label is None:
ax.legend(loc='best')
return ax

def plot_meshes(regions,
Expand Down

0 comments on commit acca794

Please sign in to comment.