Skip to content
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

feat: use apodized Piff models #69

Merged
merged 30 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
527de30
WIP use smoothed piff models
beckermr Mar 19, 2024
9df8888
vendor piff omg no why
beckermr Mar 19, 2024
681cb5a
PROD move tests to py311
beckermr Mar 19, 2024
7ef7614
ENH run tests and get package data
beckermr Mar 19, 2024
e5fbce3
TST update env for tests
beckermr Mar 20, 2024
3c72fd6
TST try tests again
beckermr Mar 20, 2024
0be125b
TST remove extra install command
beckermr Mar 20, 2024
4be3eec
BUG missed a file in tests
beckermr Mar 20, 2024
f7052c8
TST missed this one too
beckermr Mar 20, 2024
bf9afbe
REF remove exception and refactor a bit
beckermr Mar 22, 2024
8ed96e1
Merge branch 'main' into smooth-piff
beckermr Jul 15, 2024
725f084
remove piff package
beckermr Jul 15, 2024
2477e66
fix: ignore piff stuff
beckermr Jul 15, 2024
be7d1fc
feat: package Piff with an explicit patch
beckermr Jul 15, 2024
bed705d
fix: move back to apodized model
beckermr Jul 15, 2024
99deb62
fix: remove smoothed piff from tests
beckermr Jul 15, 2024
97738f9
feat: update patch to latest
beckermr Jul 15, 2024
aa99cc9
test: cancel extra tests
beckermr Jul 15, 2024
a248431
fix: do not install piff from conda
beckermr Jul 15, 2024
50174af
fix: do not install piff from conda
beckermr Jul 15, 2024
416d823
fix: fix piff tests
beckermr Jul 15, 2024
454be7c
fix: fix piff tests
beckermr Jul 15, 2024
0231caf
test: fix piff tests some more
beckermr Jul 16, 2024
f7284c0
test: fix piff tests some more
beckermr Jul 16, 2024
4221faf
fix: remove buggy patch for now
beckermr Jul 16, 2024
7dc893a
Update setup.py
beckermr Jul 16, 2024
39bb634
fix: put things back to handle wcs correctly
beckermr Jul 16, 2024
bd7d9ce
Merge branch 'smooth-piff' of https://github.com/des-science/eastlake…
beckermr Jul 16, 2024
38676d6
feat: add latest patch
beckermr Jul 16, 2024
b8e1c82
feat: update with better piff tests
beckermr Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
pull_request: null

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: tests
Expand All @@ -25,7 +29,7 @@ jobs:

- uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.8
python-version: 3.11
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true
Expand All @@ -36,7 +40,7 @@ jobs:
- name: configure conda and install code
shell: bash -l {0}
run: |
mamba install pytest flake8
conda uninstall --force --yes piff
python -m pip install -e . -vv

- name: run cli
Expand All @@ -46,13 +50,19 @@ jobs:
eastlake-src-extractor -dd
run-eastlake-sim --help

- name: test
- name: test eastlake
shell: bash -l {0}
run: |
git clone https://github.com/beckermr/des-test-data
export TEST_DESDATA=`pwd`/des-test-data
pytest -vvs eastlake

- name: test piff
shell: bash -l {0}
run: |
cd piff_package/tests
coverage run -m pytest -v

- name: lint
shell: bash -l {0}
run: |
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ eastlake/astromatic/swarp
eastlake/astromatic/src-extractor
src/sextractor*/*
src/swarp*/*

piff_package/*
!piff_package/apodize.patch
!piff_package/README.md
!piff_package/Piff-1.3.3.tar.gz
!piff_package/LICENSE
1 change: 0 additions & 1 deletion eastlake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@

from .pipeline import register_pipeline_step # noqa
from . import des_piff # noqa
from . import des_smoothpiff # noqa
82 changes: 55 additions & 27 deletions eastlake/des_piff.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,56 @@
logger = logging.getLogger(__name__)


PSF_KWARGS_COLOR_RANGES = {
"GI_COLOR": [0.0, 3.5],
"IZ_COLOR": [0.0, 0.65],
}
PSF_COLOR_DEFAULTS = {
"GI_COLOR": 1.1,
"IZ_COLOR": 0.34,
}

PSF_KWARGS = {
"g": {"GI_COLOR": 1.1},
"r": {"GI_COLOR": 1.1},
"i": {"GI_COLOR": 1.1},
"z": {"IZ_COLOR": 0.34},
"g": {"GI_COLOR": PSF_COLOR_DEFAULTS["GI_COLOR"]},
"r": {"GI_COLOR": PSF_COLOR_DEFAULTS["GI_COLOR"]},
"i": {"GI_COLOR": PSF_COLOR_DEFAULTS["GI_COLOR"]},
"z": {"IZ_COLOR": PSF_COLOR_DEFAULTS["IZ_COLOR"]},
}


def _process_color_kwargs(piff_psf, kwargs):
if "GI_COLOR" in piff_psf.interp_property_names:
kwargs.pop("IZ_COLOR", None)

if "GI_COLOR" in kwargs:
if (
kwargs["GI_COLOR"] is None or
kwargs["GI_COLOR"] == "None"
):
kwargs["GI_COLOR"] = PSF_COLOR_DEFAULTS["GI_COLOR"]

if kwargs["GI_COLOR"] < PSF_KWARGS_COLOR_RANGES["GI_COLOR"][0]:
kwargs["GI_COLOR"] = PSF_KWARGS_COLOR_RANGES["GI_COLOR"][0]
if kwargs["GI_COLOR"] > PSF_KWARGS_COLOR_RANGES["GI_COLOR"][1]:
kwargs["GI_COLOR"] = PSF_KWARGS_COLOR_RANGES["GI_COLOR"][1]

elif "IZ_COLOR" in piff_psf.interp_property_names:
kwargs.pop("GI_COLOR", None)
if "IZ_COLOR" in kwargs:
if (
kwargs["IZ_COLOR"] is None or
kwargs["IZ_COLOR"] == "None"
):
kwargs["IZ_COLOR"] = PSF_COLOR_DEFAULTS["IZ_COLOR"]

if kwargs["IZ_COLOR"] < PSF_KWARGS_COLOR_RANGES["IZ_COLOR"][0]:
kwargs["IZ_COLOR"] = PSF_KWARGS_COLOR_RANGES["IZ_COLOR"][0]
if kwargs["IZ_COLOR"] > PSF_KWARGS_COLOR_RANGES["IZ_COLOR"][1]:
kwargs["IZ_COLOR"] = PSF_KWARGS_COLOR_RANGES["IZ_COLOR"][1]

return kwargs


@functools.lru_cache(maxsize=200)
def _read_piff(file_name):
return piff.read(
Expand Down Expand Up @@ -84,26 +126,7 @@ def _draw(
# nice and big image size here cause this has been a problem
image = galsim.ImageD(ncol=n_pix, nrow=n_pix, wcs=pixel_wcs)

if "GI_COLOR" in self.getPiff().interp_property_names:
psf_kwargs.pop("IZ_COLOR", None)
if (
"GI_COLOR" in psf_kwargs and (
psf_kwargs["GI_COLOR"] is None or
psf_kwargs["GI_COLOR"] == "None"
)
):
psf_kwargs["GI_COLOR"] = 1.1

elif "IZ_COLOR" in self.getPiff().interp_property_names:
psf_kwargs.pop("GI_COLOR", None)

if (
"IZ_COLOR" in psf_kwargs and (
psf_kwargs["IZ_COLOR"] is None or
psf_kwargs["IZ_COLOR"] == "None"
)
):
psf_kwargs["IZ_COLOR"] = 0.34
psf_kwargs = _process_color_kwargs(self.getPiff(), psf_kwargs)

offset = (
image_pos.x - int(image_pos.x + 0.5),
Expand All @@ -126,8 +149,11 @@ def getPiff(self):
return self._piff

def getPSF(
self, image_pos, wcs=None,
n_pix=None, depixelize=False,
self,
image_pos,
wcs=None,
n_pix=None,
depixelize=False,
gsparams=None,
**kwargs
):
Expand Down Expand Up @@ -175,7 +201,9 @@ def getPSF(
return psf

def getPSFImage(
self, image_pos, wcs=None,
self,
image_pos,
wcs=None,
n_pix=None,
gsparams=None,
**kwargs
Expand Down
Loading
Loading