#NEWLINE# @ staticmethod #NEWLINE# def get_data_frames( network , phases = [ ] ) : #NEWLINE# #INDENT# "\n        Convert the Network (and optionally Phase) data to Pandas DataFrames.\n\n        Parameters\n        ----------\n        network : OpenPNM Network Object\n            The Network containing the data to be stored\n\n        phases : list of OpenPNM Phase Objects\n            The data on each supplied phase will be added to the CSV file\n\n        Returns\n        -------\n        A dict containing 2 Pandas DataFrames with 'pore' and 'throat' data in\n        each.\n        " #NEWLINE# if ( type ( phases ) is not list ) : #NEWLINE# #INDENT# phases = [ phases ] #NEWLINE# #UNINDENT# pdata = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# tdata = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# pprops = set ( ( network . props ( element = 'pore' , mode = [ 'all' , 'deep' ] ) + network . labels ( element = 'pore' ) ) ) #NEWLINE# tprops = set ( ( network . props ( element = 'throat' , mode = [ 'all' , 'deep' ] ) + network . labels ( element = 'throat' ) ) ) #NEWLINE# for item in pprops : #NEWLINE# #INDENT# pdata . update ( { #NEWLINE# #INDENT# item : network [ item ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# for item in tprops : #NEWLINE# #INDENT# tdata . update ( { #NEWLINE# #INDENT# item : network [ item ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# for phase in phases : #NEWLINE# #INDENT# pprops = set ( ( phase . props ( element = 'pore' , mode = [ 'all' , 'deep' ] ) + phase . labels ( element = 'pore' ) ) ) #NEWLINE# tprops = set ( ( phase . props ( element = 'throat' , mode = [ 'all' , 'deep' ] ) + phase . labels ( element = 'throat' ) ) ) #NEWLINE# for item in pprops : #NEWLINE# #INDENT# pdata . update ( { #NEWLINE# #INDENT# ( ( item + '|' ) + phase . name ) : phase [ item ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# for item in tprops : #NEWLINE# #INDENT# tdata . update ( { #NEWLINE# #INDENT# ( ( item + '|' ) + phase . name ) : phase [ item ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# for item in list ( pdata . keys ( ) ) : #NEWLINE# #INDENT# if ( _sp . shape ( pdata [ item ] ) != ( network . Np , ) ) : #NEWLINE# #INDENT# array = pdata . pop ( item ) #NEWLINE# temp = _sp . empty ( ( _sp . shape ( array ) [ 0 ] , ) , dtype = object ) #NEWLINE# for row in range ( temp . shape [ 0 ] ) : #NEWLINE# #INDENT# temp [ row ] = str ( array [ row , : ] ) . strip ( '[]' ) #NEWLINE# #UNINDENT# pdata . update ( { #NEWLINE# #INDENT# item : temp , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# for item in list ( tdata . keys ( ) ) : #NEWLINE# #INDENT# if ( _sp . shape ( tdata [ item ] ) != ( network . Nt , ) ) : #NEWLINE# #INDENT# array = tdata . pop ( item ) #NEWLINE# temp = _sp . empty ( ( _sp . shape ( array ) [ 0 ] , ) , dtype = object ) #NEWLINE# for row in range ( temp . shape [ 0 ] ) : #NEWLINE# #INDENT# temp [ row ] = str ( array [ row , : ] ) . strip ( '[]' ) #NEWLINE# #UNINDENT# tdata . update ( { #NEWLINE# #INDENT# item : temp , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# data = { #NEWLINE# #INDENT# 'pore.DataFrame' : _pd . DataFrame . from_dict ( pdata ) , #NEWLINE# 'throat.DataFrame' : _pd . DataFrame . from_dict ( tdata ) , #NEWLINE# #UNINDENT# } #NEWLINE# return data