From d29c6d4309fb138f84b058b2d0cee3a974b258b6 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Fri, 22 Dec 2023 12:14:19 +0100
Subject: [PATCH] TMSS-2877: updated constraints schema to version 9 with a
 target and calibrator section for the sky min_distance constraint

---
 .../constraints-9.json                        | 232 ++++++++++++++++++
 1 file changed, 232 insertions(+)
 create mode 100644 SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_constraints_template/constraints-9.json

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_constraints_template/constraints-9.json b/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_constraints_template/constraints-9.json
new file mode 100644
index 00000000000..a5aaac4422c
--- /dev/null
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_constraints_template/constraints-9.json
@@ -0,0 +1,232 @@
+{
+  "description": "This schema defines the scheduling constraints for a scheduling unit",
+  "name": "constraints",
+  "purpose": "technical_commissioning",
+  "schema": {
+    "$id": "https://tmss.lofar.eu/api/schemas/schedulingconstraintstemplate/constraints/9#",
+    "$schema": "http://json-schema.org/draft-06/schema#",
+    "additionalProperties": false,
+    "default": {
+      "location": "center",
+      "scheduler": "dynamic"
+    },
+    "definitions": {
+      "distance_on_sky": {
+        "maximum": 3.142,
+        "minimum": 0,
+        "type": "number"
+      },
+      "elevation": {
+        "maximum": 1.571,
+        "minimum": 0,
+        "type": "number"
+      },
+      "distance_to_bodies": {
+        "additionalProperties": false,
+        "default": {},
+        "properties": {
+          "jupiter": {
+            "$ref": "#/definitions/distance_on_sky",
+            "default": 0.5
+          },
+          "moon": {
+            "$ref": "#/definitions/distance_on_sky",
+            "default": 0.5
+          },
+          "sun": {
+            "$ref": "#/definitions/distance_on_sky",
+            "default": 0.5
+          }
+        },
+        "type": "object"
+      }
+    },
+    "description": "This schema defines the scheduling constraints for a scheduling unit",
+    "patternProperties": {
+      "^[$]schema$": {}
+    },
+    "properties": {
+      "daily": {
+        "additionalProperties": false,
+        "default": {},
+        "properties": {
+          "avoid_twilight": {
+            "default": false,
+            "description": "Do not run during sunrise or sunset",
+            "type": "boolean"
+          },
+          "require_day": {
+            "default": false,
+            "description": "Must run in daylight",
+            "type": "boolean"
+          },
+          "require_night": {
+            "default": false,
+            "description": "Must run at night",
+            "type": "boolean"
+          }
+        },
+        "type": "object"
+      },
+      "location": {
+        "default": "center",
+        "description": "Evaluate the (sky & daily) constraints at either the center (cs002) station, or the most North/East/South/West stations, or both.",
+        "enum": [
+          "center",
+          "edges",
+          "both"
+        ],
+        "type": "string"
+      },
+      "scheduler": {
+        "default": "dynamic",
+        "description": "Schedule either at the fixed_time 'time.at' moment, of dynamically taking all time constraints into consideration.",
+        "enum": [
+          "fixed_time",
+          "dynamic"
+        ],
+        "name": "Scheduler",
+        "type": "string"
+      },
+      "sky": {
+        "additionalProperties": false,
+        "default": {},
+        "properties": {
+          "min_distance": {
+            "additionalProperties": false,
+            "default": { "target":  {} },
+            "properties": {
+              "target": {
+                "$ref": "#/definitions/distance_to_bodies",
+                "default": {}
+              },
+              "calibrator": {
+                "$ref": "#/definitions/distance_to_bodies",
+                "default": {}
+              }
+            },
+            "required": [
+              "target"
+            ],
+            "type": "object"
+          },
+          "min_elevation": {
+            "additionalProperties": false,
+            "default": {},
+            "properties": {
+              "calibrator": {
+                "$ref": "#/definitions/elevation",
+                "default": 0,
+                "description": "Minimum elevation for all calibrator sources"
+              },
+              "target": {
+                "$ref": "#/definitions/elevation",
+                "default": 0,
+                "description": "Minimum elevation for all target sources"
+              }
+            },
+            "type": "object"
+          },
+          "reference_pointing": {
+            "additionalProperties": false,
+            "default": {},
+            "description": "Pointing to use as reference for scheduling, instead of the SAPs of the observation",
+            "properties": {
+              "enabled": {
+                "default": false,
+                "description": "Use reference pointing",
+                "type": "boolean"
+              },
+              "pointing": {
+                "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/pointing/8/#/definitions/pointing",
+                "default": {
+                  "angle1": 0,
+                  "angle2": 0,
+                  "direction_type": "J2000"
+                }
+              }
+            },
+            "required": [
+              "enabled",
+              "pointing"
+            ],
+            "title": "Reference pointing",
+            "type": "object"
+          },
+          "transit_offset": {
+            "additionalProperties": false,
+            "default": {},
+            "description": "Offset window to LST centering",
+            "properties": {
+              "from": {
+                "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timedelta",
+                "default": -7200,
+                "maximum": 43200,
+                "minimum": -43200
+              },
+              "to": {
+                "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timedelta",
+                "default": 7200,
+                "maximum": 43200,
+                "minimum": -43200
+              }
+            },
+            "required": [
+              "from",
+              "to"
+            ],
+            "type": "object"
+          }
+        },
+        "type": "object"
+      },
+      "time": {
+        "additionalProperties": false,
+        "default": {},
+        "properties": {
+          "after": {
+            "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timestamp",
+            "description": "Start after this moment"
+          },
+          "at": {
+            "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timestamp",
+            "description": "Start at the specified date/time. Overrules dynamic scheduler priority. To be used only if really needed. Requires 'scheduler' to be set to 'fixed_time'."
+          },
+          "before": {
+            "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timestamp",
+            "description": "End before this moment"
+          },
+          "between": {
+            "default": [],
+            "description": "Run within one of these time windows",
+            "items": {
+              "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timewindow"
+            },
+            "minItems": 0,
+            "type": "array",
+            "uniqueItems": true
+          },
+          "not_between": {
+            "default": [],
+            "description": "Do NOT run within any of these time windows",
+            "items": {
+              "$ref": "https://tmss.lofar.eu/api/schemas/commonschematemplate/datetime/9/#/definitions/timewindow"
+            },
+            "minItems": 0,
+            "type": "array",
+            "uniqueItems": true
+          }
+        },
+        "type": "object"
+      }
+    },
+    "required": [
+      "scheduler"
+    ],
+    "title": "constraints",
+    "type": "object",
+    "version": 9
+  },
+  "state": "active",
+  "version": 9
+}
-- 
GitLab