Skip to content

Commit

Permalink
Merge branch 'dev' into dev_io_root
Browse files Browse the repository at this point in the history
# Conflicts:
#	grand/sim/efield2voltage.py
#	scripts/convert_efield2voltage.py
#	sim2root/Common/IllustrateSimPipe.py
  • Loading branch information
lwpiotr committed Dec 16, 2024
2 parents 12939e4 + 4642510 commit 3444b56
Show file tree
Hide file tree
Showing 108 changed files with 8,815 additions and 589 deletions.
45 changes: 39 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
grand package |workflow| |codecov| |docs| |appimage|
====================================================
GRANDlib
========
|workflow| |codecov| |docs| |appimage|

*Core* `Python 3`_ *package for the offline software of the* `GRAND`_

*Core* `Python 3`_ *package for the offline data handling and analysis for the* `GRAND`_
*Collaboration.*

.. contents:: Contents
:local:
:depth: 2


Environment
-----------

GRAND library can be used under docker to define a correct environment, read `GRAND_wiki`_ for more information, else you must install `ROOT`_ library and compile `TURTLE`_ and `GULL`_ library under your computer.
The GRAND library - **GRANDlib** - can be used under docker to define a correct environment, read `GRAND_wiki`_ for more information, else you must install `ROOT`_ library and compile `TURTLE`_ and `GULL`_ library under your computer.

Don't forget to initialize grand library before use it with script **env/setup.sh** only in the root of the package

Expand All @@ -20,9 +26,14 @@ Don't forget to initialize grand library before use it with script **env/setup.s
Documentation
-----------
-------------

Check the `online documentation`_ for further details, but best study the examples.

Check the `online documentation`_ for further details.
Examples
--------

Examples and scripts can be found under *examples/* and *scripts/* subdirectories


How to contribute
Expand Down Expand Up @@ -90,3 +101,25 @@ The GRAND software is distributed under the LGPL-3.0 license. See the provided

.. |workflow| image:: https://github.com/grand-mother/grand/workflows/Tests/badge.svg
:target: https://github.com/grand-mother/grand/actions?query=workflow%3ATests

Citing
------

If you use GRANDlib in your work, we ask you that you please cite the following paper: R. Alves Batista et al., GRANDlib: A simulation pipeline for the Giant Radio Array for Neutrino Detection
(GRAND) (arXiv:2408.10926).

If you are citing GRANDlib in a document that will be uploaded to the arXiv, please consider using the LaTeX or BibTeX entries provided by INSPIRE (link here):

.. code:: latex

@article{GRAND:2024atu,
author = "Alves Batista, Rafael and others",
collaboration = "GRAND",
title = "{GRANDlib: A simulation pipeline for the Giant Radio Array for Neutrino Detection (GRAND)}",
eprint = "2408.10926",
archivePrefix = "arXiv",
primaryClass = "astro-ph.IM",
month = "8",
year = "2024"
}

72 changes: 72 additions & 0 deletions data/download_LFmap_grand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#! /usr/bin/env python3

'''
Created on 19 juil. 2022
@author: Jean-Marc Colley, CNRS/IN2P3/LPNHE
'''
import tarfile
import os
import sys
import os.path as osp
from urllib import request
#TODO: add progressbar to grand lib
#import progressbar

from grand import GRAND_DATA_PATH, grand_add_path_data

#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/133380/grand_model_2207.tar.gz"
#FILE_MODEL = "grand_model_2207.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/201909/grand_model_2306.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/251637/grand_model_190224.tar.gz"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/326497/LFmap.tar.gz"
FILE_MODEL = LINK_MODEL.split("/")[-1]
# class MyProgressBar():
# def __init__(self):
# self.pbar = None
#
# def __call__(self, block_num, block_size, total_size):
# if not self.pbar:
# self.pbar=progressbar.ProgressBar(maxval=total_size)
# self.pbar.start()
#
# downloaded = block_num * block_size
# if downloaded < total_size:
# self.pbar.update(downloaded)
# else:
# self.pbar.finish()


# 1- test if download is necessary
if os.path.exists(grand_add_path_data('noise/LFmap')):
print("==============================")
print('Skip download LFmap files for Galactic noise simulations')
sys.exit(0)

GRAND_DATA_PATH_1 = osp.join(grand_add_path_data('noise'))
tar_file = osp.join(GRAND_DATA_PATH_1, FILE_MODEL)

# 2- download
print("==============================")
print("Download LFmap model (~ 6.4 MB) for GRAND, please wait ...")
try:
request.urlretrieve(LINK_MODEL, tar_file)
print("Successfully downloaded")
except:
print(f"download failed {LINK_MODEL}")
sys.exit(1)

# 3- extract
print("==============================")
print('Extract tar file')
try:
my_tar = tarfile.open(tar_file)
my_tar.extractall(grand_add_path_data('noise'))
my_tar.close()
os.remove(tar_file) # delete zipped file are extraction.
except:
print(f"Extract failed '{tar_file}'")
sys.exit(1)
print("LFmap model available in grand/data/noise directory !")
sys.exit(0)
24 changes: 4 additions & 20 deletions data/download_data_grand.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,11 @@
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/133380/grand_model_2207.tar.gz"
#FILE_MODEL = "grand_model_2207.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/201909/grand_model_2306.tar.gz"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/211902/grand_model_2306.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/251637/grand_model_190224.tar.gz"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/340302/grand_model_141124.tar.gz"
FILE_MODEL = LINK_MODEL.split("/")[-1]


# class MyProgressBar():
# def __init__(self):
# self.pbar = None
#
# def __call__(self, block_num, block_size, total_size):
# if not self.pbar:
# self.pbar=progressbar.ProgressBar(maxval=total_size)
# self.pbar.start()
#
# downloaded = block_num * block_size
# if downloaded < total_size:
# self.pbar.update(downloaded)
# else:
# self.pbar.finish()


# 1- test if download is necessary
if os.path.exists(grand_add_path_data('detector')):
print("==============================")
print('Skip download data model')
Expand All @@ -49,7 +33,7 @@

# 2- download
print("==============================")
print("Download data model (~ 452MB) for GRAND, please wait ...")
print("Download data model (~ 1GB) for GRAND, please wait ...")
try:
request.urlretrieve(LINK_MODEL, tar_file)
print("Successfully downloaded")
Expand All @@ -69,4 +53,4 @@
print(f"Extract failed '{tar_file}'")
sys.exit(1)
print("data model available in grand/data directory !")
sys.exit(0)
sys.exit(0)
60 changes: 60 additions & 0 deletions data/download_grand_antenna_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env python3

'''
Created on 19 juil. 2022
@author: Jean-Marc Colley, CNRS/IN2P3/LPNHE
'''
import tarfile
import os
import sys
import os.path as osp
from urllib import request
#TODO: add progressbar to grand lib
#import progressbar

from grand import GRAND_DATA_PATH, grand_add_path_data

#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/133380/grand_model_2207.tar.gz"
#FILE_MODEL = "grand_model_2207.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/201909/grand_model_2306.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/251637/grand_model_190224.tar.gz"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/340302/grand_model_141124.tar.gz"
FILE_MODEL = LINK_MODEL.split("/")[-1]


directory = grand_add_path_data('detector')
specific_file = os.path.join(directory, 'Light_GP300Antenna_nec_Yarm_leff.npz')

# Check if the specific file exists in the directory
if os.path.isfile(specific_file):
print("==============================")
print('Skip download Grand antenna models')
sys.exit(0)

tar_file = osp.join(GRAND_DATA_PATH, FILE_MODEL)

# 2- download
print("==============================")
print("Download antenna models, RFchain, Galactic noise (~ 1GB) for GRAND, please wait ...")
try:
request.urlretrieve(LINK_MODEL, tar_file)
print("Successfully downloaded")
except:
print(f"download failed {LINK_MODEL}")
sys.exit(1)

# 3- extract
print("==============================")
print('Extract tar file')
try:
my_tar = tarfile.open(tar_file)
my_tar.extractall(grand_add_path_data(''))
my_tar.close()
os.remove(tar_file) # delete zipped file are extraction.
except:
print(f"Extract failed '{tar_file}'")
sys.exit(1)
print("Antenna models available in grand/data/detector directory !")
sys.exit(0)
72 changes: 72 additions & 0 deletions data/download_new_RFchain_grand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#! /usr/bin/env python3

'''
Created on 19 juil. 2022
@author: Jean-Marc Colley, CNRS/IN2P3/LPNHE
'''
import tarfile
import os
import sys
import os.path as osp
from urllib import request
#TODO: add progressbar to grand lib
#import progressbar

from grand import GRAND_DATA_PATH, grand_add_path_data

#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/133380/grand_model_2207.tar.gz"
#FILE_MODEL = "grand_model_2207.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/201909/grand_model_2306.tar.gz"
#LINK_MODEL = "https://forge.in2p3.fr/attachments/download/251637/grand_model_190224.tar.gz"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/312643/RFchain_V3.tar.gz"
FILE_MODEL = LINK_MODEL.split("/")[-1]
# class MyProgressBar():
# def __init__(self):
# self.pbar = None
#
# def __call__(self, block_num, block_size, total_size):
# if not self.pbar:
# self.pbar=progressbar.ProgressBar(maxval=total_size)
# self.pbar.start()
#
# downloaded = block_num * block_size
# if downloaded < total_size:
# self.pbar.update(downloaded)
# else:
# self.pbar.finish()


# 1- test if download is necessary
if os.path.exists(grand_add_path_data('detector/RFchain_v2')):
print("==============================")
print('Skip download data model')
sys.exit(0)

GRAND_DATA_PATH_1 = osp.join(grand_add_path_data('detector'))
tar_file = osp.join(GRAND_DATA_PATH_1, FILE_MODEL)

# 2- download
print("==============================")
print("Download new RFchain model (~ 450 KB) for GRAND, please wait ...")
try:
request.urlretrieve(LINK_MODEL, tar_file)
print("Successfully downloaded")
except:
print(f"download failed {LINK_MODEL}")
sys.exit(1)

# 3- extract
print("==============================")
print('Extract tar file')
try:
my_tar = tarfile.open(tar_file)
my_tar.extractall(grand_add_path_data('detector'))
my_tar.close()
os.remove(tar_file) # delete zipped file are extraction.
except:
print(f"Extract failed '{tar_file}'")
sys.exit(1)
print("data model available in grand/data/detector directory !")
sys.exit(0)
Loading

0 comments on commit 3444b56

Please sign in to comment.