Module: IO

Reading data written by simulation codes: grid-information files (<prefix>_info.txt) and column-oriented text files with densities and other fields on the grid. See examples/analyze_data.py for a complete, runnable example.

Module: Myio

This module provides functions to read and write data in different formats.

Currently supported formats: - Text files (.txt) with columnar data - Grid information files (_info.txt)

Planned features: - WDATA format support using Forbes’ python library

List of functions

libnest.myio.dimension(nx, ny, nz)[source]

Calculates the dimensionality of the problem.

Parameters:
  • nx (int) – number of grid points along x-axis

  • ny (int) – number of grid points along y-axis

  • nz (int) – number of grid points along z-axis

Returns:

dimensionality of the problem

Return type:

int

libnest.myio.readDimTxt(PATH, PREFIX)[source]

Reads data from the file PREFIX_info.txt in location PATH. It gets information about the grid size and returns them in a list.

Note

Works for 1D, 2D, and 3D grids. A dimension not listed in the file defaults to 1 (a flat direction).

Parameters:
  • PATH (str) – location path

  • PREFIX (str) – prefix of the file

Returns:

a list of points in each direction [NX, NY, NZ].

Return type:

list of int

libnest.myio.txt2df(file, sufix, cols)[source]

Reads *.txt files to pandas dataframe.

Parameters:
  • file (str) – path and prefix to the data

  • sufix (str) – sufix pointing to the type of data e. g. ‘density’, ‘delta’ etc.

  • cols (list of str) – names of columns in the file

Returns:

data about spatial extend of observables

Return type:

pandas.DataFrame