From b8d8d58b72c22e19944691630137538643925dc9 Mon Sep 17 00:00:00 2001
From: Thomas Bock <thomas.bock@ptb.de>
Date: Thu, 25 Mar 2021 08:39:55 +0100
Subject: [PATCH] ig en, date is not an array

---
 cal/utils.py                                  |  8 +-
 .../en-para_0-alt_0-method.tex                | 95 +++++++++----------
 .../en-para_2-alt_0-residual_pressure.tex     |  2 +-
 3 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/cal/utils.py b/cal/utils.py
index ee1c8d9..79e24e2 100644
--- a/cal/utils.py
+++ b/cal/utils.py
@@ -180,6 +180,7 @@ def safe_device_setup(setup_dict):
 
 def escape_items(item):
     n = str(item).replace("_", "\_")
+    n = str(item).replace("&", "\&")
     return n
 
 def get_calibration_data(cal_docs):
@@ -594,8 +595,8 @@ def get_customer(doc, countries):
     short_land = adr.get("Land")
     lang = get_lang(doc)
     cust = {
-        "Name": customer.get("Name"),
-        "AddName": customer.get("AddName"),
+        "Name": escape_items(customer.get("Name")),
+        "AddName": escape_items(customer.get("AddName")),
         "Street": adr.get("Street"),
         "Town": adr.get("Town"),
         "Zipcode": adr.get("Zipcode"),
@@ -684,9 +685,12 @@ def get_meas_date(doc):
     This works for SE3. Other formats follow.
     """
     date = doc.get("Calibration", {}).get("Measurement", {}).get("Date")
+
     if isinstance(date, list):
         if isinstance(date[0]['Value'], list):
             return date[0]['Value'][0].split(" ")[0]
+        else:
+            return date[0]['Value'].split(" ")[0]
 
 def sort_date_list(l):
     s = sorted([datetime.datetime.strptime(dt, "%Y-%m-%d") for dt in l])
diff --git a/templates/latex/calibration_procedure-ce3-ig/en-para_0-alt_0-method.tex b/templates/latex/calibration_procedure-ce3-ig/en-para_0-alt_0-method.tex
index 5cd617c..3c7ccd4 100644
--- a/templates/latex/calibration_procedure-ce3-ig/en-para_0-alt_0-method.tex
+++ b/templates/latex/calibration_procedure-ce3-ig/en-para_0-alt_0-method.tex
@@ -2,59 +2,54 @@
 ((*set helper = Helper*))
 ((*set lang = Meta["lang"]*))
 The calibration was carried out at the laboratory for  vacuum metrology at the Physikalisch-Technische Bundesanstalt (PTB).
+The device was installed in a vertical orientation.
 ((*for gas, struct in MeasurementData.items()*))
-((*if loop.index == 1*)) 
-((* for result_type, measurement_data in MeasurementData[gas].items()*))
-((*if result_type == "expansion"*))
-((*if  measurement_data.PressureRangeBegin == measurement_data.PressureRangeEnd *))
-The calibration pressure (((measurement_data.PressureRangeBegin)))
-was established in the primary standard SE3 metrologically linked to the primary standard SE2 of PTB applying the static
-expansion method.
-((*else*))
-In the pressure range from (((measurement_data.PressureRangeBegin))) to (((measurement_data.PressureRangeEnd))),
-the calibration pressure was established in the primary standard SE3
-metrologically linked to the primary standard SE2 of PTB applying the static
-expansion method.
-((*endif*))
-((*endif*))
-((*if result_type == "direct"*))
-((*if  measurement_data.PressureRangeBegin == measurement_data.PressureRangeEnd *))
-At (((measurement_data.PressureRangeBegin))) the calibration 
-was carried out by direct comparison to a secondary standard consisting of 15 diaphragm gauges.
-((*else*))
-In the range (((measurement_data.PressureRangeBegin))) to
-(((measurement_data.PressureRangeEnd))) 
-the calibration was carried out by direct comparison to a secondary standard consisting of 15 diaphragm gauges.
-((*endif*))
-((*endif*))
-((*if result_type == "pressure_balance"*))
-((*if  measurement_data.PressureRangeBegin == measurement_data.PressureRangeEnd *))
-For the pressure (((measurement_data.PressureRangeBegin))) the calibration was carried out by
-comparison with the non-rotating pressure balance FRS5 traceable to the SI units (\emph{Metrologia 46 (2009), 389--396}).           
-((*else*))
-In the range (((measurement_data.PressureRangeBegin))) to
-(((measurement_data.PressureRangeEnd))) 
-the calibration was carried out by comparison with the non-rotating pressure
-balance FRS5 traceable to the SI units (\emph{Metrologia 46 (2009), 389--396}).
-((*endif*))
-((*endif*)) 
-((*endfor*))
+
+((*if loop.index == 1*))
+
+  ((*for result_type, measurement_data in MeasurementData[gas].items()*))
+
+  ((*if measurement_data.BakeoutTemperature*))
+   Before calibration, the gauge head was baked at (((measurement_data.BakeoutTemperature)))
+   for (((measurement_data.BakeoutTime))). At \SI{100}{\degreeCelsius} the head was degassed for
+   \SI{10}{\minute}.
+   ((*endif*))
+
+  ((*if measurement_data.SputterTime*))
+  At room temperature, it was exposed for (((measurement_data.SputterTime))) at
+  (((measurement_data.SputterPressure))) argon for sputtering the ion collector.
+  ((*endif*))
+
+  ((*if result_type == "cont_expansion"*))
+  In the pressure range  (((measurement_data.PressureRangeBegin))) to
+  (((measurement_data.PressureRangeEnd))) the gauge was calibrated by comparing its reading
+  with the calibration pressure that was established by the primary standard CE3 of PTB applying
+  the continuous expansion method.
+  ((*endif*))
+
+  ((*if result_type == "srg_vg"*))
+   In the range (((measurement_data.PressureRangeBegin))) to
+   (((measurement_data.PressureRangeEnd))) it was calibrated by comparing its reading
+   with an calibrated spinning rotor gauge (SRG).
+  ((*endif*))
+
+  ((*endfor*))
 ((*endif*))
-((*endfor*))
 
-((*for gas, struct in MeasurementData.items()*))
 ((*for result_type, measurement_data in MeasurementData[gas].items()*))
-((*if result_type == "expansion" *))
-The gas temperature during calibration using the static expansion method with (((helper["gas_trans"][gas][lang])))  
-was (((measurement_data.GasTemperature))) at a room temperature of (((measurement_data.RoomTemperature))).
-((*endif*))
 
-        ((*if result_type == "direct" *))
-During the calibration by direct comparison with (((helper["gas_trans"][gas][lang]))) the temperature of the gas was 
-(((measurement_data.GasTemperature))). Here, the room temperature was (((measurement_data.RoomTemperature))).
-        ((*endif*))
+  ((*if result_type == "cont_expansion"*))
+  The gas temperature during calibration using the continuous expansion method with
+  (((helper["gas_trans"][gas][lang])))  was (((measurement_data.GasTemperature))) at a
+  room temperature of (((measurement_data.RoomTemperature))).
+  ((*endif*))
+
+  ((*if result_type == "srg_vg"*))
+  During the calibration by SRG comparison with (((helper["gas_trans"][gas][lang])))
+  the temperature of the gas was (((measurement_data.GasTemperature))). Here, the
+  room temperature was (((measurement_data.RoomTemperature))).
+  ((*endif*))
 
-        ((*if result_type == "pressure_balance"*)) 
-The gas temperature during the measurement with the non-rotating pressure balance is estimated to
-(((measurement_data.EstimatedTemperature))).
- ((*endif*)) ((*endfor*)) ((*endfor*))
+  ((*endfor*))
+
+((*endfor*))
diff --git a/templates/latex/calibration_procedure-ce3-ig/en-para_2-alt_0-residual_pressure.tex b/templates/latex/calibration_procedure-ce3-ig/en-para_2-alt_0-residual_pressure.tex
index 7380cbe..3109eb3 100644
--- a/templates/latex/calibration_procedure-ce3-ig/en-para_2-alt_0-residual_pressure.tex
+++ b/templates/latex/calibration_procedure-ce3-ig/en-para_2-alt_0-residual_pressure.tex
@@ -12,7 +12,7 @@
 ((*-endfor*))
 
 Before each calibration point the offset \(p_\text{ind,r}\) was
-recorded  (5 readings) at the base pressure and subtracted from the subsequent indication
+recorded  at the base pressure and subtracted from the subsequent indication
 \(p_\text{ind}\) to give the corrected indicated value \(p_\text{corr}\).
 ((*if offsetcontrib["is"] == "true" *))
 The contribution of the offset scatter to the total uncertainty was
-- 
GitLab