Ejemplo n.º 1
0
 def __init__(self, filename, access=sns_napi.ACC_READ):
     self.__HANDLE__ = sns_napi.open(filename, access)
     if self.__HANDLE__ is None:
         raise SystemError("Failed to read file: %s" % filename)
     self.__filename    = filename
     self.__path        = []
     self.__dataopen    = False
Ejemplo n.º 2
0
def getdata(handle):
    data=sns_napi.getdata(handle)
    nessi_data=nessi_list.NessiList()
    nessi_data.__array__.__set_from_NessiVector__(nessi_data.__array__,data)
    return nessi_data

def getslab(handle,start,size):
    data=sns_napi.getslab(handle,start,size)
    nessi_data=nessi_list.NessiList()
    nessi_data.__array__.__set_from_NessiVector__(nessi_data.__array__,data)
    return nessi_data

print dir(sns_napi)
#help(sns_napi)
handle=sns_napi.open("/SNS/users/pf9/REF_M_50-zipped.nxs")
print "opengroup(entry,NXentry)",sns_napi.opengroup(handle,"entry","NXentry")
#print "opengroup(data,NXdata)",sns_napi.opengroup(handle,"data","NXdata")
print "opengroup(bank1,NXdata)",sns_napi.opengroup(handle,"bank1","NXdata")
print "getnextentry()",sns_napi.getnextentry(handle)
print "getnextentry()",sns_napi.getnextentry(handle)
print "opendata(x_pixel_offset)",sns_napi.opendata(handle,"x_pixel_offset")
print "getattr(axis)",sns_napi.getattr(handle,"axis")
print "getattr(units)",sns_napi.getattr(handle,"units")
xpo=sns_napi.getdata(handle)
print "getdata()",xpo.__type__,xpo,len(xpo)
print "closedata()",sns_napi.closedata(handle)
print "opendata(data)",sns_napi.opendata(handle,"data")
(dims,type)=sns_napi.getinfo(handle)
print "getinfo()",(dims,type)
print "getnextattr()",sns_napi.getnextattr(handle)
Ejemplo n.º 3
0
if __name__ == "__main__":
    # deal with the command line
    import sys
    try:
        infile = sys.argv[1]
    except IndexError:
        print_help()
        sys.exit(-1)
    if not file_exists(infile):
        print "File [%s] does not exist" % infile
        print_help()
        sys.exit(-1)
    outfile = outname(infile)

    # get to the data object
    inhandle = sns_napi.open(infile)
    sns_napi.opengroup(inhandle, "entry", "NXentry")
    sns_napi.opengroup(inhandle, "data", "NXdata")
    sns_napi.opendata(inhandle, "data")
    (dims, nxclass) = sns_napi.getinfo(inhandle)
    print "DIMS = ", dims
    print "TYPE = ", nxclass
    data = getdata(inhandle, dims, False)
    axis_length = dims[2]
    data_size = 1
    for item in dims:
        data_size *= item
    print "SIZE:", len(data), data_size

    # print the data to a file
    print "writing to", outfile
Ejemplo n.º 4
0
    data = sns_napi.getdata(handle)
    nessi_data = nessi_list.NessiList()
    nessi_data.__array__.__set_from_NessiVector__(nessi_data.__array__, data)
    return nessi_data


def getslab(handle, start, size):
    data = sns_napi.getslab(handle, start, size)
    nessi_data = nessi_list.NessiList()
    nessi_data.__array__.__set_from_NessiVector__(nessi_data.__array__, data)
    return nessi_data


print dir(sns_napi)
#help(sns_napi)
handle = sns_napi.open("/SNS/users/pf9/REF_M_50-zipped.nxs")
print "opengroup(entry,NXentry)", sns_napi.opengroup(handle, "entry",
                                                     "NXentry")
#print "opengroup(data,NXdata)",sns_napi.opengroup(handle,"data","NXdata")
print "opengroup(bank1,NXdata)", sns_napi.opengroup(handle, "bank1", "NXdata")
print "getnextentry()", sns_napi.getnextentry(handle)
print "getnextentry()", sns_napi.getnextentry(handle)
print "opendata(x_pixel_offset)", sns_napi.opendata(handle, "x_pixel_offset")
print "getattr(axis)", sns_napi.getattr(handle, "axis")
print "getattr(units)", sns_napi.getattr(handle, "units")
xpo = sns_napi.getdata(handle)
print "getdata()", xpo.__type__, xpo, len(xpo)
print "closedata()", sns_napi.closedata(handle)
print "opendata(data)", sns_napi.opendata(handle, "data")
(dims, type) = sns_napi.getinfo(handle)
print "getinfo()", (dims, type)
Ejemplo n.º 5
0
if __name__=="__main__":
    # deal with the command line
    import sys
    try:
        infile=sys.argv[1]
    except IndexError:
        print_help()
        sys.exit(-1)
    if not file_exists(infile):
        print "File [%s] does not exist" % infile
        print_help()
        sys.exit(-1)
    outfile=outname(infile)

    # get to the data object
    inhandle=sns_napi.open(infile)
    sns_napi.opengroup(inhandle,"entry","NXentry")
    sns_napi.opengroup(inhandle,"data","NXdata")
    sns_napi.opendata(inhandle,"data")
    (dims,nxclass)=sns_napi.getinfo(inhandle)
    print "DIMS = ",dims
    print "TYPE = ",nxclass
    data=getdata(inhandle,dims,False)
    axis_length=dims[2]
    data_size=1
    for item in dims:
        data_size*=item
    print "SIZE:",len(data),data_size

    # print the data to a file
    print "writing to",outfile