Exemplo n.º 1
0
def test_wstat_single_array_ungrouped_filtered(clean_astro_ui, hide_logging, single_array_setup):
    ui.ungroup()
    filter_data()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    check_stat(375, 420.8390856766203)
Exemplo n.º 2
0
def test_wstat_group_ungrouped_all(clean_astro_ui, hide_logging, group_setup):
    ui.ungroup(1)

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    expval = 880.8442022201893
    check_stat(1024, expval, 1)
Exemplo n.º 3
0
def test_wstat_single_scalar_ungrouped_filtered(clean_astro_ui, hide_logging, single_scalar_setup):
    ui.ungroup()
    filter_data()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    check_stat(375, 416.0601496345599)
Exemplo n.º 4
0
    def test_wstat_ungrouped_filtered(self):
        ui.ungroup()
        self._filter_data()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        self._check_stat(375, 420.8390856766203)
Exemplo n.º 5
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup(1)

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        expval = 880.8442022201893
        self._check_stat(1, 1024, expval)
Exemplo n.º 6
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup(1)

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        expval = 880.8442022201893
        self._check_stat(1, 1024, expval)
Exemplo n.º 7
0
    def test_wstat_ungrouped_filtered(self):
        ui.ungroup()
        self._filter_data()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        self._check_stat(375, 420.8390856766203)
Exemplo n.º 8
0
def test_wstat_group_ungrouped_filtered(clean_astro_ui, hide_logging, group_setup):
    ui.ungroup(1)
    filter_data()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    expval = 397.4089421041855
    check_stat(375, expval, 1)
Exemplo n.º 9
0
    def test_wstat_ungrouped_filtered(self):
        ui.ungroup(1)
        self._filter_data()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        expval = 397.4089421041855
        self._check_stat(1, 375, expval)
Exemplo n.º 10
0
    def test_wstat_ungrouped_filtered(self):
        ui.ungroup(1)
        self._filter_data()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        expval = 397.4089421041855
        self._check_stat(1, 375, expval)
Exemplo n.º 11
0
def test_wstat_two_scalar_ungrouped_all(clean_astro_ui, hide_logging, two_scalar_setup):
    ui.ungroup(1)
    ui.ungroup(2)

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    exp1 = 657.2275371837611
    exp2 = 880.8442022201893
    check_stat(1024, exp1, 1)
    check_stat(1024, exp2, 2)
    check_stat2(exp1 + exp2)
Exemplo n.º 12
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup(1)
        ui.ungroup(2)

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        exp1 = 657.2275371837611
        exp2 = 880.8442022201893
        self._check_stat(1, 1024, exp1)
        self._check_stat(2, 1024, exp2)
        self._check_stat2(exp1 + exp2)
Exemplo n.º 13
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup(1)
        ui.ungroup(2)

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        exp1 = 657.2275371837611
        exp2 = 880.8442022201893
        self._check_stat(1, 1024, exp1)
        self._check_stat(2, 1024, exp2)
        self._check_stat2(exp1 + exp2)
Exemplo n.º 14
0
def test_wstat_two_scalar_ungrouped_filtered(clean_astro_ui, hide_logging, two_scalar_setup):
    ui.ungroup(1)
    ui.ungroup(2)
    filter_data()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    exp1 = 420.50951039235736
    exp2 = 397.4089421041855
    check_stat(375, exp1, 1)
    check_stat(375, exp2, 2)
    check_stat2(exp1 + exp2)
Exemplo n.º 15
0
def test_filter_bad_ungrouped(make_data_path, clean_astro_ui):
    """Check behavior when the data is ungrouped.

    This is a test of the current behavior, to check that
    values still hold. It may be necessary to change this
    test if we change the quality handling.
    """

    infile = make_data_path('q1127_src1_grp30.pi')
    ui.load_pha(infile)
    pha = ui.get_data()
    assert pha.quality_filter is None
    assert pha.mask is True

    assert ui.get_dep().shape == (439, )
    ui.ungroup()
    assert ui.get_dep().shape == (1024, )
    assert pha.quality_filter is None
    assert pha.mask is True

    ui.ignore_bad()
    assert ui.get_dep().shape == (1024, )
    assert pha.quality_filter is None

    expected = np.ones(1024, dtype=bool)
    expected[996:1025] = False
    assert pha.mask == pytest.approx(expected)

    # At this point we've changed the mask array so Sherpa thinks
    # we've applied a filter, so a notice is not going to change
    # anything. See issue #1169
    #
    ui.notice(0.5, 7)
    assert pha.mask == pytest.approx(expected)

    # We need to ignore to change the mask.
    #
    ui.ignore(None, 0.5)
    ui.ignore(7, None)
    expected[0:35] = False
    expected[479:1025] = False
    assert pha.mask == pytest.approx(expected)
Exemplo n.º 16
0
    def load(self, filename):
        self.modelFile = filename
        with open(filename, 'r') as f:
            self.pca = json.load(f)
        for k, v in self.pca.items():
            self.pca[k] = np.array(v)
        nactivedata = self.pca['ihi'] - self.pca['ilo']
        assert self.pca['hi'].shape == (
            nactivedata,
        ), 'spectrum has different number of channels: %d vs %s' % (len(
            self.pca['hi']), self.ndata)
        assert self.pca['lo'].shape == self.pca['hi'].shape
        assert self.pca['mean'].shape == self.pca['hi'].shape
        assert len(self.pca['components']) == nactivedata
        assert nactivedata <= self.ndata
        ilo = int(self.pca['ilo'])
        ihi = int(self.pca['ihi'])
        self.cts = self.data[ilo:ihi]
        self.ncts = self.cts.sum(
        )  # 'have ncts background counts for deconvolution
        self.x = np.arange(ihi - ilo)
        self.ilo = ilo
        self.ihi = ihi

        # Only notice the channels between ilo + 1 and ihi (channel starts from 1, while index from 0).
        # The stat value will be affected, for assessment of goodness-of-fit for background.
        self.grouping0 = ui.get_grouping()
        ui.set_analysis('channel')
        # The channel filters, filter0 and filter_chan are all native channels.
        # ui.get_filter() will, instead, reture the binned channels if the spectrum is grouped.
        if self.grouping0 is not None:
            ui.ungroup()
        self.filter0 = ui.get_filter()
        ui.ignore()
        ui.notice(
            self.ilo + 1, self.ihi
        )  # ui.notice(a, b), from channel a to channel b, including channels a, b.
        self.filter_chan = ui.get_filter()
        ui.set_analysis('energy')
        if self.grouping0 is not None:
            ui.group()
Exemplo n.º 17
0
def test_wstat_single_scalar_ungrouped_all(clean_astro_ui, hide_logging, single_scalar_setup):
    ui.ungroup()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    check_stat(1024, 652.9968167212116)
Exemplo n.º 18
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        self._check_stat(1024, 663.0160968458746)
Exemplo n.º 19
0
    def test_wstat_ungrouped_all(self):
        ui.ungroup()

        # Used git commit 770359b5004374b969ebb63c173f293419397b4c
        # to create the oracle value, on a linux 64-bit machine.
        self._check_stat(1024, 663.0160968458746)
Exemplo n.º 20
0
def test_wstat_single_array_ungrouped_all(clean_astro_ui, hide_logging, single_array_setup):
    ui.ungroup()

    # Used git commit 770359b5004374b969ebb63c173f293419397b4c
    # to create the oracle value, on a linux 64-bit machine.
    check_stat(1024, 663.0160968458746)