diff --git a/ipq/AN_IPQ_FPA.ipynb b/ipq/AN_IPQ_FPA.ipynb index 1e0b4c6766ef651b96d6ca0e3bdcd01d2c49eded..df8378e8465a8754c99270ba11f34d2cfd70ef8f 100644 --- a/ipq/AN_IPQ_FPA.ipynb +++ b/ipq/AN_IPQ_FPA.ipynb @@ -77,6 +77,7 @@ "from lhcsmapi.Timer import Timer\n", "\n", "print(\"Loading (8/15)\")\n", + "from lhcsmapi.metadata import signal_metadata\n", "from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n", "\n", "print(\"Loading (9/15)\")\n", @@ -218,21 +219,14 @@ " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_MEAS\", \"I_REF\", \"I_A\"]\n", " )\n", "\n", - " circuit_name_to_earth_measurement_df = ipq_query.get_circuit_name_to_earth_measurement_dataframe(\n", - " circuit_type, circuit_name\n", + " source_fgc_earth = signal_metadata.get_fgc_with_earth_measurement(\n", + " circuit_name, min(filter(lambda x: x is not None, [timestamp_fgc_b1, timestamp_fgc_b2]))\n", " )\n", - " if circuit_name_to_earth_measurement_df[\"Power converter with earth measurement\"].values[0] == \"B1\":\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b1, timestamp_fgc_b1, source_fgc_b1, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B1\"\n", - " timestamp_fgc_earth = timestamp_fgc_b1\n", - " else:\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B2\"\n", - " timestamp_fgc_earth = timestamp_fgc_b2\n", + " timestamp_fgc_earth = timestamp_fgc_b1 if source_fgc_earth == source_fgc_b1 else timestamp_fgc_b2\n", + " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", + " timestamp_fgc_earth, timestamp_fgc_earth, source_fgc_earth, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", + " )\n", + " col_earth_max_suffix = source_fgc_earth[-2:]\n", "\n", " # PIC\n", " timestamp_pic = ipq_query.find_timestamp_pic(timestamp_fgc, spark=spark)\n", @@ -927,7 +921,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.9.18" }, "sparkconnect": { "bundled_options": [ diff --git a/ipq/AN_IPQ_PLI1.c3.ipynb b/ipq/AN_IPQ_PLI1.c3.ipynb index 3b1ab1d4834c88bae73bca0d80a5396c97ee44a1..d993c9270d3d09dff47997b30d72946fb7e65848 100644 --- a/ipq/AN_IPQ_PLI1.c3.ipynb +++ b/ipq/AN_IPQ_PLI1.c3.ipynb @@ -95,6 +95,7 @@ "from lhcsmapi.Timer import Timer\n", "\n", "print(\"Loading (8/14)\")\n", + "from lhcsmapi.metadata import signal_metadata\n", "from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n", "\n", "print(\"Loading (9/14)\")\n", @@ -238,21 +239,12 @@ " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_MEAS\", \"I_REF\", \"I_A\"]\n", " )\n", "\n", - " circuit_name_to_earth_measurement_df = ipq_query.get_circuit_name_to_earth_measurement_dataframe(\n", - " circuit_type, circuit_name\n", + " source_fgc_earth = signal_metadata.get_fgc_with_earth_measurement(circuit_name, Time.to_unix_timestamp(t_start))\n", + " timestamp_fgc_earth = timestamp_fgc_b1 if source_fgc_earth == source_fgc_b1 else timestamp_fgc_b2\n", + " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", + " timestamp_fgc_earth, timestamp_fgc_earth, source_fgc_earth, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", " )\n", - " if circuit_name_to_earth_measurement_df[\"Power converter with earth measurement\"].values[0] == \"B1\":\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b1, timestamp_fgc_b1, source_fgc_b1, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B1\"\n", - " timestamp_fgc_earth = timestamp_fgc_b1\n", - " else:\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B2\"\n", - " timestamp_fgc_earth = timestamp_fgc_b2\n", + " col_earth_max_suffix = source_fgc_earth[-2:]\n", "\n", " # QDS\n", " source_timestamp_qds_df = ipq_query.find_source_timestamp_qds_board_ab(\n", diff --git a/ipq/AN_IPQ_PLI2.f3.ipynb b/ipq/AN_IPQ_PLI2.f3.ipynb index fc7ee277dd779eca2fc7485d8e86cf74112fe5da..9030a7b93fcf93bf3e580c1e0168aecd3a081dd8 100644 --- a/ipq/AN_IPQ_PLI2.f3.ipynb +++ b/ipq/AN_IPQ_PLI2.f3.ipynb @@ -100,6 +100,7 @@ "from lhcsmapi.Timer import Timer\n", "\n", "print(\"Loading (8/13)\")\n", + "from lhcsmapi.metadata import signal_metadata\n", "from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n", "\n", "print(\"Loading (9/13)\")\n", @@ -240,21 +241,12 @@ " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_MEAS\", \"I_REF\", \"I_A\"]\n", " )\n", "\n", - " circuit_name_to_earth_measurement_df = ipq_query.get_circuit_name_to_earth_measurement_dataframe(\n", - " circuit_type, circuit_name\n", + " source_fgc_earth = signal_metadata.get_fgc_with_earth_measurement(circuit_name, Time.to_unix_timestamp(t_start))\n", + " timestamp_fgc_earth = timestamp_fgc_b1 if source_fgc_earth == source_fgc_b1 else timestamp_fgc_b2\n", + " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", + " timestamp_fgc_earth, timestamp_fgc_earth, source_fgc_earth, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", " )\n", - " if circuit_name_to_earth_measurement_df[\"Power converter with earth measurement\"].values[0] == \"B1\":\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b1, timestamp_fgc_b1, source_fgc_b1, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B1\"\n", - " timestamp_fgc_earth = timestamp_fgc_b1\n", - " else:\n", - " i_earth_df, i_earth_pcnt_df = ipq_query.query_pc_pm_with_source(\n", - " timestamp_fgc_b2, timestamp_fgc_b2, source_fgc_b2, signal_names=[\"I_EARTH\", \"I_EARTH_PCNT\"]\n", - " )\n", - " col_earth_max_suffix = \"B2\"\n", - " timestamp_fgc_earth = timestamp_fgc_b2\n", + " col_earth_max_suffix = source_fgc_earth[-2:]\n", "\n", " # PIC\n", " timestamp_pic = ipq_query.find_timestamp_pic(timestamp_fgc, spark=spark)\n", @@ -913,7 +905,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.18" }, "sparkconnect": { "bundled_options": [ @@ -938,4 +930,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +}