{
  "$id": "https://www.hestia.earth/schema-data/json-schema/Measurement.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$comment": "Schema version 39.0.1",
  "title": "Measurement",
  "description": "A soil or climate Measurement on a [Site](/schema/Site). For example, the soil pH on 3 January 2020. The [method](/schema/Measurement#method) used to take the Measurement often changes the results, and it should ideally be specified. Each Measurement must be unique, and the fields which determine uniqueness are defined in the <code>[measurements](/schema/Site#measurements)</code> field of the Site.\n",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Measurement",
      "enum": [
        "Measurement"
      ]
    },
    "@type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Measurement",
      "enum": [
        "Measurement"
      ],
      "extend": true
    },
    "term": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the Measurement.",
      "examples": [
        {
          "@id": "organicCarbonPerKgSoil",
          "@type": "Term",
          "name": "Organic carbon (per kg soil)",
          "units": "g C / kg soil",
          "termType": "measurement"
        },
        {
          "@id": "sandSoilTexture",
          "@type": "Term",
          "name": "Sand (soil texture)",
          "termType": "soilTexture"
        }
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "description": {
      "type": "string",
      "description": "A short description of the Measurement.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "value": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "boolean"
        ]
      },
      "description": "The quantity of the Measurement. If an average, it should always be the mean. Can be a single number (array of length one), an array of numbers with associated dates (e.g., representing multiple Measurements over time) or a boolean (e.g., Heavy winter precipitation can be either true or false).",
      "examples": [
        [
          0.1916,
          0.197,
          0.6794
        ]
      ],
      "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": [
        [
          [
            0.039,
            0.24,
            0.269,
            0.342,
            0.068
          ],
          [
            0.097,
            0.654,
            0.161,
            0.064,
            0.009
          ],
          [
            0.98,
            0.755,
            0.923,
            0.269,
            0.47
          ]
        ]
      ],
      "exportDefaultCSV": true,
      "maxItems": 1000
    },
    "sd": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "number",
            "minimum": 0
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "The standard deviation of value.",
      "examples": [],
      "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",
        "replications",
        "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": [],
      "searchable": true,
      "minimum": 1,
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "dates": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A corresponding array to value, representing the dates (and times) of the Measurements in ISO 8601 format (YYYY-MM-DD, YYYY-MM, YYYY, --MM-DD, --MM, or YYYY-MM-DDTHH:mm:ssZ).",
      "examples": [
        [
          "1989-01",
          "1989-01-01",
          "1989-01-01T20:20:39"
        ]
      ],
      "dateTimePattern": true,
      "arraySameSize": [
        "value"
      ],
      "exportDefaultCSV": true
    },
    "startDate": {
      "type": "string",
      "description": "For period Measurements, the start date of the Measurement in ISO 8601 format (YYYY-MM-DD, YYYY-MM, or YYYY).",
      "examples": [],
      "datePattern": true,
      "exportDefaultCSV": true
    },
    "endDate": {
      "type": "string",
      "description": "For period Measurements, the end date of the Measurement in ISO 8601 format (YYYY-MM-DD, YYYY-MM, or YYYY).",
      "examples": [],
      "datePattern": true,
      "searchable": true,
      "exportDefaultCSV": true
    },
    "measurementDuration": {
      "type": "number",
      "description": "The duration of the Measurement in days.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "depthUpper": {
      "type": "number",
      "minimum": 0,
      "maximum": 9999,
      "description": "For soil Measurements, the upper (shallower) depth of the Measurement interval in centimeters, using positive numbers.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "depthLower": {
      "type": "number",
      "minimum": 0,
      "maximum": 9999,
      "description": "For soil Measurements, the lower (deeper) depth of the Measurement interval in centimeters.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "latitude": {
      "type": "number",
      "minimum": -90,
      "maximum": 90,
      "description": "The latitude of the Measurement if different from the centroid of the Site (-90 to 90, WGS84 datum).",
      "examples": [],
      "exportDefaultCSV": true
    },
    "longitude": {
      "type": "number",
      "minimum": -180,
      "maximum": 180,
      "description": "The longitude of the Measurement if different from the centroid of the Site (-90 to 90, WGS84 datum).",
      "examples": [],
      "exportDefaultCSV": true
    },
    "methodClassification": {
      "type": "string",
      "description": "    An on-site physical measurement is based on weather stations or\n    indoor climate monitoring units on the Site or on soil samples\n    taken from the Site.\n\n    A physical measurement on nearby site is based on data from\n    nearby weather stations or indoor climate monitoring units or on soil samples\n    from nearby Sites which can be assumed to represent the current Site.\n\n    modelled using other measurements means the data\n    are estimated by applying a statistical or process based model, which is\n    associated with some error, to other measurements.\n\n    A tier 1 model quantifies the Measurement using activity data (i.e.,\n    data on Inputs, Practices, etc.) using a\n    simple equation with parameters which are not country or region specific.\n\n    A tier 2 model quantifies the Measurement from activity data using a\n    simple equation, often of the same form as the tier 1 model, but with\n    geographically specific parameters (e.g., other Site Measurements).\n\n    A tier 3 model quantifies the Measurement from activity data but uses\n    equations or algorithms that differ from the tier 1 model and\n    tier 2 model approaches. Tier 3 approaches include process based models\n    and statistical models with various forms.\n\n    A geospatial dataset is data in raster or vector format with\n    sub-regional and sub-national spatial resolution.\n\n    regional statistical data are soil or climate measurements\n    representative of the region.\n\n    country-level statistical data are soil or climate\n    measurements representative of the country.\n\n    expert opinion is a soil or climate measurement estimated by an\n    individual or organisation with context-specific knowledge.\n\n    An unsourced assumption is a soil or climate measurement\n    estimated by pure assumption or provided without any information on its source.\n",
      "examples": [
        "on-site physical measurement",
        "geospatial dataset"
      ],
      "enum": [
        "on-site physical measurement",
        "modelled using other measurements",
        "tier 3 model",
        "tier 2 model",
        "tier 1 model",
        "physical measurement on nearby site",
        "geospatial dataset",
        "regional statistical data",
        "country-level statistical data",
        "expert opinion",
        "unsourced assumption"
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "methodClassificationDescription": {
      "type": "string",
      "description": "Further description or justification of the methodClassification.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "method": {
      "$ref": "./Term-deep.json#",
      "description": "For physical measurements, a reference to the Term describing the method used to acquire the measurement.",
      "examples": [
        {
          "@id": "chromicAcidWetOxidation",
          "@type": "Term",
          "name": "Chromic acid wet oxidation",
          "termType": "methodMeasurement"
        }
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "methodDescription": {
      "type": "string",
      "description": "A free text field describing the method used to acquire the Measurement.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "source": {
      "$ref": "./Source-deep.json#",
      "description": "A reference to the Source of these data, if different from the defaultSource of the Site.",
      "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 Measurement, which would override any default properties specified in the term.",
      "examples": [],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "key.@id",
        "date",
        "startDate",
        "endDate"
      ]
    },
    "schemaVersion": {
      "type": "string",
      "description": "Version of the schema when the data was 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 Sites.",
      "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": [
                  "measurement",
                  "soilTexture",
                  "soilType",
                  "usdaSoilType"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "method"
        ]
      },
      "then": {
        "properties": {
          "method": {
            "properties": {
              "termType": {
                "enum": [
                  "methodMeasurement",
                  "model"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "required": [
              "min"
            ]
          },
          {
            "required": [
              "max"
            ]
          },
          {
            "required": [
              "sd"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "statsDefinition"
        ]
      }
    },
    {
      "if": {
        "required": [
          "statsDefinition"
        ]
      },
      "then": {
        "anyOf": [
          {
            "required": [
              "value"
            ]
          },
          {
            "required": [
              "min"
            ]
          },
          {
            "required": [
              "max"
            ]
          },
          {
            "required": [
              "sd"
            ]
          }
        ]
      }
    }
  ],
  "oneOf": [
    {
      "required": [
        "@type"
      ]
    },
    {
      "required": [
        "type"
      ]
    }
  ],
  "required": [
    "term",
    "methodClassification"
  ]
}