Skip to content
Karl Tarbet edited this page Sep 19, 2017 · 7 revisions

Contents

#Writing Equations

Besides importing different types of data you can calculate data in Pisces using a calculation Series. From the Data Menu (or context menu) select ‘Add Calculation Series’. You will then be prompted to enter a name for this series, units, and the equation.

The equations you write will reference other data in Pisces. The Series name in the Pisces tree can be used like a variable in time series equations. (There is another method to define equations using table names not described here) The name must begin with a letter, can contain numbers and the underscore (_) . If your Series name has a space you will need to wrap it in single quotes in the expressions where it is used. The table below shows examples of naming a series for use in an equation.

Name in Pisces Example use in equation Description
Series1 Series1*1.98347 Convert cfs to acre feet/day
Jck_af Jck_af Underscore ‘_’ can be used
Jck af ‘jck af’ Space separated names require quotes in expressions
Jck af: Jackson Lake acre-feet ‘jck af’ The colon ‘:’ separates the alias used in equations from the longer description

Please Don’t name your series the same as a function (see below) or one of the reserved words: true or false.

The time component is optional and simplified in the expressions. The actual time stamp, such as ‘12-25-2001 23:59.00’, is not part of the expression. Instead the DateTime parameter “t” is used. Variations such as “t-1” for previous time step are often used. Higher level operations such Read(t1,t2), or Calculate(t1,t2), or Update(t1,t2) provide actual DateTime ranges. Where: t1 and t2 represent beginning and ending dates and times.

Example 1: Compute approximate unregulated daily flow into a Reservoir

(Jck_AF[t-1] – Jck_AF[t])/1.98347 + Jck_QD

Where: • Jck_AF is Jackson lake content series of data (acre-feet) • Jck_QD is daily outflow from Jackson Lake (cfs) • The JCK_QU series contains the expression above and represents the unregulated daily inflow to Jackson Lake.

Example 3 : Convert Fahrenheit to Celsius "5/9*(jackson-32)"

In native Pisces the expressions are performed in memory using a recursive decent parser adapted for a mixture of scalar and time series data. See Herbert Schildt’s C#: The Complete Reference (Chapter 26 2002) for an example of a recursive decent parser of parser.

#List of Pisces Functions

Name Description Example usage
If performs if/else statement. If(Series,value1,value2). Series values that are >0 get value 1 else value2. Alternate form all arguments are series If(Series series, Series thenValue, Series elseValue) If( emi_zs, RectangularContractedWeir(emi_gh,3.0),GenericWeir(emi_gh,0.07175,64.49,1.742) )
TimeWeightedDailyAverage Computes a Time weightedd daily average, by interpolating midnight values and performing numerical integration Example: TimeWeightedDailyAverage(series1)
DailyMax Computes a daily maximum. The input data should have a interval smaller than daily Example: DailyMax(series1)
DailyMin Computes a daily minimum. The input data should have a interval smaller than daily Example: DailyMin(series1)
Max series Example: Max(series1,double)
Min series Example: Min(series1,double)
Abs Computes a absolute value for each data point in the series Example: Abs(series1)
SevenDayMovingAverage Computes a 7 Day moving average, by looking 3 days forward and back Example: SevenDayMovingAverage(series1)
Merge Merges two series Example: Merge(observed,estimated)
SevenDADMAX Computes the maximum value each day and then computes a seven day moving average Example: SevenDADMAX(series1)
HourlyFilter Used to condense data (5 minute for example) to hourly. The hourly filter returns all values at the top of the hour (where the minute = 0). Example: HourlyFilter(series1)
FillMissingWithZero Fills in missing daily or monthly data with zeros. Example: FillMissingWithZero(series1)
HourlyAverage Creates Hourly avearge Example: HourlyAverage(series)
InterpolateHourly Creates Hourly data by interpolating at 1 hour increment Example: InterpolateHourly(series)
MovingAverage Computes a Moving average based on the number of hours specified Example: MovingAverage(series1,hours)
WeeklyAverageSimple Computes a average by increment of 7 days. If your data is instantaneous a daily average will first be computed Example: WeeklyAverageSimple(series1)
DaysInMonth Creates a Series which contains the number of days in the month Example: DaysInMonth(series)
MonthlySummaryForPeriodOfRecord Computes a monthly average across all years. result is 12 values. Example: MonthlySummaryForPeriodOfRecord(daily)
MonthlyAverage Computes an average by month Example: MonthlyAverage(daily)
MonthlySum Computes a monthly sum Example: MonthlySum(daily)
MonthlyMax Computes a monthly Max Example: MonthlyMax(daily)
MonthlyMin Computes a monthly Min Example: MonthlyMin(daily)
EndOfMonth Returns the last value in each month. Example: EndOfMonth(daily)
HourlyResidual Computes an hourly residual based on input series and decay of each input in hours. Example: HourlyResidual(Seriesdose, decayHours)
If returns a series composed of thenvalue or elseValues Example: If(series, ifValue, elseValue)
SmoothingInterpolateOutliers Replaces data above or below a user specified maximum and minimum, by interpolating from nearest ‘good’ data. Example: SmoothingInterpolateOutliers(series,min,max)
EstimateDailyFromMonthly Estimates Daily data based on monthly and partial daily. This was designed for estimating missing diversion data. This is performed by using the time pattern from a Summary Hydrograph and scaling data to ensure the monthly volume matches. Example: EstimateDailyFromMonthly(daily_cfs,monthly_acre_feet,bool merge)
EstimateDailyFromMonthly Estimates Daily data based on monthly and partial daily. This was designed for estimating missing diversion data. This is performed by using the time pattern from a Summary Hydrograph and scaling data to ensure the monthly volume matches. Example: EstimateDailyFromMonthly(daily_cfs,monthly_acre_feet,bool merge = false,bool medianOnly=false, bool setMissingToZero=true)
SumSetMissingToZero Sums a list of Series. Missing data is replaced with a zero. Example: SumSetMissingToZero(series1,series2,...)
InterpolateWithStyle Estimates a series between pairs of date ranges based on the shape of an observed series while preserving flow balance. Example: InterpolateWithStyle(Observed Data, Data to be Overwritten, Date1A [Format: "2000-01-31"] , Date1B, Date2A, Date2B, ... )
MLRInterpolationPisces Performs a Multiple Linear Regression using different combinations of the input interpolator Series and assigns the best fit as the interpolated value so long as the input fit tolerance is met. Example: MLRInterpolation(fitTolerance = value between 0.0 & 1.0, Series-0 to be interpolated, Series-1 used for interpolation, Series-2 used for interpolation, Series-3, Series-4, ...
FileRatingTable Performs simple Rating table lookup from a file Example: FileRatingTable(series1,"table.csv")
FileLookupInterpolate2D Performs 2D lookup from a file with linear interpolation in both dimensions using two series Example: FileLookupInterpolate2D(series1, series2, csvFile)
FileLookupInterpolate2DIslandPark Performs 2D lookup from a file to determine outflow of a reservoir with two gates and forebay elevation. Example: FileLookupInterpolate2DIslandPark(forebaySeries,gate1Series, gate2Series, singlegate.csv,twogates.csv).
DailyEtAscePenmanMontieth Evapotranspiration ASCE Penman-Montieth: Tall Cd=0.38, Cn=1600; Short Cd=0.34,Cn=900 Example: DailyEtAscePenmanMontieth(mm, mn, mx, ym, wr, sr,latitude,elevation,Cd,Cn)
DailyEtKimberlyPenman Reference Evapotranspiration (in/day)(1982 Kimberly-Penman equation) Example: DailyEtKimberlyPenman( mm, mn, mx, ym, wr, sr,lat,elev)
DewPointTemperature DewPointTemperature Example: DewPointTemperature( degF, percent)
UofIStreamflowDisaggregation Disaggregates monthly data to daily cfs values. Example: UofIStreamflowDisaggregation(DailySeries,MonthlySeries,bool smooth = true,bool merge = false)
HydrometDaily Hydromet daily data Example: HydrometDaily(cbtt,pcode)
HydrometInstant Hydromet instant data (15 minute) Example: HydrometInstant(cbtt,pcode)
HydrometForecastMonthlyToDaily Converts Monthy Forecast points to a sparse daily series Example: HydrometForecastMonthlyToDaily(fc,fcm)
HydrometResidualForecast Compute Residual Forecast Example: HydrometResidualForecast(forecast,runoff,residual)
HydrometRuleCurve Compute Residual Forecast Example: HydrometResidualForecast(cbtt,pcode)
DailySnowCourseToMonthly Reads daily NRCS snowcourse data into monthly Example: DailySnowCourseToMonthly(triplet)
CipolettiWeir CipolettiWeir equation 3.367lenghth^1.5 Example: CipolettiWeir(head,length)
RectangularContractedWeir Fully Contracted Rectangular Weir (Francis equation) Q=3.33h^1.5(length-.2*h) Example: RectangularContractedWeir(head,length)
GenericWeir Generic weir equation width_factor*(head+offset+shift)^exponent Example: GenericWeir(head,offset,width_factor,exponent)
ConstantShift ConstantShift Example: ConstantShift(h)
LookupShift LookupShift from series properties Example: LookupShift(ch)
WaterYearResidual Calculates remaining runoff for every day to end of endMonth, provide inflow series and integer month Example: WaterYearResidual(inflow,endMonth)
DailyWaterYearRunningTotal Daily accumulation beginning October 1 Example: DailyWaterYearRunningTotal(incremental,cumulative)
DailyCalendarYearRunningTotal Daily accumulation beginning January 1 Example: DailyCalendarYearRunningTotal(incremental,cumulative)
DailyChange Daily Change between Midnight Values Example: DailyChange(series1)
DailyMidnight Midnight Values Example: DailyMidnight(series1)
DailyGrowingDegree Growing Degree Days Example: DailyGrowingDegree(sMax, sMin,tmax,tbase)
DailyAzimuth Sums values for each day. Example: DailySum(series1)
DailySum Sums values for each day. Example: DailySum(series1,requiredNumberOfPoints)
DailyAverage Computes a daily average. No minimum number of points required per day Example: DailyAverage(series1)
DailyAverage Computes a daily average with required number of points. Example: DailyAverage(series1,requiredNumberOfPoints)

Clone this wiki locally