#NEWLINE# def __getitem__( self , key ) : #NEWLINE# #INDENT# if self . is_remote : #NEWLINE# #INDENT# getitem = partial ( robust_getitem , catch = RuntimeError ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# getitem = operator . getitem #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# data = getitem ( self . array , key ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# msg = 'The indexing operation you are attempting to perform is not valid on netCDF4.Variable object. Try loading your data into memory first by calling .load().' #NEWLINE# if ( not PY3 ) : #NEWLINE# #INDENT# import traceback #NEWLINE# msg += ( '\n\nOriginal traceback:\n' + traceback . format_exc ( ) ) #NEWLINE# #UNINDENT# raise IndexError ( msg ) #NEWLINE# #UNINDENT# if ( key . ndim == 0 ) : #NEWLINE# #INDENT# data = np . asscalar ( data ) #NEWLINE# #UNINDENT# return data