%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://stsci.edu/schemas/asdf/transform/property/compound_bounding_box-1.2.0"
title: >
  Compound bounding box for a model.

description: |
  This object contains a compound bounding box for a model, which defines
  a set of input-selectable bounding boxes. It consists of a list of selector_args
  together with a list of input-key bounding box pairs. The selector
  args are an ordered list of model inputs with an indication of whether
  or not to ignore the input in the bounding box selected. The key for
  each bounding box entry corresponds to the values of the selector args
  (in the order listed) which will select the accompanying bounding box.


examples:
  -
    - A compound bounding box with one selector_args and 1D bounding_box
    - asdf-standard-1.6.0
    - |
      !transform/constant-1.6.0
        value: 1
        dimensions: 2
        bounding_box: !transform/property/compound_bounding_box-1.2.0
          selector_args:
            - argument: x
              ignore: true
          cbbox:
            - key: [0] # value of input x is 0 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  y: [1.0, 2.0]
            - key: [3] # value of input x is 3 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  y: [4.0, 5.0]
  -
    - A compound bounding box with one selector_args and 2D bounding_box
    - asdf-standard-1.6.0
    - |
      !transform/concatenate-1.4.0
        forward:
          - !transform/concatenate-1.4.0
            forward:
              - !transform/shift-1.4.0
                offset: 1.0
              - !transform/shift-1.4.0
                offset: 2.0
          - !transform/shift-1.4.0
            offset: 3.0
        bounding_box: !transform/property/compound_bounding_box-1.2.0
          selector_args:
            - argument: x
              ignore: true
          cbbox:
            - key: [0] # value of input x is 0 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x0: [1.0, 2.0]
                  x1: [3.0, 4.0]
            - key: [5] # value of input x is 5 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x0: [6.0, 7.0]
                  x1: [8.0, 9.0]
          order: 'C'
  -
    - A compound bounding box with two selector_args and 1D bounding_box
    - asdf-standard-1.6.0
    - |
      !transform/concatenate-1.4.0
        forward:
          - !transform/concatenate-1.4.0
            forward:
              - !transform/shift-1.4.0
                offset: 1.0
              - !transform/shift-1.4.0
                offset: 2.0
          - !transform/shift-1.4.0
            offset: 3.0
        bounding_box: !transform/property/compound_bounding_box-1.2.0
          selector_args:
            - argument: x0
              ignore: true
            - argument: x1
              ignore: true
          cbbox:
            - key: [0, 1] # both value of input x0 is 0 and value of input x1 is 1 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x: [2.0, 3.0]
            - key: [4, 5] # both value of input x0 is 4 and value of input x1 is 5 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x: [6.0, 7.0]
  -
    - A compound bounding box with one selector_args and 1D bounding_box
    - asdf-standard-1.6.0
    - |
      !transform/concatenate-1.4.0
        forward:
          - !transform/concatenate-1.4.0
            forward:
              - !transform/shift-1.4.0
                offset: 1.0
              - !transform/shift-1.4.0
                offset: 2.0
          - !transform/shift-1.4.0
            offset: 3.0
        bounding_box: !transform/property/compound_bounding_box-1.2.0
          selector_args:
            - argument: x
              ignore: true
          cbbox:
            - key: [0] # both value of input x is 0
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x0: [2.0, 3.0]
            - key: [1] # both value of input x is 1
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x0: [6.0, 7.0]
          ignore: [x1]
  -
    - A compound bounding box with two selector_args and 2D bounding_box
    - asdf-standard-1.6.0
    - |
      !transform/concatenate-1.4.0
        forward:
          - !transform/concatenate-1.4.0
            forward:
              - !transform/shift-1.4.0
                offset: 1.0
              - !transform/shift-1.4.0
                offset: 2.0
          - !transform/concatenate-1.4.0
            forward:
              - !transform/shift-1.4.0
                offset: 3.0
              - !transform/shift-1.4.0
                offset: 4.0
        bounding_box: !transform/property/compound_bounding_box-1.2.0
          selector_args:
            - argument: x00
              ignore: true
            - argument: x10
              ignore: true
          cbbox:
            - key: [0, 1] # both value of input x00 is 0 and value of input x10 is 1 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x01: [2.0, 3.0]
                  x11: [4.0, 5.0]
            - key: [6, 7] # both value of input x00 is 6 and value of input x10 is 7 to select this box
              bbox: !transform/property/bounding_box-1.2.0
                intervals:
                  x01: [8.0, 9.0]
                  x11: [10.0, 11.0]
          order: 'F'

definitions:
  selector_arg:
    description: |
      This object contains the description of a single selector argument.

    type: object
    properties:
      argument:
        type: string
      ignore:
        type: boolean
    required: [argument, ignore]

  selector_args:
    description: |
      This object contains a list of all the selector arguments.

    type: array
    minItems: 1
    items:
      $ref: "#/definitions/selector_arg"
  cbbox_entry:
    description: |
      This object contains a single input-bounding_box entry for a
      compound_bounding_box. Note that each key must have the same
      number of items as the selector arguments. Moreover, each value
      for a key is the actual input value for the model, not the name
      of the input

    type: object
    properties:
      key:
        type: array
        minItems: 1
        items:
          type: number
      bbox:
        tag: tag:stsci.edu:asdf/transform/property/bounding_box-1.*
    required: [key, bbox]

  cbbox:
    description: |
      This object contains the map of the bounding boxes. Note that
      each compound_bounding_box entry should have bboxes of the same
      size

    type: array
    minItems: 1
    items:
      $ref: "#/definitions/cbbox_entry"

  ignore:
    type: array
    items:
      type: string

  order:
    enum: ['C', 'F']


type: object
properties:
  selector_args:
    $ref: "#/definitions/selector_args"
  cbbox:
    $ref: "#/definitions/cbbox"
  ignore:
    $ref: "#/definitions/ignore"
  order:
    $ref: "#/definitions/order"
required: [selector_args, cbbox]
...
