spacetelescope / jwst

Python library for science observations from the James Webb Space Telescope
https://jwst-pipeline.readthedocs.io/en/latest/
Other
558 stars 164 forks source link

Outlier detection ignores masks when in_memory is True #8776

Closed stscijgbot-jp closed 5 days ago

stscijgbot-jp commented 6 days ago

Issue JP-3743 was created on JIRA by Ned Molter:

The introduction of ModelLibrary (JP-3690) introduced a bug where the drizzled array weights are ignored entirely when the in_memory parameter is set to True.  This can be seen by modifying this unit test as follows, such that it's meaningful with respect to the weights array and weight threshold:


def test_create_median(three_sci_as_asn, tmp_cwd):
"""Test creation of median on disk vs in memory"""
    lib_on_disk = ModelLibrary(three_sci_as_asn, on_disk=True)
    lib_in_memory = ModelLibrary(three_sci_as_asn, on_disk=False)
    # make this test meaningful w.r.t. handling of weights
    with (lib_on_disk, lib_in_memory):
        for lib in [lib_on_disk, lib_in_memory]:
            for model in lib:
                model.wht = np.ones_like(model.data)
                model.wht[4,9] = 0.5
                lib.shelve(model, modify=True)

    median_on_disk = create_median(lib_on_disk, 0.7, on_disk=True)
    median_in_memory = create_median(lib_in_memory, 0.7, on_disk=False)

    assert np.isnan(median_in_memory[4,9])

    # Make sure the median library is the same for on-disk and in-memory
    assert np.allclose(median_on_disk, median_in_memory, equal_nan=True) ```
 
stscijgbot-jp commented 5 days ago

Comment by Ned Molter on JIRA:

Fixed by #8777 

stscijgbot-jp commented 8 hours ago

Comment by David Law on JIRA:

Internal issue, closing based on clean regression tests.