Changeset 1230


Ignore:
Timestamp:
14/04/09 18:56:40 (3 years ago)
Author:
Freddie Akeroyd
Message:

Merg in r1212:r1222 from trunk. Refs #115.

Location:
branches/4.2
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/Windows_extra/libNeXus-0.def

    r1104 r1230  
    2222_NXIGETGROUPINFO@16 
    2323_NXIGETINFO@16 
     24_NXIGETRAWINFO@16 
    2425_NXIGETNEXTATTR@16 
    2526_NXIGETNEXTENTRY@16 
     
    8182nxigetgroupid_ 
    8283nxigetgroupinfo_ 
     84nxigetrawinfo_ 
    8385nxigetinfo_ 
    8486nxigetnextattr_ 
  • branches/4.2/bindings/cpp/NeXusFile.hpp

    r1108 r1230  
    2222 * Documentation for the NeXus C++ API. 
    2323 * 2000-2008 the NeXus group. 
     24 * \defgroup cpp_types C++ Types 
     25 * \ingroup cpp_main 
     26 * \defgroup cpp_core C++ Core 
     27 * \ingroup cpp_main 
    2428 */ 
    2529 
     
    3741   * \li INT64 int8_t if available on the machine 
    3842   * \li UINT64 uint8_t if available on the machine 
     43   * \ingroup cpp_types 
    3944   */ 
    4045  enum NXnumtype { 
     
    6065   * \li RLE Run length encoding (only HDF-4) 
    6166   * \li HUF Huffmann encoding (only HDF-4) 
     67   * \ingroup cpp_types 
    6268   */ 
    6369  enum NXcompression { 
     
    9096  /** 
    9197   * The Object that allows access to the information in the file. 
     98   * \ingroup cpp_core 
    9299   */ 
    93100  class NXDLL_EXPORT File 
  • branches/4.2/bindings/cpp/NeXusStream.cpp

    r1108 r1230  
    3030// Revision of last commit $LastChangedRevision$  
    3131// Date of last commit     $LastChangedDate$ 
    32 // Author of last commit   $LastChangedBy$ 
     32// Last changed by         $LastChangedBy$ 
    3333////////////////////////////////////////////////////////////////////////// 
    3434 
     
    3636 * \file NeXusStream.cpp 
    3737 * Implementation of IOStream like interface to NeXus files 
     38 * \author Freddie Akeroyd, STFC ISIS Facility, GB 
    3839 * \version $LastChangedRevision$ 
    3940 * \date    $LastChangedDate$ 
  • branches/4.2/bindings/cpp/NeXusStream.hpp

    r1108 r1230  
    3131// Revision of last commit $LastChangedRevision$  
    3232// Date of last commit     $LastChangedDate$ 
    33 // Author of last commit   $LastChangedBy$ 
     33// Last changed by         $LastChangedBy$ 
    3434////////////////////////////////////////////////////////////////////////// 
    3535 
     
    3737 * \file NeXusStream.hpp 
    3838 * Header for IOStream like interface to NeXus files 
     39 * \author Freddie Akeroyd, STFC ISIS Facility, GB 
    3940 * \version $LastChangedRevision$ 
    4041 * \date    $LastChangedDate$ 
     42 * \defgroup cpp_stream IOstream like interface 
     43 * \ingroup cpp_main 
    4144 */ 
    4245 
     
    5760    }; 
    5861 
     62    /// \ingroup cpp_stream 
    5963    enum StreamModifier { Close=0 }; 
    6064 
     
    9599    }; 
    96100 
     101    /// \ingroup cpp_stream 
    97102    class NXDLL_EXPORT Attr : public ISerialisable 
    98103    { 
     
    164169    }; 
    165170     
     171    /// \ingroup cpp_stream 
    166172    class NXDLL_EXPORT Group : public ObjectWithAttr 
    167173    { 
     
    214220    }; 
    215221 
     222    /// \ingroup cpp_stream 
    216223    class NXDLL_EXPORT Data : public ObjectWithAttr 
    217224    { 
     
    245252    }; 
    246253 
     254    /// \ingroup cpp_stream 
    247255   NXDLL_EXPORT File& operator<<(File& nf, const ISerialisable& obj); 
     256     
     257    /// \ingroup cpp_stream 
    248258   NXDLL_EXPORT File& operator>>(File& nf, const ISerialisable& obj); 
    249259 
     260    /// \ingroup cpp_stream 
    250261   NXDLL_EXPORT File& operator<<(File& nf, const StreamModifier sm); 
     262  
     263    /// \ingroup cpp_stream 
    251264   NXDLL_EXPORT File& operator>>(File& nf, const StreamModifier sm); 
    252265 
  • branches/4.2/bindings/idl/NXtest.xml

    r1180 r1230  
    44xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    55xsi:schemaLocation="http://definition.nexusformat.org/schema/3.0 http://definition.nexusformat.org/schema/3.0/BASE.xsd" 
    6 file_time="2009-01-20T08:33:43+01:00"> 
     6file_time="2009-02-20T10:05:53+01:00"> 
    77    <NXentry name="entry" hugo="namenlos" cucumber="passion"> 
    88      <ch_data NAPItype="NX_CHAR[10]">NeXus Data</ch_data> 
  • branches/4.2/bindings/python/nxs/napi.py

    r1205 r1230  
    419419        Corresponds to NXmakegroup(handle, name, nxclass) 
    420420        """ 
     421        #print "makegroup",self._loc(),name,nxclass 
    421422        status = nxlib.nximakegroup_(self.handle, name, nxclass) 
    422423        if status == ERROR: 
     
    556557        Corresponds to NXopengroup(handle, name, nxclass) 
    557558        """ 
    558         #print "open group",nxclass,name 
     559        #print "opengroup",self._loc(),name,nxclass 
    559560        if nxclass is None: 
    560561            nxclass = self.__getnxclass(name) 
     
    575576        Corresponds to NXclosegroup(handle) 
    576577        """ 
    577         #print "close group" 
     578        #print "closegroup" 
     579        if self._indata: 
     580            raise NeXusError, "Close data before group at %s"%(self._loc()) 
    578581        status = nxlib.nxiclosegroup_(self.handle) 
    579582        if status == ERROR: 
    580             raise NeXusError, "Could not close group at %s"%(name,self._loc()) 
     583            raise NeXusError, "Could not close group at %s"%(self._loc()) 
    581584        self._path.pop() 
    582585 
     
    603606        if status == ERROR: 
    604607            raise ValueError, "Could not get group info: %s"%(self._loc()) 
    605         #print "group info",nxclass.value,name.value,n.value 
     608        #print "getgroupinfo",self._loc(),nxclass.value,name.value,n.value 
    606609        name = path.value.split('/')[-1]  # Protect against HDF5 returning path 
    607610        return n.value,name,nxclass.value 
     
    655658        #if nxclass == 'SDS': 
    656659        #    dtype = _pytype_code(storage.value) 
    657         #print "group next",nxclass.value, name.value, storage.value 
     660        #print "nextentry",nxclass.value, name.value, storage.value 
    658661        return name.value,nxclass.value 
    659662 
     
    728731 
    729732    # ==== Data ==== 
    730     nxlib.nxigetinfo_.restype = c_int 
    731     nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
    732     def getinfo(self): 
     733    nxlib.nxigetrawinfo_.restype = c_int 
     734    nxlib.nxigetrawinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
     735    def getrawinfo(self): 
    733736        """ 
    734737        Returns the tuple dimensions,type for the currently open dataset. 
     
    740743        complex values. 
    741744 
     745        Unlike getinfo(), the size of the string storage area is 
     746        returned rather than the length of the stored string. 
     747 
     748        Raises NeXusError if this fails. 
     749 
     750        Corresponds to NXgetrawinfo(handle, &rank, dims, &storage), 
     751        but with storage converted from HDF values to numpy compatible 
     752        strings, and rank implicit in the length of the returned dimensions. 
     753        """ 
     754        rank = c_int(0) 
     755        shape = numpy.zeros(MAXRANK, 'i') 
     756        storage = c_int(0) 
     757        status = nxlib.nxigetrawinfo_(self.handle, _ref(rank), shape.ctypes.data, 
     758                                     _ref(storage)) 
     759        if status == ERROR: 
     760            raise NeXusError, "Could not get data info: %s"%(self._loc()) 
     761        shape = shape[:rank.value]+0 
     762        dtype = _pytype_code[storage.value] 
     763        #print "getrawinfo",self._loc(),"->",shape,dtype 
     764        return shape,dtype 
     765 
     766    nxlib.nxigetinfo_.restype = c_int 
     767    nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
     768    def getinfo(self): 
     769        """ 
     770        Returns the tuple dimensions,type for the currently open dataset. 
     771        Dimensions is an integer array whose length corresponds to the rank 
     772        of the dataset and whose elements are the size of the individual 
     773        dimensions.  Storage type is returned as a string, with 'char' for 
     774        a stored string, '[u]int[8|16|32]' for various integer values or 
     775        'float[32|64]' for floating point values.  No support for 
     776        complex values. 
     777 
     778        Unlike getrawinfo(), the length of the stored string is 
     779        returned rather than the size of the string storage area. 
     780 
    742781        Raises NeXusError if this fails. 
    743782 
     
    758797        shape = shape[:rank.value]+0 
    759798        dtype = _pytype_code[storage.value] 
    760         #print "data info",shape,dtype 
     799        #print "getinfo",self._loc(),"->",shape,dtype 
    761800        return shape,dtype 
    762801 
     
    771810        Corresponds to NXopendata(handle, name) 
    772811        """ 
    773         #print "opening data",name 
    774         status = nxlib.nxiopendata_(self.handle, name) 
     812        #print "opendata",self._loc(),name 
     813        if self._indata: 
     814            status = ERROR 
     815        else: 
     816            status = nxlib.nxiopendata_(self.handle, name) 
    775817        if status == ERROR: 
    776818            raise ValueError, "Could not open data %s: %s"%(name, self._loc()) 
     
    789831        Corresponds to NXclosedata(handle) 
    790832        """ 
    791         #print "closing data" 
     833        #print "closedata" 
    792834        status = nxlib.nxiclosedata_(self.handle) 
    793835        if status == ERROR: 
    794836            raise NeXusError,\ 
    795                 "Could not close data at %s"%(name,self._loc()) 
     837                "Could not close data at %s"%(self._loc()) 
    796838        self._path.pop() 
    797839        self._indata = False 
     
    815857        # TODO: With keywords for value and attr, this can be used for 
    816858        # TODO: makedata, opendata, putdata, putattr, putattr, ..., closedata 
    817         #print "Data",name,dtype,shape 
     859        #print "makedata",self._loc(),name,shape,dtype 
    818860        storage = _nxtype_code[str(dtype)] 
    819861        shape = numpy.array(shape,'i') 
     
    865907        Return the data.  If data is a string (1-D char array), a python 
    866908        string is returned.  If data is a scalar (1-D numeric array of 
    867         length 1), a python numeric scalar is returned. 
     909        length 1), a python scalar is returned.  If data is a string  
     910        array, a numpy array of type 'S#' where # is the maximum string 
     911        length is returned.  If data is a numeric array, a numpy array 
     912        is returned. 
    868913 
    869914        Raises ValueError if this fails. 
     
    873918        # TODO: consider accepting preallocated data so we don't thrash memory 
    874919        shape,dtype = self.getinfo() 
    875         datafn,pdata,size = self._poutput(dtype,shape) 
     920        data,pdata,size,datafn = self._poutput(dtype,shape) 
    876921        status = nxlib.nxigetdata_(self.handle,pdata) 
    877922        if status == ERROR: 
    878923            raise ValueError, "Could not read data: %s"%(self._loc()) 
    879         #print "data",ret() 
     924        #print "getdata",self._loc(),shape,dtype 
    880925        return datafn() 
    881926 
     
    894939        """ 
    895940        # TODO: consider accepting preallocated data so we don't thrash memory 
    896         shape,dtype = self.getinfo() 
    897         datafn,pdata,size = self._poutput(dtype,slab_shape) 
     941        shape,dtype = self.getrawinfo() 
     942        data,pdata,size,datafn = self._poutput(dtype,slab_shape) 
    898943        slab_offset = numpy.array(slab_offset,'i') 
    899944        slab_shape = numpy.array(slab_shape,'i') 
     
    916961        Corresponds to NXputdata(handle, data) 
    917962        """ 
    918         shape,dtype = self.getinfo() 
     963        shape,dtype = self.getrawinfo() 
     964        #print "putdata",self._loc(),shape,dtype 
    919965        data,pdata = self._pinput(data,dtype,shape) 
    920966        status = nxlib.nxiputdata_(self.handle,pdata) 
     
    935981        Corresponds to NXputslab(handle,data,offset,shape) 
    936982        """ 
    937         shape,dtype = self.getinfo() 
     983        shape,dtype = self.getrawinfo() 
    938984        data,pdata = self._pinput(data,dtype,slab_shape) 
    939985        slab_offset = numpy.array(slab_offset,'i') 
     
    10111057            raise NeXusError, "Could not get next attr: %s"%(self._loc()) 
    10121058        dtype = _pytype_code[storage.value] 
    1013         #print "next attr",name.value,length.value,dtype 
     1059        #print "getnextattr",name.value,length.value,dtype 
    10141060        return name.value, length.value, dtype 
    10151061 
     
    10271073        """ 
    10281074        if dtype is 'char': length += 1  # HDF4 needs zero-terminator 
    1029         datafn,pdata,size = self._poutput(str(dtype),[length]) 
     1075        data,pdata,size,datafn = self._poutput(str(dtype),[length]) 
    10301076        storage = c_int(_nxtype_code[str(dtype)]) 
    1031         #print "retrieving",name,length,dtype,size 
     1077        #print "getattr",self._loc(),name,length,size,dtype 
    10321078        size = c_int(size) 
    10331079        status = nxlib.nxigetattr_(self.handle,name,pdata,_ref(size),_ref(storage)) 
    10341080        if status == ERROR: 
    10351081            raise ValueError, "Could not read attr %s: %s" % (name,self._loc()) 
    1036         #print "attr",name,datafn(),size 
     1082        #print "getattr",self._loc(),name,datafn() 
    10371083        return datafn() 
    10381084 
     
    13041350        """ 
    13051351        Build space to collect a nexus data element. 
    1306         Returns datafn,data,size where 
    1307         - datafn is a lamba expression to extract the value out of the element. 
    1308         - pdata is the value to pass to C (effectively a void *) 
     1352        Returns data,pdata,size,datafn where 
     1353        - data is a python type to hold the returned data 
     1354        - pdata is the pointer to the start of the data 
    13091355        - size is the number of bytes in the data block 
    1310         Note that ret can return a string, a scalar or an array depending 
     1356        - datafn is a lamba expression to extract the return value from data 
     1357        Note that datafn can return a string, a scalar or an array depending 
    13111358        on the data type and shape of the data group. 
    13121359        """ 
     
    13141361            # string - use ctypes allocator 
    13151362            size = int(shape[0]) 
    1316             pdata = ctypes.create_string_buffer(size) 
    1317             datafn = lambda: pdata.value 
     1363            data = ctypes.create_string_buffer(size) 
     1364            pdata = data 
     1365            datafn = lambda: data.value 
    13181366        else: 
    1319             # numeric - use numpy array 
    1320             if dtype=='char': dtype = 'uint8' 
    1321             data = numpy.zeros(shape,dtype) 
     1367            # scalar, array or string list - use numpy array 
     1368            if dtype=='char':  
     1369                data = numpy.zeros(shape[:-1], dtype='S%i'%shape[-1]) 
     1370            else: 
     1371                data = numpy.zeros(shape, dtype) 
    13221372            if len(shape) == 1 and shape[0] == 1: 
    13231373                datafn = lambda: data[0] 
     
    13261376            pdata = data.ctypes.data 
    13271377            size = data.nbytes 
    1328         return datafn,pdata,size 
     1378        return data,pdata,size,datafn 
    13291379 
    13301380    def _pinput(self, data, dtype, shape): 
    13311381        """ 
    1332         Convert an input array to a C pointer to a dense array.  This may 
    1333         require conversion of the array, so the new array is returned along 
    1334         with its pointer. 
     1382        Convert an input array to a C pointer to a dense array. 
     1383 
     1384        Returns data, pdata where  
     1385        - data is a possibly new copy of the array 
     1386        - pdata is a pointer to the beginning of the array.   
     1387        Note that you must hold a reference to data for as long  
     1388        as you need pdata to keep the memory from being released to the heap. 
    13351389        """ 
    13361390        if dtype == "char": 
    1337             # Character data - pad with zeros to the right length 
    1338             if not _is_string_like(data): 
    1339                 raise ValueError,"Expected character data: %s"%(self._loc()) 
    1340             if len(data) < shape[0]: 
    1341                 data += '\000'*(shape[0]-len(data)) 
     1391            data = numpy.asarray(data, dtype='S%d'%(shape[-1])) 
    13421392        else: 
    13431393            # Convert scalars to vectors of length one 
    13441394            if numpy.prod(shape) == 1 and not hasattr(data,'shape'): 
    1345                 data = numpy.array([data],dtype=dtype) 
     1395                data = numpy.array([data], dtype=dtype) 
    13461396            # Check that dimensions match 
    13471397            # Ick! need to exclude dimensions of length 1 in order to catch 
     
    13491399            input_shape = numpy.array([i for i in data.shape if i != 1]) 
    13501400            target_shape = numpy.array([i for i in shape if i != 1]) 
    1351             if len(input_shape) != len(target_shape) or (input_shape != target_shape).any(): 
     1401            if len(input_shape) != len(target_shape) \ 
     1402                    or (input_shape != target_shape).any(): 
    13521403                raise ValueError,\ 
    1353                     "Shape mismatch %s!=%s: %s"%(data.shape,shape,self.filename) 
     1404                    "Shape mismatch %s!=%s: %s"%(data_shape,shape,self._loc()) 
     1405            # Check data type 
    13541406            if str(data.dtype) != dtype: 
    13551407                raise ValueError,\ 
    13561408                    "Type mismatch %s!=%s: %s"%(dtype,data.dtype,self._loc()) 
    13571409 
    1358         if dtype == 'char': 
    1359             # String: hand it over as usual for strings.  Assumes the string 
    1360             # is the correct length for the storage area. 
    1361             pdata = data 
    1362         else: 
    1363             # Vector: assume it is of the correct storage class and size 
    1364             data = numpy.ascontiguousarray(data) 
    1365             pdata = data.ctypes.data 
    1366  
     1410        data = numpy.ascontiguousarray(data) 
     1411        pdata = data.ctypes.data 
     1412             
    13671413        return data,pdata 
    13681414 
  • branches/4.2/bindings/python/nxstest.py

    r1180 r1230  
    132132    # .. demonstrate extensible data 
    133133    file.makedata('flush_data','int32',[nxs.UNLIMITED]) 
     134    file.opendata('flush_data') 
    134135    for i in range(7): 
    135         file.opendata('flush_data') 
    136136        file.putslab(i,[i],[1]) 
    137         file.flush() 
    138         # Oops... why isn't there a closedata()? 
     137    file.closedata() 
     138    file.flush() 
    139139    file.closegroup() 
    140140 
     
    142142    file.makegroup('sample','NXsample') 
    143143    file.opengroup('sample','NXsample') 
    144     file.makedata('ch_data','char',[12]) 
     144    file.makedata('ch_data','char',[20]) 
    145145    file.opendata('ch_data') 
    146146    file.putdata('NeXus sample') 
     
    231231            fail("%s retrieved %s"%(dtype,get)) 
    232232 
     233 
    233234    # Check attribute types 
    234235    file.opendata('r8_data') 
     
    255256    for i in range(100): comp_array[i,:] *= i 
    256257    expected = comp_array 
    257     file.opengroup('data','NXdata') 
    258     file.opendata('comp_data') 
     258    file.opengroup('data','NXdata') #/entry/data 
     259    file.opendata('comp_data')      #/entry/data/comp_data 
    259260    get = file.getdata() 
    260     file.closedata()  #/entry/data/comp_data 
    261     file.closegroup() #/entry/data 
     261    file.closedata()                #/entry/data/comp_data 
     262    file.closegroup()               #/entry/data 
    262263    if not (get == expected).all(): 
    263264        fail("compressed data differs") 
    264265        print get 
     266         
     267    # Check strings 
     268    file.opengroup('sample','NXsample') #/entry/sample 
     269    file.opendata('ch_data')            #/entry/sample/ch_data 
     270    rawshape,rawdtype = file.getrawinfo() 
     271    shape,dtype = file.getinfo() 
     272    get = file.getdata() 
     273    file.closedata()                    #/entry/sample/ch_data 
     274    file.closegroup()                   #/entry/sample 
     275    if not (shape[0]==12 and dtype=='char'): 
     276        fail("returned string info is incorrect") 
     277        print shape,dtype 
     278    if not (rawshape[0]==20 and rawdtype=='char'): 
     279        fail("returned string storage info is incorrect") 
     280        print shape,dtype 
     281    if not (get == "NeXus sample"): 
     282        fail("returned string is incorrect") 
     283        print shape,dtype 
     284 
     285 
    265286    file.closegroup() #/entry 
    266          
     287 
    267288    # Check read slab (e.g., from extensible) 
    268289 
  • branches/4.2/doc/doxygen/Doxyfile.in

    r1058 r1230  
    407407# by doxygen. Possible values are YES and NO. If left blank NO is used. 
    408408 
    409 QUIET                  = NO 
     409QUIET                  = YES 
    410410 
    411411# The WARNINGS tag can be used to turn on/off the warning messages that are  
     
    10071007 
    10081008PREDEFINED             = \ 
    1009         HDF4 \ 
    1010         HDF5 \ 
    1011         NXXML 
     1009        HDF4=1 \ 
     1010        HDF5=1 \ 
     1011        NXXML=1 \ 
     1012        NXDLL_EXPORT= 
    10121013 
    10131014# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then  
  • branches/4.2/include/napi.h

    r1206 r1230  
    2727/** \file  
    2828 * Documentation for the NeXus-API version 4.2 
    29  * 2000-2007, the NeXus group  
     29 * 2000-2007, the NeXus group 
     30 * \defgroup c_main C API  
     31 * \defgroup c_types Data Types 
     32 * \ingroup c_main 
     33 * \defgroup c_init General Initialisation and shutdown 
     34 * \ingroup c_main 
     35 * \defgroup c_readwrite Reading and Writing 
     36 * \ingroup c_main 
     37 * \defgroup c_metadata Meta data routines 
     38 * \ingroup c_main 
     39 * \defgroup c_linking Linking and Group hierarchy 
     40 * \ingroup c_main 
     41 * \defgroup c_memory Memory allocation 
     42 * \ingroup c_main 
     43 * \defgroup c_external External linking 
     44 * \ingroup c_main 
     45 * \defgroup cpp_main C++ API 
    3046 */ 
    3147   
     
    95111 
    96112/** \var NeXus data types 
     113 * \ingroup c_types 
    97114 * \li NX_FLOAT32     32 bit float 
    98115 * \li NX_FLOAT64     64 nit float == double 
     
    182199 
    183200#    define NXgetinfo           MANGLE(nxigetinfo) 
     201#    define NXgetrawinfo        MANGLE(nxigetrawinfo) 
    184202#    define NXgetnextentry      MANGLE(nxigetnextentry) 
    185203#    define NXgetdata           MANGLE(nxigetdata) 
     
    243261   * \param pHandle A file handle which will be initialized upon successfull completeion of NXopen. 
    244262   * \return NX_OK on success, NX_ERROR in the case of an error.    
     263   * \ingroup c_init 
    245264   */ 
    246265extern  NXstatus  NXopen(CONSTCHAR * filename, NXaccess access_method, NXhandle* pHandle); 
     266 
    247267  /** 
    248268   * close a NeXus file 
     
    250270   * call. 
    251271   * \return NX_OK on success, NX_ERROR in the case of an error.    
     272   * \ingroup c_init 
    252273   */ 
    253274extern  NXstatus  NXclose(NXhandle* pHandle); 
     275 
    254276  /** 
    255277   * flush data to disk 
    256278   * \param pHandle A NeXus file handle as initialized by NXopen.  
    257279   * \return NX_OK on success, NX_ERROR in the case of an error.    
     280   * \ingroup c_readwrite 
    258281   */ 
    259282extern  NXstatus  NXflush(NXhandle* pHandle); 
     
    266289   * \param NXclass the class name of the group. Should start with the prefix NX 
    267290   * \return NX_OK on success, NX_ERROR in the case of an error.    
     291   * \ingroup c_init 
    268292   */ 
    269293extern  NXstatus  NXmakegroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); 
     294 
    270295  /** 
    271296   * Step into a group. All further access will be within the opened group. 
     
    274299   * \param NXclass the class name of the group. Should start with the prefix NX 
    275300   * \return NX_OK on success, NX_ERROR in the case of an error.    
     301   * \ingroup c_init 
    276302   */ 
    277303extern  NXstatus  NXopengroup (NXhandle handle, CONSTCHAR *name, CONSTCHAR* NXclass); 
     304 
    278305  /** 
    279306   * Open the NeXus object with the path specified 
     
    283310   * Example: /entry1/sample/name  
    284311   * \return NX_OK on success, NX_ERROR in the case of an error.    
     312   * \ingroup c_init 
    285313   */ 
    286314extern  NXstatus  NXopenpath (NXhandle handle, CONSTCHAR *path); 
     315 
    287316  /** 
    288317   * Opens the group in which the NeXus object with the specified path exists 
     
    292321   * Example: /entry1/sample/name  
    293322   * \return NX_OK on success, NX_ERROR in the case of an error.    
     323   * \ingroup c_readwrite 
    294324   */ 
    295325extern  NXstatus  NXopengrouppath (NXhandle handle, CONSTCHAR *path); 
     326 
    296327  /** 
    297328   * Closes the currently open group and steps one step down in the NeXus file  
    298329   * hierarchy. 
    299330   * \return NX_OK on success, NX_ERROR in the case of an error.    
     331   * \ingroup c_init 
    300332   */ 
    301333extern  NXstatus  NXclosegroup(NXhandle handle); 
     334 
    302335  /** 
    303336   * Create a multi dimensional data array or dataset. The dataset is NOT opened.  
     
    309342   * can be NX_UNLIMITED. Data can be appended to such a dimension using NXputslab.  
    310343   * \return NX_OK on success, NX_ERROR in the case of an error.    
     344   * \ingroup c_init 
    311345   */ 
    312346extern  NXstatus  NXmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); 
     347 
    313348  /** 
    314349   * Create a compressed dataset. The dataset is NOT opened. Data from this set will automatically be compressed when  
     
    329364   * should be the same as the data dimension. If you write it in slabs, this is your preferred slab size.  
    330365   * \return NX_OK on success, NX_ERROR in the case of an error.    
     366   * \ingroup c_init 
    331367   */ 
    332368extern  NXstatus  NXcompmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[], int comp_typ, int bufsize[]); 
     369 
    333370  /** 
    334371   * Switch compression on. This routine is superseeded by NXcompmakedata and thus  
     
    340377   * \li NX_COMP_RLE run length encoding (only HDF-4) 
    341378   * \li NX_COMP_HUF Huffmann encoding (only HDF-4) 
     379   * \ingroup c_init 
    342380   */ 
    343381extern  NXstatus  NXcompress (NXhandle handle, int compr_type); 
     382 
    344383  /** 
    345384   * Open access to a dataset. After this call it is possible to write and read data or  
     
    348387   * \param label The name of the dataset 
    349388   * \return NX_OK on success, NX_ERROR in the case of an error.    
     389   * \ingroup c_init 
    350390   */ 
    351391extern  NXstatus  NXopendata (NXhandle handle, CONSTCHAR* label); 
     392 
    352393  /** 
    353394   * Close access to a dataset.  
    354395   * \param handle A NeXus file handle as initialized by NXopen.  
    355396   * \return NX_OK on success, NX_ERROR in the case of an error.    
     397   * \ingroup c_readwrite 
    356398   */ 
    357399extern  NXstatus  NXclosedata(NXhandle handle); 
     400 
    358401  /** 
    359402   * Write data to a datset which has previouly been opened with NXopendata.  
     
    363406   * \param data Pointer to data to write. 
    364407   * \return NX_OK on success, NX_ERROR in the case of an error.    
     408   * \ingroup c_init 
    365409   */ 
    366410extern  NXstatus  NXputdata(NXhandle handle, void* data); 
     411 
    367412  /** 
    368413   * Write an attribute. The kind of attribute written depends on the   
     
    376421   * \param iType The NeXus data type of the attribute.  
    377422   * \return NX_OK on success, NX_ERROR in the case of an error.    
     423   * \ingroup c_readwrite 
    378424   */ 
    379425extern  NXstatus  NXputattr(NXhandle handle, CONSTCHAR* name, void* data, int iDataLen, int iType); 
     426 
    380427  /** 
    381428   * Write  a subset of a multi dimensional dataset. 
     
    385432   * \param size An array holding the size of the data subset to write in each dimension. 
    386433   * \return NX_OK on success, NX_ERROR in the case of an error.    
     434   * \ingroup c_readwrite 
    387435   */ 
    388436extern  NXstatus  NXputslab(NXhandle handle, void* data, int start[], int size[]);     
     437 
    389438  /** 
    390439   * Retrieve link data for a dataset. This link data can later on be used to link this  
     
    394443   * for linking.  
    395444   * \return NX_OK on success, NX_ERROR in the case of an error.    
     445   * \ingroup c_readwrite 
    396446   */ 
    397447extern  NXstatus  NXgetdataID(NXhandle handle, NXlink* pLink); 
     448 
    398449  /** 
    399450   * Create a link to the group or dataset described by pLink in the currently open  
     
    403454   * by either a call to NXgetdataID or NXgetgroupID. 
    404455   * \return NX_OK on success, NX_ERROR in the case of an error.    
     456   * \ingroup c_readwrite 
    405457   */ 
    406458extern  NXstatus  NXmakelink(NXhandle handle, NXlink* pLink); 
     459 
    407460  /** 
    408461   * Create a link to the group or dataset described by pLink in the currently open  
     
    413466   * by either a call to NXgetdataID or NXgetgroupID. 
    414467   * \return NX_OK on success, NX_ERROR in the case of an error.    
     468   * \ingroup c_linking 
    415469   */ 
    416470extern  NXstatus  NXmakenamedlink(NXhandle handle, CONSTCHAR* newname, NXlink* pLink); 
     471 
    417472  /** 
    418473   * Open the source group of a linked group or dataset. Returns an error when the item is  
     
    420475   * \param handle A NeXus file handle as initialized by NXopen. 
    421476   * \return NX_OK on success, NX_ERROR in the case of an error.    
     477   * \ingroup c_linking 
    422478   */ 
    423479extern  NXstatus  NXopensourcegroup(NXhandle handle); 
     480 
    424481  /** 
    425482   * Read a complete dataset from the currently open dataset into memory.  
     
    429486   * and unwelcome ways. 
    430487   * \return NX_OK on success, NX_ERROR in the case of an error.    
     488   * \ingroup c_readwrite 
    431489   */ 
    432490extern  NXstatus  NXgetdata(NXhandle handle, void* data); 
     491 
    433492  /** 
    434493   * Retrieve information about the curretly open dataset. 
     
    440499   * \param datatype A pointer to an integer which be set to the NeXus data type code for this dataset. 
    441500   * \return NX_OK on success, NX_ERROR in the case of an error.    
     501   * \ingroup c_metadata 
    442502   */ 
    443503extern  NXstatus  NXgetinfo(NXhandle handle, int* rank, int dimension[], int* datatype); 
     504 
    444505  /** 
    445506   * Get the next entry in the currently open group. This is for retrieving infromation about the  
     
    451512   * \param datatype The NeXus data type if the item is a SDS.  
    452513   * \return NX_OK on success, NX_ERROR in the case of an error, NX_EOD when there are no more items.    
     514   * \ingroup c_readwrite 
    453515   */ 
    454516extern  NXstatus  NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int* datatype); 
     517 
    455518  /** 
    456519   * Read a subset of data from file into memory.  
     
    461524   * \param size An array holding the size of the data subset to read for each dimension. 
    462525   * \return NX_OK on success, NX_ERROR in the case of an error.    
     526   * \ingroup c_readwrite 
    463527   */ 
    464528extern  NXstatus  NXgetslab(NXhandle handle, void* data, int start[], int size[]); 
     529 
    465530  /** 
    466531   * Iterate over global, group or dataset attributes depending on the currently open group or  
     
    472537   * \param iType A pointer to an integer which be set to the NeXus data type of the attribute. 
    473538   * \return NX_OK on success, NX_ERROR in the case of an error, NX_EOD when there are no more items.    
     539   * \ingroup c_readwrite 
    474540   */ 
    475541extern  NXstatus  NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType); 
     542 
    476543  /** 
    477544   * Read an attribute. 
     
    482549   * \param iType A pointer to an integer which will had been set to the NeXus data type of the attribute. 
    483550   * \return NX_OK on success, NX_ERROR in the case of an error.    
     551   * \ingroup c_readwrite 
    484552   */ 
    485553extern  NXstatus  NXgetattr(NXhandle handle, char* name, void* data, int* iDataLen, int* iType); 
     554 
    486555  /** 
    487556   * Get the count of attributes in the currently open dataset, group or global attributes when at root level. 
     
    489558   * \param no_items A pointer to an integer which be set to the number of attributes available. 
    490559   * \return NX_OK on success, NX_ERROR in the case of an error.    
     560   * \ingroup c_readwrite 
    491561   */ 
    492562extern  NXstatus  NXgetattrinfo(NXhandle handle, int* no_items); 
     563 
    493564  /** 
    494565   * Retrieve link data for the currently open group. This link data can later on be used to link this  
     
    498569   * for linking.  
    499570   * \return NX_OK on success, NX_ERROR in the case of an error.    
     571   * \ingroup c_readwrite 
    500572   */ 
    501573extern  NXstatus  NXgetgroupID(NXhandle handle, NXlink* pLink); 
     574 
    502575  /** 
    503576   * Retrieve information about the currently open group. 
     
    509582   * \param nxclass The NeXus class name of the group. 
    510583   * \return NX_OK on success, NX_ERROR in the case of an error.    
     584   * \ingroup c_readwrite 
    511585   */ 
    512586extern  NXstatus  NXgetgroupinfo(NXhandle handle, int* no_items, NXname name, NXname nxclass); 
     587 
    513588  /** 
    514589   * Tests if two link data structures describe the same item. 
     
    517592   * \param pSecondID The second link data structure. 
    518593   * \return NX_OK when both link data structures describe the same item, NX_ERROR else.    
     594   * \ingroup c_readwrite 
    519595   */ 
    520596extern  NXstatus  NXsameID(NXhandle handle, NXlink* pFirstID, NXlink* pSecondID); 
     
    524600   * \param handle A NeXus file handle as initialized by NXopen. 
    525601   * \return NX_OK on success, NX_ERROR in the case of an error.    
     602   * \ingroup c_readwrite 
    526603   */ 
    527604extern  NXstatus  NXinitgroupdir(NXhandle handle); 
     605 
    528606  /** 
    529607   * Resets a pending attribute search to the start again. To be called in a Nxgetnextattr loop when  
     
    531609   * \param handle A NeXus file handle as initialized by NXopen. 
    532610   * \return NX_OK on success, NX_ERROR in the case of an error.    
     611   * \ingroup c_readwrite 
    533612   */ 
    534613extern  NXstatus  NXinitattrdir(NXhandle handle); 
     614 
    535615  /** 
    536616   * Sets the format for number printing. This call has only an effect when using the XML physical file  
     
    540620   * \param format The C-language format string to use for this data type. 
    541621   * \return NX_OK on success, NX_ERROR in the case of an error.    
     622   * \ingroup c_readwrite 
    542623   */ 
    543624extern  NXstatus  NXsetnumberformat(NXhandle handle, int type, char *format); 
     625 
    544626  /** 
    545627   * Inquire the filename of the currently open file. FilenameBufferLength of the file name  
     
    549631   * \param  filenameBufferLength The length of the filename buffer. 
    550632   * \return NX_OK on success, NX_ERROR in the case of an error.    
     633   * \ingroup c_readwrite 
    551634   */ 
    552635extern  NXstatus  NXinquirefile(NXhandle handle, char *filename, int filenameBufferLength); 
     636 
    553637  /** 
    554638   * Test if a group is actually pointing to an external file. If so, retrieve the URL of the  
     
    560644   * \param urlLen The length of the Url buffer. At maximum urlLen bytes will be copied to url. 
    561645   * \return NX_OK when the group is pointing to an external file, NX_ERROR else. 
     646   * \ingroup c_readwrite 
    562647   */ 
    563648extern  NXstatus  NXisexternalgroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *nxclass, char *url, int urlLen);  
     649 
    564650  /** 
    565651   * Create a link to an external file. This works by creating a NeXus group under the current level in  
     
    572658   * path to the group in the external file which appears in the first file.   
    573659   * \return NX_OK on success, NX_ERROR in the case of an error.    
     660   * \ingroup c_readwrite 
    574661   */ 
    575662extern  NXstatus  NXlinkexternal(NXhandle handle, CONSTCHAR *name, CONSTCHAR *nxclass, CONSTCHAR *url); 
     663 
    576664  /** 
    577665   * Utility function which allocates a suitably sized memory area for the dataset characteristics specified. 
     
    581669   * \param datatype The NeXus data type of the data. 
    582670   * \return NX_OK when allocation succeeds, NX_ERROR in the case of an error.    
     671   * \ingroup c_memory 
    583672   */  
    584673extern  NXstatus  NXmalloc(void** data, int rank, int dimensions[], int datatype); 
     674 
    585675  /** 
    586676   * Utility function to release the memory for data. 
    587677   * \param data A pointer to a pointer to free. 
    588678   * \return NX_OK on success, NX_ERROR in the case of an error.    
     679   * \ingroup c_memory 
    589680   */ 
    590681extern  NXstatus  NXfree(void** data); 
     
    594685    NAPI internals  
    595686------------------------------------------------------------------------*/ 
     687  /** 
     688   * Retrieve information about the currently open dataset. In contrast to the main function below,  
     689   * this function does not try to find out about the size of strings properly.  
     690   * \param handle A NeXus file handle as initialized by NXopen. 
     691   * \param rank A pointer to an integer which will be filled with the rank of  
     692   * the dataset. 
     693   * \param dimension An array which will be initialized with the size of the dataset in any of its  
     694   * dimensions. The array must have at least the size of rank. 
     695   * \param datatype A pointer to an integer which be set to the NeXus data type code for this dataset. 
     696   * \return NX_OK on success, NX_ERROR in the case of an error.    
     697   * \ingroup c_metadata 
     698   */ 
     699extern  NXstatus  NXgetrawinfo(NXhandle handle, int* rank, int dimension[], int* datatype); 
     700 
    596701/** \typedef void (*ErrFunc)(void *data, char *text) 
    597702 * All NeXus error reporting happens through this special function, the  
     
    603708 */ 
    604709typedef void (*ErrFunc)(void *data, char *text); 
     710 
    605711  /** 
    606712   * Set an error function. 
     
    610716   */ 
    611717extern  void  NXMSetError(void *pData, ErrFunc newErr); 
     718 
    612719  /** 
    613720   * Retrieve the current error display function 
     
    615722   */ 
    616723extern ErrFunc NXMGetError(); 
     724 
    617725  /** 
    618726   * Suppress error reports from the NeXus-API 
    619727   */ 
    620728extern  void  NXMDisableErrorReporting(); 
     729 
    621730  /** 
    622731   * Enable error reports from the NeXus-API 
  • branches/4.2/src/napi.c

    r1104 r1230  
    3535#include "napi.h" 
    3636#include "nxstack.h" 
     37 
     38/** 
     39 * \mainpage NeXus API documentation 
     40 * \section sec_purpose Purpose of API 
     41 * The NeXus Application Program Interface is a suite of subroutines, written in C but with wrappers in Fortran 77 and 90.  
     42 *  The subroutines call HDF routines to read and write the NeXus files with the correct structure.  
     43 * An API serves a number of useful purposes:  
     44 * - It simplifies the reading and writing of NeXus files.  
     45 * - It ensures a certain degree of compliance with the NeXus standard.  
     46 * - It allows the development of sophisticated input/output features such as automatic unit conversion. This has not been implemented yet.  
     47 * - It hides the implementation details of the format. In particular, the API can read and write HDF4,  
     48     HDF5 (and shortly XML) files using the same routines.  
     49 * For these reasons, we request that all NeXus files are written using the supplied API. We cannot be  
     50 * sure that anything written using the underlying HDF API will be recognized by NeXus-aware utilities.  
     51 * 
     52 * \section sec_core Core API 
     53 * The core API provides the basic routines for reading, writing and navigating NeXus files. It is designed to be modal;  
     54 * there is a hidden state that determines which groups and data sets are open at any given moment, and  
     55 * subsequent operations are implicitly performed on these entities. This cuts down the number of parameters  
     56 * to pass around in API calls, at the cost of forcing a certain pre-approved mode d'emploi. This mode d'emploi  
     57 * will be familiar to most: it is very similar to navigating a directory hierarchy; in our case, NeXus groups are the  
     58 * directories, which contain data sets and/or other directories.  
     59 * 
     60 * The core API comprises several functional groups which are listed on the \b Modules tab  
     61 * 
     62 * C programs that call the above routines should include the following header file:  
     63 * \code 
     64 * #include "napi.h" 
     65 * \endcode 
     66 */ 
     67 
     68 
    3769 
    3870/*--------------------------------------------------------------------- 
     
    825857    return status; 
    826858  } 
    827      
     859/*---------------------------------------------------------------------------*/ 
     860  NXstatus  NXgetrawinfo (NXhandle fid, int *rank,  
     861                                    int dimension[], int *iType) 
     862  { 
     863    int status; 
     864    char *pPtr = NULL; 
     865 
     866    pNexusFunction pFunc = handleToNexusFunc(fid); 
     867    status = pFunc->nxgetinfo(pFunc->pNexusData, rank, dimension, iType); 
     868    return status; 
     869  } 
    828870  /*-------------------------------------------------------------------------*/ 
    829871  
  • branches/4.2/src/napi4.c

    r1085 r1230  
    11451145    iRet = SDwritedata (pFile->iCurrentSDS, iStart, iStride, iSize, data); 
    11461146    if (iRet < 0) { 
     1147      /* HEprint(stdout,0); */ 
    11471148      sprintf (pError, "ERROR: failure to write data to %s", pBuffer); 
    11481149      NXIReportError (NXpData, pError); 
  • branches/4.2/src/napi5.c

    r1111 r1230  
    17981798     vid = getAttVID(pFile); 
    17991799 
     1800     pName[0] = '\0'; 
    18001801     idx=pFile->iAtt5.iCurrentIDX; 
    18011802     iRet=0; 
  • branches/4.2/src/napi_exports.h

    r942 r1230  
    256256    return NXmakenamedlink(fid, newname, pLink); 
    257257} 
     258 
     259NXstatus CALL_MODE NXIGETRAWINFO(NXhandle handle, int* rank, int dimension[], int* datatype) 
     260{ 
     261    return NXgetrawinfo(handle, rank, dimension, datatype); 
     262} 
     263 
  • branches/4.2/src/nexus_symbols_win.txt

    r942 r1230  
    2222NXIGETNEXTATTR@16 
    2323NXIGETNEXTENTRY@16 
     24NXIGETRAWINFO@16 
    2425NXIGETSLAB@16 
    2526NXIINITATTRDIR@4 
Note: See TracChangeset for help on using the changeset viewer.