Coder Social home page Coder Social logo

lala5th / g4numpyanalysis Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 321 KB

It is a class developed for easily writing data to npz format in a multithreaded environment. Designed losely based on the geant4 analysis classes

License: MIT License

CMake 8.95% C++ 91.05%
geant4 npz analysis-managers

g4numpyanalysis's Introduction

build

G4NumpyAnalysis

This is a wrapper class for a slightly modified cnpy, which can write std::tuple objects developed for use in Geant4 simulations. While it was developed for the framework of Geant4, but it may be useful for other threaded applications, as such there is no dependence on Geant libraries.

This updated cnpy code can be found within the forked repository Lala5th/cnpy.

Requires libizp to function.

Installation

To build you will need cmake. To install do

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install/dir ..
make
make install

Usage

After install it should work with cmake's find_package() command as well as with using

-L/path/to/install/dir -lG4NumpyAnalysis

with g++.

To use it include the NumpyAnalysisManager.hh header file.

Description

It implements a proprietary analysis manager, which is quite different from the analysis managers provided by Geant4. It is accessed similarly via invoking NumpyAnalysisManager::GetInstance(bool continousWrite = true), which returns the active instance or creates an instance if it's not yet initialised. If it is not yet initialised the boolean parameter decides whether the data will be written at once when WriteData() is called, or continously into separate .npy files and only merged into an npz archive at the time of the WriteData() call. The other methods are SetFilename(std::string), which changes the name of the output npz archive (default is out.npz). CreateDataset<typename... COLS>(std::string title), which creates a new datatable with COLS as columns, while returning the id of the new datatable. If the manager is in continous write mode this also creates a new datafile named title.npy. AddData<typename... COLS>(int id, COLS...) adds a row to the datatable with the matching id [!Not checked in not continous write, but same template arguments must be used, or template can sometimes be dropped in second case. Care must be taken as it only works in specific cases where it can guess type specifically, otherwise leads to unwanted/undefined behaviour]. Finally WriteData() writes the npz object to disk.

While it is technically thread-safe, it is advisable that worker threads do not access it, otherwise (if badly handled), the datatables might store the same data multiple times. In Geant4 the IsMaster() function can be quite helpful so worker threads do not accidentally smear the data.

Goals

  • Write Basic manager
  • Add mode for writing invidual datafiles
  • Add way to group several columns together (i.e. group vectors into a special dtype)

g4numpyanalysis's People

Contributors

lala5th avatar

Stargazers

 avatar

Watchers

 avatar  avatar

g4numpyanalysis's Issues

CI

The CI fails due to a misconfig with libzip. The other checks would succeed if reached, however libzip.so is not detected. I am unsure how to progress/fix the issue

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.