riggsd / guano-py

Python reference implementation of the GUANO bat acoustics metadata specification
http://guano-md.org
MIT License
13 stars 5 forks source link

Location help please #24

Closed Pete-the-Geek closed 11 months ago

Pete-the-Geek commented 11 months ago

I'm trying to use guano_edit.py to add Loc Position to a WAV file that contains other GUANO metadata but I'm getting errors. It is probably a Python NOOB issue but

guano_edit.py 'Loc Position: (1, 1)' 20231102_210205_NoID.wav produces an error guano_edit.py 'Loc Position: (1, 1)' 20231102_210205_NoID.wav {'Loc Position': '(1, 1)'}

20231102_210205_NoID.wav Traceback (most recent call last): File "/home/user/.local/bin/guano_edit.py", line 100, in main() File "/home/user/.local/bin/guano_edit.py", line 96, in main update(gfile, md, dry_run=DRY_RUN) File "/home/user/.local/bin/guano_edit.py", line 75, in update print(gfile.to_string()) File "/home/user/.local/lib/python3.10/site-packages/guano.py", line 418, in to_string v = self._serialize(k, v) File "/home/user/.local/lib/python3.10/site-packages/guano.py", line 228, in _serialize return serialize(value) File "/home/user/.local/lib/python3.10/site-packages/guano.py", line 177, in 'Loc Position': lambda value: '%f %f' % value, TypeError: must be real number, not str

I have tried other types of Position formats with the same error. What is the correct format please?

riggsd commented 11 months ago

Are you able to try https://github.com/riggsd/guano-py/blob/master/bin/guano_edit.py on master branch?

There was indeed a bug which wasn't coercing value types on the way in, that should now be fixed.

Values should be specified just as they're represented in the GUANO metadata, eg:

./bin/guano_edit.py  'Loc Position: 37.18780 -86.10573'  filename.wav
Pete-the-Geek commented 11 months ago

This was perfect. I'm still getting done minor errors on some files with recreating the wav file but I'll persist and see. Thanks for speedy assistance