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

[Bug]: recenter_frames with fourier induces artifact at bright sources #233

Open
1 task done
taichiuyama opened this issue Nov 28, 2024 · 7 comments
Open
1 task done
Assignees
Labels
bug Something isn't working image tools other

Comments

@taichiuyama
Copy link

Check Existing Issues

  • Yes, I have checked existing issues to ensure this problem hasn't already been reported.

Instrument or Category

Image Tools

Description

I recently updated spaceKLIP and now I got stripe-like artifact features at residual stellar light and a bright background star after I ran recenter_frames by FT. If I select spline it doesn't induce the artifacts.
I tried blurring the frames before recenter_frames to avoid this feature but it still appeared unless I blurred it too much. Should I select spline to avoid this? or are there any other ways to avoid the artifact at bright pixels?

Error traceback output

No response

What operating system are you using?

pop_os 22.04

What version of Python are you running?

python 3.11

What Python packages do you have installed?

_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
alabaster 0.7.13 pypi_0 pypi
anyio 4.2.0 pypi_0 pypi
argon2-cffi 23.1.0 pypi_0 pypi
argon2-cffi-bindings 21.2.0 pypi_0 pypi
arrow 1.3.0 pypi_0 pypi
asdf 3.5.0 pypi_0 pypi
asdf-astropy 0.5.0 pypi_0 pypi
asdf-coordinates-schemas 0.3.0 pypi_0 pypi
asdf-standard 1.1.1 pypi_0 pypi
asdf-transform-schemas 0.5.0 pypi_0 pypi
asdf-unit-schemas 0.1.0 pypi_0 pypi
asdf-wcs-schemas 0.4.0 pypi_0 pypi
asteval 1.0.5 pypi_0 pypi
astropy 7.0.0 pypi_0 pypi
astropy-iers-data 0.2024.11.25.0.34.48 pypi_0 pypi
astroquery 0.4.7 pypi_0 pypi
asttokens 2.4.1 pypi_0 pypi
async-lru 2.0.4 pypi_0 pypi
attrs 23.2.0 pypi_0 pypi
babel 2.14.0 pypi_0 pypi
bayesicfitting 3.2.0 pypi_0 pypi
beautifulsoup4 4.12.2 pypi_0 pypi
blas 1.0 mkl
bleach 6.1.0 pypi_0 pypi
bqplot 0.12.42 pypi_0 pypi
bqplot-gl 0.0.0 pypi_0 pypi
bqplot-image-gl 1.4.11 pypi_0 pypi
bzip2 1.0.8 h7b6447c_0
c-ares 1.19.1 h5eee18b_0
ca-certificates 2023.12.12 h06a4308_0
casa-formats-io 0.2.2 pypi_0 pypi
certifi 2023.11.17 pypi_0 pypi
cffi 1.16.0 pypi_0 pypi
charset-normalizer 3.3.2 pypi_0 pypi
click 8.1.7 pypi_0 pypi
cloudpickle 3.0.0 pypi_0 pypi
comm 0.2.1 pypi_0 pypi
contourpy 1.2.0 pypi_0 pypi
corner 2.2.2 pypi_0 pypi
crds 11.17.14 pypi_0 pypi
cryptography 41.0.7 pypi_0 pypi
cycler 0.12.1 pypi_0 pypi
dask 2023.12.1 pypi_0 pypi
debugpy 1.8.0 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
dill 0.3.7 pypi_0 pypi
docutils 0.20.1 pypi_0 pypi
drizzle 2.0.0 pypi_0 pypi
echo 0.8.0 pypi_0 pypi
emcee 3.1.4 pypi_0 pypi
et-xmlfile 1.1.0 pypi_0 pypi
executing 2.0.1 pypi_0 pypi
fast-histogram 0.12 pypi_0 pypi
fastjsonschema 2.19.1 pypi_0 pypi
filelock 3.13.1 pypi_0 pypi
fonttools 4.47.0 pypi_0 pypi
fqdn 1.5.1 pypi_0 pypi
freetype-py 2.4.0 pypi_0 pypi
fsspec 2023.12.2 pypi_0 pypi
future 0.18.3 pypi_0 pypi
glue-astronomy 0.10.0 pypi_0 pypi
glue-core 1.17.1 pypi_0 pypi
glue-jupyter 0.20.0 pypi_0 pypi
glue-qt 0.3.0 pypi_0 pypi
glue-vispy-viewers 1.1.0 pypi_0 pypi
gwcs 0.21.0 pypi_0 pypi
h5py 3.9.0 py311hdd6beaf_0
hdf5 1.12.1 h2b7332f_3
healpy 1.16.6 pypi_0 pypi
hsluv 5.0.4 pypi_0 pypi
html5lib 1.1 pypi_0 pypi
idna 3.6 pypi_0 pypi
imageio 2.33.1 pypi_0 pypi
imagesize 1.4.1 pypi_0 pypi
importlib-metadata 7.0.1 pypi_0 pypi
intel-openmp 2023.1.0 hdb19cb5_46306
ipydatawidgets 4.3.5 pypi_0 pypi
ipygoldenlayout 0.4.0 pypi_0 pypi
ipykernel 6.28.0 pypi_0 pypi
ipympl 0.9.3 pypi_0 pypi
ipypopout 1.2.0 pypi_0 pypi
ipysplitpanes 0.2.0 pypi_0 pypi
ipython 8.19.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
ipyvolume 0.6.3 pypi_0 pypi
ipyvue 1.10.1 pypi_0 pypi
ipyvuetify 1.8.10 pypi_0 pypi
ipywebrtc 0.6.0 pypi_0 pypi
ipywidgets 8.1.5 pypi_0 pypi
isoduration 20.11.0 pypi_0 pypi
jaraco-classes 3.3.0 pypi_0 pypi
jdaviz 3.8.1 pypi_0 pypi
jedi 0.19.1 pypi_0 pypi
jeepney 0.8.0 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
jmespath 1.0.1 pypi_0 pypi
joblib 1.3.2 pypi_0 pypi
json5 0.9.14 pypi_0 pypi
jsonpointer 2.4 pypi_0 pypi
jsonschema 4.20.0 pypi_0 pypi
jsonschema-specifications 2023.12.1 pypi_0 pypi
jupyter 1.0.0 pypi_0 pypi
jupyter-client 8.6.0 pypi_0 pypi
jupyter-console 6.6.3 pypi_0 pypi
jupyter-core 5.7.0 pypi_0 pypi
jupyter-events 0.9.0 pypi_0 pypi
jupyter-lsp 2.2.1 pypi_0 pypi
jupyter-server 2.12.2 pypi_0 pypi
jupyter-server-terminals 0.5.1 pypi_0 pypi
jupyterlab 4.0.10 pypi_0 pypi
jupyterlab-pygments 0.3.0 pypi_0 pypi
jupyterlab-server 2.25.2 pypi_0 pypi
jupyterlab-widgets 3.0.13 pypi_0 pypi
jwst 1.16.1 pypi_0 pypi
jwst-backgrounds 1.2.0 pypi_0 pypi
keyring 24.3.0 pypi_0 pypi
kiwisolver 1.4.5 pypi_0 pypi
krb5 1.20.1 h143b758_1
lazy-loader 0.3 pypi_0 pypi
ld_impl_linux-64 2.38 h1181459_1
libcurl 8.5.0 h251f7ec_0
libedit 3.1.20230828 h5eee18b_0
libev 4.33 h7f8727e_1
libffi 3.4.4 h6a678d5_0
libgcc-ng 11.2.0 h1234567_1
libgfortran-ng 11.2.0 h00389a5_1
libgfortran5 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libnghttp2 1.57.0 h2d74bed_0
libssh2 1.10.0 hdbd6064_2
libstdcxx-ng 11.2.0 h1234567_1
libuuid 1.41.5 h5eee18b_0
lmfit 1.3.2 pypi_0 pypi
locket 1.0.0 pypi_0 pypi
lxml 5.0.1 pypi_0 pypi
markupsafe 2.1.3 pypi_0 pypi
matplotlib 3.8.2 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
mistune 3.0.2 pypi_0 pypi
mkl 2023.1.0 h213fc3f_46344
mkl-service 2.4.0 py311h5eee18b_1
mkl_fft 1.3.8 py311h5eee18b_0
mkl_random 1.2.4 py311hdb19cb5_0
more-itertools 10.1.0 pypi_0 pypi
mpl-scatter-density 0.7 pypi_0 pypi
natsort 8.4.0 pypi_0 pypi
nbclient 0.7.4 pypi_0 pypi
nbconvert 7.14.0 pypi_0 pypi
nbformat 5.9.2 pypi_0 pypi
ncurses 6.4 h6a678d5_0
ndcube 2.2.0 pypi_0 pypi
nest-asyncio 1.5.8 pypi_0 pypi
networkx 3.2.1 pypi_0 pypi
notebook 7.0.6 pypi_0 pypi
notebook-shim 0.2.3 pypi_0 pypi
numpy 1.25.2 pypi_0 pypi
numpy-base 1.23.5 py311hf175353_1
numpydoc 1.6.0 pypi_0 pypi
opencv-python-headless 4.9.0.80 pypi_0 pypi
openpyxl 3.1.2 pypi_0 pypi
openssl 3.0.13 h7f8727e_0
overrides 7.4.0 pypi_0 pypi
packaging 23.2 pypi_0 pypi
pandas 2.1.4 pypi_0 pypi
pandocfilters 1.5.0 pypi_0 pypi
parsley 1.3 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
partd 1.4.1 pypi_0 pypi
pexpect 4.9.0 pypi_0 pypi
photutils 1.10.0 pypi_0 pypi
pillow 10.2.0 pypi_0 pypi
pip 23.3.1 py311h06a4308_0
platformdirs 4.1.0 pypi_0 pypi
poppy 1.1.1 pypi_0 pypi
prometheus-client 0.19.0 pypi_0 pypi
prompt-toolkit 3.0.43 pypi_0 pypi
psutil 5.9.7 pypi_0 pypi
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
pvextractor 0.4 pypi_0 pypi
pycparser 2.21 pypi_0 pypi
pyerfa 2.0.1.1 pypi_0 pypi
pygments 2.17.2 pypi_0 pypi
pyklip 2.8 pypi_0 pypi
pynrc 1.0.4 pypi_0 pypi
pyopengl 3.1.7 pypi_0 pypi
pyparsing 3.1.1 pypi_0 pypi
pysiaf 0.24.1 pypi_0 pypi
pysynphot 2.0.0 pypi_0 pypi
python 3.11.7 h955ad1f_0
python-dateutil 2.8.2 pypi_0 pypi
python-json-logger 2.0.7 pypi_0 pypi
pythreejs 2.4.2 pypi_0 pypi
pytz 2023.3.post1 pypi_0 pypi
pyvo 1.5 pypi_0 pypi
pyyaml 6.0.1 pypi_0 pypi
pyzmq 25.1.2 pypi_0 pypi
qtconsole 5.5.1 pypi_0 pypi
qtpy 2.4.1 pypi_0 pypi
rad 0.18.0 pypi_0 pypi
radio-beam 0.3.7 pypi_0 pypi
readline 8.2 h5eee18b_0
referencing 0.32.1 pypi_0 pypi
regions 0.8 pypi_0 pypi
requests 2.31.0 pypi_0 pypi
rfc3339-validator 0.1.4 pypi_0 pypi
rfc3986-validator 0.1.1 pypi_0 pypi
roman-datamodels 0.18.0 pypi_0 pypi
rpds-py 0.16.2 pypi_0 pypi
scikit-image 0.22.0 pypi_0 pypi
scipy 1.14.1 pypi_0 pypi
secretstorage 3.3.3 pypi_0 pypi
semantic-version 2.10.0 pypi_0 pypi
send2trash 1.8.2 pypi_0 pypi
setuptools 68.2.2 py311h06a4308_0
shapely 2.0.2 pypi_0 pypi
sidecar 0.7.0 pypi_0 pypi
six 1.16.0 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
snowballstemmer 2.2.0 pypi_0 pypi
soc-roman-tools 0.1.0 pypi_0 pypi
soupsieve 2.5 pypi_0 pypi
spaceklip 2.1.1.dev80+g7051516 pypi_0 pypi
specreduce 1.3.0 pypi_0 pypi
spectral-cube 0.6.5 pypi_0 pypi
specutils 1.12.0 pypi_0 pypi
spherical-geometry 1.3.1 pypi_0 pypi
sphinx 7.2.6 pypi_0 pypi
sphinxcontrib-applehelp 1.0.7 pypi_0 pypi
sphinxcontrib-devhelp 1.0.5 pypi_0 pypi
sphinxcontrib-htmlhelp 2.0.4 pypi_0 pypi
sphinxcontrib-jsmath 1.0.1 pypi_0 pypi
sphinxcontrib-qthelp 1.0.6 pypi_0 pypi
sphinxcontrib-serializinghtml 1.1.9 pypi_0 pypi
sqlite 3.41.2 h5eee18b_0
stack-data 0.6.3 pypi_0 pypi
stcal 1.9.0 pypi_0 pypi
stdatamodels 2.1.2 pypi_0 pypi
stpipe 0.7.0 pypi_0 pypi
stsci-image 2.3.5 pypi_0 pypi
stsci-imagestats 1.8.0 pypi_0 pypi
stsci-stimage 0.2.9 pypi_0 pypi
stsynphot 1.4.0 pypi_0 pypi
synphot 1.5.0 pypi_0 pypi
tabulate 0.9.0 pypi_0 pypi
tbb 2021.8.0 hdb19cb5_0
terminado 0.18.0 pypi_0 pypi
tifffile 2023.12.9 pypi_0 pypi
tinycss2 1.2.1 pypi_0 pypi
tk 8.6.12 h1ccaba5_0
toolz 0.12.0 pypi_0 pypi
tornado 6.4 pypi_0 pypi
tqdm 4.66.1 pypi_0 pypi
traitlets 5.14.1 pypi_0 pypi
traittypes 0.2.1 pypi_0 pypi
tweakwcs 0.8.9 pypi_0 pypi
types-python-dateutil 2.8.19.14 pypi_0 pypi
tzdata 2023.4 pypi_0 pypi
uncertainties 3.2.2 pypi_0 pypi
uri-template 1.3.0 pypi_0 pypi
urllib3 2.1.0 pypi_0 pypi
vispy 0.14.1 pypi_0 pypi
voila 0.4.3 pypi_0 pypi
wcwidth 0.2.12 pypi_0 pypi
webbpsf 1.4.0 pypi_0 pypi
webbpsf-ext 1.2.3 pypi_0 pypi
webcolors 1.13 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
websocket-client 1.7.0 pypi_0 pypi
websockets 12.0 pypi_0 pypi
wheel 0.41.2 py311h06a4308_0
widgetsnbextension 4.0.13 pypi_0 pypi
wiimatch 0.3.2 pypi_0 pypi
xlrd 2.0.1 pypi_0 pypi
xz 5.4.5 h5eee18b_0
zipp 3.17.0 pypi_0 pypi

Additional context or information

Screenshot from 2024-11-28 14-41-05

@wbalmer
Copy link
Collaborator

wbalmer commented Dec 2, 2024

Hi @taichiuyama ,

I took a look at this with some proprietary data in the MASK335R / F444W mode.

I used the branch shift_methods where I implemented separate keywords for the measurement of shifts (e.g. fourier shifting or spline shifting, and then subtraction) and the eventual image shifts themselves.

fourier shifting appears to give the most reliable results when computing the underlying shifts, regardless of the rippling artifacts, so i would not use the spline shifting to compute the underlying shifts.

as for the eventual image shifts (to avoid interpolation artefacts), at very high contrast (1e-6) the spline shifting appears to perform worse in contrast by about 1.2x at key spatial separations (0-2"), see plots below. it could in principle be used to avoid the fourier rippling if your science case requires less stringent contrast limits than those shown. the noise also might behave differently in different limits (e.g. photon noise limited at 1e-4, where the host star is faint) which would require more tests. In Jens' beta Pic b paper, we had to "overblur" the data to avoid these artifacts, but in some ways this is an unavoidable consequence of the undersigned of the data.

Others might have more insight.

compare_contrast_shifts

compare_contrast_shifts_ratio

@taichiuyama
Copy link
Author

taichiuyama commented Dec 3, 2024

thank you @wbalmer , one more question, do you have any ideas why the current spaceKLIP version has heavier artifacts than v1 (left: old version as of Apr 1 2024, right: current version)?
Screenshot from 2024-12-02 16-38-21

@taichiuyama
Copy link
Author

taichiuyama commented Dec 6, 2024

@wbalmer
one more, even if I ignore this artifact I found the v2 pipeline resulted in worse image registration when I compared the final output, seeing more speckle residuals than the v1 output. Possibly related to some other libraries imported in spaceklip, do you have any ideas? see comparison of roll-subtracted images with v1 (left) and v2 (right)
I'll post another issue if you want to check more.

v1_roll-subimage v2_roll-subimage

@wbalmer
Copy link
Collaborator

wbalmer commented Dec 6, 2024

Hi @taichiuyama it looks like the bad pixel step might have truncated some of the actual psf speckles in your version 2 reduction , hence the extra discontinuities and therefore the residuals and shifting artifacts. for instance if the sigma threshold is too low it might flag peaks in the psf as bad.

what functions/parameters did you use to flag and remove the bad pixels in your dataset? feel free to reach out on the ers slack directly

@wbalmer
Copy link
Collaborator

wbalmer commented Dec 6, 2024

these bad pixel steps have changed since v1, if i recall correctly

@taichiuyama
Copy link
Author

thanks for pointing out, ok I'll rerun the badpix fixing step and if I still see them I'll post on slack

@kdlawson
Copy link
Contributor

Chiming in late here, but another reason you might see a change in Fourier artifacts between SpaceKLIP versions is if modulo 1 of the shift being applied in the newest version is closer to a half pixel (a shift of 0.9 pixels induces less significant artifacts than a shift of 0.5 pixels). At some point, I believe SpaceKLIP changed the aligned position to always fall on a pixel center rather than a pixel intersection (in the case of axes with round numbers of pixels). This could easily result in the new shift modulo 1 being closer to 0.5, resulting in brighter artifacts.

You could check this for the aligned images, which should have a FITS extension called IMSHIFTS that records the shifts applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working image tools other
Projects
None yet
Development

No branches or pull requests

8 participants