osmose.java_config_reconcile

Reconcile a STAGED OSMOSE config so the Java 4.4.1 engine can load and run it.

Java 4.4.1 mangles species names: Species.java builds the internal name via species.name.spN.replaceAll("_","").replaceAll("-","") (cod_west -> codwest), but leaves every NAME-BASED reference untouched — movement.species.mapN values and the predation-accessibility / fishery-matrix headers and rows still carry the underscore. So MapSet.getSpecies and Matrix.getIndexPrey/getIndexPred can no longer resolve them and the run aborts ("... does not match any predefined species name"). The Python engine keeps the raw names, so this only bites the Java path.

This pass rewrites a staged config to what Java expects, mirroring Java’s own stripping and repairing the matrix inconsistencies the disaggregation left behind (which Python tolerates):

  1. Name sanitize — strip _/- from species + fishery names in the name-resolving master keys (species.name.sp*, movement.species.map*, fisheries.name.fsh*) and in the matrix headers/rows, so references match Java’s stripped internal names.

  2. Column dedup — collapse duplicate predator columns in predation-accessibility (a config that already ships a background-predator column, then has it re-added by the background staging, ends up with two).

  3. Fishery-matrix reconcile — give catchability + discards the same fishery columns and a row for every prey in the accessibility universe, preserving existing cell values by name and zero-filling the rest (the disaggregation updated catchability but left discards stale with an aggregate cod row and no trawlcod_east column). Zero-fill is faithful to the Python engine, which silently applies a zero discard rate to any species absent from the discards file.

Staged-copy only — operates in place on stage_dir; never reads or writes data/. General, not Baltic-specific: a no-op on a config that already has alphanumeric names and consistent matrices. Intended to run AFTER write_temp_config + stage_background_for_java.

Functions

reconcile_config_for_java(stage_dir[, ...])

Make the staged config at stage_dir loadable/runnable by Java 4.4.1 (see module docstring).

sanitize_java_name(name)

Return name as Java 4.4.1 stores it internally: _ and - removed.