def get(self, cycle_list, dataitem=None, isotope=None, sparse=<NUM_LIT:1>):
ck out the inputs<EOL>t1=time.time()<EOL>isotopes_of_interest = []<EOL>nested_list = False<EOL>if isinstance(cycle_list, basestring):<EOL><INDENT>cycle_list = [cycle_list]<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>if len(cycle_list) == <NUM_LIT:1>:<EOL><INDENT>nested_list = True<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass <EOL><DEDENT><DEDENT>if isinstance(dataitem, basestring):<EOL><INDENT>dataitem = [dataitem]<EOL><DEDENT>if isinstance(isotope, basestring):<EOL><INDENT>isotope = [isotope]<EOL><DEDENT>if dataitem==None and isotope==None:<EOL><INDENT>option_ind = <NUM_LIT:1><EOL>dataitem = cycle_list<EOL>if not any([item in self.hattrs for item in dataitem]):<EOL><INDENT>cycle_list = self.cycles<EOL><DEDENT>else:<EOL><INDENT>first_file = mrT.File(self.h5s[<NUM_LIT:0>].filename,'<STR_LIT:r>')<EOL>dat = []<EOL>for item in dataitem:<EOL><INDENT>tmp = first_file.attrs.get(item, None)<EOL>try:<EOL><INDENT>if len(tmp) == <NUM_LIT:1>:<EOL><INDENT>tmp = tmp[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>except TypeError: <EOL><INDENT>pass<EOL><DEDENT>dat.append(tmp)<EOL><DEDENT>if (len(dat) == <NUM_LIT:1>) and (not nested_list):<EOL><INDENT>dat = dat[<NUM_LIT:0>]<EOL><DEDENT>first_file.close()<EOL>return dat<EOL><DEDENT>if any([item.split('<STR_LIT:->')[<NUM_LIT:0>] in self.isos for item in dataitem]):<EOL><INDENT>return self.get(cycle_list,dataitem,sparse=sparse)<EOL><DEDENT><DEDENT>elif isotope==None:<EOL><INDENT>option_ind = <NUM_LIT:2><EOL>cycle_list = cycle_list<EOL>dataitem = dataitem<EOL>if isinstance(dataitem, basestring):<EOL><INDENT>dataitem = [dataitem]<EOL><DEDENT>new_dataitem = []<EOL>new_isotopes = []<EOL>for item in dataitem:<EOL><INDENT>if item.split('<STR_LIT:->')[<NUM_LIT:0>] in self.isos:<EOL><INDENT>new_isotopes.append(item)<EOL><DEDENT>else:<EOL><INDENT>new_dataitem.append(item)<EOL><DEDENT><DEDENT>if len(new_isotopes) != <NUM_LIT:0>:<EOL><INDENT>tmp = []<EOL>try:<EOL><INDENT>tmp = self.get(cycle_list,new_dataitem + ['<STR_LIT>'],new_isotopes,sparse=sparse)<EOL><DEDENT>except: <EOL><INDENT>tmp =  self.get(cycle_list,new_dataitem + ['<STR_LIT>'],new_isotopes,sparse=sparse)<EOL><DEDENT>dat = []<EOL>if isinstance(cycle_list, basestring):<EOL><INDENT>tmp = [tmp]<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>if len(cycle_list) == <NUM_LIT:1>:<EOL><INDENT>tmp = [tmp]<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>tmp = [tmp]<EOL><DEDENT><DEDENT>for cyc in tmp:<EOL><INDENT>temp_dataitem = []<EOL>for item in dataitem:<EOL><INDENT>if item in new_dataitem:<EOL><INDENT>temp_dataitem.append(cyc[new_dataitem.index(item)])<EOL><DEDENT>else:<EOL><INDENT>if len(new_dataitem) == <NUM_LIT:0>:<EOL><INDENT>temp_dataitem = cyc<EOL><DEDENT>else:<EOL><INDENT>if len(new_isotopes) == <NUM_LIT:1>:<EOL><INDENT>temp_dataitem.append(cyc[-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>temp_dataitem.append(cyc[-<NUM_LIT:1>][new_isotopes.index(item)])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>dat.append(temp_dataitem)<EOL><DEDENT>if (len(dat) == <NUM_LIT:1>) and (not nested_list):<EOL><INDENT>dat = dat[<NUM_LIT:0>]<EOL><DEDENT>return dat<EOL><DEDENT><DEDENT>else:<EOL>is an implicite rule here that if you want <NUM_LIT:2>D arrays you have<EOL>e <NUM_LIT:3> args, or, in other words you have to give a cycle or cycle<EOL><INDENT>there is no good reason for that, except the programmers<EOL><DEDENT>ss<EOL><INDENT>option_ind = <NUM_LIT:3><EOL>cycle_list = cycle_list<EOL>dataitem = dataitem<EOL>isotopes_of_interest = isotope<EOL><DEDENT>d to find out the shellnb to know if any yps array may just be<EOL>row array, as - for example- in the surf.h5 files<EOL><INDENT>try: <EOL><INDENT>cycle_list[<NUM_LIT:0>]<EOL><DEDENT>except (TypeError,IndexError):<EOL><INDENT>cycle_list = [cycle_list]<EOL><DEDENT>shellnb=self.get(cycle_list[<NUM_LIT:0>],'<STR_LIT>')<EOL><DEDENT>if sparse <<NUM_LIT:1>:<EOL><INDENT>sparse=<NUM_LIT:1><EOL><DEDENT>try:<EOL><INDENT>for x in range(len(cycle_list)):<EOL><INDENT>cycle_list[x] = str(cycle_list[x])<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>cycle_list = [str(cycle_list)]<EOL><DEDENT>if option_ind != <NUM_LIT:1>:<EOL><INDENT>try: <EOL><INDENT>if cycle_list.isdigit():<EOL><INDENT>cycle_list = [cycle_list]<EOL>for cycle in cycle_list:<EOL><INDENT>if len(cycle) != len(self.cycles[<NUM_LIT:0>]):<EOL><INDENT>diff = len(self.cycles[<NUM_LIT:0>])-len(cycle)<EOL>OO = '<STR_LIT>'<EOL>while diff >=<NUM_LIT:1>:<EOL><INDENT>OO+='<STR_LIT:0>'<EOL><DEDENT>cycle = OO+cycle<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except AttributeError: <EOL><INDENT>if cycle_list[<NUM_LIT:0>].isdigit():<EOL><INDENT>for x in range(len(cycle_list)):<EOL><INDENT>if len(str(cycle_list[x])) != len(str(self.cycles[<NUM_LIT:0>])):<EOL><INDENT>diff = len(str(self.cycles[<NUM_LIT:0>]))-len(str(cycle_list[x]))<EOL>OO = '<STR_LIT>'<EOL>while diff >=<NUM_LIT:1>:<EOL><INDENT>OO+='<STR_LIT:0>'<EOL>diff-=<NUM_LIT:1><EOL><DEDENT>try:<EOL><INDENT>cycle_list[x] = OO+cycle_list[x]<EOL><DEDENT>except TypeError:<EOL><INDENT>cycle_list[<NUM_LIT:0>] = OO+cycle_list[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>dat = []<EOL>cycle_list.sort()<EOL>cyclelist=np.array(list(map(int, cycle_list)))<EOL>cycles_requested = []<EOL>file_min=[]<EOL>file_max=[]<EOL>try:<EOL><INDENT>for h5 in self.h5s:<EOL><INDENT>file_min.append(int(h5.cycle[<NUM_LIT:0>]))<EOL>file_max.append(int(h5.cycle[-<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>print('<STR_LIT>'+h5.filename+'<STR_LIT>')<EOL>print('<STR_LIT>')<EOL>print('<STR_LIT>')<EOL>raise IOError('<STR_LIT>')<EOL><DEDENT>file_min.sort()<EOL>file_max.sort()<EOL>for h5 in self.h5s:<EOL><INDENT>min_file = int(h5.cycle[<NUM_LIT:0>])<EOL>max_file = int(h5.cycle[-<NUM_LIT:1>])<EOL>min_list = int(cyclelist[<NUM_LIT:0>])<EOL>max_list = int(cyclelist[-<NUM_LIT:1>])<EOL>index_min = None <EOL>index_max = None <EOL>if len(file_min) == <NUM_LIT:1>:<EOL><INDENT>min_file = min_list - <NUM_LIT:1><EOL>max_file = max_list + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>file_index = file_min.index(min_file)<EOL>if file_index == <NUM_LIT:0>:<EOL><INDENT>if min_list - <NUM_LIT:1> < min_file:<EOL><INDENT>min_file = min_list - <NUM_LIT:1><EOL><DEDENT>max_file = (file_min[file_index + <NUM_LIT:1>] + max_file)//<NUM_LIT:2><EOL><DEDENT>elif file_index == len(file_min) - <NUM_LIT:1>:<EOL><INDENT>min_file = (file_max[file_index - <NUM_LIT:1>] + min_file)//<NUM_LIT:2> + <NUM_LIT:1><EOL>if max_list + <NUM_LIT:1> > max_file:<EOL><INDENT>max_file = max_list + <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>min_file = (file_max[file_index - <NUM_LIT:1>] + min_file)//<NUM_LIT:2> + <NUM_LIT:1><EOL>max_file = (file_min[file_index + <NUM_LIT:1>] + max_file)//<NUM_LIT:2><EOL><DEDENT><DEDENT>if (max_list < min_file) or (max_file < min_list):<EOL><INDENT>continue<EOL><DEDENT>elif (min_list <= min_file) and (max_file <= max_list):<EOL><INDENT>index_min = bisect.bisect_left(cyclelist, min_file)<EOL>index_max = bisect.bisect_right(cyclelist, max_file)<EOL><DEDENT>elif (min_file <= min_list) and (max_list <= max_file):<EOL><INDENT>index_min = None<EOL>index_max = None<EOL><DEDENT>else:<EOL><INDENT>if min_list > min_file:<EOL><INDENT>index_min = None<EOL>index_max = bisect.bisect_right(cyclelist, max_file)<EOL><DEDENT>else:<EOL><INDENT>index_min = bisect.bisect_left(cyclelist, min_file)<EOL>index_max = None<EOL><DEDENT><DEDENT>imin = index_min<EOL>if index_min == None:<EOL><INDENT>imin = <NUM_LIT:0><EOL><DEDENT>imax = index_max<EOL>if index_max == None:<EOL><INDENT>imax = len(cyclelist)<EOL><DEDENT>request_min = bisect.bisect_left(cycles_requested, imin)<EOL>request_max = bisect.bisect_right(cycles_requested, imax)<EOL>del cycles_requested[request_min:request_max]<EOL>if ((request_max-request_min) % <NUM_LIT:2>) ==<NUM_LIT:1>:<EOL><INDENT>if request_min % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>cycles_requested.insert(request_min, imin)<EOL><DEDENT>else:<EOL><INDENT>cycles_requested.insert(request_min, imax)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if request_min % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>cycles_requested.insert(request_min, imin)<EOL>cycles_requested.insert(request_min + <NUM_LIT:1>, imax)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not self.h5sStarted[self.h5s.index(h5)]:<EOL><INDENT>h5.start()<EOL>h5.join()<EOL>temp = h5.fetch_data_sam(dataitem,cycle_list[index_min:index_max],len(cycle_list),len(dat))<EOL>self.h5sStarted[self.h5s.index(h5)]=True<EOL><DEDENT>else:<EOL><INDENT>temp = h5.fetch_data_sam(dataitem,cycle_list[index_min:index_max],len(cycle_list),len(dat))<EOL><DEDENT>temp_dat = []<EOL>for temp_num, temp_cycle in enumerate(temp):<EOL><INDENT>temp_dataforcycle = []<EOL>for dataitem_num, temp_dataitem in enumerate(temp_cycle):<EOL><INDENT>temp_dataitem=self.red_dim(temp_dataitem)<EOL><INDENT>if option_ind == <NUM_LIT:3> and isotopes_of_interest != []:<EOL><DEDENT>if (dataitem[dataitem_num] == '<STR_LIT>' or dataitem[dataitem_num] == '<STR_LIT>') and isotopes_of_interest != []:<EOL><INDENT>index = []<EOL>iso_tmp = []<EOL>if '<STR_LIT>' in dataitem[dataitem_num]: <EOL><INDENT>iso_tmp = self.isotopes<EOL><DEDENT>else:<EOL><INDENT>iso_tmp = self.elements<EOL><DEDENT>for iso in isotopes_of_interest: <EOL><INDENT>x = iso_tmp.index(iso)<EOL>index.append(x)<EOL><DEDENT>if index == []:<EOL><INDENT>index = [<NUM_LIT:0>]<EOL><DEDENT>islist=True<EOL>if len(cycle_list)==<NUM_LIT:1>:<EOL><INDENT>islist=False<EOL>
Get Data from HDF5 files.

There are three ways to call this function

1. get(dataitem)

    Fetches the datatiem for all cycles. If dataitem is a header
    attribute or list of attributes then the data is retured.
    If detaitem an individulal or list of column attributes,
    data columns or isotopes/elements the data is returned for
    all cycles.

2. get(cycle_list, dataitem)

    Fetches the dataitem or list of dataitems for the cycle
    or list of cycles. The variable dataitems can contain column
    attributes, data columns, and isotopes/elemnts.

3. get(cycle_list, dataitem, isotope)

    Fetches the dataitems like the seccond method except that
    one of the dataitems must be either "iso_massf" or "yps",
    and in the data returned "iso_massf" and "yps" are replaced
    with the data from the isotopes.  The isotopes must be in
    the form given by se.isotopes or se.elements.

Parameters
----------
cycle_list : list, integer or string
    If cycle_list is a list or string and all of the entries
    are header attributes then the attributes are returned.

    If cycle_list is a list or string of dataitems then the
    dataitems are fetched for all cycles.

    If cycle_list is a list, integer or string of cycle numbers
    then data is returned for those cycles.
dataitem: list or string, optional
    If dataitem is not None then the data for each item is
    returned for the cycle or list of cycles. dataitem may be an
    individual or a mixed list of column attributes, column
    data or isotopes/elements. If dataitem is None then
    cycle_list must be a string.  The default is None.
isotope: list or string, optional
    If one of the dataitems is "iso_massf" or "yps" then it is
    replaced with the data from the individual isotopes/elements
    listed in isotope.  The default is None.
sparse : int
    Implements a sparsity factor on the fetched data i.e. only
    the i th cycle in cycle_list data is returned,
    where i = sparse.