SU2
Classes | Functions
data.py File Reference

python package for data utility functions More...

Classes

class  SU2.io.data.mat_bunch
 

Functions

def SU2.io.data.load_data (file_name, var_names=None, file_format='infer', core_name='python_data')
 
def SU2.io.data.save_data (file_name, data_dict, append=False, file_format='infer', core_name='python_data')
 
def SU2.io.data.load_pickle (file_name)
 
def SU2.io.data.save_pickle (file_name, data_dict)
 
def SU2.io.data.rec2dict (array_in)
 
def SU2.io.data.flatten_list (input_list)
 
def SU2.io.data.append_nestdict (base_dict, add_dict)
 

Detailed Description

python package for data utility functions

Author
T. Lukaczyk, F. Palacios
Version
5.0.0 "Raven"

SU2 Original Developers: Dr. Francisco D. Palacios. Dr. Thomas D. Economon.

SU2 Developers: Prof. Juan J. Alonso's group at Stanford University. Prof. Piero Colonna's group at Delft University of Technology. Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. Prof. Alberto Guardone's group at Polytechnic University of Milan. Prof. Rafael Palacios' group at Imperial College London. Prof. Edwin van der Weide's group at the University of Twente. Prof. Vincent Terrapon's group at the University of Liege.

Copyright (C) 2012-2017 SU2, the open-source CFD code.

SU2 is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

SU2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with SU2. If not, see http://www.gnu.org/licenses/.

Function Documentation

§ append_nestdict()

def SU2.io.data.append_nestdict (   base_dict,
  add_dict 
)
append_nestdict(base_dict,add_dict)
    appends base_dict with add_dict, allowing for 
    updating nested dictionaries
    will update base_dict in place

§ flatten_list()

def SU2.io.data.flatten_list (   input_list)
flatten an irregular list of lists of any depth

§ load_data()

def SU2.io.data.load_data (   file_name,
  var_names = None,
  file_format = 'infer',
  core_name = 'python_data' 
)
data = load_data( file_name, var_names=None   ,
                      file_format = 'infer'       ,
                      core_name   = 'python_data'  )
        
    loads dictionary of data from python pickle or matlab struct
    
    Inputs:
        file_name   - data file name
        var_names   - variable names to read
        file_format - 'infer', 'pickle', or 'matlab'
        core_name   - data is stored under a dictionary with this name
    
    default looks for variable 'python_data' in file_name
    file_format = pickle, will return any python object
    file_format = matlab, will return strings or float lists and 
    requires scipy.io.loadmat
    file_format = infer (default), will infer format from extention 
    ('.mat','.pkl')

§ load_pickle()

def SU2.io.data.load_pickle (   file_name)
data = load_pickle(file_name)
    loads a pickle with core_data dictionaries
    assumes first entry is a list of all following data names
    returns dictionary of data

§ rec2dict()

def SU2.io.data.rec2dict (   array_in)
converts numpy record array to dictionary of lists 
    needed for loading matlab data
    assumes array comes from scipy.io.loadmat, with
    squeeze_me = False and struct_as_record = True

§ save_data()

def SU2.io.data.save_data (   file_name,
  data_dict,
  append = False,
  file_format = 'infer',
  core_name = 'python_data' 
)
save_data( file_name, data_dict, append=False ,
               file_format = 'infer'              ,
               core_name='python_data'             ):
        
    Inputs:
        file_name   - data file name
        data_dict   - a dictionary or bunch to write
        append      - True/False to append existing data
        file_format - 'infer', 'pickle', or 'matlab'
        core_name   - data is stored under a dictionary with this name
    
    file_format = pickle, will save any pickleable python object
    file_format = matlab, will save strings or float lists and 
    requires scipy.io.loadmat
    file_format = infer (default), will infer format from extention 
    ('.mat','.pkl')
    
    matlab format saves data file from matlab 5 and later 
    will save nested dictionaries into nested matlab structures
    cannot save classes and modules
    uses scipy.io.loadmat

§ save_pickle()

def SU2.io.data.save_pickle (   file_name,
  data_dict 
)
save_pickle(file_name,data_dict)
    saves a core data dictionary
    first pickle entry is a list of all following data names