Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev snonis #93

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
2 changes: 1 addition & 1 deletion examples/grandlib_classes/dummy_reconstruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
Loading
Loading