{
  "$id": "https://www.hestia.earth/schema-data/json-schema/Animal.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$comment": "Schema version 39.0.1",
  "title": "Animal",
  "description": "A type of animal present during the [Cycle](/schema/Cycle). Adding multiple blank nodes of this type specifies the population (\"herd composition\") or describes a polyculture system. Use <code>[properties](/schema/Animal#properties)</code> to add information describing each animal type, such as [Liveweight per head](/term/liveweightPerHead), [Liveweight gain](/term/liveweightGain), [Age](/term/age), [Mortality rate](/term/mortalityRate), or [Pregnancy rate total](/term/pregnancyRateTotal). Use <code>[inputs](/schema/Animal#inputs)</code> to specify the Inputs for each animal type such as the feed use. Input quantities should be the total for all animals represented by this blank node and not the input quantity per head. Use <code>[practices](/schema/Animal#practices)</code> to specify Practices describing each each animal type such as the [animal breed](/glossary?page=1&termType=animalBreed).\n",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Animal",
      "enum": [
        "Animal"
      ]
    },
    "@type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Animal",
      "enum": [
        "Animal"
      ],
      "extend": true
    },
    "animalId": {
      "type": "string",
      "pattern": "^[\\w\\-\\.\\s\\(\\)]+$",
      "description": "An identifier for each Animal which must be unique within the Cycle.",
      "examples": [
        "dairy-cattles"
      ],
      "exportDefaultCSV": true
    },
    "term": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the Animal.",
      "examples": [
        {
          "@id": "dairyCattleCowLactating",
          "@type": "Term",
          "name": "Dairy cattle, cow (lactating)",
          "units": "number",
          "termType": "liveAnimal"
        }
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "description": {
      "type": "string",
      "description": "A description of the Animal type.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "referencePeriod": {
      "type": "string",
      "description": "    The data are a time-weighted average over the Cycle. The recommended\n    value.\n\n    The data describe the Animal at the start of Cycle.\n\n    The data describe the Animal at the end of Cycle.\n",
      "examples": [
        "average"
      ],
      "enum": [
        "average",
        "start of Cycle",
        "end of Cycle"
      ],
      "exportDefaultCSV": true
    },
    "value": {
      "type": "number",
      "description": "The number of Animals per functionalUnit. If using an average reference period, the number should be a time-weighted average which takes into account transitions between different categories that occur during the Cycle (e.g., female calves becoming heifers) and mortalities.",
      "examples": [
        30
      ],
      "recommended": true,
      "exportDefaultCSV": true
    },
    "distribution": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "description": "An array of up to 1000 random samples from the posterior distribution of value</code. This should describe the entire distribution of the dataset and not the distribution of the mean.",
      "examples": [],
      "exportDefaultCSV": true,
      "maxItems": 1000
    },
    "sd": {
      "type": "number",
      "minimum": 0,
      "description": "The standard deviation of value.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "min": {
      "type": "number",
      "description": "The minimum of value.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "max": {
      "type": "number",
      "description": "The maximum of value.",
      "examples": [],
      "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": [],
      "enum": [
        "sites",
        "cycles",
        "replications",
        "animals",
        "other observations",
        "time",
        "spatial",
        "regions",
        "simulated",
        "modelled"
      ],
      "exportDefaultCSV": true
    },
    "observations": {
      "type": "number",
      "minimum": 1,
      "description": "The number of observations the descriptive statistics are calculated over.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "price": {
      "type": "number",
      "minimum": 0,
      "description": "The price of the Animal. The price should be expressed per animal. The currency must be specified.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "The three letter currency code in ISO 4217 format.",
      "examples": [],
      "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), inputs (see Input) and practices (see Practice).    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
    },
    "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 Animal type, which would override any default properties specified in the term.",
      "examples": [
        [
          {
            "@type": "Property",
            "term": {
              "@id": "liveweightPerHead",
              "@type": "Term",
              "name": "Liveweight per head",
              "units": "kg liveweight / head",
              "termType": "property"
            },
            "value": 300
          },
          {
            "@type": "Property",
            "term": {
              "@id": "mortalityRate",
              "@type": "Term",
              "name": "Mortality rate",
              "units": "%",
              "termType": "property"
            },
            "value": 4.5
          }
        ]
      ],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "key.@id",
        "date",
        "startDate",
        "endDate"
      ]
    },
    "inputs": {
      "type": "array",
      "items": {
        "$ref": "./Input.json#"
      },
      "description": "The Inputs (e.g., feed or veterinary drugs). Values for each Input should be a sum over all animals represented by this blank node and not a value per head.",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "dates",
        "startDate",
        "endDate",
        "isAnimalFeed",
        "producedInCycle",
        "transport.term.@id",
        "operation.@id",
        "country.@id",
        "region.@id",
        "impactAssessment.id"
      ]
    },
    "practices": {
      "type": "array",
      "items": {
        "$ref": "./Practice.json#"
      },
      "description": "The Practices used to describe the system each Animal type is in or to describe management practices specific to each animal type (e.g., the Milk yield per cow (FPCM)).",
      "examples": [],
      "searchable": true,
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "key.@id",
        "dates",
        "startDate",
        "endDate",
        "areaPercent",
        "ownershipStatus"
      ]
    },
    "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": [
                  "liveAnimal",
                  "liveAquaticSpecies"
                ]
              }
            }
          }
        }
      }
    },
    {
      "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": {
        "anyOf": [
          {
            "required": [
              "price"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "currency"
        ]
      }
    },
    {
      "if": {
        "required": [
          "methodClassification"
        ]
      },
      "then": {
        "required": [
          "methodClassificationDescription"
        ]
      }
    }
  ],
  "oneOf": [
    {
      "required": [
        "@type"
      ]
    },
    {
      "required": [
        "type"
      ]
    }
  ],
  "required": [
    "animalId",
    "term",
    "referencePeriod"
  ]
}