Exemplo n.º 1
0
def load_data_2d(file_full_name, dtype=None, out_of_core=False):
    dtype = python_dtype_to_Vivaldi_dtype(dtype)
    file_name, extension = split_file_name_and_extension(file_full_name)
    el = extension.lower()
    if out_of_core:
        if extension == 'dat':
            file_info = matrixio.read_dat(filename, out_of_core=True)
            file_name = file_info['FileName']
            assert (file_name != None)

            if 'Path' in file_info:
                # user defined path
                path = file_info['Path']
            else:
                # default is find same folder
                idx = file_full_name.rfind('/')
                path = file_full_name[:idx + 1]

            shape = file_info['Resolution'].split()
            shape[0], shape[1] = int(shape[1]), int(shape[0])
            contents_dtype = file_info['Format'].lower()
            chan = 1

            temp = Data_package()
            temp.out_of_core = True

            temp.data_dtype = numpy.ndarray
            temp.file_name = path + file_name
            temp.file_dtype = python_dtype_to_Vivaldi_dtype(contents_dtype)

            temp.buffer_dtype = numpy.ndarray
            if dtype != None: dtype = dtype
            else: dtype = contents_dtype
            if chan != 1: dtype += str(chan)

            temp.set_buffer_contents_dtype(dtype)

            data_range = shape_to_range(shape)
            temp.set_data_range(data_range)
            temp.set_buffer_range(data_range)
            temp.set_full_buffer_range(data_range)

            return temp

    else:
        st = time.time()
        data = matrixio.read_2d_data(file_full_name)

        dtype = Vivaldi_dtype_to_python_dtype(dtype)
        if dtype != None:
            data = data.astype(dtype)
        else:
            dtype = data.dtype
        print 'load_data_2d_rgb:', file_full_name, 'dtype:', data.dtype, 'shape:', data.shape, 'loading time:', 1000 * (
            time.time() - st), 'ms'

        return data
    return None
Exemplo n.º 2
0
def load_data_2d(file_full_name, dtype=None, out_of_core=False):
	dtype = python_dtype_to_Vivaldi_dtype(dtype)
	file_name, extension = split_file_name_and_extension(file_full_name)
	el = extension.lower()
	if out_of_core:
		if extension == 'dat':
			file_info = matrixio.read_dat(file_full_name, out_of_core=True)
			file_name = file_info['FileName']
			assert(file_name != None)
			
			if 'Path' in file_info:
				# user defined path
				path = file_info['Path']
			else:
				# default is find same folder
				idx = file_full_name.rfind('/')
				path = file_full_name[:idx+1] 

			shape = file_info['Resolution'].split()
			shape[0],shape[1] = int(shape[1]),int(shape[0])
			contents_dtype = file_info['Format'].lower()
			chan = 1

			temp = Data_package()
			temp.out_of_core = True

			temp.data_dtype = numpy.ndarray
			temp.file_name = path + file_name
			temp.file_dtype = python_dtype_to_Vivaldi_dtype(contents_dtype)

			temp.buffer_dtype = numpy.ndarray
			if dtype != None: dtype = dtype
			else: dtype = contents_dtype
			if chan != 1: dtype += str(chan)
	
			temp.set_buffer_contents_dtype(dtype)
	
			data_range = shape_to_range(shape)
			temp.set_data_range(data_range)
			temp.set_buffer_range(data_range)
			temp.set_full_buffer_range(data_range)

			return temp

	else:
		st = time.time()
		data = matrixio.read_2d_data(file_full_name)

		dtype = Vivaldi_dtype_to_python_dtype(dtype)
		if dtype != None:
			data = data.astype(dtype)
		else: dtype = data.dtype
		#print 'load_data_2d_rgb:', file_full_name, 'dtype:', data.dtype, 'shape:', data.shape,'loading time:',1000*(time.time()-st),'ms'
	
		return data
	return None