Skip to content

wl cal patches#958

Merged
unbohn merged 6 commits into
isofit:dev_3xfrom
pgbrodrick:wavelength_cal_patch
May 22, 2026
Merged

wl cal patches#958
unbohn merged 6 commits into
isofit:dev_3xfrom
pgbrodrick:wavelength_cal_patch

Conversation

@pgbrodrick

Copy link
Copy Markdown
Collaborator

Fix breaks to wavelength calibration utility not caught in tests (tests do not use cli).

@pgbrodrick

Copy link
Copy Markdown
Collaborator Author
Screenshot 2026-05-10 at 9 15 55 AM

Expected result achieved with nominal wavelength_cal call.

@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown
📊 Generated results:

URL: isofit/isofit-test-results#30
SHA: 47059ef

@pgbrodrick pgbrodrick changed the base branch from dev to dev_3x May 11, 2026 16:23
Comment on lines +185 to +188
if isinstance(rho_dif_dif, np.ndarray) and len(rho_dif_dif) != len(RT.wl):
rho_dif_dif = interp1d(
surface.wl, rho_dif_dif, fill_value="extrapolate", bounds_error=False
)(RT.wl)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evan-greenbrg / @unbohn - please review if this is the right place for this to live.

@evan-greenbrg evan-greenbrg May 14, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required, and consistent because of the eq_11 calculation in RT:

L358 radiative_transfer.py

eq_11_term = 1 - (r["sphalb"] * rho_dif_dif)

L_tot = L_dir_dir + L_dif_dir + L_dir_dif + L_dif_dif
L_dif_dir /= eq_11_term
L_dif_dif /= eq_11_term

Although we use a slightly different syntax in forward.py:

in calc_meas:

        rho_dir_dir, rho_dif_dir = self.calc_rfl(x_surface, geom)
        rho_dir_dir_hi = self.upsample(self.surface.wl, rho_dir_dir)
        rho_dif_dir_hi = self.upsample(self.surface.wl, rho_dif_dir)

        # Adjacency effects
        rho_dir_dif_hi = (
            self.upsample(self.surface.wl, geom.bg_rfl)
            if isinstance(geom.bg_rfl, np.ndarray)
            else rho_dir_dir_hi
        )
        rho_dif_dif_hi = (
            self.upsample(self.surface.wl, geom.bg_rfl)
            if isinstance(geom.bg_rfl, np.ndarray)
            else rho_dif_dir_hi
        )

The only difference is that fm.upsample handles multidim arrays:

    def upsample(self, wl, q):
        """Linear interpolation to RT wavelengths."""
        # Only interpolate if these aren't close
        close = len(wl) == len(self.RT.wl) and np.allclose(wl, self.RT.wl)

        # or if any dimension is the wrong size
        interp = (np.array(q.shape) != len(self.RT.wl)).all()

        if not close or interp:
            if q.ndim > 1:
                return np.array(
                    [interp1d(wl, qi, fill_value="extrapolate")(self.RT.wl) for qi in q]
                )
            else:
                p = interp1d(wl, q, fill_value="extrapolate")
                return p(self.RT.wl)
        return q

Would update for consistency, except that invert_algebraic does not have access to fm.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I say we accept as is then, and make this more intuitive in the 4x implementation.

@evan-greenbrg

Copy link
Copy Markdown
Collaborator

I updated the wavelength cal test: pgbrodrick#21

Associated tutorials PR: isofit/isofit-tutorials#53

@pgbrodrick

Copy link
Copy Markdown
Collaborator Author

@unbohn , now that checks clear, this is ready for merge!

@unbohn

unbohn commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Roger, @pgbrodrick. Merging. Do we want to do a 3x patch release with this?

@unbohn unbohn merged commit 2b8081e into isofit:dev_3x May 22, 2026
111 of 135 checks passed
@pgbrodrick

Copy link
Copy Markdown
Collaborator Author

Yes I think so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants