Skip to content
Snippets Groups Projects
Commit ca509bad authored by Michal Maciejewski's avatar Michal Maciejewski
Browse files

Added changes to PC I_EARTH_PCNT plot

parent 01953bfd
No related branches found
Tags 1.4.92
No related merge requests found
Pipeline #2329130 failed
Showing with 51660 additions and 16 deletions
name = "lhcsmapi"
__version__ = "1.4.91"
__version__ = "1.4.92"
def get_lhcsmapi_version() -> None:
......
......@@ -174,16 +174,16 @@ class BusbarResistanceAnalysis(CircuitAnalysis):
"""
# Find plateau start and end based on the current profile
plateau_starts = []
plateau_ends = []
for i_meas_raw_df in i_meas_raw_dfs:
if i_meas_raw_df.max().values[0] < 100 and len(i_meas_raw_dfs) > 3: # For IT it is OK
print('There is at least one signal with the peak current below 100 A.')
return [], []
plateau_starts = []
plateau_ends = []
for i_meas_raw_df in i_meas_raw_dfs:
if i_meas_raw_df.max().values[0] > i_meas_threshold:
plateau_start, plateau_end = BusbarResistanceAnalysis.\
plateau_start, plateau_end = BusbarResistanceAnalysis. \
find_plateau_start_and_end(i_meas_raw_df, i_meas_threshold=i_meas_threshold,
min_duration_in_sec=min_duration_in_sec,
time_shift_in_sec=time_shift_in_sec)
......
......@@ -779,7 +779,7 @@ class Pc13kARqAnalysis(Pc13kAAnalysis):
@check_dataframe_empty(mode='any', warning='At least one DataFrame is empty, I_EARTH_PCNT analysis skipped!')
def analyze_i_earth_pcnt_pc(self, circuit_name: str, timestamp_fgc: int, i_meas_df: pd.DataFrame,
i_meas_ref_df: pd.DataFrame, i_earth_pcnt_df: pd.DataFrame,
i_earth_pcnt_ref_df: pd.DataFrame) -> None:
i_earth_pcnt_ref_df: pd.DataFrame, xlim=(5, 120)) -> None:
""" Method plotting main power converter current and percentage earth current. Earth current is shown with its
reference. Reference percentage earth current is scaled according to the main currents. A comment related to the
percentage earth current is updated.
......@@ -796,9 +796,9 @@ class Pc13kARqAnalysis(Pc13kAAnalysis):
scaling = (i_meas_df.max() / i_meas_ref_df.max()).values[0]
PlotBuilder().with_signal(i_meas_df, title=title, grid=True) \
.with_ylabel(ylabel='I_MEAS, [A]') \
.with_signal([i_earth_pcnt_df[i_earth_pcnt_df.index > 3],
i_earth_pcnt_ref_df[i_earth_pcnt_ref_df.index > 3] * scaling]) \
.with_signal([i_earth_pcnt_df,
i_earth_pcnt_ref_df * scaling]) \
.with_ylabel(ylabel='I_EARTH_PCNT, [%]') \
.with_legend(labels=['I_EARTH_PCNT', 'I_EARTH_PCNT (Reference)']) \
.with_xlim((5, 120)) \
.with_xlim(xlim) \
.plot()
......@@ -427,3 +427,24 @@ class MappingMetadata(object):
def get_sector_name_for_circuit_name(circuit_name: str) -> str:
circ_name_to_sector_df = MappingMetadata.read_circuit_name_to_sector()
return circ_name_to_sector_df[circ_name_to_sector_df['Circuit name'] == circuit_name]['Sector name'].values[0]
@staticmethod
def get_circuit_name_to_earth_measurement_dataframe(circuit_type: str, circuit_name:str) -> pd.DataFrame:
""" Method returning a DataFrame with information on power converter with earth current measurement:
- B1
- B2
- B1 and B2
:param circuit_type: circuit type
:type circuit_type: str
:param circuit_name: circuit name
:type circuit_name: str
:return: QPS schematic name
"""
if 'IPQ' in circuit_type:
full_path = os.path.join(selected_path, 'earth_current/IPQ_EarthCurrent.csv')
else:
raise KeyError('Circuit type {} is not supported!'.format(circuit_type))
circuit_name_to_earth_measurement = pd.read_csv(full_path)
return circuit_name_to_earth_measurement[circuit_name_to_earth_measurement['Circuit name'] == circuit_name]
\ No newline at end of file
Circuit name,Power converter with earth measurement
RQ4.L1,B2
RQ5.L1,B1
RQ6.L1,B2
RQ7.L1,B1
RQ8.L1,B1
RQ9.L1,B1
RQ10.L1,B1
RQ4.R1,B1
RQ5.R1,B1
RQ6.R1,B1
RQ7.R1,B2
RQ8.R1,B2
RQ9.R1,B2
RQ10.R1,B2
RQ4.L2,B1
RQ5.L2,B1
RQ6.L2,B1
RQ7.L2,B1
RQ8.L2,B1
RQ9.L2,B1
RQ10.L2,B1
RQ4.R2,B1
RQ5.R2,B1
RQ6.R2,B1
RQ7.R2,B1
RQ8.R2,B1
RQ9.R2,B1
RQ10.R2,B1
RQ5.L4,B2
RQ6.L4,B1
RQ7.L4,B1
RQ8.L4,B1
RQ9.L4,B1
RQ10.L4,B1
RQ5.R4,B2
RQ6.R4,B1
RQ7.R4,B1
RQ8.R4,B1
RQ9.R4,B1
RQ10.R4,B1
RQ4.L5,B1
RQ5.L5,B1
RQ6.L5,B2
RQ7.L5,B1
RQ8.L5,B1
RQ9.L5,B1
RQ10.L5,B1
RQ4.R5,B1
RQ5.R5,B2
RQ6.R5,B2
RQ7.R5,B2
RQ8.R5,B2
RQ9.R5,B2
RQ10.R5,B2
RQ4.L6,B2
RQ5.L6,B1
RQ8.L6,B1
RQ9.L6,B1
RQ10.L6,B1
RQ4.R6,B2
RQ5.R6,B1
RQ8.R6,B2
RQ9.R6,B2
RQ10.R6,B2
RQ4.L8,B1
RQ5.L8,B1
RQ6.L8,B1
RQ7.L8,B1
RQ8.L8,B1
RQ9.L8,B1
RQ10.L8,B1
RQ4.R8,B1
RQ5.R8,B1
RQ6.R8,B1
RQ7.R8,B1
RQ8.R8,B1
RQ9.R8,B1
RQ10.R8,B1
\ No newline at end of file
Circuit name,Number of apertures,Beam 1,Beam 2,RQF B1/B2,RQD B1/B2,Inductance [H],EE Resistance [ohm]
RQx.A12,47,Ext,Int,Odd/Even,Even/Odd,0.2744,0.0066
RQx.A23,51,Int,Ext,Even/Odd,Odd/Even,0.2856,0.0077
RQx.A34,51,Int,Ext,Odd/Even,Even/Odd,0.2856,0.0077
RQx.A45,47,Int,Ext,Even/Odd,Odd/Even,0.2744,0.0066
RQx.A56,47,Ext,Int,Odd/Even,Even/Odd,0.2744,0.0066
RQx.A67,51,Ext,Int,Even/Odd,Odd/Even,0.2856,0.0077
RQx.A78,51,Ext,Int,Odd/Even,Even/Odd,0.2856,0.0077
RQx.A81,47,Int,Ext,Even/Odd,Odd/Even,0.2744,0.0066
\ No newline at end of file
RQD/F.A12,47,Ext,Int,Odd/Even,Even/Odd,0.2744,0.0066
RQD/F.A23,51,Int,Ext,Even/Odd,Odd/Even,0.2856,0.0077
RQD/F.A34,51,Int,Ext,Odd/Even,Even/Odd,0.2856,0.0077
RQD/F.A45,47,Int,Ext,Even/Odd,Odd/Even,0.2744,0.0066
RQD/F.A56,47,Ext,Int,Odd/Even,Even/Odd,0.2744,0.0066
RQD/F.A67,51,Ext,Int,Even/Odd,Odd/Even,0.2856,0.0077
RQD/F.A78,51,Ext,Int,Odd/Even,Even/Odd,0.2856,0.0077
RQD/F.A81,47,Int,Ext,Even/Odd,Odd/Even,0.2744,0.0066
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -140,6 +140,55 @@ class TestItCircuitQuery(unittest.TestCase):
if mock_show is not None:
mock_show.assert_called()
@patch("matplotlib.pyplot.show")
def test_calculate_current_plateau_start_end_pno_a9_3(self, mock_show=None):
# arrange
t_start = '2021-02-17 18:40:46.780000000'
t_end = '2021-02-17 21:03:48.855000000'
circuit_name = 'RQX.L8'
it_query = ItCircuitQuery('IT', circuit_name)
hwc_test = 'PNO.a9'
spark = None
i_meas_raw_dfs = [read_csv('resources/hwc/it/pno_a9_3', 'I_MEAS_RQX'),
read_csv('resources/hwc/it/pno_a9_3', 'I_MEAS_RTQX1'),
read_csv('resources/hwc/it/pno_a9_3', 'I_MEAS_RTQX2')]
# act
with patch.object(NxcalsDbQueryBuilder, 'execute_signal_query') as mock_read:
mock_read.return_value = i_meas_raw_dfs
plateau_start_act, plateau_end_act = it_query.calculate_current_plateau_start_end(
Time.to_unix_timestamp(t_start),
Time.to_unix_timestamp(t_end),
i_meas_threshold=5,
min_duration_in_sec=100,
time_shift_in_sec=(60, 40),
spark=spark)
title = '%s, %s: %s-%s' % (
circuit_name, hwc_test, Time.to_string(t_start).split('.')[0], Time.to_string(t_end).split('.')[0])
ax = PlotBuilder().with_signal([i_meas_raw_dfs[0], i_meas_raw_dfs[2]], title=title, grid=True) \
.with_ylabel(ylabel='I_MEAS_RQX, I_MEAS_RTQX2, [A]') \
.with_signal(i_meas_raw_dfs[1]) \
.with_ylabel(ylabel='I_MEAS_RTQX1, [A]') \
.with_ylim((0, 600)) \
.plot(show_plot=False).get_axes()[0]
for ps, pe in zip(plateau_start_act, plateau_end_act):
ax.axvspan(xmin=ps, xmax=pe, facecolor='xkcd:orange')
plt.show()
# assert
plateau_start_ref = [1613583784093461504, 1613586098498007040]
plateau_end_ref = [1613584885303426560, 1613587198707797248]
self.assertListEqual(plateau_start_ref, plateau_start_act)
self.assertListEqual(plateau_end_ref, plateau_end_act)
if mock_show is not None:
mock_show.assert_called()
@patch("matplotlib.pyplot.show")
def test_calculate_current_plateau_start_end2(self, mock_show=None):
# arrange
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment