def get_var(self, name):
<EOL>rank = self.get_var_rank(name)<EOL>shape = np.empty((MAXDIMS, ), dtype='<STR_LIT>', order='<STR_LIT:F>')<EOL>shape = self.get_var_shape(name)<EOL>assert sum(shape[rank:]) == <NUM_LIT:0><EOL>type_ = self.get_var_type(name)<EOL>is_numpytype = type_ in TYPEMAP<EOL>if is_numpytype:<EOL><INDENT>arraytype = ndpointer(dtype=TYPEMAP[type_],<EOL>ndim=rank,<EOL>shape=shape,<EOL>flags='<STR_LIT:F>')<EOL><DEDENT>elif not type_:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(name))<EOL><DEDENT>else:<EOL><INDENT>arraytype = self.make_compound_ctype(name)<EOL><DEDENT>data = arraytype()<EOL>c_name = create_string_buffer(name)<EOL>get_var = self.library.get_var<EOL>get_var.argtypes = [c_char_p, POINTER(arraytype)]<EOL>get_var.restype = None<EOL>get_var(c_name, byref(data))<EOL>if not data:<EOL><INDENT>logger.info("<STR_LIT>")<EOL>return None<EOL><DEDENT>if is_numpytype:<EOL><INDENT>array = np.ctypeslib.as_array(data)<EOL><DEDENT>else:<EOL><INDENT>array = structs2pandas(data.contents)<EOL><DEDENT>return array<EOL>
Return an nd array from model library