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

Feature/make slit illum interactive #330

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9d51871
The first iteration of adding interactivity to the makeSlitIllum prim…
Jan 4, 2022
5a305c8
The first attempt of separating regions from fitting. Created a custo…
Jan 13, 2022
a319f1b
bin editing works
Jan 14, 2022
65a4542
bin editing works
Jan 14, 2022
8e0b19c
Bin editor correctly accepts parsed user bins
Jan 24, 2022
8663ff3
Both interactive bin editor and bin fitter work with data correctly
Jan 24, 2022
855f6d2
Enable masking in bin fitting
Jan 25, 2022
592ffd4
Added interactive interface for last step 1d fitting, section param a…
Feb 7, 2022
dbd126a
Merge branch 'master' into feature/makeSlitIllum_interactive
Feb 7, 2022
9779ab3
Cleaned up the makeSlitIllum code
Feb 23, 2022
b6c4b0d
Removed some comments and optimized some code
Feb 24, 2022
21f9c0a
Merge branch 'master' into feature/makeSlitIllum_interactive
Feb 24, 2022
20a3588
Fix PrimitiveVisualizer to accept ui_params=None
Feb 24, 2022
9d49249
Fix BinResettingUI due to loss of dependency
Feb 24, 2022
cc063fb
remove cyclip.c from git
chris-simpson Feb 24, 2022
b501e3c
fixed lingering tic marks when reducing number of bins, added padding…
Feb 24, 2022
8d71ab9
made path to set y_range so that it will respect updates, using for m…
Feb 25, 2022
9ac50ff
Interpolation etc
Mar 8, 2022
1e7506d
Removed interactive interface for the interpolation step; added bound…
Mar 23, 2022
02915f4
Modified tests for makeSlitIllum and updated ref file
Mar 23, 2022
8a27aaf
Merge branch 'master' into feature/makeSlitIllum_interactive
Mar 24, 2022
f1f43ec
Added Jinja2==3.0.3 to conda_deps in tox.ini
Mar 24, 2022
3bfce0d
Removed an accidental comment
Mar 28, 2022
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
42 changes: 29 additions & 13 deletions geminidr/gmos/parameters_gmos_longslit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,37 @@ def setDefaults(self):


class makeSlitIllumConfig(config.Config):
bins = config.Field("Total number of bins across the dispersion axis.",
int, None, optional=True)
border = config.Field("Size of the border added to the reconstructed slit illumination image",
int, 0, optional=True)
debug_plot = config.Field("Create diagnosis plots?",
bool, False, optional=True)
smooth_order = config.Field("Spline order to smooth binned data",
int, 3, optional=True)
bins = config.Field("Either total number of bins across the dispersion axis, "
"or a comma-separated list \n "
"of pixel coordinate pairs defining then dispersion bins, e.g. 1:300,301:500",
(int, str), None, optional=True)
regions = config.Field("Sample regions along the slit", str, None, optional=True)
suffix = config.Field("Filename suffix",
str, "_slitIllum", optional=True)
x_order = config.Field("Order of the x-component of the Chebyshev2D model used to reconstruct data",
int, 4, optional=True)
y_order = config.Field("Order of the y-component of the Chebyshev2D model used to reconstruct data",
int, 4, optional=True)

function = config.ChoiceField("Fitting function to use for bin fitting (spatial direction)", str,
allowed={"spline3": "Cubic spline",
"chebyshev": "Chebyshev polynomial",
"legendre": "Legendre polynomial",
"spline1": "Linear spline"},
default="spline3", optional=False)
order = config.Field("Order of the bin fitting function",
int, 20, optional=True)
hsigma = config.RangeField("High rejection threshold (sigma) of the bin fit",
float, 3., min=0)
lsigma = config.RangeField("Low rejection threshold (sigma) of the bin fit",
float, 3., min=0)
niter = config.RangeField("Maximum number of iterations",
int, 3, min = 0, optional=True)
grow = config.RangeField("Growth radius for rejected pixels of the bin fit",
float, 0, min=0, optional=True)
interp_order = config.RangeField("Order of the spline interpolator",
int, 3, min=1, max=5, optional=True)
debug_boundary_ext = config.Field("Extrapolate outside interpolation interval? If 'False'"
"boundary values are used", bool, False, optional=True)
interactive = config.Field("Set to activate an interactive preview to fine tune the input parameters",
bool, False, optional=True)
border = config.Field("Size of the border added to the reconstructed slit illumination image",
int, 2, optional=True)

class normalizeFlatConfig(config.core_1Dfitting_config):
suffix = config.Field("Filename suffix", str, "_normalized", optional=True)
Expand Down
508 changes: 250 additions & 258 deletions geminidr/gmos/primitives_gmos_longslit.py

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions geminidr/gmos/tests/longslit/test_make_slit_illum.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
"""
Tests for the `makeSlitIllum` primitive. The primitive itself is
defined in :mod:`~geminidr.core.primitives_spect` but these tests use GMOS Spect
data.
Tests for the `makeSlitIllum` primitive.
"""
import os
import pytest
Expand Down Expand Up @@ -49,7 +47,7 @@ def test_create_slit_illumination_with_mosaicked_data(ad, change_working_dir, re
constant.

There are several ways of doing this but, given the noise levels, we bin
the data, fit a polynomium, and check that the fitted polynomium has its 1st
the data, fit a polynomial, and check that the fitted polynomial has its 1st
and 2nd coefficients almost zero.
"""
plot = request.config.getoption("--do-plots")
Expand All @@ -63,7 +61,7 @@ def test_create_slit_illumination_with_mosaicked_data(ad, change_working_dir, re
assert hasattr(ad[0], "wcs")

p = primitives_gmos_longslit.GMOSLongslit([ad])
p.makeSlitIllum(bins=25, border=10, debug_plot=plot)
p.makeSlitIllum(bins=25, border=10)
slit_illum_ad = p.writeOutputs(
suffix="_mosaickedSlitIllum", strip=True)[0]

Expand Down Expand Up @@ -122,7 +120,7 @@ def test_create_slit_illumination_with_multi_extension_data(ad, change_working_d
cwd = os.getcwd()
print("Running tests inside folder:\n {}".format(cwd))
p = primitives_gmos_longslit.GMOSLongslit([ad])
p.makeSlitIllum(bins=25, border=10, debug_plot=plot)
p.makeSlitIllum(bins=25, border=10)
slit_illum_ad = p.writeOutputs()[0]

for ext, slit_ext in zip(ad, slit_illum_ad):
Expand Down
Loading