Skip to content

Commit

Permalink
Merge branch 'dev_sim2root' into dev_io_root
Browse files Browse the repository at this point in the history
# Conflicts:
#	data/download_data_grand.py
#	grand/sim/detector/rf_chain.py
#	sim2root/Common/sim2root.py
  • Loading branch information
lwpiotr committed Dec 16, 2024
2 parents 3444b56 + 0694fa9 commit f7bf59f
Show file tree
Hide file tree
Showing 21 changed files with 258 additions and 145 deletions.
23 changes: 18 additions & 5 deletions data/download_data_grand.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@

#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"
LINK_MODEL = "https://forge.in2p3.fr/attachments/download/211902/grand_model_2306.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 @@ -33,7 +46,7 @@

# 2- download
print("==============================")
print("Download data model (~ 1GB) for GRAND, please wait ...")
print("Download data model (~ 452 MB) for GRAND, please wait ...")
try:
request.urlretrieve(LINK_MODEL, tar_file)
print("Successfully downloaded")
Expand All @@ -53,4 +66,4 @@
print(f"Extract failed '{tar_file}'")
sys.exit(1)
print("data model available in grand/data directory !")
sys.exit(0)
sys.exit(0)
72 changes: 72 additions & 0 deletions data/download_new_RFchain.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)
1 change: 1 addition & 0 deletions env/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ cd $script_full_path

# download data model for GRAND
data/download_data_grand.py
data/download_new_RFchain.py

cd $call_path
Loading

0 comments on commit f7bf59f

Please sign in to comment.