Hi All,
I have a SEG-Y I/O library that I wrote in Python to do some data processing, but it fails on SEG-Y files that use IBM floating point instead of IEEE. Python's struct.unpack and struct.pack don't support IBM floating point, and I'd rather stay pure Python for simplicity and cross-platform reasons.
SEG-Y on Wikipedia, Another reference
Does anyone have experience with bitwise arithmetic in Python, and particularly how to do this conversion?
Many thanks!
Edit: Still interested in a solution, but I found a way to work around the problem (by converting to a different format outside Python). Thanks for reading.
IBM to IEEE floating point?
- bsmithyman
- Experienced Member
- Posts: 126
- Joined: Fri Feb 12, 2010 10:31 pm
- Contact:
IBM exponents are written to the power of 16 instead of 2 as in binary IEEE !?
Check out the examples
http://en.wikipedia.org/wiki/IBM_Floati ... chitecture
vs.
http://en.wikipedia.org/wiki/Single_pre ... int_format
Or double if that's your case.
Python - no idea
Check out the examples
http://en.wikipedia.org/wiki/IBM_Floati ... chitecture
vs.
http://en.wikipedia.org/wiki/Single_pre ... int_format
Or double if that's your case.
Python - no idea
Probably not the most confused programmer anymore on the XCORE forum.
- bsmithyman
- Experienced Member
- Posts: 126
- Joined: Fri Feb 12, 2010 10:31 pm
- Contact:
Yeah, it turned out that Seismic Unix files were really easy to read (a great package if you're looking for free/OS seismic processing tools). Essentially they're the traces from the SEG-Y standard, minus EBCIDIC and binary headers, and pre-converted to nice standardized IEEE floating point. It took about 5 lines of code to adapt my program to be able to read that, so I just sidestepped the whole issue.
The strange thing is that small IBM floating point values, interpreted as IEEE, still *look* a lot like the right values, just off by an order of magnitude or so...
The strange thing is that small IBM floating point values, interpreted as IEEE, still *look* a lot like the right values, just off by an order of magnitude or so...