-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from punch-mission/replace-punchdata
remove remaining punchdata references
- Loading branch information
Showing
11 changed files
with
101 additions
and
96 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
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
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 |
---|---|---|
@@ -1,68 +0,0 @@ | ||
from datetime import datetime | ||
|
||
import numpy as np | ||
import pytest | ||
from astropy.nddata import StdDevUncertainty | ||
from astropy.wcs import WCS | ||
from punchbowl.data import NormalizedMetadata, PUNCHData | ||
|
||
from punchpipe.controlsegment.db import File | ||
from punchpipe.controlsegment.util import match_data_with_file_db_entry | ||
|
||
|
||
@pytest.fixture() | ||
def sample_punchdata(shape=(50, 50), level=0): | ||
data = np.random.random(shape) | ||
uncertainty = StdDevUncertainty(np.sqrt(np.abs(data))) | ||
wcs = WCS(naxis=2) | ||
wcs.wcs.ctype = "HPLN-ARC", "HPLT-ARC" | ||
wcs.wcs.cunit = "deg", "deg" | ||
wcs.wcs.cdelt = 0.1, 0.1 | ||
wcs.wcs.crpix = 0, 0 | ||
wcs.wcs.crval = 1, 1 | ||
wcs.wcs.cname = "HPC lon", "HPC lat" | ||
|
||
meta = NormalizedMetadata({"LEVEL": level}) | ||
return PUNCHData(data=data, uncertainty=uncertainty, wcs=wcs, meta=meta) | ||
|
||
|
||
def test_match_data_with_file_db_entry_fails_on_empty_list(sample_punchdata): | ||
file_db_entry_list = [] | ||
with pytest.raises(RuntimeError): | ||
match_data_with_file_db_entry(sample_punchdata, file_db_entry_list) | ||
|
||
|
||
def test_match_data_with_file_db_entry(sample_punchdata): | ||
file_db_entry_list = [ | ||
File( | ||
level=1, | ||
file_type="XX", | ||
observatory="Y", | ||
file_version="0", | ||
software_version="0", | ||
date_created=datetime.now(), | ||
date_obs=datetime.now(), | ||
date_beg=datetime.now(), | ||
date_end=datetime.now(), | ||
polarization="ZZ", | ||
state="created", | ||
processing_flow=0, | ||
), | ||
File( | ||
level=100, | ||
file_type="XX", | ||
observatory="Y", | ||
file_version="0", | ||
software_version="0", | ||
date_created=datetime.now(), | ||
date_obs=datetime.now(), | ||
date_beg=datetime.now(), | ||
date_end=datetime.now(), | ||
polarization="ZZ", | ||
state="created", | ||
processing_flow=0, | ||
), | ||
] | ||
output = match_data_with_file_db_entry(sample_punchdata, file_db_entry_list) | ||
assert len(output) == 1 | ||
assert output == file_db_entry_list[0] | ||
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
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,69 @@ | ||
from datetime import datetime | ||
|
||
import numpy as np | ||
import pytest | ||
from astropy.nddata import StdDevUncertainty | ||
from astropy.wcs import WCS | ||
from punchbowl.data import NormalizedMetadata | ||
from ndcube import NDCube | ||
|
||
from punchpipe.controlsegment.db import File | ||
from punchpipe.controlsegment.util import match_data_with_file_db_entry | ||
|
||
|
||
@pytest.fixture() | ||
def sample_punchdata(shape=(50, 50), level=0): | ||
data = np.random.random(shape) | ||
uncertainty = StdDevUncertainty(np.sqrt(np.abs(data))) | ||
wcs = WCS(naxis=2) | ||
wcs.wcs.ctype = "HPLN-ARC", "HPLT-ARC" | ||
wcs.wcs.cunit = "deg", "deg" | ||
wcs.wcs.cdelt = 0.1, 0.1 | ||
wcs.wcs.crpix = 0, 0 | ||
wcs.wcs.crval = 1, 1 | ||
wcs.wcs.cname = "HPC lon", "HPC lat" | ||
|
||
meta = NormalizedMetadata({"LEVEL": level}) | ||
return NDCube(data=data, uncertainty=uncertainty, wcs=wcs, meta=meta) | ||
|
||
|
||
def test_match_data_with_file_db_entry_fails_on_empty_list(sample_punchdata): | ||
file_db_entry_list = [] | ||
with pytest.raises(RuntimeError): | ||
match_data_with_file_db_entry(sample_punchdata, file_db_entry_list) | ||
|
||
|
||
def test_match_data_with_file_db_entry(sample_punchdata): | ||
file_db_entry_list = [ | ||
File( | ||
level=1, | ||
file_type="XX", | ||
observatory="Y", | ||
file_version="0", | ||
software_version="0", | ||
date_created=datetime.now(), | ||
date_obs=datetime.now(), | ||
date_beg=datetime.now(), | ||
date_end=datetime.now(), | ||
polarization="ZZ", | ||
state="created", | ||
processing_flow=0, | ||
), | ||
File( | ||
level=100, | ||
file_type="XX", | ||
observatory="Y", | ||
file_version="0", | ||
software_version="0", | ||
date_created=datetime.now(), | ||
date_obs=datetime.now(), | ||
date_beg=datetime.now(), | ||
date_end=datetime.now(), | ||
polarization="ZZ", | ||
state="created", | ||
processing_flow=0, | ||
), | ||
] | ||
output = match_data_with_file_db_entry(sample_punchdata, file_db_entry_list) | ||
assert len(output) == 1 | ||
assert output == file_db_entry_list[0] |
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
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
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
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
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 |
---|---|---|
|
@@ -24,9 +24,10 @@ dependencies = [ | |
"pyyaml", | ||
"click", | ||
"waitress", | ||
"prefect-sqlalchemy" | ||
"prefect-sqlalchemy", | ||
"pylibjpeg[libjpeg]" | ||
] | ||
requires-python = ">=3.10" | ||
requires-python = ">=3.11" | ||
authors = [ | ||
{name = "J. Marcus Hughes", email = "[email protected]"}, | ||
] | ||
|
@@ -57,6 +58,7 @@ docs = ["sphinx", | |
"sphinx-favicon", | ||
"sphinxcontrib-mermaid", | ||
"sphinx-automodapi"] | ||
dev = ["punchpipe[test,docs]", "pre-commit"] | ||
|
||
[project.scripts] | ||
punchpipe = "punchpipe.cli:run" | ||
|
@@ -75,7 +77,7 @@ packages = ["punchpipe"] | |
skip = "*.fts,*.fits,venv,*.pro,*.asdf,*.ipynb" | ||
|
||
[tool.ruff] | ||
target-version = 'py310' | ||
target-version = 'py311' | ||
exclude = ['tests', 'scripts', 'docs'] | ||
line-length=120 | ||
|
||
|
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