next up previous contents index
Next: Handling character strings Up: Importing SIC objects Previous: SIC structures   Contents   Index


SIC images

Standalone headers or tables are imported like any other structure or array respectively. SIC images, which combines a header with a table, are also imported in SicVar instances. Thus, image elements are accessed through standard indexing to the instance itself, and header components through attributes of this instance:

>>> Sic.comm('DEFINE IMAGE F centaurus2.gdf WRITE')
PygildasWarning: 'max' is a ndarray attribute, could not overwrite it.
PygildasWarning: 'min' is a ndarray attribute, could not overwrite it.
PygildasWarning: 'ndim' is a ndarray attribute, could not overwrite it.
You have to take care that numpy.ndarray's provide a large set of attributes and methods, and some of them have name identicals to headers components: they are not imported and only a warning is printed.

>>> f
[[ 0.01676085  0.0141144   0.0194073   0.0141144   0.0105858 ]
 [ 0.02911095  0.01852515  0.0141144   0.01323225  0.0123501 ]
 [ 0.09968295  0.0264645   0.          0.0141144   0.01499655]
 [ 0.035286    0.0141144   0.01676085  0.01499655  0.01323225]
 [ 0.0229359   0.017643    0.0123501   0.0158787   0.0158787 ]]
>>> f[0,0]
0.0167608503252
>>> print f
<SicVar instance>
array([[ 0.01676085,  0.0141144 ,  0.0194073 ,  0.0141144 ,  0.0105858 ],
       [ 0.02911095,  0.01852515,  0.0141144 ,  0.01323225,  0.0123501 ],
       [ 0.09968295,  0.0264645 ,  0.        ,  0.0141144 ,  0.01499655],
       [ 0.035286  ,  0.0141144 ,  0.01676085,  0.01499655,  0.01323225],
       [ 0.0229359 ,  0.017643  ,  0.0123501 ,  0.0158787 ,  0.0158787 ]], dtype=float32)
rms       = 0.0                                        REAL*4 0D
major     = 0.0                                        REAL*4 0D
blan      = 8                                       INTEGER*4 0D
ptype     = 3                                       INTEGER*4 0D
system    = 'EQUATORIAL  '                       CHARACTER*12 0D
... (and so on for all header elements)
>>> print f.rms # 'rms' is an attribute of 'f', and a SicVar itself.
<SicVar instance>
array(0.0, dtype=float32)



Gildas manager 2014-07-01