Coder Social home page Coder Social logo

cortex-lab / npytools Goto Github PK

View Code? Open in Web Editor NEW
7.0 10.0 1.0 16 KB

[WIP] Command-line utilities to deal with NPY array files

License: MIT License

Makefile 5.69% Python 94.31%
npy npy-files python numpy numpy-arrays scientific-computing numerical-computation

npytools's Introduction

Command-line utilities to deal with NPY array files

The NPY format

The NPY file format is used to store NumPy arrays. It is becoming a de facto standard for storing arbitrarily large multidimensional arrays. For instance, the International Brain Laboratory uses it for a large part of its data.

Although first implemented in a Python library, there are now libraries in many languages, including the following (some of the libraries below may be experimental):

npytools

Even if the NPY format is quite simple (a header with metadata about the array, such as its dtype and shape, followed by the raw binary data), and NPY files can be easily open in Python, there is also a need for command-line tools to manage and quickly inspect NPY files.

npytools is a minimal Python library that provides such tools.

Installation

Dependencies : Python 3, NumPy, click (which can be installed with pip install click).

To install npytools: pip install git+https://github.com/cortex-lab/npytools.git

npyshow

npypshow is a simple command-line tool that will display metadata and possibly basic statistics about an array stored in a NPY file. The array is memmapped and therefore not entirely loaded in memory, unless the --show-stats option is used.

$ npyshow myarray.npy --show-stats
+----------|----------------+
| shape    | (524, 82, 374) |
| dtype    | float32        |
| filesize | 64.3M          |
| size     | 16070032       |
| min      | -0.59231997    |
| mean     | -3.6333304e-06 |
| median   | 0.0            |
| max      | 0.58112603     |
| zero     | 15049624 (93%) |
| nan      | 0              |
| inf      | 0              |
+----------|----------------+
[[[ 0.      0.     ...  0.      0.    ]
  [ 0.      0.     ...  0.      0.    ]
  ...
  [ 0.0007  0.0099 ...  0.      0.    ]
  [ 0.0003  0.004  ...  0.      0.    ]]

 ...

 [[ 0.      0.     ...  0.      0.    ]
  [ 0.      0.     ...  0.      0.    ]
  ...
  [ 0.      0.     ...  0.      0.    ]
  [ 0.      0.     ...  0.      0.    ]]]

Running npyshow on multiple files (Unix)

To quickly call npyshow on all _ibl_*.npy file, call:

ls -1 _ibl_*.npy | xargs -l npyshow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.