{
  "$id": "https://www.hestia.earth/schema-data/json-schema/Input.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$comment": "Schema version 39.0.1",
  "title": "Input",
  "description": "An Input used during the [Cycle](/schema/Cycle) or [Transformation](/schema/Transformation). Each Input must be unique, and the fields which determine uniqueness are defined in the <code>[inputs](/schema/Cycle#inputs)</code> field of the Cycle or [Transformation](/schema/Transformation#inputs).\n",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Input",
      "enum": [
        "Input"
      ]
    },
    "@type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Input",
      "enum": [
        "Input"
      ],
      "extend": true
    },
    "term": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the Input.",
      "examples": [
        {
          "@id": "CAS-34494-04-7",
          "@type": "Term",
          "name": "Glyphosate",
          "units": "g active ingredient",
          "termType": "pesticideAI"
        }
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "description": {
      "type": "string",
      "description": "A description of the Input.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "value": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "null"
        ]
      },
      "description": "The quantity of the Input. If an average, it should always be the mean. Can be a single number (array of length one) or an array of numbers with associated dates (e.g., representing an application schedule).",
      "examples": [
        [
          400
        ]
      ],
      "exportDefaultCSV": true,
      "recommended": true
    },
    "distribution": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "array"
        ]
      },
      "description": "An array of up to 1000 random samples from the posterior distribution of valuedates field.",
      "examples": [],
      "exportDefaultCSV": true,
      "maxItems": 1000
    },
    "sd": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "number",
            "minimum": 0
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "The standard deviation of value.",
      "examples": [
        [
          180
        ]
      ],
      "minimum": 0,
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "min": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "null"
        ]
      },
      "description": "The minimum of value.",
      "examples": [],
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "max": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "null"
        ]
      },
      "description": "The maximum of value.",
      "examples": [],
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "percentile10th": {
      "type": "number",
      "description": "The 10th percentile of value.",
      "examples": [],
      "exportDefaultCSV": false,
      "internal": true
    },
    "percentile90th": {
      "type": "number",
      "description": "The 90th percentile of value.",
      "examples": [],
      "exportDefaultCSV": false,
      "internal": true
    },
    "statsDefinition": {
      "type": "string",
      "description": "What the descriptive statistics (sd, min, max, and value) are calculated across, or whether they are simulated or the output of a model. spatial refers to descriptive statistics calculated across spatial units (e.g., pixels) within a region or country. time refers to descriptive statistics calculated across units of time (e.g., hours).",
      "examples": [
        "replications"
      ],
      "enum": [
        "sites",
        "cycles",
        "replications",
        "animals",
        "other observations",
        "time",
        "spatial",
        "regions",
        "simulated",
        "modelled"
      ],
      "exportDefaultCSV": true
    },
    "observations": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "number",
            "minimum": 1
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "The number of observations the descriptive statistics are calculated over.",
      "examples": [
        [
          10
        ]
      ],
      "searchable": true,
      "minimum": 1,
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "dates": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A corresponding array to value, representing the dates of the Inputs in ISO 8601 format (YYYY-MM-DD, YYYY-MM, YYYY, --MM-DD, --MM, or YYYY-MM-DDTHH:mm:ssZ).",
      "examples": [],
      "dateTimePattern": true,
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "startDate": {
      "type": "string",
      "description": "For Inputs over periods different to Cycle, the start date of the Input (if different from the start date of the Cycle]) in [ISO 8601 format (YYYY-MM-DD).",
      "examples": [],
      "datePattern": true,
      "exportDefaultCSV": true
    },
    "endDate": {
      "type": "string",
      "description": "For Inputs over periods different to Cycle, the end date of the Input (if different from the end date of the Cycle]) in [ISO 8601 format (YYYY-MM-DD).",
      "examples": [],
      "datePattern": true,
      "exportDefaultCSV": true
    },
    "inputDuration": {
      "type": "number",
      "description": "The duration of the Input in days.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "methodClassification": {
      "type": "string",
      "description": "A classification of the method used to acquire or estimate the term and value. Overrides the defaultMethodClassification specified in the Cycle. methodClassification should be specified separately for properties (see Property) and transport (see Transport).    physical measurement means the amount is quantified using weighing,\n    volume measurement, metering, chemical methods, or other physical approaches.\n\n    verified survey data means the data are initially collected through\n    surveys; all or a subset of the data are verified using physical methods; and\n    erroneous survey data are discarded or corrected.\n\n    non-verified survey data means the data are collected through\n    surveys that have not been subjected to verification.\n\n    modelled means a previously calibrated model is used to estimate\n    this data point from other data points describing this Cycle.\n\n    estimated with assumptions means a documented assumption is used\n    to estimate this data point from other data points describing this Cycle.\n\n    consistent external sources means the data are taken from external\n    datasets referring to different producers/enterprises:\n\n        Using the same technology (defined as the same\n        System or the same key Practices\n        as those specified in the Cycle);\n\n        At the same date (defined as occurring within the\n        startDate and endDate of the Cycle);\n        and\n\n        In the same region or country.\n\n    Modelling or assumptions may have also been used to transform these data.\n\n    inconsistent external sources means the data are taken from external\n    datasets referring to different producers/enterprises:\n\n        Using a different technology (defined as a different\n        System or using different key\n        Practices to those specified in the Cycle);\n\n        At a different date (defined as occurring within the\n        startDate and endDate of the Cycle);\n        or\n\n        In a different region or country.\n\n    Modelling or assumptions may have also been used to transform these data.\n\n    expert opinion means the data have been estimated by experts in\n    the field.\n\n    unsourced assumption means the data do not have a clear source\n    and/or are based on assumptions only.\n",
      "examples": [],
      "enum": [
        "physical measurement",
        "verified survey data",
        "non-verified survey data",
        "modelled",
        "estimated with assumptions",
        "consistent external sources",
        "inconsistent external sources",
        "expert opinion",
        "unsourced assumption"
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "methodClassificationDescription": {
      "type": "string",
      "description": "A justification of the methodClassification used. If the data were estimated with assumptions this field should also describe the assumptions. This is a required field if methodClassification is specified.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "model": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the model used to estimate these data.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "modelDescription": {
      "type": "string",
      "description": "A free text field, describing the model used to estimate these data.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "isAnimalFeed": {
      "type": "boolean",
      "description": "true if this Input is fed to animals. A required field for Inputs which could potentially be animal feed (defined as Inputs of termType = crop, aquaticCrop, forage, liveAnimal, animalProduct, liveAquaticSpecies, feedFoodAdditive, processedFood, or waste in animal production Cycles).",
      "examples": [],
      "exportDefaultCSV": true
    },
    "variety": {
      "type": "string",
      "description": "The variety (cultivar) of a crop or breed of animal. Standardised variety names are defined in external glossaries, such as the OECD, GEVES, PLUTO, or CPVO glossaries.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "fate": {
      "type": "string",
      "description": "The fate of the Input. This field can be used for Inputs into Transformations only, to univocally match the Input with the Cycle Product.",
      "examples": [],
      "enum": [
        "sold",
        "sold to export market",
        "sold to domestic market",
        "sold for breeding",
        "sold for fattening",
        "sold for slaughter",
        "home consumption",
        "fodder",
        "bedding",
        "breeding",
        "saved for seeds",
        "processing",
        "burnt for fuel",
        "burnt",
        "anaerobic digestion",
        "composted",
        "used as fertiliser",
        "used as soil amendment",
        "used as mulch"
      ],
      "exportDefaultCSV": true
    },
    "fromCycle": {
      "type": "boolean",
      "description": "A required field for Inputs into Transformations only. true if this Input is a Product from the Cycle. false if this Input was added at the Transformation stage only (e.g., diesel used to power a grain dryer) or false if this Input is a Product from a previous Transformation.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "producedInCycle": {
      "type": "boolean",
      "description": "Whether an input is produced and used during the Cycle, e.g., true if the forage is grown on the pasture where animals are grazing, false if it is grown elsewhere.",
      "examples": []
    },
    "price": {
      "type": "number",
      "minimum": 0,
      "description": "The price paid for this Input. The currency must be specified. The price should be expressed per the units defined in the term, for example per \"kg active ingredient\". In situations where a term describes one physical item (e.g., \"NP Blend\" fertiliser) but the glossary uses terms with unit that split the item (e.g., \"NP Blend (kg N)\" and \"NP Blend (kg P2O5)\") the price must be divided by the relative mass of each term.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "priceSd": {
      "type": "number",
      "minimum": 0,
      "description": "The standard deviation of price.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "priceMin": {
      "type": "number",
      "minimum": 0,
      "description": "The minimum of price.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "priceMax": {
      "type": "number",
      "minimum": 0,
      "description": "The maximum of price.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "priceStatsDefinition": {
      "type": "string",
      "description": "What the descriptive statistics for price are calculated across.",
      "examples": [],
      "enum": [
        "cycles",
        "time",
        "cycles and time"
      ],
      "exportDefaultCSV": true
    },
    "cost": {
      "type": "number",
      "minimum": 0,
      "description": "The total cost of this Input (price x quantity), expressed as a positive value. The currency must be specified.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "costSd": {
      "type": "number",
      "minimum": 0,
      "description": "The standard deviation of cost.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "costMin": {
      "type": "number",
      "minimum": 0,
      "description": "The minimum of cost.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "costMax": {
      "type": "number",
      "minimum": 0,
      "description": "The maximum of cost.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "costStatsDefinition": {
      "type": "string",
      "description": "What the descriptive statistics for cost are calculated across.",
      "examples": [],
      "enum": [
        "cycles",
        "time",
        "cycles and time"
      ],
      "exportDefaultCSV": true
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "The three letter currency code in ISO 4217 format.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "lifespan": {
      "type": "number",
      "description": "For Inputs used to create Infrastructure, the lifespan of this Input expressed in decimal years.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "operation": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the operation associated with this Input (e.g., for the Input diesel the operation could be Soil decompaction, machine unspecified).",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "country": {
      "$ref": "./Term-deep.json#",
      "description": "The country where this Input came from.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "region": {
      "$ref": "./Term-deep.json#",
      "description": "The region where this Input came from.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "impactAssessment": {
      "$ref": "./ImpactAssessment-deep.json#",
      "description": "A reference to the node containing environmental impact data related to producing this product and transporting it to the Site.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "impactAssessmentIsProxy": {
      "type": "boolean",
      "description": "\n      The impactAssessment\n        referred to represents data from the actual supply chain (e.g., data from\n        the actual supplying farm or the supplying feed mill).\n\n      Set to false\n\n      The impactAssessment\n        referred to is a proxy for the actual supply chain (e.g., global or\n        regional average data).\n\n      Set to true\n\n Required if impactAssessment is specified.\n",
      "examples": [],
      "exportDefaultCSV": true
    },
    "site": {
      "$ref": "./Site-deep.json#",
      "description": "If the Cycle occurred on multiple Sites, the Site where this Input was used.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "source": {
      "$ref": "./Source-deep.json#",
      "description": "A reference to the Source of these data, if different from the defaultSource of the Cycle.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "otherSources": {
      "type": "array",
      "items": {
        "$ref": "./Source-deep.json#"
      },
      "description": "A list of references to any other sources of these data.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "properties": {
      "type": "array",
      "items": {
        "$ref": "./Property.json#"
      },
      "description": "A list of Properties of the Input, which would override any default properties specified in the term.",
      "examples": [],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "key.@id",
        "value",
        "share",
        "date",
        "startDate",
        "endDate"
      ]
    },
    "transport": {
      "type": "array",
      "items": {
        "$ref": "./Transport.json#"
      },
      "description": "A list of Transport stages to bring this Input to the Cycle.",
      "examples": [],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "value",
        "distance"
      ]
    },
    "schemaVersion": {
      "type": "string",
      "description": "The version of the schema when these data were created.",
      "examples": [],
      "internal": true
    },
    "added": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of fields that have been added to the original dataset.",
      "examples": [],
      "internal": true
    },
    "addedVersion": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of versions of the model used to add these fields.",
      "examples": [],
      "internal": true
    },
    "updated": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of fields that have been updated on the original dataset.",
      "examples": [],
      "internal": true
    },
    "updatedVersion": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of versions of the model used to update these fields.",
      "examples": [],
      "internal": true
    },
    "aggregated": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of fields that have been 'aggregated' using data from multiple Cycles.",
      "examples": [],
      "internal": true
    },
    "aggregatedVersion": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of versions of the aggregation engine corresponding to each aggregated field.",
      "examples": [],
      "internal": true
    }
  },
  "allOf": [
    {
      "if": {
        "required": [
          "term"
        ]
      },
      "then": {
        "properties": {
          "term": {
            "properties": {
              "termType": {
                "enum": [
                  "biologicalControlAgent",
                  "electricity",
                  "feedFoodAdditive",
                  "fuel",
                  "material",
                  "inorganicFertiliser",
                  "organicFertiliser",
                  "fertiliserBrandName",
                  "biochar",
                  "pesticideAI",
                  "pesticideBrandName",
                  "processingAid",
                  "seed",
                  "otherOrganicChemical",
                  "otherInorganicChemical",
                  "soilAmendment",
                  "substrate",
                  "water",
                  "animalProduct",
                  "crop",
                  "aquaticCrop",
                  "forage",
                  "liveAnimal",
                  "liveAquaticSpecies",
                  "excreta",
                  "processedFood",
                  "veterinaryDrug",
                  "waste"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "model"
        ]
      },
      "then": {
        "properties": {
          "model": {
            "properties": {
              "termType": {
                "enum": [
                  "model"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "operation"
        ]
      },
      "then": {
        "properties": {
          "operation": {
            "properties": {
              "termType": {
                "enum": [
                  "operation"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "required": [
              "min"
            ]
          },
          {
            "required": [
              "max"
            ]
          },
          {
            "required": [
              "sd"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "statsDefinition"
        ]
      }
    },
    {
      "if": {
        "required": [
          "statsDefinition"
        ]
      },
      "then": {
        "anyOf": [
          {
            "required": [
              "value"
            ]
          },
          {
            "required": [
              "min"
            ]
          },
          {
            "required": [
              "max"
            ]
          },
          {
            "required": [
              "sd"
            ]
          }
        ]
      }
    },
    {
      "if": {
        "required": [
          "country"
        ]
      },
      "then": {
        "properties": {
          "country": {
            "properties": {
              "termType": {
                "enum": [
                  "region"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "region"
        ]
      },
      "then": {
        "properties": {
          "region": {
            "properties": {
              "termType": {
                "enum": [
                  "region"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "region"
        ]
      },
      "then": {
        "required": [
          "country"
        ]
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "required": [
              "cost"
            ]
          },
          {
            "required": [
              "price"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "currency"
        ]
      }
    },
    {
      "if": {
        "required": [
          "impactAssessment"
        ]
      },
      "then": {
        "required": [
          "impactAssessmentIsProxy"
        ]
      }
    },
    {
      "if": {
        "required": [
          "methodClassification"
        ]
      },
      "then": {
        "required": [
          "methodClassificationDescription"
        ]
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "required": [
              "priceMin"
            ]
          },
          {
            "required": [
              "priceMax"
            ]
          },
          {
            "required": [
              "priceSd"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "priceStatsDefinition"
        ]
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "required": [
              "costMin"
            ]
          },
          {
            "required": [
              "costMax"
            ]
          },
          {
            "required": [
              "costSd"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "costStatsDefinition"
        ]
      }
    },
    {
      "if": {
        "required": [
          "inputs"
        ]
      },
      "then": {
        "properties": {
          "inputs": {
            "items": {
              "not": {
                "required": [
                  "lifespan"
                ]
              }
            }
          }
        }
      }
    }
  ],
  "oneOf": [
    {
      "required": [
        "@type"
      ]
    },
    {
      "required": [
        "type"
      ]
    }
  ],
  "required": [
    "term"
  ]
}