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
Refactor FluxPointEstimator to use Datasets #2112
Changes from 4 commits
be10253
6cb0a20
352cc25
5b8952a
70f9e0b
5ba7b53
aea5aa6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,6 +518,24 @@ def copy(self): | |
"""A deep copy.""" | ||
return copy.deepcopy(self) | ||
|
||
def to_spectrum_dataset(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, it is probably much better to have this function on |
||
"""Creates a SpectrumDatasetOnOff from a SpectrumObservation object""" | ||
from .dataset import SpectrumDatasetOnOff | ||
|
||
# Build mask from quality vector | ||
quality = self.on_vector.quality | ||
mask = quality == 0 | ||
|
||
return SpectrumDatasetOnOff( | ||
counts_on=self.on_vector, | ||
aeff=self.aeff, | ||
counts_off=self.off_vector, | ||
edisp=self.edisp, | ||
livetime=self.livetime, | ||
mask=mask, | ||
) | ||
|
||
|
||
|
||
class SpectrumObservationList(UserList): | ||
"""List of `~gammapy.spectrum.SpectrumObservation` objects.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
import abc | ||
import copy | ||
from collections import Counter | ||
import numpy as np | ||
from astropy.utils import lazyproperty | ||
|
@@ -57,11 +58,13 @@ def __init__(self, datasets, mask=None): | |
|
||
self.mask = mask | ||
|
||
@lazyproperty | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it safe to make Imagine you want to test another spectral model by doing something like this:
Will the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. This is a problem that arises when we set / modify the models on datasets after init. I'll check again what makes sense here and then change it consistently on all dataset classes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've looked into this a bit and currently there is the problem, that we attach the covariance matrix to the For the parallel evaluation of datasets we have to re-think the parameter handling and distribution of parameters in the |
||
def parameters(self): | ||
# join parameter lists | ||
parameters = [] | ||
for dataset in self.datasets: | ||
parameters += dataset.parameters.parameters | ||
self.parameters = Parameters(parameters) | ||
return Parameters(parameters) | ||
|
||
@property | ||
def datasets(self): | ||
|
@@ -105,3 +108,7 @@ def __str__(self): | |
str_ += "\t{key}: {value} \n".format(key=key, value=value) | ||
|
||
return str_ | ||
|
||
def copy(self): | ||
"""A deep copy.""" | ||
return copy.deepcopy(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this method can be removed I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or renamed? not sure what it does.