invalid SOFA files for UTF-8 strings
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 37
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyfar/sofar
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Move sofar-related pyfar functionality to sofarMay be free again @f-brinkmann claimed this 92 days ago, and no pull request is open. Openfeature
-
[MAINT] Remove restrcition for Numpy 2.5Possibly taken @f-brinkmann claimed this 28 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 56/100
-
Move to h5netcdfMay be free again @hoyer-a claimed this 127 days ago, and no pull request is open. Openenhancement
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kludex/python-multipart#375 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 3 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 11 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
FuRongJun-1999/dsh-memory#1000 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gcivil-nyu-org/team5-mon-fall26#154 ·
Maintainers usually reply within 1 day