...
 
Commits (38)
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
#qmake #qmake
*.user *.user
# ide
*.tags*
# linux
.nfs*
#swig #swig
py/unsio/py_unsio.py py/unsio/py_unsio.py
py/unsio/py_unsio_wrap.cpp py/unsio/py_unsio_wrap.cpp
...@@ -14,9 +20,12 @@ py/unsio/py_unsio_wrap.cpp ...@@ -14,9 +20,12 @@ py/unsio/py_unsio_wrap.cpp
dist dist
*egg-info* *egg-info*
__pycache__ __pycache__
py/unsio/version*
*.pyc
# tilda # tilda
*~ *~
*.whl
py/wheels
# Compiled Object files # Compiled Object files
*.slo *.slo
...@@ -71,5 +80,5 @@ Makefile.in ...@@ -71,5 +80,5 @@ Makefile.in
*.cubin *.cubin
*.fatbin *.fatbin
# unknown
taxon
#
# Copyright Jean-Charles Lambert, 2018-2019
#
# - YAML file for Continous Integration / Continous Deployement
# - unsio and python-unsio packages (RPM or DEB) are automatically
# generated at new commit for different linux distribution
# - add manylinux building for python-module
#
# - Documentation :
# https://docs.gitlab.com/ee/ci/yaml/
stages:
- build
- testpypi
- pypi
variables :
TWINE_USERNAME: jcl
TWINE_PASSWORD: $TEST_PY_PASSWD
WHEEL : 0
TESTPYPI : 0
PYPI : 0
OSX : 0
TESTPYPIOSX : 0
PYPIOSX : 0
before_script:
# clone
#- git clone https://gitlab.lam.fr/jclamber/unsio.git
#- cd unsio
#- git branch -r
#- git checkout origin/new_cmake
#
# BUILD wheels for all linux flavors/python
#
manylinux2010 :
stage : build
image : portus.lam.fr/jclamber/unsio-manylinux2010
only :
variables:
- $WHEEL == "1"
script:
# build
- CI/script/build-unsio.sh
- CI/script/build-wheel.sh
- CI/script/repair-wheel.sh
- /opt/python/cp37-cp37m/bin/python setup.py sdist -d wheel
- CI/script/test-unsio.sh
cache:
key: manylinux2010
paths:
- wheel/
artifacts:
name: "manylinux2010"
paths:
- test-*.res
- wheel/*
expire_in: 1 week
# Push wheel to testpypi repos
push-testpypi-manylinux2010:
stage: testpypi
image : portus.lam.fr/jclamber/unsio-manylinux2010
only :
variables:
- $TESTPYPI == "1"
script:
- /opt/python/cp37-cp37m/bin/python -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD --repository-url https://test.pypi.org/legacy/ ./wheel/python*unsio*manylinux2010* ./wheel/python*unsio*gz
cache:
key: manylinux2010
paths:
- wheel/
# Push wheel to pypi repos
push-pypi-manylinux2010:
stage: pypi
image : portus.lam.fr/jclamber/unsio-manylinux2010
only :
variables:
- $PYPI == "1"
script:
- /opt/python/cp37-cp37m/bin/python -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD ./wheel/python*unsio*manylinux2010* ./wheel/python*unsio*gz
cache:
key: manylinux2010
paths:
- wheel/
#
# MANYLINUX1
#
manylinux1 :
stage : build
image : portus.lam.fr/jclamber/unsio-manylinux1
only :
variables:
- $WHEEL == "1"
script:
# build
- CI/script/build-unsio-manylinux1.sh
- CI/script/build-wheel.sh
- CI/script/repair-wheel.sh
#- /opt/python/cp37-cp37m/bin/python setup.py sdist -d wheel
- CI/script/test-unsio.sh
cache:
key: manylinux1
paths:
- wheel/
artifacts:
name: "manylinux1"
paths:
- test-*.res
- wheel/*
expire_in: 1 week
# Push wheel to testpypi repos
push-testpypi-manylinux1:
stage: testpypi
image : portus.lam.fr/jclamber/unsio-manylinux1
only :
variables:
- $TESTPYPI == "1"
script:
- /opt/python/cp37-cp37m/bin/python -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD --repository-url https://test.pypi.org/legacy/ ./wheel/python*unsio*manylinux1*
cache:
key: manylinux1
paths:
- wheel/
# Push wheel to pypi repos
push-pypi-manylinux1:
stage: pypi
image : portus.lam.fr/jclamber/unsio-manylinux1
only :
variables:
- $PYPI == "1"
script:
- /opt/python/cp37-cp37m/bin/python -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD ./wheel/python*unsio*manylinux1*
cache:
key: manylinux1
paths:
- wheel/
#
# BUILD wheels for macosx
#
OSX:
stage : build
tags:
- osx_10.13.6
only :
variables:
- $OSX == "1"
script:
# build
- CI/scriptOSX/build-unsio.sh
- CI/scriptOSX/build-wheel.sh
- CI/scriptOSX/repair-wheel.sh
- CI/scriptOSX/test-unsio.sh
cache:
key: osx
paths:
- wheel/
artifacts:
name: "osx-wheel"
paths:
- test-*.res
- wheel/*
expire_in: 1 week
# Push wheel to testpypi repos
push-testpypi-OSX:
stage: testpypi
tags:
- osx_10.13.6
only :
variables:
- $TESTPYPIOSX == "1"
script:
- python3.7 -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD --repository-url https://test.pypi.org/legacy/ ./wheel/python*unsio*macosx*
cache:
key: osx
paths:
- wheel/
# Push wheel to pypi repos
push-pypi-OSX:
stage: pypi
tags:
- osx_10.13.6
only :
variables:
- $PYPIOSX == "1"
script:
- python3.7 -m twine upload --disable-progress-bar -u $TWINE_USERNAME -p $TWINE_PASSWORD ./wheel/python*unsio*macosx*
cache:
key: osx
paths:
- wheel/
#
# RPM Distros
#
opensuse42.3 :
stage : build
image: ppfb.lam.fr:5000/jcl-dev/opensuse42.3
only :
- tags
script:
# build
- ../CI/build-rpm.sh 0opensuse42.3
artifacts:
name: "opensuse42.3"
paths:
- unsio/build/*.rpm
- unsio/dist/*.rpm
- unsio/dist/*.gz
fedora28 :
stage : build
image: ppfb.lam.fr:5000/jcl-dev/fedora28
only :
- tags
script:
# build
- ../CI/build-rpm.sh 0fc28
artifacts:
name: "fedora28"
paths:
- unsio/build/*.rpm
- unsio/dist/*.rpm
- unsio/dist/*.gz
fedora27 :
stage : build
image: ppfb.lam.fr:5000/jcl-dev/fedora27
only :
- tags
script:
# build
- ../CI/build-rpm.sh 0fc27
artifacts:
name: "fedora27"
paths:
- unsio/build/*.rpm
- unsio/dist/*.rpm
- unsio/dist/*.gz
mageia6 :
stage : build
image: ppfb.lam.fr:5000/jcl-dev/mageia6
only :
- tags
script:
# build
- ../CI/build-rpm.sh 0mga6
artifacts:
name: "mageia6"
paths:
- unsio/build/*.rpm
- unsio/dist/*.rpm
- unsio/dist/*.gz
#
# DEB distos
#
ubuntu 18.04:
stage : build
image: ppfb.lam.fr:5000/jcl-dev/ubuntu18.04
only :
- tags
script:
# build
- ../CI/build-deb.sh 0ubuntu18.04
artifacts:
name: "ubuntu18.04"
paths:
- unsio/build/*.deb
- unsio/my_deb/*.deb
- unsio/my_deb/*.gz
ubuntu 16.04:
stage : build
image: ppfb.lam.fr:5000/jcl-dev/ubuntu16.04
only :
- tags
script:
# build
- ../CI/build-deb.sh 0ubuntu16.04
artifacts:
name: "ubuntu16.04"
paths:
- unsio/build/*.deb
- unsio/my_deb/*.deb
- unsio/my_deb/*.gz
FROM quay.io/pypa/manylinux1_x86_64
RUN yum install -y gcc-c++ make pcre-devel ccache wget \
cfitsio-devel zlib-devel
# Install SWIG 4.0.1 + cmake3.2.12 + hdf5-1.8.21
RUN \
cd /opt &&\
curl -L 'https://sourceforge.net/projects/swig/files/swig/swig-4.0.1/swig-4.0.1.tar.gz' \
--output swig-4.0.1.tar.gz &&\
tar xzf swig-4.0.1.tar.gz &&\
cd /opt/swig-4.0.1 &&\
./configure --prefix=/opt/usr &&\
make -j4 && make install &&\
cd /opt &&\
curl -L https://cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.sh \
--output cmake-3.2.3-Linux-x86_64.sh &&\
chmod +x cmake-3.2.3-Linux-x86_64.sh &&\
./cmake-3.2.3-Linux-x86_64.sh --prefix=/opt/usr --skip-license &&\
rm -f cmake-3.2.3-Linux-x86_64.sh &&\
cd /opt &&\
curl -L https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.21/src/hdf5-1.8.21.tar.gz \
--output hdf5-1.8.21.tar.gz &&\
tar zxvf hdf5-1.8.21.tar.gz &&\
cd hdf5-1.8.21 &&\
./configure --prefix=/opt/usr --enable-cxx &&\
make -j 4 && make install &&\
rm -rf hdf5-1.8.21.tar.gz hdf5-1.8.21
# Install numpy minimum requirements for swig
# Install twin
RUN \
/opt/python/cp27-cp27m/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp27-cp27mu/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp34-cp34m/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp35-cp35m/bin/pip install numpy==1.9.0 twine &&\
/opt/python/cp36-cp36m/bin/pip install numpy==1.11.3 twine &&\
/opt/python/cp37-cp37m/bin/pip install numpy==1.14.5 twine
# trick to resize image
FROM quay.io/pypa/manylinux1_x86_64
RUN yum install -y gcc-c++ make pcre-devel ccache wget \
cfitsio-devel zlib-devel
COPY --from=0 /opt/usr /opt/usr
COPY --from=0 /opt/python /opt/python
COPY --from=0 /opt/_internal /opt/_internal
ENV PATH /opt/usr/bin/:$PATH
FROM quay.io/pypa/manylinux2010_x86_64
RUN yum install -y gcc-c++ make pcre-devel ccache wget \
hdf5-devel cmake3 cfitsio-devel zlib-devel
# Install SWIG 4.0.1
RUN \
cd /opt &&\
curl -L 'https://sourceforge.net/projects/swig/files/swig/swig-4.0.1/swig-4.0.1.tar.gz' \
--output swig-4.0.1.tar.gz &&\
tar xzf swig-4.0.1.tar.gz &&\
cd /opt/swig-4.0.1 &&\
./configure --prefix=/opt/usr &&\
make -j4 && make install
# Install numpy minimum requirements for swig
# Install twin
RUN \
/opt/python/cp27-cp27m/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp27-cp27mu/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp34-cp34m/bin/pip install numpy==1.8.2 twine &&\
/opt/python/cp35-cp35m/bin/pip install numpy==1.9.0 twine &&\
/opt/python/cp36-cp36m/bin/pip install numpy==1.11.3 twine &&\
/opt/python/cp37-cp37m/bin/pip install numpy==1.14.5 twine
# trick to resize image
FROM quay.io/pypa/manylinux2010_x86_64
RUN yum install -y gcc-c++ make pcre-devel ccache wget \
hdf5-devel cmake3 cfitsio-devel zlib-devel
COPY --from=0 /opt/usr /opt/usr
COPY --from=0 /opt/python /opt/python
COPY --from=0 /opt/_internal /opt/_internal
ENV PATH /opt/usr/bin/:$PATH
#!/bin/bash
HDF5_ROOT=/usr/opt cmake . -DCMAKE_INSTALL_PREFIX=/usr
make -j 4
make install
#!/bin/bash
cmake3 . -DCMAKE_INSTALL_PREFIX=/usr
make -j 5
make install
#!/bin/bash
# build wheel
#PATH=/opt/usr/bin/:/opt/python/cp27-cp27m/bin:${PATH} pip wheel ./unsio/ -w wheelhouse
rm -f wheel/*unsio*manylinux*.whl wheel/*unsio*tar.gz wheelhouse/*unsio*manylinux*.whl
# build wheel
for PYBIN in /opt/python/*/bin/; do
echo "Compiling using pip version ${PYBIN}...."
PATH=/opt/usr/bin/:${PYBIN}:${PATH} pip wheel --no-deps ./ -w wheelhouse
done
#!/bin/bash
cd /
git clone https://gitlab.lam.fr/jclamber/unsio.git
cd /unsio
#git checkout --track origin/saveheader
#!/bin/bash
# Bundle external shared libraries into the wheels
for whl in wheelhouse/*unsio*.whl; do
echo "repairing $whl...."
auditwheel repair "$whl" -w ./wheel
done
#!/bin/bash
# install & test wheel
for PYPATH in /opt/python/*; do
echo "Testing with ${PYPATH}...."
PATH=/opt/usr/bin/:${PYPATH}/bin:${PATH} pip install wheel/*unsio*`basename ${PYPATH}`-manylinux*.whl
PATH=/opt/usr/bin/:${PYPATH}/bin:${PATH} python -m unsio.test.ctestunsio --out test-`basename ${PYPATH}`.res
done
#!/bin/bash
# Configure building environment
# We must deactivate RPATH (-DNO_RPATH=1) to allow to unsiolib to
# be included into the wheels
cmake . -DNO_RPATH=1
make -j 2
make install
#!/bin/bash
rm -f wheel/*unsio*osx*.whl wheelhouse/*unsio*osx*.whl
# Activate python environement
# Build wheel
for PYENV in ${HOME}/venv/unsio*; do
echo "Activate ${PYENV}...."
source ${PYENV}/bin/activate
pip wheel --no-deps ./ -w wheelhouse
deactivate
done
#!/bin/bash
# Activate python37 to have delocate-wheel
# delocate-wheel works the same with all python versions
source ${HOME}/venv/unsio37/bin/activate
# Bundle external shared libraries into the wheels
for whl in wheelhouse/*unsio*.whl; do
echo "repairing $whl...."
delocate-wheel "$whl" -w ./wheel
done
# de-activate python37
deactivate
#!/bin/bash
# Install unsio wheel for every python
# Run test program
for PYVER in 34 35 36 37; do
PYENV=${HOME}/venv/unsio${PYVER}
echo "Activate ${PYENV}...."
source ${PYENV}/bin/activate
pip install wheel/*unsio*${PYVER}*-macosx*.whl
python -m unsio.test.ctestunsio --out test-${PYVER}.res
deactivate
done
include py/unsio/numpy.i include py/unsio/numpy.i py/unsio/py_unsio.i
include src/uns.h src/snapshotinterface.h src/componentrange.h src/userselection.h src/snapshotinterface.h src/ctools.h src/version.h include src/uns.h src/snapshotinterface.h src/componentrange.h src/userselection.h src/snapshotinterface.h src/ctools.h src/version.h
exclude py/unsio/py_unsio.py exclude py/unsio/py_unsio.py py/unsio/version.py
# ABOUT ## ABOUT
**UNSIO** (**U**niversal **N**body **S**napshot **I**nput **O**utput) is an API which perform input/output operations in a generic way, **UNSIO** (**U**niversal **N**body **S**napshot **I**nput **O**utput) is an API which perform input/output operations in a generic way,
and on different kind of nbody files format (nemo, Gadget binaries 1 and 2, Gadget hdf5, Ramses). By using this API, and on different kind of nbody files format (nemo, Gadget binaries 1 and 2, Gadget hdf5, Ramses). By using this API,
a user could write only one analysis program which will work on all known files format supported by UNSIO. a user could write only one analysis program which will work on all known files format supported by UNSIO.
It's not necessary anymore to know how is implemented a file format, UNSIO will do transparently and automatically It's not necessary anymore to know how is implemented a file format, UNSIO will do transparently and automatically
all the hard work for you ! With UNSIO, you will spend less time to develop your analysis program. all the hard work for you ! With UNSIO, you will spend less time to develop your analysis program.
UNSIO comes with an integrated sqlite3 database which can be used to retrieve automatically all your data UNSIO comes with an integrated sqlite3 database which can be used to retrieve automatically all your data
among terabytes of hard disks. among terabytes of hard disks.
## Features ## Features
...@@ -12,18 +12,77 @@ among terabytes of hard disks. ...@@ -12,18 +12,77 @@ among terabytes of hard disks.
UNSIO can be used from different languages (C,C++,Fortran and Python) UNSIO can be used from different languages (C,C++,Fortran and Python)
## Supported files format : ## Supported files format :
* [NEMO](https://teuben.github.io/nemo/) * [**NEMO** (read and write)](https://teuben.github.io/nemo/)
* GADGET 1 (read) [http://www.mpa-garching.mpg.de/gadget/] * [**GADGET 1** (read)](http://www.mpa-garching.mpg.de/gadget/)
* GADGET 2 (read an write) * **GADGET 2** (read an write)
* GADGET 3/hdf5 (reda and write) * **GADGET 3/hdf5** (read and write)
* [RAMSES (read)](http://www.itp.uzh.ch/~teyssier/Site/RAMSES.html) * [**RAMSES** (read)](https://bitbucket.org/rteyssie/ramses)
* list of files stored in a file * **List of files** stored in a file
* simulations stored in SQLITE3 database * Simulations stored in **SQLITE3** database
## License
UNSIO is open source and released under the terms of the [CeCILL2 Licence](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)
# Webpage ## Installing python wrapper
PLease visit : https://projets.lam.fr/projects/unsio ```console
pip install python-unsio -U
```
## to get some docstring help
```console
pydoc(unsio.input)
pydoc(unsio.output)
```
## Usage
- In the example below, we load a RAMSES simulation and we save it in GADGET3 file format
```python
import unsio.input as uns_in # unsio reading module
myfile="/home/jcl/output_00004" # input RAMSES simulation
# we instantiate a CUNS_IN object
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
# read stars positions
status,poss=my_in.getData("stars","pos")
# read gas positions
status,posg=my_in.getData("gas","pos")
# read gas densities
status,rho=my_in.getData("gas","rho")
# read time simulation
status,timex=my_in.getData("time")
#
# Writing
#
import unsio.output as uns_out # unsio writing module
myoutfile="snapshot.g3" # output file name
# we instantiate a CUNS_OUT object
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
# prepare data to be saved
# set time
status=my_out.setData(timex,"time")
# set stars positions
status=my_out.setData(poss,"stars","pos")
# set gas positions
status=my_out.setData(posg,"gas","pos")
# set gas densities
status=my_out.setData(rho,"gas","rho")
# write on file system
my_out.save()
# close
my_out.close()
```
## License
UNSIO is open source and released under the terms of the [CeCILL2 Licence](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)
## Webpage
PLease visit :
- [UNSIO project home page](https://projets.lam.fr/projects/unsio)
- [Python reading manual](https://projets.lam.fr/projects/unsio/wiki/PythonReadDataNew)
- [Python writing manual](https://projets.lam.fr/projects/unsio/wiki/PythonWriteDataNew)
from __future__ import print_function from __future__ import print_function
from unsio.py_unsio import *
try: try:
from unsio.py_unsio import * from unsio.py_unsio import *
except: except:
import sys import sys
print("Unable to import [unsio.py_unsio]....",file=sys.stderr) print("Unable to import [unsio.py_unsio]....",file=sys.stderr)
from .version import version as __version__
#from . import test, csnapshot #from . import test, csnapshot
#from .csnapshot import * #from .csnapshot import *
__version__ = '0.9.2'
This diff is collapsed.
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import unsio
#
# class CSsnapshot
#
class CUNS_OUT:
"""Output Operations on UNS snapshots
This class provide methods for saving data in an UNS compatible snapshots
"""
__uns=None
__verbose=False
__verbose_debug=False
__float32=True
__loaded=False
__outfile=None
__uns_type=None
select=None
__is_valid=False
__data_type=None
# -----------------------------------------------------
# constructor
#
def __init__(self,outfile, uns_type, float32=True, verbose=False, verbose_debug=False):
"""
The Constructor for CUNS_OUT class
example :
- instantiate an object to save file "mysnap" in gadget3 with float precision
import unsio.output as uns_out
my_out=uns_out.CUNS_OUT("mysnap","gadget3")
Args:
outfile (str) : output file name
uns_type(str) : UNS file format
available format for saving are :
- gadget2, gadget3(hdf5), nemo
float32 (bool): save data in float value or double value.
example:
float32=True (save in float)
float32=False (save in double)
(default: True)
"""
self.__float32 = float32
self.__outfile = outfile
self.__uns_type = uns_type
self.__verbose = verbose
self.__verbose_debug = verbose_debug
if self.__float32:
if self.__verbose_debug:
print("saving in SINGLE precision floating values")
self.__data_type = np.float32
self.__uns = unsio.CunsOut(self.__outfile,self.__uns_type)
else:
if self.__verbose_debug:
print("saving in DOUBLE precision floating values")
self.__data_type = np.float64
self.__uns = unsio.CunsOutD(self.__outfile,self.__uns_type)
self.__is_valid = True
# -----------------------------------------------------
# setData
#
def setData(self,data_array,select,tag=None):
"""
General method to set Data Array/Value respecting to components to an uns snapshot
example:
- set numpy array pos as positions for gas component
status=obj.setData(pos,"gas","pos")
- set float value timex as simulation time
status=obj.setData(timex,"time")
Args:
data_array (array|float) : 1D numpy_array or single value
select (str) : component gas,stars,disk,halo,bndry or bulge
tag (str) : array to set
example :
tag="pos"
tag="acc"
pos,vel,mass,rho...etc see https://projets.lam.fr/projects/unsio/wiki/GetDataDescription
IMPORTANT : if 'tag' is None, then 'select' is treated as 'tag' (see above)
Return :
status : 1 if success, 0 otherwise
"""
if not self.__is_valid:
raise RuntimeError("CUNS_OUT is not valid")
ok=0
if tag is None: # only one value
tab_value_F=["time"]
tab_value_I=["nbody","nsel"]
if tab_value_I.count(select) > 0:
ok=self.__uns.setValueI(select,data_array)
else:
ok=self.__uns.setValueF(select,data_array)
else:
if tag != "id": #not id, then we save float arrays
ok = self.__uns.setArrayF(select,tag,data_array)
else: # save id's array of integers
ok = self.__uns.setArrayI(select,tag,data_array)
if self.__verbose_debug:
print("setData : [select=%s, tag=%s, ok=%d ]"%(select,tag,ok))
return ok
# -----------------------------------------------------
# save
#
def save(self):
"""save data presumbly set on file"""
if not self.__is_valid:
raise RuntimeError("CUNS_OUT is not valid")
self.__uns.save()
# -----------------------------------------------------
# close
#
def close(self):
"""close open file"""
if not self.__is_valid:
raise RuntimeError("CUNS_OUT is not valid")
self.__uns.close()
//-*- C -*- //-*- C -*-
// ============================================================================ // ============================================================================
// Copyright Jean-Charles LAMBERT - 2008-2015 // Copyright Jean-Charles LAMBERT - 2008-2019
// Centre de donneeS Astrophysiques de Marseille (CeSAM) // Centre de donneeS Astrophysiques de Marseille (CeSAM)
// e-mail: Jean-Charles.Lambert@lam.fr // e-mail: Jean-Charles.Lambert@lam.fr
// address: Aix Marseille Universite, CNRS, LAM // address: Aix Marseille Universite, CNRS, LAM
// Laboratoire d'Astrophysique de Marseille // Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert // Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie // 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France // 13388 Marseille cedex 13 France
// CNRS UMR 7326 // CNRS UMR 7326
// ============================================================================ // ============================================================================
// Swig python interface for UNSIO // Swig python interface for UNSIO
// ============================================================================ // ============================================================================
...@@ -126,4 +126,3 @@ ...@@ -126,4 +126,3 @@
//%template(CunsOutF) uns::CunsOut2<float>; //%template(CunsOutF) uns::CunsOut2<float>;
%template(CunsOut) uns::CunsOut2<float>; %template(CunsOut) uns::CunsOut2<float>;
%template(CunsOutD) uns::CunsOut2<double>; %template(CunsOutD) uns::CunsOut2<double>;
from . import ctestunsio #from . import ctestunsio
#!/usr/bin/env python
from __future__ import print_function
import platform
import sys
class CPlateform:
"""
Detect running platform
"""
__fdout=None # file descriptor
__out=None # file name
__is_open=False # out file is not open
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
def __init__(self,out=None, fdout=None):
"""
Set file descriptor to save platform information
"""
self.__fdout = fdout
self.__out = out
if (fdout is None and out is not None): # open a new file
try:
self.__fdout=open(out,"w")
self.__is_open=True
except:
print("Impossible to write into file file[%s]\n"%(out))
sys.exit()
else :
if (fdout is None and out is None) : # sys.stderr defaul
self.__fdout=sys.stderr # default file desc if fdout is None
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# display
def display(self):
"""
Display platform information
"""
print("""
Python version : %s
dist : %s
linux_distribution: %s
system : %s
machine : %s
platform : %s
version : %s
mac_ver : %s
uname : %s
""" % (
sys.version.split('\n'),
str(platform.dist()),
self.__linux_distribution(),
platform.system(),
platform.machine(),
platform.platform(),
platform.version(),
platform.mac_ver(),
platform.uname(),
),
file=self.__fdout)
if self.__is_open:
self.__fdout.close()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# __linux_distribution
def __linux_distribution(self):
try:
return platform.linux_distribution()
except:
return "N/A"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
import argparse
# help
parser = argparse.ArgumentParser(description="Print info on platform",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('--out', help='save info in outfilename, if None on screen', type=str, default=None)
args=parser.parse_args()
process(args)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def process(args):
info=CPlateform(args.out)
info.display()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
This diff is collapsed.
#!/usr/bin/env python
#
# In the example below, we load a RAMSES simulation that
# we save in gadget3 file format
#
import unsio.input as uns_in # unsio reading module
myfile="/home/jcl/output_00004" # input RAMSES simulation
# we instantiate object
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
# read stars positions
status,poss=my_in.getData("stars","pos")
# read gas positions
status,posg=my_in.getData("gas","pos")
# read gas densities
status,rho=my_in.getData("gas","rho")
# read time simulation
status,timex=my_in.getData("time")
#
# Writing
#
import unsio.output as uns_out # unsio writing module
myoutfile="snapshot.g3" # output file name
# we instantiate object
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
# prepare data to be saved
# set time
status=my_out.setData(timex,"time")
# set positions for stars
status=my_out.setData(poss,"stars","pos")
# set positions for gas
status=my_out.setData(posg,"gas","pos")
# set density for gas
status=my_out.setData(rho,"gas","rho")
# write on file system
my_out.save()
# close
my_out.close()
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# compile wheel # compile wheel
for PYBIN in /opt/python/*/bin/; do for PYBIN in /opt/python/*/bin/; do
echo "Compiling using pip version ${PYBIN}...." echo "Compiling using pip version ${PYBIN}...."
(cd /unsio; ${PYBIN}/python setup.py clean --all)
PATH=/opt2/local/swig-p37/bin/:${PATH} "${PYBIN}/pip" wheel /unsio/ -w wheelhouse PATH=/opt2/local/swig-p37/bin/:${PATH} "${PYBIN}/pip" wheel /unsio/ -w wheelhouse
done done
......
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
for PYBIN in /opt/python/*/bin/; do for PYBIN in /opt/python/*/bin/; do
echo "Compiling using pip version ${PYBIN}...." echo "Compiling using pip version ${PYBIN}...."
#"${PYBIN}/python" #"${PYBIN}/python"
(cd /unsio; ${PYBIN}/python setup.py clean --all)
PATH=/opt2/local/swig-p37/bin/:${PATH} "${PYBIN}/pip" wheel /unsio/ -w wheelhouse PATH=/opt2/local/swig-p37/bin/:${PATH} "${PYBIN}/pip" wheel /unsio/ -w wheelhouse
done done
...@@ -2,15 +2,19 @@ ...@@ -2,15 +2,19 @@
# install mandatory packages # install mandatory packages
/opt2/scripts/install_requirements.sh #/opt2/scripts/install_requirements.sh
/unsio/py/wheels/linux/install_requirements.sh
# build and install UNSIO library # build and install UNSIO library
/opt2/scripts/build_unsio.sh #/opt2/scripts/build_unsio.sh
/unsio/py/wheels/linux/build_unsio.sh
# build wheels for every python version # build wheels for every python version
#/opt2/scripts/build_wheel.sh #/opt2/scripts/build_wheel.sh
/opt/python/cp37-cp37m/bin/python /unsio/py/wheels/linux/build_wheel.py /unsio/py/wheels/linux/build_wheel.sh
#/opt/python/cp37-cp37m/bin/python /unsio/py/wheels/linux/build_wheel.py
# repair wheels for every python version # repair wheels for every python version
#/opt2/scripts/repair_wheel.sh #/opt2/scripts/repair_wheel.sh
/unsio/py/wheels/linux/repair_wheel.sh
...@@ -5,14 +5,14 @@ UNSIO : Universal Nbody Snapshot Input Output ...@@ -5,14 +5,14 @@ UNSIO : Universal Nbody Snapshot Input Output
""" """
from distutils.core import setup, Extension import numpy
import numpy,os,sys import os
from setuptools import setup, Extension, find_packages import sys
from setuptools import setup, Extension
from setuptools.command.build_py import build_py as _build_py from setuptools.command.build_py import build_py as _build_py
#import setuptools.command.build_ext
# find out numpy include directory. # find out numpy include directory.
try: try:
numpy_include = numpy.get_include() numpy_include = numpy.get_include()
except AttributeError: except AttributeError:
...@@ -22,82 +22,125 @@ if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 4): ...@@ -22,82 +22,125 @@ if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 4):
raise RuntimeError("Python version 2.7 or >= 3.4 required.") raise RuntimeError("Python version 2.7 or >= 3.4 required.")
# detect python version (2 or 3) # detect python version (2 or 3)
pyversion="3" pyversion = "3"
if sys.version_info[0]<3 : if sys.version_info[0] < 3:
pyversion="" pyversion = ""
with open('README.md', 'r') as f:
long_description="""\ long_description = f.read()
UNSIO (*U*niversal *N*body *S*napshot *I*nput *O*utput) is an API which perform input/output operations in a generic way, and on different kind of nbody files format (nemo, Gadget binaries 1 and 2, Gadget hdf5, Ramses).
By using this API, a user could write only one analysis program which will work on all known files format supported by UNSIO.
It's not necessary anymore to know how is implemented a file format, UNSIO will do transparently and automatically all the hard work for you ! With UNSIO, you will spend less time to develop your analysis program.
UNSIO comes with an integrated sqlite3 database which can be used to retrieve automatically all your data among terabytes of hard disks.
"""
# trick to add SWIG generated module # trick to add SWIG generated module
# see https://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module # see https://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
# and especially : https://stackoverflow.com/questions/29477298/setup-py-run-build-ext-before-anything-else/48942866#48942866 # and especially : https://stackoverflow.com/questions/29477298/setup-py-run-build-ext-before-anything-else/48942866#48942866
# and the fix for python2 https://stackoverflow.com/questions/1713038/super-fails-with-error-typeerror-argument-1-must-be-type-not-classobj-when/1713052#1713052
class build_py(_build_py): class build_py(_build_py, object):
def run(self): def run(self):
self.run_command("build_ext") self.run_command("build_ext")
if pyversion=="": # python2 if pyversion == "": # python2
return super().run() return super(build_py, self).run()
else: # python3 else: # python3
return super().run() return super().run()
setup(
#name='python'+pyversion+'-unsio',
name='python-unsio',
version='0.9.2',
description='A python wrapper to unsio',
long_description=long_description,
author='Jean-Charles LAMBERT',
author_email='jean-charles.lambert@lam.fr',
url='https://projets.lam.fr/projects/unsio',
license='CeCILL2.1 (https://opensource.org/licenses/CECILL-2.1)',
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: C",
"Programming Language :: C++",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Software Development"],
platforms = ["Linux", "Mac OS-X", "Unix"],
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
package_dir={'':'py'}, # all packages are under 'py' directory
packages=['unsio','unsio/test'],
#cmdclass = {'install':Build_ext_first},
#cmdclass={'build': CustomBuild, 'install': CustomInstall},
cmdclass = {'build_py' : build_py},
py_modules=['unsio/py_unsio'],
ext_modules = [
Extension("unsio/_py_unsio",
sources=[ "py/unsio/py_unsio.i"],
swig_opts=['-c++','-modern', '-Isrc','-I./py/unsio', '-Iswig'],
include_dirs = [numpy_include,'src'],
libraries=['unsio'],
library_dirs=['/Users/jcl/local/unsio/lib','/usr/lib64','/lib64'],
runtime_library_dirs=['/Users/jcl/local/unsio/lib','/usr/lib64','/lib64']
)
],
entry_points = {
"console_scripts": [
"test_unsio_lib = unsio.test.ctestunsio:commandLine",
],
},
#install_requires=['numpy'],
setup_requires=['numpy']
#
)
#
# version management
#
MAJOR = '0'
MINOR = '9'
MICRO = '3rc5'
VERSION = '%s.%s.%s' % (MAJOR, MINOR, MICRO)
#
# write_version : write unsio version in py/unsio/version.py file
# it's imported from __init__.py as __version__
def write_version_py(filename='py/unsio/version.py'):
cnt = """
# THIS FILE IS GENERATED FROM PYTHON-UNSIO SETUP.PY
#
version = '%(version)s'
"""
a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION})
finally:
a.close()
#
# setup_package :
#
def setup_package():
# generate version
write_version_py()
# metada for setup
metadata = dict(
# name='python'+pyversion+'-unsio',
name='python-unsio',
version=VERSION,
description='A python wrapper to unsio',
long_description=long_description,
long_description_content_type='text/markdown',
author='Jean-Charles LAMBERT',
author_email='jean-charles.lambert@lam.fr',
url='https://projets.lam.fr/projects/unsio/wiki',
license='CeCILL2.1 (https://opensource.org/licenses/CECILL-2.1)',
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: C",
"Programming Language :: C++",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Software Development"],
platforms=["Linux", "Mac OS-X", "Unix"],
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
package_dir={'': 'py'}, # all packages are under 'py' directory
packages=['unsio', 'unsio/test'],
# cmdclass = {'install':Build_ext_first},
# cmdclass={'build': CustomBuild, 'install': CustomInstall},
cmdclass={'build_py': build_py},
py_modules=['unsio/py_unsio'],
ext_modules=[
Extension("unsio/_py_unsio",
sources=["py/unsio/py_unsio.i"],
swig_opts=['-c++', '-modern', '-Isrc',
'-I./py/unsio', '-Iswig'],
include_dirs=[numpy_include, 'src'],
libraries=['unsio'],
library_dirs=[
os.environ['HOME']+'/local/unsio/lib',
os.environ['HOME']+'/local/unsio/lib/x86_64-linux-gnu',
'/usr/lib64', '/lib64'],
runtime_library_dirs=[
os.environ['HOME']+'/local/unsio/lib',
os.environ['HOME']+'/local/unsio/lib/x86_64-linux-gnu',
'/usr/lib64', '/lib64']
)
],
entry_points={
"console_scripts": [
"test_unsio_lib = unsio.test.ctestunsio:commandLine",
],
},
install_requires=['numpy'],
setup_requires=['numpy']
#
)
setup(**metadata)
#
# main
#
if __name__ == '__main__':
setup_package()
...@@ -176,6 +176,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -176,6 +176,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
int ngridlevel [nlevelmax][ncpu ]; int ngridlevel [nlevelmax][ncpu ];
int ngridbound [nlevelmax][ nboundary]; int ngridbound [nlevelmax][ nboundary];
double xc[3][8]; double xc[3][8];
double gamma;
int ngrida; int ngrida;
std::string infile; std::string infile;
...@@ -236,7 +237,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -236,7 +237,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
hydro.readDataBlock((char *) &nvarh); hydro.readDataBlock((char *) &nvarh);
particles->nvarh = nvarh; particles->nvarh = nvarh;
//std::cerr << "nvarh = " << nvarh << "\n" ; //std::cerr << "nvarh = " << nvarh << "\n" ;
hydro.skipBlock(4); // ndim,levelmax,nboundary,gamma hydro.skipBlock(3); // ndim,levelmax,nboundary
hydro.readDataBlock((char *) &gamma); // gamma
// -------------- // --------------
// Open GRAV file and skip header // Open GRAV file and skip header
...@@ -368,9 +370,11 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -368,9 +370,11 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
} }
if (ngrida>0) { if (ngrida>0) {
// Loop over cells // Loop over cells
for (int ind=0;ind<twotondim;ind++) { //for (int ind=0;ind<twotondim;ind++) {
// Store data cube
for (int i=0;i<ngrida;i++) { for (int i=0;i<ngrida;i++) {
// Store data cube
//for (int i=0;i<ngrida;i++) {
for (int ind=0;ind<twotondim;ind++) {
// compute cell center // compute cell center
double px=xg[0*ngrida+i]+xc[0][ind]-xbound[0]; // x double px=xg[0*ngrida+i]+xc[0][ind]-xbound[0]; // x
double py=xg[1*ngrida+i]+xc[1][ind]-xbound[1]; // y double py=xg[1*ngrida+i]+xc[1][ind]-xbound[1]; // y
...@@ -463,7 +467,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -463,7 +467,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
if (req_bits&TEMP_BIT && nvarh>(4+offset_2d)) { if (req_bits&TEMP_BIT && nvarh>(4+offset_2d)) {
double temp=0.0; double temp=0.0;
if (rho!=0.0) { if (rho!=0.0) {
temp=std::max(0.0,var[(4+offset_2d)*ngrida*twotondim+ind*ngrida+i]/rho); temp=std::max(0.0,var[(4+offset_2d)*ngrida*twotondim+ind*ngrida+i]/((gamma-1)*rho));
} }
particles->temp.push_back(temp); particles->temp.push_back(temp);
particles->load_bits |= TEMP_BIT; particles->load_bits |= TEMP_BIT;
...@@ -489,7 +493,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles, ...@@ -489,7 +493,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
} }
// particles ID // particles ID
if (req_bits&ID_BIT) { if (req_bits&ID_BIT) {
particles->id.push_back(-1.); // no id for gas, use "-1" //particles->id.push_back(-1.); // no id for gas, use "-1"
particles->id.push_back(-1.*(((particles->ngas+1)*(ncpu-1)+icpu+1))); // no id for gas, use "-1"
particles->load_bits |= ID_BIT; particles->load_bits |= ID_BIT;
} }
if (take|| !req_bits) { // !req_bits for uns_info and display=f if (take|| !req_bits) { // !req_bits for uns_info and display=f
......
...@@ -36,6 +36,13 @@ typedef struct { ...@@ -36,6 +36,13 @@ typedef struct {
double aexp,hexp,aexp_old,epot_tot_int,epot_tot_old; double aexp,hexp,aexp_old,epot_tot_int,epot_tot_old;
} Header; } Header;
template <class T> class T_Header {
public:
T time;
T boxlen, omega_m, omega_l, omega_k, omega_b, h0, aexp_ini, boxlen_ini;
T aexp,hexp,aexp_old,epot_tot_int,epot_tot_old;
};
class CAmr { class CAmr {
public: public:
CAmr(const std::string,const bool _v=true); CAmr(const std::string,const bool _v=true);
...@@ -66,7 +73,6 @@ public: ...@@ -66,7 +73,6 @@ public:
int getNbody() { return nbody;} int getNbody() { return nbody;}
Header * getHeader() { return &header; } Header * getHeader() { return &header; }
private: private:
// some variables // some variables
...@@ -80,6 +86,7 @@ private: ...@@ -80,6 +86,7 @@ private:
int lmin,lmax; int lmin,lmax;
CFortIO amr, hydro, grav; CFortIO amr, hydro, grav;
int readHeader(); int readHeader();
bool checkGravity(const int ngrida,const int ilevel,const int icpu, int * gridfile); bool checkGravity(const int ngrida,const int ilevel,const int icpu, int * gridfile);
// amr header variables // amr header variables
static const double XH, mH, kB; static const double XH, mH, kB;
...@@ -87,6 +94,7 @@ private: ...@@ -87,6 +94,7 @@ private:
int twotondim; int twotondim;
double xbound[3]; double xbound[3];
Header header; Header header;
// hydro // hydro
int nvarh; int nvarh;
double scale_nH; double scale_nH;
......
...@@ -133,7 +133,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -133,7 +133,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
// read masses // read masses
tmp[6] = new double[npart]; // alloc tmp[6] = new double[npart]; // alloc
part.readDataBlock((char *) tmp[6]); part.readDataBlock((char *) tmp[6]);
double * agetmp, * metaltmp; double * agetmp, * metaltmp=NULL;
int * id=NULL; int * id=NULL;
char * family=NULL; char * family=NULL;
......
...@@ -44,6 +44,8 @@ namespace tools { ...@@ -44,6 +44,8 @@ namespace tools {
#define CM_BIT (1 << 21) #define CM_BIT (1 << 21)
#define SSL_BIT (1 << 22) #define SSL_BIT (1 << 22)
#define HYDRO_BIT (1 << 23) #define HYDRO_BIT (1 << 23)
#define NH_BIT (1 << 24)
#define SFR_BIT (1 << 25)
// Component BITS // Component BITS
#define ALL_BIT (1 << 1) #define ALL_BIT (1 << 1)
......
This diff is collapsed.
// ============================================================================ // ============================================================================
// Copyright Jean-Charles LAMBERT - 2008-2016 // Copyright Jean-Charles LAMBERT - 2008-2016
// Centre de donneeS Astrophysiques de Marseille (CeSAM) // Centre de donneeS Astrophysiques de Marseille (CeSAM)
// e-mail: Jean-Charles.Lambert@lam.fr // e-mail: Jean-Charles.Lambert@lam.fr
// address: Aix Marseille Universite, CNRS, LAM // address: Aix Marseille Universite, CNRS, LAM
// Laboratoire d'Astrophysique de Marseille // Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert // Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie // 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France // 13388 Marseille cedex 13 France
// CNRS UMR 7326 // CNRS UMR 7326
// ============================================================================ // ============================================================================
/** /**
...@@ -41,10 +41,20 @@ typedef struct io_header_1 ...@@ -41,10 +41,20 @@ typedef struct io_header_1
double BoxSize; double BoxSize;
double Omega0; double Omega0;
double OmegaLambda; double OmegaLambda;
double HubbleParam; double HubbleParam;
char fill[256- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8]; /* fills to 256 Bytes */ char fill[256- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8]; /* fills to 256 Bytes */
} t_io_header_1; } t_io_header_1;
template <class T> class CG2_T_Header {
public:
T time;
T redshift;
T BoxSize;
T Omega0;
T OmegaLambda;
T HubbleParam;
};
typedef struct s_data_type_header { typedef struct s_data_type_header {
int size_bytes; int size_bytes;
int items; int items;
...@@ -71,7 +81,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -71,7 +81,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
{DOUBLE ,1}, // double BoxSize; {DOUBLE ,1}, // double BoxSize;
{DOUBLE ,1}, // double Omega0; {DOUBLE ,1}, // double Omega0;
{DOUBLE ,1}, // double OmegaLambda; {DOUBLE ,1}, // double OmegaLambda;
{DOUBLE ,1}, // double HubbleParam; {DOUBLE ,1}, // double HubbleParam;
{CHAR ,96} // char fill[256- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8]; {CHAR ,96} // char fill[256- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8];
}; };
...@@ -82,7 +92,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -82,7 +92,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
// --------------------------------------------------- // ---------------------------------------------------
template <class T> class CSnapshotGadgetIn : public CSnapshotInterfaceIn<T> { template <class T> class CSnapshotGadgetIn : public CSnapshotInterfaceIn<T> {
public: public:
// READING constrcuctor // READING constrcuctor
CSnapshotGadgetIn(const std::string, const std::string, const std::string, const bool verb=false); CSnapshotGadgetIn(const std::string, const std::string, const std::string, const bool verb=false);
...@@ -121,7 +131,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -121,7 +131,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
bool lonely_file; bool lonely_file;
//data //data
T * mass, * pos, * vel, * acc, *pot, * rho, * hsml, * age, * metal, * intenerg, * temp; T * mass, * pos, * vel, * acc, *pot, * rho,
* hsml, * age, * metal, * intenerg, * temp, * nh, *sfr;
int * id; int * id;
// new data for Sergey // new data for Sergey
T * zs, * zsmt, * im, * cm, * ssl; T * zs, * zsmt, * im, * cm, * ssl;
...@@ -130,6 +141,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -130,6 +141,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
T tframe,redshift; T tframe,redshift;
int ntotmasses; int ntotmasses;
t_io_header_1 header; t_io_header_1 header;
CG2_T_Header<T> t_header;
int npartTotal, npart, npart_total_local; int npartTotal, npart, npart_total_local;
int array_vs_file_size; // array vs file 0:same 1:smaler(half) 2:bigger(double) int array_vs_file_size; // array vs file 0:same 1:smaler(half) 2:bigger(double)
inline void checkFileVsArray(const int bytes_to_read, const int size_data, const int npart) { inline void checkFileVsArray(const int bytes_to_read, const int size_data, const int npart) {
...@@ -179,6 +191,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -179,6 +191,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
T * getMetalGas(int & n) { n=header.npartTotal[0]; return metal;} T * getMetalGas(int & n) { n=header.npartTotal[0]; return metal;}
T * getMetalStars(int & n) { n=header.npartTotal[4]; return metal+header.npartTotal[0];} T * getMetalStars(int & n) { n=header.npartTotal[4]; return metal+header.npartTotal[0];}
T * getTemp(int & n) { n=header.npartTotal[0]; return temp;} T * getTemp(int & n) { n=header.npartTotal[0]; return temp;}
T * getNh(int & n) { n=header.npartTotal[0]; return nh;}
T * getSfr(int & n) { n=header.npartTotal[0]; return sfr;}
T * getU(int & n) { n=header.npartTotal[0]; return intenerg;} T * getU(int & n) { n=header.npartTotal[0]; return intenerg;}
T * getRho(int & n) { n=header.npartTotal[0]; return rho;} T * getRho(int & n) { n=header.npartTotal[0]; return rho;}
T * getHsml(int & n) { n=header.npartTotal[0]; return hsml;} T * getHsml(int & n) { n=header.npartTotal[0]; return hsml;}
...@@ -193,7 +207,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = { ...@@ -193,7 +207,7 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
T * getCm(int & n) { n=1*(header.npartTotal[0]+header.npartTotal[4]); return cm;} T * getCm(int & n)