/// <summary>Constructor</summary>
 /// <param name="xproperty">x property</param>
 /// <param name="x">x values.</param>
 /// <param name="y">y values.</param>
 public LinearInterpolationFunction(string xproperty, double[] x, double[] y)
 {
     XProperty = xproperty;
     XYPairs   = new XYPairs();
     XYPairs.X = x;
     XYPairs.Y = y;
 }
 /// <summary>Constructor</summary>
 /// <param name="xproperty">x property</param>
 /// <param name="x">x values.</param>
 /// <param name="y">y values.</param>
 public LinearInterpolationFunction(string xproperty, double[] x, double[] y)
 {
     XProperty = xproperty;
     XYPairs = new XYPairs();
     XYPairs.X = x;
     XYPairs.Y = y;
 }
Esempio n. 3
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs = model as XYPairs;
            this.xyPairsView = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent = this.xyPairs;
            (this.graph.Series[0] as Series).XFieldName = Apsim.FullPath(graph.Parent) + ".X";
            (this.graph.Series[0] as Series).YFieldName = Apsim.FullPath(graph.Parent) + ".Y";
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
            string xAxisTitle = LookForXAxisTitle();
            if (xAxisTitle != null)
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN);

            string yAxisTitle = LookForYAxisTitle();
            if (yAxisTitle != null)
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN);

            xyPairsView.Graph.FormatTitle(xyPairs.Parent.Name);
        }
Esempio n. 4
0
        /// <summary>Writes documentation for this function by adding to the list of documentation tags.</summary>
        /// <param name="tags">The list of tags to add to.</param>
        /// <param name="headingLevel">The level (e.g. H2) of the headings.</param>
        /// <param name="indent">The level of indentation 1, 2, 3 etc.</param>
        public override void Document(List <AutoDocumentation.ITag> tags, int headingLevel, int indent)
        {
            // add a heading.
            tags.Add(new AutoDocumentation.Heading(Name, headingLevel));

            // write memos.
            foreach (IModel memo in Apsim.Children(this, typeof(Memo)))
            {
                memo.Document(tags, -1, indent);
            }

            // Links aren't resolved at this point so go find xy pairs manually.
            XYPairs xypairs = Apsim.Child(this, "XYPairs") as XYPairs;

            // add graph and table.
            if (xypairs != null)
            {
                tags.Add(new AutoDocumentation.GraphAndTable(xypairs, Name, "Temperature (oC)", Name + " (deg. day)", indent));
            }
        }
Esempio n. 5
0
        /// <summary>Linint3hrlies the temporary.</summary>
        /// <param name="tmax">The tmax.</param>
        /// <param name="tmin">The tmin.</param>
        /// <param name="ttFn">The tt function.</param>
        public double Linint3hrlyTemp(double tmax, double tmin, XYPairs ttFn)
        {
            // --------------------------------------------------------------------------
            // Eight interpolations of the air temperature are
            // calculated using a three-hour correction factor.
            // For each air three-hour air temperature, a value
            // is calculated.  The eight three-hour estimates
            // are then averaged to obtain the daily value.
            // --------------------------------------------------------------------------

            // Local Variables
            double tot = 0.0;            // sum_of of 3 hr interpolations

            for (int period = 1; period <= num3hr; period++)
            {
                // get mean temperature for 3 hr period (oC)
                double tmean_3hour = temp_3hr(tmax, tmin, period);
                tot = tot + ttFn.ValueIndexed(tmean_3hour);
            }
            return(tot / (double)num3hr);
        }
Esempio n. 6
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs = model as XYPairs;
            this.xyPairsView = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
        }
 /// <summary>Values for x.</summary>
 /// <param name="XValue">The x value.</param>
 /// <returns></returns>
 public double ValueForX(double XValue)
 {
     return(XYPairs.ValueIndexed(XValue));
 }
Esempio n. 8
0
        /// <summary>Linint3hrlies the temporary.</summary>
        /// <param name="tmax">The tmax.</param>
        /// <param name="tmin">The tmin.</param>
        /// <param name="ttFn">The tt function.</param>
        /// <returns></returns>
        public double Linint3hrlyTemp(double tmax, double tmin, XYPairs ttFn)
        {
            // --------------------------------------------------------------------------
            // Eight interpolations of the air temperature are
            // calculated using a three-hour correction factor.
            // For each air three-hour air temperature, a value
            // is calculated.  The eight three-hour estimates
            // are then averaged to obtain the daily value.
            // --------------------------------------------------------------------------

            // Local Variables
            double tot = 0.0;            // sum_of of 3 hr interpolations

            for (int period = 1; period <= num3hr; period++)
            {
                // get mean temperature for 3 hr period (oC)
                double tmean_3hour = temp_3hr(tmax, tmin, period);
                tot = tot + ttFn.ValueIndexed(tmean_3hour);
            }
            return tot / (double)num3hr;
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphAndTable"/> class.
 /// </summary>
 /// <param name="xyPairs">The xy pairs.</param>
 /// <param name="title">Graph title.</param>
 /// <param name="xName">The x axis title.</param>
 /// <param name="yName">The y axis title.</param>
 /// <param name="indent">The indentation.</param>
 public GraphAndTable(XYPairs xyPairs, string title, string xName, string yName, int indent)
 {
     this.title = title;
     this.xyPairs = xyPairs;
     this.xName = xName;
     this.yName = yName;
     this.indent = indent;
 }