Commit 59f9e4c8 authored by Benjamin Schwenker's avatar Benjamin Schwenker
Browse files

Merge branch 'master' of https://gitlab.desy.de/benjamin.schwenker/bg_net into...

Merge branch 'master' of https://gitlab.desy.de/benjamin.schwenker/bg_net into 40-http-exception-not-caught
parents b5e21bc0 42163636
......@@ -69,14 +69,18 @@ def get_start_end(year, month):
last_day = calendar.monthrange(year, month)[1]
start = "{:d}-{:02d}-{:02d} 00:00:00".format(year, month, 1)
start = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(start, "%Y-%m-%d %H:%M:%S"))
if now_jst.year == year and now_jst.month == month:
# Download current month
end = "{:d}-{:02d}-{:02d} {:02d}:{:02d}:00".format(year, month, now_jst.day, now_jst.hour, now_jst.minute)
end = pytz.timezone('Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
else:
# Download historic month
end = "{:d}-{:02d}-{:02d} 23:59:59".format(year, month, last_day)
end = pytz.timezone('Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
end = end + datetime.timedelta(seconds=1)
return start, end
......@@ -94,9 +98,6 @@ def download_archive(year, month, data_folder, connectVPN=None):
"""
logging.info('Starting download_archive ...')
# Get start and end time in JST, as strings
start, end = get_start_end(year, month)
data_folder = os.path.expandvars(data_folder)
superkekb_archiver = EpicsArchiver(
......@@ -105,11 +106,8 @@ def download_archive(year, month, data_folder, connectVPN=None):
server_prefix='/archappl_skekb'
)
# Specify a time interval (say a month). You will create daily summary data frames for this time interval
start = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(start, "%Y-%m-%d %H:%M:%S"))
end = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
# Get start and end time in JST
start, end = get_start_end(year, month)
# Check that end is not on future
if end > indexer_utils.get_now_jst():
......
This diff is collapsed.
......@@ -240,6 +240,12 @@ SKB2_ACC_PVS = [
"VAHCCG:D11_HER:PRES:AVG",
"VAHCCG:D12_HER:PRES:AVG",
"MG_TEMP:D08_AIR1:KX_TEMP", # Temperature PVs
"MG_TEMP:D08_AIR2:KX_TEMP",
"CO_KIKAI:AOH571",
"CO_KIKAI:AOH521",
"CO_KIKAI:ANK571",
"BMD:FAST:DCCT:INJRATE",
"BMHD08:INJ:Q",
"BMHD08:INJ:X",
......@@ -576,17 +582,17 @@ SKB2_ACC_PVS = [
]
# Uncomment when you plan to work with MR optic PVS
# SKB2_ACC_PVS = SKB2_ACC_PVS + SKB2_MR_OPTICS_LER_PVS + SKB2_MR_OPTICS_HER_PVS
SKB2_ACC_PVS = SKB2_ACC_PVS + SKB2_MR_OPTICS_LER_PVS + SKB2_MR_OPTICS_HER_PVS
# Unit string for variables. Using latex, for matplotlib plots
SKB2_UNITS = {
"VXD_Rad": "mRad/s",
"CLAWS": "MHz/s",
"PXD": "%",
"CLAWS_RATE": "MHz/s",
"PXD_OCC": "%",
"SVD_OccMon": "%",
"CDC": r'$\mu$A',
"TOP": "Hz",
"ECLTRG": "Hz",
"CDC_CUR_AVERAGE": r'$\mu$A',
"TOP_L1_SCALER_RATE": "Hz",
"ECLTRG_FAM_rate": "Hz",
"ECL_LUM_MON_ACC": r'$cm^{-2}s^{-1}10^{30}$',
"ECL_SPECIFIC_LUM_MON_ACC": r'$cm^{-2}s^{-1}mA^{-2}10^{30}$',
'BMHDCCT_LIFE': 'min',
......@@ -597,7 +603,10 @@ SKB2_UNITS = {
'SVD_OccMon.*': "%",
'PXD_O_.*_AVG_OCC_cur': "%",
"F_B_HER": 'unit(O)/nPa/mA',
"F_B_LER": 'unit(O)/nPa/mA',
"F_T_HER": r'unit(O)$\mu$m$^{3}$/mA',
"F_T_LER": r'unit(O)$\mu$m$^{3}$/mA',
"SKB_HER_current": "mA",
"SKB_LER_current": "mA",
"HER_BUNCH_CURRENT": "mA",
......
......@@ -63,15 +63,15 @@
\vspace{5pt}
$F_{T,L}=\frac{I_{L}^{2}}{\sigma_{X,L} \cdot \sigma_{Y,L} \cdot (\sigma_{Z,0,L} + \sigma_{Z,1,L} \cdot I_{L}/n_{b,L}) \cdot n_{b,L}}$\\
\vspace{5pt}
Bunch lengthening coefficients from {\color{blue}\href{https://indico.belle2.org/event/3644/contributions/17579/attachments/9395/14437/B2GM_Feb2021_NATOCHII_2.pdf}{\underline{here}}}\\
Bunch lengthening coefficients from {\color{blue}\href{https://indico.belle2.org/event/5891/contributions/30066/attachments/14979/22501/SuperKEKB.pdf}{\underline{here}}}\\
\vspace{5pt}
$\sigma_{{Z,0,H}} = 4.9065$ $\mu$\\
$\sigma_{{Z,0,H}} = 6.0211$ mm\\
\vspace{5pt}
$\sigma_{{Z,1,H}} = 2.2922$ $\mu$m/mA\\
$\sigma_{{Z,1,H}} = 1.3711$ mm/mA\\
\vspace{5pt}
$\sigma_{{Z,0,L}} = 4.1474$ $\mu$m\\
$\sigma_{{Z,0,L}} = 5.4466$ mm\\
\vspace{5pt}
$\sigma_{{Z,1,L}} = 2.6337$ $\mu$m/mA\\
$\sigma_{{Z,1,L}} = 1.7642$ mm/mA\\
\vspace{10pt}
$O$ denotes the hitrate as 1Hz time series. \\
Note that $T_{H,L}$ are $B_{H,L}$ are neural networks modeling the sensitivity to storage bg.\\
......
......@@ -43,12 +43,12 @@ preparation:
}
# SigmaZ coefficients for bunch lengthening model
# See Andrii B2GM Feb. 2021, Background session.
# H.Ikeda https://indico.belle2.org/event/5891/contributions/30066/attachments/14979/22501/SuperKEKB.pdf
sigmaZ_params : {
HER_z0: 4.9065,
HER_z1: 2.2922,
LER_z0: 4.1474,
LER_z1: 2.6337,
HER_z0: 6.0211,
HER_z1: 1.3711,
LER_z0: 5.4466,
LER_z1: 1.7642,
}
# Gate lag
......
......@@ -66,6 +66,7 @@ import sys
import glob
import subprocess
import logging
import traceback
from sklearn.model_selection import train_test_split
from path_explain import PathExplainerTF
import shutil
......@@ -291,17 +292,22 @@ def report_on_channel(
# Output path for plots
save_path = "./{}_plots".format(channel)
# Load the data, for training ONLY!
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
# Load the data, for training ONLY!
try:
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[]
)
except Exception as e:
logging.error(traceback.format_exc())
return
if x.size == 0:
logging.info('Error: No data for training found. Quit reporting on {}'.format(obs))
logging.error('Error: No data for training found. Quit reporting on {}'.format(obs))
return
# Make train test split
......@@ -464,14 +470,19 @@ def report_on_hitrate(
# Output path for plots
save_path = "./{}_plots".format(channel)
# Load the data, for training ONLY!
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
# Load the data, for training ONLY!
try:
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
except Exception as e:
logging.error(traceback.format_exc())
return
if x[0].size == 0:
logging.info('Error: No data for training found. Quit reporting on {}'.format(obs))
......@@ -1064,11 +1075,18 @@ def main():
attachments = []
for channel in channels:
file_name = get_jobname(shift=args.shift, channel=channel, report_day=start, tag=args.tag) + '.pdf'
attachments.append( os.path.join(args.report_path, file_name) )
file_path = os.path.join(args.report_path, file_name)
if Path(file_path).is_file():
attachments.append( file_path )
# Should guarantee fixed order of attachments in eLog entry
attachments = sorted(attachments)
if args.skbsrv_cred:
logging.info("Uploading reports to skbsrv server")
connectVPN = connect_vpn.ConnectVPN(cmd=args.vpn_cmd, cred_path=args.vpn_cred)
ReportsToWebServer(attachments, start, args.shift, args.skbsrv_cred, connectVPN).copy()
# Upload reports to the elog
if args.elog:
success = bg_net.report_to_elog.elog(
......@@ -1092,10 +1110,5 @@ def main():
else:
logging.info("Created reports: \n" + ", ".join(attachments))
if args.skbsrv_cred:
logging.info("Uploading reports to skbsrv server")
connectVPN = connect_vpn.ConnectVPN(cmd=args.vpn_cmd, cred_path=args.vpn_cred)
ReportsToWebServer(attachments, start, args.shift, args.skbsrv_cred, connectVPN).copy()
if __name__ == '__main__':
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment