Skip to content

Commit

Permalink
Merge 99fe85e into f944a45
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-fiorito-11 committed May 19, 2021
2 parents f944a45 + 99fe85e commit bfd9190
Show file tree
Hide file tree
Showing 66 changed files with 11,944 additions and 4,195 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ branches:
except: gh-pages

before_install:
- git clone https://github.com/njoy/NJOY2016.git && (cd NJOY2016 && mkdir build && cd build && cmake .. && make) # install NJOY
- git clone https://github.com/njoy/NJOY2016.git && (cd NJOY2016 && mkdir build && cd build && cmake -DPython3_EXECUTABLE=$(which python3) .. && make) # install NJOY
- rm -rf NJOY2016/tests
- pip install sphinx sphinx_rtd_theme codecov numpydoc coveralls pytest-cov
- pip install -r requirements.txt
Expand All @@ -31,8 +31,7 @@ install:
- python setup.py install

script:
- pytest --cov=sandy/
-pytest --nbval notebooks/fy_notebook.ipynb
- pytest --cov=sandy sandy

after_success:
- coveralls
Expand Down
108 changes: 108 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Installation

## Download

The SANDY source code is available as a git repository.
The recommended way to get SANDY is by cloning the source package using your
local git distribution
(*click [here](https://git-scm.com/downloads) to download it!*).

```sh
git clone https://github.com/luca-fiorito-11/sandy.git
cd sandy
```

If a `SSL Certificate problem` appears when pushing or pulling with git,
one can tell git to not perform the validation of the certificate using the
global option:

```git
git config --global http.sslVerify false
```

## Installation using Anaconda

### Downloading Anaconda
The recommended way to install the SANDY requirements (especially on Windows)
is with the Anaconda distribution, which already includes several python
packages and few other cool tools.
The installer for the most recent Anaconda distributions can be found
[here](https://www.anaconda.com/products/individual).
For the Anaconda installation documentation, click
[here](https://docs.anaconda.com/anaconda/install/).

### Getting started with Anaconda
The user guide to get yourself acquainted with Anaconda is available
[here](https://docs.anaconda.com/anaconda/user-guide/).
On a Windows machine we recommend that you use the Anaconda Prompt terminal.

### Installing SANDY

We advise to install the SANDY dependences in a python environment that was
not previously altered.
You can do so from a terminal/Anaconda Prompt using the package/environment
management system `conda` included in Anaconda, as
```sh
conda update --name base conda
conda create -y --name sandy-devel -c conda-forge python=3.7 jupyterlab jupyter_nbextensions_configurator
```
I like to include jupyterlab to my environment!

Then, dependences are installed from the requirement file,
```sh
conda install --force-reinstall -y --name sandy-devel -c conda-forge --file requirements_conda.txt
```
Make sure you are in the folder `sandy` that you cloned with git and where
file `requirement.txt` is located.

From now on, every time you want to use SANDY in your python distribution
you need to activate the correct environemt.
```sh
conda activate sandy-devel
...
conda deactivate
```
To manage your python environments read the
[conda cheatsheet](https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf).
Do not forget to add the `sandy` folder to your `PYTHONPATH`, or else you
won't be able to use SANDY when you change folder.
You can do the following

**in Linux**
```sh
export PYTHONPATH="/path/to/sandy:${PYTHONPATH}"
```
Add the previous command to your `${HOME}/.bashrc` or `${HOME}/.bash_profile`
file to make your changes permanent.

**in Windows**
```dos
set PYTHONPATH=%PYTHONPATH%;C:\path\to\sandy
```
or, if you want the changes to be permanent,
```dos
setx PYTHONPATH=%PYTHONPATH%;C:\path\to\sandy
```

## Running python
1. Open a terminal/Anaconda Prompt
2. Switch to the correct python environment
3. Type `python` or `ipython` to open up a python/ipython session,
4. Then type,
```python
import sandy
```

Now, if `sandy` is available you are ready to roll!

## Running SANDY in a Jupyter notebook

For combatibility issues we recommend installing a python kernel specific
for the `sandy-devel` environment.
For that, you can run the following after making sure that `ipykernel` is
installed in the virtual environment.

```sh
conda activate sandy-devel
python -m ipykernel install --user --name sandy-devel --display-name "Python3 (sandy-devel)"
```
11 changes: 11 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
import pandas as pd
import pytest


collect_ignore = ["setup.py"]


@pytest.fixture(autouse=True, scope='session')
def pandas_terminal_width():
pd.options.display.float_format = '{:.5e}'.format
pd.set_option('display.max_columns', 1000)
pd.set_option('display.width', 1000)
80 changes: 59 additions & 21 deletions notebooks/decay_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@
"metadata": {},
"outputs": [],
"source": [
"import sandy\n",
"import os\n",
"\n",
"import yaml\n",
"\n",
"from IPython.core.interactiveshell import InteractiveShell\n",
"InteractiveShell.ast_node_interactivity = \"all\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import sandy\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -43,11 +56,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"tape = sandy.read_formatted_file(\"dec-027_Co_060.endf\")"
"tape = sandy.Endf6.from_file(\"dec-027_Co_060.endf\")"
]
},
{
Expand All @@ -60,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -89,15 +102,15 @@
" 'spin': 2.0,\n",
" 'parity': 1.0,\n",
" 'decay_energy': {'beta': 56430.24,\n",
" 'gamma': 6614.704,\n",
" 'gamma': 6614.704000000001,\n",
" 'alpha': 0.0,\n",
" 'total': 63044.943999999996},\n",
" 'decay_energy_uncertainties': {'beta': 8461.567,\n",
" 'gamma': 425.0476,\n",
" 'alpha': 0.0}}}"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -116,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -148,7 +161,7 @@
" decay_energy:\n",
" alpha: 0.0\n",
" beta: 56430.24\n",
" gamma: 6614.704\n",
" gamma: 6614.704000000001\n",
" total: 63044.943999999996\n",
" decay_energy_uncertainties:\n",
" alpha: 0.0\n",
Expand Down Expand Up @@ -226,7 +239,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -265,7 +278,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -350,7 +363,7 @@
"3 270601 280600 1.0 0.0024 1.103702e-03"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -369,7 +382,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -424,7 +437,7 @@
"270601 0.0 0.0"
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -443,7 +456,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -498,7 +511,7 @@
"270601 1.110223e-16 1.0"
]
},
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -518,9 +531,16 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: NumExpr defaulting to 4 threads.\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -573,7 +593,7 @@
"270601 0.000000e+00 -0.001104"
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -600,9 +620,18 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dumping decay data for ZAM=270600...\n",
"dumping decay data for ZAM=270601...\n"
]
}
],
"source": [
"h5filename = \"decay.hdf5\"\n",
"libname = \"endfb_71\"\n",
Expand All @@ -611,13 +640,22 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"rdd2 = sandy.DecayData.from_hdf5(h5filename, libname)\n",
"assert rdd2.get_decay_chains().equals(chains)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"os.remove(h5filename)"
]
}
],
"metadata": {
Expand All @@ -636,7 +674,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit bfd9190

Please sign in to comment.