Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read or write Guano MD from zero cross/Anabat format files #16

Open
ColinTalbert opened this issue May 17, 2019 · 2 comments
Open

Read or write Guano MD from zero cross/Anabat format files #16

ColinTalbert opened this issue May 17, 2019 · 2 comments

Comments

@ColinTalbert
Copy link
Contributor

I've played around with this a bit, but it seems fairly complex and maybe something someone else has already solved. The code from the Zcant package appears related but doesn't quite seem to work for this for me.

I'd be happy to work on this if it makes sense in the current package.

@abfleishman
Copy link
Contributor

@ColinTalbert @riggsd
We (CMI/NABat/BCI) are hoping to write (and read) metadata from/to zero-cross/Anabat. After a brief perusal, it seems like there is no tool for this at the moment? Do you know if anyone has made any progress on this?

Unfortunately, this is outside of my skill level to implement. Any chance either of you has time to work on this?

@riggsd
Copy link
Owner

riggsd commented Jun 12, 2021

Hi Colin, Abram,

This library is specifically focused on GUANO metadata. It was easy and "free" to add support for WAV files as they're so ubiquitous that they're supported out-of-the-box by the Python standard library, so we don't pull in any extra dependencies, and there's almost no extra complexity added to this library. Not to mention that a WAV file's underlying RIFF format is designed to be extensible, so adding GUANO metadata to a WAV file is compatible with every program that reads WAV files.

The Anabat file format is considerably more complex, and adding Anabat file support to this library would probably overwhelm the maintenance of this library, not to mention that it'd completely change the point of this project. It makes more sense for an Anabat library to import the GUANO library as a dependency. That is exactly what ZCANT does; in fact, ZCANT includes a one-file Anabat file format API in Python, and uses this library for its GUANO metadata:

https://github.com/riggsd/zcant/blob/master/zcant/anabat.py

With that said, the Anabat file format was NOT designed for extensibility; rather, it was designed to be terse and focused, written by the tiniest of microcontrollers decades ago. I brainstormed with Chris Corben on how we could embed GUANO metadata in the Anabat file format, and that recommendation is implemented in the ZCANT code above and documented in this section of the GUANO Metadata Specification on "Embedding in Anabat Files":

https://github.com/riggsd/guano-spec/blob/master/guano_specification.md#embedding-in-anabat-files

An alternate idea, if you're not up for embedding GUANO metadata within the limited binary constraints of an Anabat file (or an extensible WAV file, for that matter) is to write the GUANO metadata as a sidecar file. For a file named MySite_EPFU.zc you'd write the contents of the GUANO metadata UTF-8 encoded to the sidecar file MySite_EPFU.guano. This makes it easy to find, easy to read, and easy to edit; the downside is that it doubles the number of files in a directory, and makes it unfortunately easy to misplace the metadata. It'd still be up to reading applications to recognize and support sidecar files. But if it's your data and your application, you can make that choice. The README file from this project shows an example of writing a sidecar file:

# write GUANO metadata somewhere else, say an Anabat file or text file
with open('sidecar_file.guano', 'wb') as outfile:
    outfile.write( g.serialize() )

While I'm personally very time-constrained these days, I could spin off the Anabat support code from ZCANT into its own library (with GUANO support provided by this one) if that'd be useful for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants