{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "pqprocedure.json",
    "title": "PQProcedure",
    "type": "object",
    "description": "Generic class for precipitation - discharge procedure. Default order of boundaries is: precipitation, potential evapotranspiration, dicharge, soil moisture. Properties for parameters and initial conditions are not set here thus should be set in derived classes",
    "allOf": [
        {
            "$ref": "procedure.json"
        },
        {
            "properties": {
                "type": {
                    "type": "string"
                },
                "initial_states": {
                    "oneOf": [
                        {
                            "type": "object"
                        },
                        {
                            "type": "array"
                        }
                    ],
                    "description": "Initial states"
                },
                "parameters": {
                    "type": "object",
                    "description": "Model parameters"
                },
                "extra_pars": {
                    "$ref": "pqprocedure.json#/$defs/ExtraPars"
                },
                "boundaries": {
                    "oneOf": [
                        {
                            "type": "array",
                            "items": {
                                "allOf": [
                                    { "$ref": "procedureboundary.json"},
                                    {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "type": "string",
                                                "enum": ["pma","etp","q_obs","smc_obs"]
                                            }
                                        }
                                    }
                                ]
                            },
                            "minItems": 2,
                            "maxItems": 4
                        },
                        {
                            "type": "array",
                            "description": "list of lists of observations",
                            "items": {
                                "$ref": "observationlist.json"
                            },
                            "minItems": 2,
                            "maxItems": 4
                        },
                        {
                            "type": "string",
                            "description": "Path to CSV file. First column must be the datetime index. Headers (first row) must indicate input names: 'pma', 'etp', 'q_obs', 'smc_obs'"
                        }
                    ]
                },
                "outputs": {
                    "oneOf": [
                        {
                            "type": "array",
                            "items": {
                                "allOf": [
                                    { "$ref": "procedureboundary.json"},
                                    {
                                        "type": "object",
                                        "properties": {
                                            "name": {
                                                "enum": ["q_sim", "smc_sim"]
                                            }
                                        }
                                    }
                                ]
                            },
                            "minItems": 1,
                            "maxItems": 2
                        },
                        {
                            "type": "array",
                            "description": "list of lists of observations",
                            "items": {
                                "$ref": "observationlist.json"
                            },
                            "minItems": 1,
                            "maxItems": 2
                        },
                        {
                            "type": "string",
                            "description": "Path to CSV file. First column must be the datetime index. Headers (first row) must indicate output names"
                        }
                    ]
                }
            },
            "required": [
                "type",
                "parameters",
                "extra_pars",
                "boundaries",
                "outputs"
            ]
        }
    ],
    "$defs": {
        "ExtraPars": {
            "type": "object",
            "description": "additional parameters, for example basin parameters. If a particular basin parameter is not set and required by the procedure function, it will try to retrieve it from the boundary node metadata available at the input api",
            "properties": {
                "area": {
                    "type": "number",
                    "description": "basin area in square meters"
                },
                "fill_nulls": {
                    "type": "boolean",
                    "description": "If missing PMAD values, fill up with zeros"
                },
                "rho": {
                    "type": "number",
                    "description": "soil porosity (0-1)"
                },
                "ae": {
                    "type": "number",
                    "description": "effective area (0-1)"
                },
                "wp": {
                    "type": "number",
                    "description": "wilting point of soil (0-1)"
                }
            }
        }
    }
}