Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed name from instrument and its dependencies #498

Merged
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
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
Loading