planetarypy / planetaryimage

Python PDS and Isis Cube file parser.
BSD 3-Clause "New" or "Revised" License
39 stars 20 forks source link

The pixel_type code needs extending to handle more types #16

Closed godber closed 9 years ago

godber commented 9 years ago

We only handle integer types. We should handle all valid types.

For example 32 bit float PC_REAL to support this:

https://github.com/RyanBalfanz/PyPDS/issues/20

Also, the fact that we are using both a chain of if statements AND dictionary lookup seems a little redundant to me. I think the existing implementation can be changed to use nested dictionaries exclusively. Or at least nearly so.

godber commented 9 years ago

The possible data types for an image object are outlined in Chapter 3 of the PDS3 reference document:

https://pds.nasa.gov/documents/sr/Chapter03.pdf

Also, "Appendix C - Internal Representation of Data Types" is useful:

https://pds.nasa.gov/documents/sr/AppendixC.pdf

Below, I have extracted the data types valid for SAMPLE_TYPE, which is what image objects would use:

IBM_INTEGER            IBM 360/370 mainframe 1-, 2-, and 4-byte signed integers
IBM_REAL               IBM 360/370 mainframe real number (4- or 8-byte)
IBM_UNSIGNED_INTEGER   IBM 360/370 mainframe 1-, 2-, and 4-byte unsigned integers
IEEE_REAL              4-, 8- and 10-byte real numbers
LSB_INTEGER            1-, 2-, and 4-byte signed integers
LSB_UNSIGNED_INTEGER   1-, 2-, and 4-byte unsigned integers
MAC_INTEGER            alias for MSB_INTEGER
MAC_REAL               alias for IEEE_REAL
MAC_UNSIGNED_INTEGER   alias for MSB_UNSIGNED_INTEGER
MSB_INTEGER            1-, 2-, and 4-byte signed integers
MSB_UNSIGNED_INTEGER   1-, 2-, and 4-byte unsigned integers
PC_INTEGER             alias for LSB_INTEGER
PC_REAL                4-, 8-, and 10-byte real numbers in IBM/PC format
PC_UNSIGNED_INTEGER    alias for LSB_UNSIGNED_INTEGER
SUN_INTEGER            alias for MSB_INTEGER
SUN_REAL               alias for IEEE_REAL
SUN_UNSIGNED_INTEGER   alias for MSB_UNSIGNED_INTEGER
VAX_DOUBLE             alias for VAX_REAL
VAX_INTEGER            alias for LSB_INTEGER
VAX_REAL               Vax F-, D-, and H-type (4-, 8- and 16-byte, respectively) real numbers
VAX_UNSIGNED_INTEGER   alias for LSB_UNSIGNED_INTEGER
VAXG_REAL              Vax G-type (8-byte) real numbers