<?xml version="1.0" encoding="UTF-8"?>
<!-- 
United States Geological Survey - Water Resources Disipline - National Water Information System

The Computation schema defines the XML structure that holds the instructions for 
performing time-series computations.

Version 1.1 - 11/18/2003 - Original schema design.
Version 1.2 - 08/17/2005 - Modifications to bring into line with database design 
                           and include all elements of the computation instructions.
-->
<xsd:schema version="5.0" 
            xmlns:nwis="http://water.usgs.gov/XML/NWIS/5.0"
            
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            
            elementFormDefault="qualified">

	<xsd:include schemaLocation="../shared/IEEE754FloatValue.xsd"/>
	<xsd:include schemaLocation="../shared/RecordHistory.xsd"/>
	<xsd:include schemaLocation="../site/Site.xsd"/>
	<xsd:include schemaLocation="DataDescriptor.xsd"/>

	<xsd:element name="StageDischargeComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing a standard stage discharge computation, which uses a rating which defines the relationship between stage and discharge.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="StageDataDescriptorNumber" type="xsd:integer">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the stage gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="SlopeDischargeComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing a computation of discharge unit values where slope is a factor. This computation uses the fall in water surface between two gages.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="BaseStageDataDescriptorNumber" type="xsd:integer">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the base gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>

				<xsd:element name="AuxiliaryStageDataDescriptor">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the auxilliary gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
					<xsd:complexType>
						<xsd:sequence>
							<xsd:element ref="SiteIdentifier" minOccurs="0" maxOccurs="3"/>
							<xsd:element name="DataDescriptorNumber" type="xsd:integer"/>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>

				<xsd:element name="UpstreamFlag" type="xsd:boolean">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The flag indicating whether the base gage is upstream from the auxiliary gage. If true the base gage is upstream from the auxiliary gage and if false the auxiliary gage is upstream from the base gage. This flag is used in the time-series computation of stream flow at a slope station and indicates how the gage-height records should be subtracted from one another to compute the fall of the water's surface.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="LowerStageLimit" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the lowest gage height where slope is a factor in the slope-discharge time-series computation. Gage height below this value will use a standard rating computation. This value is expressed in the units of the base gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="UpperStageLimit" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the highest gage height where slope is a factor in the slope-discharge time-series computation. Gage height above this value will use a standard rating computation. This value is expressed in the units of the base gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="MaximumFallLimit" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the highest value of fall between the base and auxiliary gage heights where slope is a factor in Fall values above this value will use a standard rating computation. This value is expressed in the units of the base gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="BaseSlopeDatum" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The base slope datum is a correction that is added to the measured fall during the slope discharge computation. This value is used to "equalize" the base and auxiliary gage data and is expressed in the units of the base gage parameter.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="VelocityDischargeComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing a computation of discharge unit values where velocity is a factor. This computation uses stage to compute cross-sectiona area and velocity and area to compute discharge.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="StageDataDescriptorNumber" type="xsd:integer">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the stage unit values.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>

				<xsd:element name="VelocityDataDescriptorNumber" type="xsd:integer">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the velocity unit values.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="LowerStageLimit" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the lowest gage height where velocity is a factor in the velocity-discharge time-series computation. Gage heights below this value will use a standard rating computation. This value is expressed in the units of the gage height.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="UpperStageLimit" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the highest gage height where velocity is a factor in the velocity-discharge time-series computation. Gage heights above this value will use a standard rating computation. This value is expressed in the units of the gage height.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="RegressionEquationUsedFlag" type="xsd:boolean">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>"Y"/"N" Flag indicating the use of the regression equation "mean_velocity = X*Vi + Y*Stage*Vi + C" instead of the rating table.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="XCoefficient" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>Correlation coefficient for velocity value for computing a mean adjusted velocity for a velocity-discharge computation.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="YCoefficient" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>Correlation coefficient for stage value for computing a mean adjusted velocity for a velocity-discharge computation.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="Constant" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>Constant value for computing a mean adjusted velocity for a velocity-discharge computation.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>

			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="RainfallComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The RainfallDischarge element defines the information needed to compute rainfall unit values using a differencing method.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="MinimumThreshold" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value indicating the minimum rainfall threshold where a smaller rainfall value is considered measurement noise and is set to zero in the rainfall unit values computation. This value is expressed in the units of the rainfall parameter.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="FirstLastThreshold" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value of the threshold where the difference between the first rain gage and last rain gage reading for a single day is not exceeded. This means that there was effectively no rainfall and any reading for the day is just sampling noise. Values for the day are set to zero. The threshold is considered to be in the units of the rainfall parameter.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="SiphonThreshold" type="IEEE754FloatValueType" minOccurs="0">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The value of the water level in a rain gage where the drain siphon takes effect. The threshold is considered to be in the units of the rainfall parameter.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="NoComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>A computation where no unit values are computed.</Definition>
			</xsd:documentation>
		</xsd:annotation>
	</xsd:element>

	<xsd:element name="GeneralComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>A computation where unit values for a data descriptor are computed from unit values of an input data descriptor using a rating.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="InputDataDescriptorNumber" type="xsd:integer">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The pointer to the data descriptor defining the input gage.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>



	<xsd:element name="UnitValueComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing the unit values computation.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
			
				<xsd:choice>
					<xsd:element ref="NoComputation"/>
					<xsd:element ref="GeneralComputation"/>
					<xsd:element ref="StageDischargeComputation"/>
					<xsd:element ref="SlopeDischargeComputation"/>
					<xsd:element ref="VelocityDischargeComputation"/>
					<xsd:element ref="RainfallComputation"/>
				</xsd:choice>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="DailyValueComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing the daily values computation.</Definition>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="StatisticCode" type="xsd:NMTOKEN" maxOccurs="10">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The code identifying the statistic to compute.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="TimeSeriesComputation">
		<xsd:annotation>
			<xsd:documentation>
				<Definition>The instructions for performing the time-series computations.</Definition>
			</xsd:documentation>
		</xsd:annotation>  
	            <xsd:complexType>
			<xsd:sequence>
				<xsd:element name="StartDateTime" type="DateTimeWithDatum">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The effective starting date and time of the time-series computation instruction set.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>

				<xsd:element name="EndDateTime" type="DateTimeWithDatum">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The effective ending date and time of the time-series computation instruction set.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element ref="DataAgingCode"/>
	                        <xsd:element name="ComputationCode" type="xsd:NMTOKEN">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The code indicating the type of unit values computation to be performed.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="MissingGapDuration" type="xsd:positiveInteger">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The time in minutes between consecutive unit values that defines a gap of missing unit values. This time is used to flag daily values as incomplete when they are calculated from unit values that have this gap exceeded. It is also used for deciding whether to interpolate unit values during UV computations and midnight calculations.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="StandardReportIndicator" type="xsd:boolean">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>A true or false flag indicating the type of time-series computation primary report to be generated during primary computations is to be the standard primary report. "Y" indicates that the standard report shall be generated and "N" indicates that the historical primary report will be generated.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
                        	<xsd:element name="PeakBaseMeasure" type="IEEE754FloatValueType">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The base discharge used in the peakflow computation.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="IntervalBetweenPeaksMeasure" type="IEEE754FloatValueType">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>The interval between peaks value.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
				<xsd:element name="SiteVisitShiftIndicator" type="xsd:boolean">
					<xsd:annotation>
						<xsd:documentation>
							<Definition>A true or false flag indicating theis there are site visit shifts.</Definition>
						</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
                                <xsd:group ref="HistoryGroup"/>
				<xsd:choice>
					<xsd:element ref="NoComputation"/>
					<xsd:element ref="GeneralComputation"/>
					<xsd:element ref="StageDischargeComputation"/>
					<xsd:element ref="SlopeDischargeComputation"/>
					<xsd:element ref="VelocityDischargeComputation"/>
					<xsd:element ref="RainfallComputation"/>
				</xsd:choice>
				<xsd:element ref="DailyValueComputation" minOccurs="0"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
</xsd:schema>
