ccpn.core.lib.SpectrumDataSources.lib package

Submodules

ccpn.core.lib.SpectrumDataSources.lib.BinaryHeader module

This file the BinaryHeader data access class

it serves as int/float/char translator of the actual spectral header data

class ccpn.core.lib.SpectrumDataSources.lib.BinaryHeader.BinaryHeader(headerSize, wordSize=4)[source]

Bases: object

A class to convert binary header data into ints, float or char-strings Used for formats like NmrPipe and Felix, that contain mixed binary header data intValues and floatValues defined in words

property bytesAsHexTuple

- None, immutable - Return all bytes as a tuple of hexadecimal strings

bytesToString(start, stop, strip=False)[source]

Return bytes within range(start,stop) (eg. (10,14) converts bytes 10,11,12,13 to chr and returns it as a string optionally strip string of ‘'

fromBytes(bytes)[source]

Intialise the header from bytes; return self

read(fp, doSeek=True)[source]

Read and initialise the header from binary file pointed to by fp; return self :param doSeek: seek to start of file if True

swapBytes()[source]

Swap the bytes of intValues and floatValues

wordsToString(start, stop)[source]

Return words within range(start,stop) (eg. (10,14) converts words 10,11,12,13 to chr and returns it as a string

ccpn.core.lib.SpectrumDataSources.lib.NmrPipeFDdict module

This file contains the NmrPipe DF definitions as copied from the C-code

ccpn.core.lib.SpectrumDataSources.lib.NmrPipeHeader module

This file contains the NmrPipe header class

class ccpn.core.lib.SpectrumDataSources.lib.NmrPipeHeader.NmrPipeHeader(headerSize, wordSize=4)[source]

Bases: ccpn.core.lib.SpectrumDataSources.lib.BinaryHeader.BinaryHeader

Class to read from / write to NMRPipe binary header; All values are stored as 4 byte floats, except a ‘axisLabels’ that are stored as 8bytes onto two float-words

defs = [('dimensionCount', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDDIMCOUNT')), ('transposed', (<function NmrPipeHeader.getBool>, <function NmrPipeHeader.setInt>, False, False, False, 'FDTRANSPOSED')), ('nFiles', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDFILECOUNT')), ('pipeDimension', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDPIPEFLAG')), ('sliceCount', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDSLICECOUNT')), ('nusDimension', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDNUSDIM')), ('nusType', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDUSER6')), ('dimensionOrder', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, True, 0, ['FDDIMORDER1', 'FDDIMORDER2', 'FDDIMORDER3', 'FDDIMORDER4'])), ('axisLabels', (<function NmrPipeHeader.toChar8>, <function NmrPipeHeader.fromChar8>, True, True, '', ['FDF2LABEL', 'FDF1LABEL', 'FDF3LABEL', 'FDF4LABEL'])), ('dataTypes', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2QUADFLAG', 'FDF1QUADFLAG', 'FDF3QUADFLAG', 'FDF4QUADFLAG'])), ('domain', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2FTFLAG', 'FDF1FTFLAG', 'FDF3FTFLAG', 'FDF4FTFLAG'])), ('pointCounts', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, True, 0, ['FDSIZE', 'FDSPECNUM', 'FDF3SIZE', 'FDF4SIZE'])), ('tdSizes', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2TDSIZE', 'FDF1TDSIZE', 'FDF3TDSIZE', 'FDF4TDSIZE'])), ('spectralWidthsHz', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2SW', 'FDF1SW', 'FDF3SW', 'FDF4SW'])), ('spectrometerFrequencies', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2OBS', 'FDF1OBS', 'FDF3OBS', 'FDF4OBS'])), ('referenceValues', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2CAR', 'FDF1CAR', 'FDF3CAR', 'FDF4CAR'])), ('referencePoints', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0.0, ['FDF2CENTER', 'FDF1CENTER', 'FDF3CENTER', 'FDF4CENTER'])), ('origin', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2ORIG', 'FDF1ORIG', 'FDF3ORIG', 'FDF4ORIG'])), ('apodCode', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2APODCODE', 'FDF1APODCODE', 'FDF3APODCODE', 'FDF4APODCODE'])), ('apodParameter1', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ1', 'FDF1APODQ1', 'FDF3APODQ1', 'FDF4APODQ1'])), ('apodParameter2', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ2', 'FDF1APODQ2', 'FDF3APODQ2', 'FDF4APODQ2'])), ('apodParameter3', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ3', 'FDF1APODQ3', 'FDF3APODQ3', 'FDF4APODQ3'])), ('apodSizes', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2APOD', 'FDF1APOD', 'FDF3APOD', 'FDF4APOD'])), ('firstPoint', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 1.0, ['FDF2C1', 'FDF1C1', 'FDF3C1', 'FDF4C1'])), ('zeroFill', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2ZF', 'FDF1ZF', 'FDF3ZF', 'FDF4ZF'])), ('ftSize', (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2FTSIZE', 'FDF1FTSIZE', 'FDF3FTSIZE', 'FDF4FTSIZE'])), ('phases0', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2P0', 'FDF1P0', 'FDF3P0', 'FDF4P0'])), ('phases1', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2P1', 'FDF1P1', 'FDF3P1', 'FDF4P1'])), ('userValues', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, nan, ['FDUSER1', 'FDUSER2', 'FDUSER3', 'FDUSER4', 'FDUSER5'])), ('tau', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, 0, 'FDTAU')), ('temperature', (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, 0.0, 'FDTEMPERATURE'))]
defsDict = {'apodCode': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2APODCODE', 'FDF1APODCODE', 'FDF3APODCODE', 'FDF4APODCODE']), 'apodParameter1': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ1', 'FDF1APODQ1', 'FDF3APODQ1', 'FDF4APODQ1']), 'apodParameter2': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ2', 'FDF1APODQ2', 'FDF3APODQ2', 'FDF4APODQ2']), 'apodParameter3': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2APODQ3', 'FDF1APODQ3', 'FDF3APODQ3', 'FDF4APODQ3']), 'apodSizes': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2APOD', 'FDF1APOD', 'FDF3APOD', 'FDF4APOD']), 'axisLabels': (<function NmrPipeHeader.toChar8>, <function NmrPipeHeader.fromChar8>, True, True, '', ['FDF2LABEL', 'FDF1LABEL', 'FDF3LABEL', 'FDF4LABEL']), 'dataTypes': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2QUADFLAG', 'FDF1QUADFLAG', 'FDF3QUADFLAG', 'FDF4QUADFLAG']), 'dimensionCount': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDDIMCOUNT'), 'dimensionOrder': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, True, 0, ['FDDIMORDER1', 'FDDIMORDER2', 'FDDIMORDER3', 'FDDIMORDER4']), 'domain': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2FTFLAG', 'FDF1FTFLAG', 'FDF3FTFLAG', 'FDF4FTFLAG']), 'firstPoint': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 1.0, ['FDF2C1', 'FDF1C1', 'FDF3C1', 'FDF4C1']), 'ftSize': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2FTSIZE', 'FDF1FTSIZE', 'FDF3FTSIZE', 'FDF4FTSIZE']), 'nFiles': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDFILECOUNT'), 'nusDimension': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDNUSDIM'), 'nusType': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDUSER6'), 'origin': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2ORIG', 'FDF1ORIG', 'FDF3ORIG', 'FDF4ORIG']), 'phases0': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2P0', 'FDF1P0', 'FDF3P0', 'FDF4P0']), 'phases1': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2P1', 'FDF1P1', 'FDF3P1', 'FDF4P1']), 'pipeDimension': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDPIPEFLAG'), 'pointCounts': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, True, 0, ['FDSIZE', 'FDSPECNUM', 'FDF3SIZE', 'FDF4SIZE']), 'referencePoints': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0.0, ['FDF2CENTER', 'FDF1CENTER', 'FDF3CENTER', 'FDF4CENTER']), 'referenceValues': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2CAR', 'FDF1CAR', 'FDF3CAR', 'FDF4CAR']), 'sliceCount': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, False, False, 0, 'FDSLICECOUNT'), 'spectralWidthsHz': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2SW', 'FDF1SW', 'FDF3SW', 'FDF4SW']), 'spectrometerFrequencies': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, True, True, 0.0, ['FDF2OBS', 'FDF1OBS', 'FDF3OBS', 'FDF4OBS']), 'tau': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, 0, 'FDTAU'), 'tdSizes': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2TDSIZE', 'FDF1TDSIZE', 'FDF3TDSIZE', 'FDF4TDSIZE']), 'temperature': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, 0.0, 'FDTEMPERATURE'), 'transposed': (<function NmrPipeHeader.getBool>, <function NmrPipeHeader.setInt>, False, False, False, 'FDTRANSPOSED'), 'userValues': (<function NmrPipeHeader.getFloat>, <function NmrPipeHeader.setFloat>, False, False, nan, ['FDUSER1', 'FDUSER2', 'FDUSER3', 'FDUSER4', 'FDUSER5']), 'zeroFill': (<function NmrPipeHeader.getInt>, <function NmrPipeHeader.setInt>, True, True, 0, ['FDF2ZF', 'FDF1ZF', 'FDF3ZF', 'FDF4ZF'])}
fromChar8(loc, value)[source]

set and convert value at loc

getBool(loc)[source]

Convert and return value at loc to boolean

getFloat(loc)[source]

Return value at loc as float

getInt(loc)[source]

Convert and return value at loc to int

getParameterValue(parameterName)[source]

Get the value(s) for parameterName;

property parameterNames: list

- list, immutable - Return parameter names as a list

setDefaultValues()[source]

Setting the magic numbers and default values

setFloat(loc, value)[source]

set and convert value at loc

setInt(loc, value)[source]

set and convert value at loc; int’s (and bool) are mapped on floats, so piggyback on the setFloat method

setParameterValue(parameterName, value=None)[source]

Set the value(s) for parameterName; use default if Value is None

toChar8(loc)[source]

Convert and return values starting at loc, +8-bytes to string