invalid SOFA files for UTF-8 strings

Aperta
#147 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@f-brinkmann ci sta già lavorando.

Dal 24/10/2026.

  • #149 di @f-brinkmann — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Start by reproducing the issue with the netCDF4 example and inspect sofar's writing and validate paths for string attributes. Confirm how UTF-8 descriptions are written and checked, then verify that the resulting SOFA file uses only allowed NC_CHAR attributes and that validation handles invalid NC_STRING attributes correctly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Following https://github.com/sofacoustics/SOFAtoolbox/issues/95#event-31983840895

I think there is an issue in sofar.

Writing a UTF-8 string as a SOFA description will produce an NC_STRING attribute [due to a fallback in the netcdf4-python backend](https://github.com/Unidata/netcdf4-python/blob/v1.7.3rel/src/netCDF4/_netCDF4.pyx#L1867-L1874.

For example:

"""Show netCDF4 writing a UTF-8 variable attribute as NC_STRING."""
from pathlib import Path

from netCDF4 import Dataset

filename = Path("test.sofa")
with Dataset(filename, "w", format="NETCDF4") as file:
    file.createDimension("S", 1)
    variable = file.createVariable("Data.String", "S1", ("S",))
    variable.AsciiDescription = "ear"
    variable.Utf8Description = "Hörlappen"

ncdump test.sofa gives

netcdf test {
dimensions:
	S = 1 ;
variables:
	char Data.String(S) ;
		Data.String:AsciiDescription = "ear" ;
		string Data.String:Utf8Description = "Hörlappen" ;
data:

 Data.String = "" ;
}

The SOFA standard only allows NC_CHAR attributes so this would create an invalid file. I think this problem is twofold: one in writing to the file and another in validate because sofar happily validates and reads NC_STRING correctly.

Lingua principale
Python
Stelle
37
Fork
4
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 pyfar/sofar

Tutte le issue di pyfar/sofar

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.