Upgraded RB and RQ
%% Cell type:markdown id: tags: | ||
<h1><center>Analysis of an FPA in an IPQ Circuit</center></h1> | ||
The Individually Powered Quadrupole magnets (IPQs) in the LHC are located on both sides of the Interaction Regions (IR), in the matching sector and in the dispersion suppressor. The IPQ circuits RQ4 to RQ7 are part of the matching sector, and the IPQ circuits RQ8 to RQ10 are part of the dispersion suppressor. The magnets Q4 to Q6 are operated at | ||
4.5 K, whereas the magnets Q7 to Q10 are operated at 1.9 K. | ||
The MQM quadrupole consists of two individually powered apertures assembled in a common yoke structure. | ||
The MQY wide-aperture quadrupole consists of two individually powered apertures assembled in a common yoke structure. | ||
%% Cell type:markdown id: tags: | ||
# Analysis Assumptions | ||
- We consider standard analysis scenarios, i.e., all signals can be queried. If a signal is missing, an analysis can raise a warning and continue or an error and abort the analysis. | ||
- In case a signal is not needed for the analysis, a particular analysis is skipped. In other words, all signals have to be available in order to perform an analysis. | ||
- It is recommended to execute each cell one after another. However, since the signals are queried prior to analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present). | ||
# Plot Convention | ||
- Scales are labeled with signal name followed by a comma and a unit in square brackets, e.g., I_MEAS, [A]. | ||
- If a reference signal is present, it is represented with a dashed line. | ||
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively. | ||
- The grid comes from the left axis. | ||
- The title contains timestamp, circuit name, and signal name allowing to re-access the signal. | ||
- The plots assigned to the left scale have colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3). | ||
- Each plot has an individual time-synchronization mentioned explicitly in the description. | ||
- If an axis has a single signal, then the color of the label matches the signal's color. Otherwise, the label color is black. | ||
%% Cell type:markdown id: tags: | ||
# 0. Initialise Working Environment | ||
%% Cell type:code id: tags: | ||
``` python | ||
import io | ||
import re | ||
import sys | ||
import pandas as pd | ||
import numpy as np | ||
from datetime import datetime | ||
import time | ||
from IPython.display import display, Javascript, HTML | ||
from lhcsmapi.Time import Time | ||
from lhcsmapi.Timer import Timer | ||
from lhcsmapi.analysis.expert_input import get_expert_decision | ||
from lhcsmapi.analysis.report_template import apply_report_template | ||
from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery | ||
from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis | ||
# GUI | ||
from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule | ||
from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator | ||
from lhcsmapi.gui.pc.IpqFgcPmSearchBaseModule import IpqFgcPmSearchBaseModule | ||
analysis_start_time = datetime.now().strftime("%Y.%m.%d_%H%M%S") | ||
import lhcsmapi | ||
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__)) | ||
with io.open("../__init__.py", "rt", encoding="utf8") as f: | ||
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1) | ||
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version)) | ||
``` | ||
%% Cell type:markdown id: tags: | ||
# 1. Select FGC Post Mortem Entry | ||
%% Cell type:markdown id: tags:skip_cell | ||
In order to perform the analysis of a FPA in an IPQ circuit please: | ||
1. Select circuit name prefix (e.g., RQ5) | ||
2. Choose start and end time | ||
3. Choose analysis mode (Automatic by default) | ||
Once these inputs are provided, click 'Find FGC PM entries' button. This will trigger a search of the PM database in order to provide a list of timestamps of FGC events associated with the selected circuit name for the provided period of time. Select one timestamp from the 'FGC PM Entries' list to be processed by the following cells. | ||
**Note that 24 hours is the maximum duration of a single PM query for an event. To avoid delays in querying events, please restrict your query duration as much as possible.** | ||
%% Cell type:code id: tags: | ||
``` python | ||
circuit_type = 'IPQ' | ||
fgc_pm_search = FgcPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2018-12-10 00:00:00+01:00', | ||
end_date_time='2018-12-11 00:00:00+01:00'), IpqFgcPmSearchBaseModule(), circuit_type=circuit_type) | ||
``` | ||
%% Cell type:markdown id: tags: | ||
# 2. Query All Signals Prior to Analysis | ||
%% Cell type:code id: tags:skip_output | ||
``` python | ||
with Timer(): | ||
timestamp_fgc = fgc_pm_search.get_fgc_timestamp() | ||
circuit_name = fgc_pm_search.get_fgc_circuit() | ||
author = fgc_pm_search.get_author() | ||
is_automatic = fgc_pm_search.is_automatic_mode() | ||
ipq_query = IpqCircuitQuery(circuit_type, circuit_name, max_executions=14) | ||
# PC | ||
source_timestamp_fgc_df = ipq_query.find_source_timestamp_pc(t_start=timestamp_fgc-1e9, t_end=timestamp_fgc+1e9) | ||
source_fgc_b1, timestamp_fgc_b1 = ipq_query.split_source_timestamp_fgc(source_timestamp_fgc_df, 'B1') | ||
source_fgc_b2, timestamp_fgc_b2 = ipq_query.split_source_timestamp_fgc(source_timestamp_fgc_df, 'B2') | ||
i_meas_b1_df, i_ref_b1_df, i_a_b1_df, i_earth_b1_df, i_earth_pcnt_b1_df = ipq_query.query_pc_pm_with_source(timestamp_fgc_b1, timestamp_fgc_b1, | ||
source_fgc_b1, signal_names=['I_MEAS', 'I_REF', 'I_A', 'I_EARTH', 'I_EARTH_PCNT']) | ||
i_meas_b2_df, i_ref_b2_df, i_a_b2_df, i_earth_b2_df, i_earth_pcnt_b2_df = ipq_query.query_pc_pm_with_source(timestamp_fgc_b2, timestamp_fgc_b2, | ||
source_fgc_b2, signal_names=['I_MEAS', 'I_REF', 'I_A', 'I_EARTH', 'I_EARTH_PCNT']) | ||
# PIC | ||
timestamp_pic = ipq_query.find_timestamp_pic(timestamp_fgc, spark=spark) | ||
# QDS | ||
source_timestamp_qds_df = ipq_query.find_source_timestamp_qds(timestamp_fgc_b1, duration=[(2, 's'), (2, 's')]) | ||
timestamp_qds = np.nan if source_timestamp_qds_df.empty else source_timestamp_qds_df.loc[0, 'timestamp'] | ||
u_res_b1_df, u_res_b2_df = ipq_query.query_qds_pm(timestamp_qds, timestamp_fgc, signal_names=['U_RES_B1', 'U_RES_B2']) | ||
u_1_b1_df, u_1_b2_df = ipq_query.query_qds_pm(timestamp_qds, timestamp_fgc, signal_names=['U_1_B1', 'U_1_B2']) | ||
u_2_b1_df, u_2_b2_df = ipq_query.query_qds_pm(timestamp_qds, timestamp_fgc, signal_names=['U_2_B1', 'U_2_B2']) | ||
# QH | ||
u_hds_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS']) | ||
u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else [] | ||
# # Reference | ||
u_hds_ref_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'], is_ref=True) | ||
u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else [] | ||
# LEADS B1 | ||
u_hts_b1_dfs = ipq_query.query_leads(timestamp_fgc, source_timestamp_qds_df, system='LEADS_B1', signal_names=['U_HTS'], spark=spark, duration=[(300, 's'), (900, 's')]) | ||
u_res_b1_dfs = ipq_query.query_leads(timestamp_fgc, source_timestamp_qds_df, system='LEADS_B1', signal_names=['U_RES'], spark=spark, duration=[(300, 's'), (900, 's' |