Skip to content

Updated the handling of gridded data in loading and formatting model data#392

Open
Paul-Carvalho wants to merge 5 commits into
fishset-lite-devfrom
fsl-load-grid-update
Open

Updated the handling of gridded data in loading and formatting model data#392
Paul-Carvalho wants to merge 5 commits into
fishset-lite-devfrom
fsl-load-grid-update

Conversation

@Paul-Carvalho
Copy link
Copy Markdown
Collaborator

Description

This PR introduces several stability and compatibility improvements to the format_model_data function. The primary focus is on expanding gridded data capabilities, preventing Cartesian "join explosions" during temporal data merges, and smoothing out integration with the Shiny GUI.

Key Changes

  • Enabled Multi-Variable Gridded Data: Updated the joining logic in the "Add gridded data" section to properly handle and merge gridded data tables that contain multiple variables.
  • Case-Insensitive impute Argument: Wrapped the impute input in tolower() prior to the validation checks. This ensures that capitalized inputs passed directly from the GUI dropdowns (e.g., "Mean" or "Median") are handled seamlessly without throwing an error.
  • Robust Temporal Validation & Coercion: * Added a heuristic detection step to identify date variables in the gridded data (accounting for formal Date classes, Unix timestamps, and string names).
    • Added a safeguard that aborts the merge with an informative error if a gridded table contains a date variable but the target main dataframe does not (e.g., if the user forgot to include it in select_vars). This prevents catastrophic Cartesian join explosions.
    • Implemented dynamic coercion to guarantee that the temporal columns in both the gridded table and the main dataframe are standardized to the exact same Date class before executing the left_join.

Testing

  • Existing unit tests for format_model_data cover these operational updates and pass successfully without requiring any modifications.

Associated issues

@Paul-Carvalho Paul-Carvalho added this to the FishSET Lite milestone May 28, 2026
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.

1 participant