Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Vertical: z sign convention is guessed in plots and ignored in matching

Aperta
#715 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@otzi5300 ci sta già lavorando.

Dal 24/9/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

Vertical data has no declared z convention (positive up or positive down). Matching ignores the question, and the plots guess.

Matching

_interpolate_to_obs_depths interpolates observation z directly against model z. An observation given as positive-down depth, which is how CTD casts are usually logged, fails against a MIKE 3 dfsu:

import mikeio
import modelskill as ms

df = mikeio.read("docs/data/vertical/VerticalProfile_obs1.dfs0").to_dataframe()  # z: -30..0
mr = ms.model_result("docs/data/vertical/sigma_z_coast.dfsu", item="Salinity")

ms.match(ms.VerticalObservation(df, item="Salinity", z_item="z", x=657500, y=6553600), mr)
# 108 matched points

ms.match(ms.VerticalObservation(df.assign(z=-df["z"]), item="Salinity", z_item="z", x=657500, y=6553600), mr)
# ValueError: zero-size array to reduction operation maximum which has no identity

The error does not point at the cause. If the two z ranges only touch at the surface, the match returns just the z=0 points and raises no error.

Plots

VerticalPlotter._pos_z inverts the y-axis in profile() and hovmoller() when abs(z.max()) > abs(z.min()). All-positive elevations above the seabed (z = 0..30, surface at 30) are taken as depths and drawn upside down. For mixed-sign z the result depends on which extreme is larger.

Proposal

  • VerticalObservation and VerticalModelResult take positive: Literal["up", "down"] | None = None. Resolve it from z.attrs["positive"] (CF convention), then the argument, then default to "up" (the MIKE convention). After construction z.attrs["positive"] is always set. Do not infer it from the sign of the values.
  • match() converts the observation z to the model's convention.
  • The plots read the attribute; _pos_z is removed with no fallback.
  • The user guide states the convention and shows the positive argument.
Lingua principale
Python
Stelle
56
Fork
9
Merge medio
1h 24m
PR unite (30g)
2

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DHI/modelskill

Tutte le issue di DHI/modelskill

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.