Skip to content

Surface statevector hookups and overhaul.#871

Merged
pgbrodrick merged 2 commits into
isofit:devfrom
evan-greenbrg:glint/statevector_config
Apr 20, 2026
Merged

Surface statevector hookups and overhaul.#871
pgbrodrick merged 2 commits into
isofit:devfrom
evan-greenbrg:glint/statevector_config

Conversation

@evan-greenbrg

@evan-greenbrg evan-greenbrg commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Early stages, needs to be tested. Description also to be fleshed out.

This does two things:

  1. Allow the user to specify state-vector optimization parameters directly in the surface.json file. This can be done by explicitly pointing to a surface model, or broadly including the relevant parameters.

I'll include more fleshed out specifics, but along the lines of:

  "SKY_GLINT": {
    "bounds": [
      0.0,
      10.0
    ],
    "init": 0.318,
    "prior_mean": 0.318,
    "prior_sigma": 0.001,
    "scale": 1
 },

These will propagate into the surface.mat file, which will in turn be read by the build_config script.

  1. I updated how we read in surface statevector optimziation parameters. These now come from (if not specified) named tuples in the same format as the StatevectorConfigElement. Default StatevectorConfigElement are then used for the surface models that have non-rfl state-vector elements. Within this context, values specified in the surface.json act as "overrides" for the defaults.

  2. I added a warnings section for check_config_validity(). Currently, this is only used for matching the non-reflectance surface statevector elements between .json and .mat files. Failing the check prints a warning:

WARNING:root:Configured non-reflectance surface statevector elements do not match .mat file.
Run will use configured values in the .json config.
Mismatching values:
SKY_GLINT: prior_mean
SUN_GLINT: init

@evan-greenbrg evan-greenbrg force-pushed the glint/statevector_config branch 2 times, most recently from 250ec24 to b2ad2a0 Compare February 18, 2026 21:09
@evan-greenbrg evan-greenbrg marked this pull request as ready for review February 19, 2026 17:37
@evan-greenbrg

evan-greenbrg commented Feb 23, 2026

Copy link
Copy Markdown
Collaborator Author
  • Replace get_single_element_by_name to get
  • Add commented text helpers with some of the old syntax to help with text searches to backtrack some of the syntax changes.
  • Review surface_thermal statevector terms.
  • Make sure the instrument statevector terms work.

@davidraythompson

Copy link
Copy Markdown
Collaborator

This looks good! @evan-greenbrg I like the way that folding glint priors into the .mat file makes it easier to keep the config file assumptions consistent with the .mat file. e.g. to avoid double bookkeeping glinty libraries with a physical glint model.

@pgbrodrick

Copy link
Copy Markdown
Collaborator

Ensure that setting the values is reasonably intuitive.

@unbohn

unbohn commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Hitting an edge case here when initializing the forward model with an already existing main config file: if that file does not include the statevector key in the surface section, any updates in that respect from a freshly created mat file are not transferred to the main config, and not considered within the inversion.

Solution could be to implement a check if the surface mat file that is indicated in the main config provides the statevector key, and if not present in the main config as well, adopt those keys and values.

@pgbrodrick

Copy link
Copy Markdown
Collaborator

Discussed solution:

  • throw warning if there's a difference between .json input and .mat.

Comment thread isofit/utils/template_construction.py Outdated
@evan-greenbrg evan-greenbrg force-pushed the glint/statevector_config branch from 82defbc to f654b33 Compare March 23, 2026 16:52
@evan-greenbrg evan-greenbrg requested a review from jammont March 23, 2026 19:23
Surface statevector can come from surface.json. Overhaul internal surface statevector hookups

Typo

Breaking out RT, surface, instrument StateVectorConfig

Debugging examples

Logging bug

Change get_config_single_element to get

Added some additonal comments

typo
@github-actions

Copy link
Copy Markdown
📊 Generated results:

URL: isofit/isofit-test-results#25
SHA: d2328bb

@evan-greenbrg

evan-greenbrg commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator Author

This PR does not introduce any changes that by default impact the underlying physics or jacobian. This is supported by null deltas between dev branch solutions and this branch.

Reflectance:

image

Atmosphere:

image

@pgbrodrick

pgbrodrick commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the tests @evan-greenbrg.

Given that sun & sky glint are now config terms, and given that the glint model requires (based on indexing) both of them to be populated in order to use, we should have a condition in the configuration that requires the mutual presence of both parameters if either is populated and we're in glint mode. I don't see it - am I missing it, or is this something we need to fill in?

Outside of this, I'm ready to merge.

@evan-greenbrg

evan-greenbrg commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the tests @evan-greenbrg.

Given that sun & sky glint are now config terms, and given that the glint model requires (based on indexing) both of them to be populated in order to use, we should have a condition in the configuration that requires the mutual presence of both parameters if either is populated and we're in glint mode. I don't see it - am I missing it, or is this something we need to fill in?

Outside of this, I'm ready to merge.

This is a good point. As it's currently written, the user could theoretically only provide one of the glint terms in the config, and the other config value would be pulled from the default. No matter if specified, the necessary glint config terms for the prior and scale values will be accessible.

We could add an explicit check that if one of the terms is specified custom within the config, the other would have to be as well. Surface statevector terms are treated independently from a config standpoint--analogous to the RT statevector terms.

@pgbrodrick

Copy link
Copy Markdown
Collaborator

Agreed - given this is an uncommon pathway, I'd be willing to merge as we flag to fix later - thoughts? Or would you prefer to fix first?

@evan-greenbrg

Copy link
Copy Markdown
Collaborator Author

Agreed - given this is an uncommon pathway, I'd be willing to merge as we flag to fix later - thoughts? Or would you prefer to fix first?

I'm conflicted on this. In the glint case, I think a check that raises some log if a Default config is used is a useful one. However, this PR would be nice to get in before the RT refactor as the config/state variable configs may change when removing RT_engines.

Barring any strong reservations, I would lean to consider merging this, then patching.

@pgbrodrick pgbrodrick merged commit b765f1a into isofit:dev Apr 20, 2026
27 checks passed
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.

5 participants