-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" Roman tests for source catalog creation """ | ||
|
||
import asdf | ||
import pytest | ||
|
||
from romancal.stpipe import RomanStep | ||
from romancal.multiband_catalog.multiband_catalog_step import MultibandCatalogStep | ||
|
||
# mark all tests in this module | ||
pytestmark = [pytest.mark.bigdata, pytest.mark.soctests] | ||
|
||
fieldlist = [ | ||
"ra_centroid", # DMS374 positions on ICRF | ||
"dec_centroid", # DMS374 positions on ICRF | ||
"F158_aper30_flux", # DMS399 aperture fluxes | ||
"F158_aper50_flux", # DMS399 aperture fluxes | ||
"F158_aper70_flux", # DMS399 aperture fluxes | ||
"F158_aper_total_flux", # DMS375 fluxes | ||
"F158_aper_total_flux_err", # DMS386 flux uncertainties | ||
"flags", # DMS387 dq_flags | ||
] | ||
|
||
|
||
def test_multiband_catalog(rtdata_module): | ||
rtdata = rtdata_module | ||
inputasnfn = "L3_skycell_mbcat_asn.json" | ||
# note that this input association currently only has a single | ||
# filter in it, so this is more of an existence proof for the multiband | ||
# catalogs than a detailed test. Using only a single catalog lets us | ||
# rely on the existing regtest files. | ||
outputfn = "r0099101001001001001_r274dp63x31y81_prompt_cat.asdf" | ||
rtdata.get_asn(f"WFI/image/{inputasnfn}") | ||
rtdata.output = outputfn | ||
rtdata.input = inputasnfn | ||
rtdata.get_truth(f"truth/WFI/image/{outputfn}") | ||
aftruth = asdf.open(f"truth/{outputfn}") | ||
args = ['romancal.step.MultibandCatalogStep', inputasnfn, | ||
'--deblend', 'True', # use deblending, DMS 393 | ||
] | ||
RomanStep.from_cmdline(args) | ||
afcat = asdf.open(outputfn) | ||
for field in fieldlist: | ||
assert field in afcat['roman']['source_catalog'].dtype.names | ||
|
||
# DMS 393: multiband catalog uses both PSF-like and extend-source-like | ||
# kernels | ||
assert ( | ||
set(aftruth['roman']['source_catalog'].dtype.names) == | ||
set(afcat['roman']['source_catalog'].dtype.names)) | ||
# weak assertion that our truth file must at least have the same | ||
# catalog fields as the file produced here. Exactly matching rows | ||
# would require a lot of okifying things that aren't obviously | ||
# the same, but we can easily check that the columns match up | ||
# by name. | ||
|
||
step = MultibandCatalogStep() | ||
step.log.info('DMS391: successfully used multiple kernels to detect ' | ||
'sources.') | ||
step.log.info('DMS393: successfully used deblending to separate blended ' | ||
'sources.') |