spacepy
spacepy copied to clipboard
Can't control metadata order in JSON headed ASCII
It would be nice to be able to order the JSON metadata when writing an ASCII file. You can specify the order of the data in toJSONheadedASCII, but writeJSONmetadata uses the same "order" of vars, and the metadata aren't vars so there's no way I can find to order the header.
I can't promise this'll be a high priority item, but I'll put it on my list. What's your envisaged use case? The ordering of data columns is to allow consistent ordering and let folks use naive readers that required fixed column numbers. I'm not immediately seeing a clear use (other than "i'd really like to see time listed first in the metadata") of ordered metadata.
Any insight on what your use is would help with designing an implementation. Of course, a pull request with a candidate solution would also be welcomed!
This comes from processing lanl geo into hourly/daily files. The copyright attr as the top of the file is nice, but doesn't seem to be possible in toJSONheadedASCII()
Got it. I'll give it some thought.
I am working on this one right now, I am finding a bit of a mess in datamodel.py with str, unicode, bytes etc, I will attempt to fix and add tests as needed.
Another use case just came up, putting here for posterity.
I made a JSON headed ASCII file of the species resolved CREME96 worst 5-minutes. There are 92 species that are being put in the header in alphabetic order not Z order or the specified order, challenging as they bounce around between the header and column number.