Measurement Campaign
The measurement campaign toolbox can be accessed in a script via Toolbox.MeasurementCampaign. which contains commands to perform calculations on the time series available in the project, export data, load data from files, do reports and manage the time series data.
Every time a script contains commands from this toolbox a report will be generated.
Management
In this section we look at the commands available to manage the reports generated, the time series in the project and other.
Reports
Its possible to suppress the creation of a report, control the name and location where the report is created and insert comments in the report.
// Disable creating of a report. When set this is valid for the whole script.
Toolbox.MeasurementCampaign.SuppressReporting = true;
// Can take the full path to the file, or if only the name the file is placed next
// to the workbook. If not specified then takes name of workbook and date time stamp.
Toolbox.MeasurementCampaign.FlushReport("MyReport.docx");
// Takes an optional boolen second argument to indicate if MS Word should not be opened
// after completion of the procedure. true means not opening while false is the default
// and means to open Word.
Toolbox.MeasurementCampaign.FlushReport("MyReport.docx", true);
Add content to report
Add custom text or a custom table with values to the generated report. Its possible to apply the WF styles to the generated content.
// Insert a comment in the report. It will be highlighted in the report and
// generate a section visible in the navigation pane.
Toolbox.MeasurementCampaign.InsertComment("A comment");
// Insert custom text. By default will use normal style.
Toolbox.MeasurementCampaign.InsertCustomText("This is example text added to the report.");
// WF styles can be used to create headings or other.
Toolbox.MeasurementCampaign.InsertCustomText(
"This is example text added to the report.",
"WFHeading1");
// Insert a custom table using a WF style to customize the layout.
// Use \t to separate columns and \n to separate lines.
Toolbox.MeasurementCampaign.InsertCustomTable(
"Value 1\tValue 2\n1.0\t1.1\n2.0\t2.1",
"WFCentredTable");
Time Series
In order to use a time series in calculations it must first be loaded in to the script. The bellow commands show how
to load the different types of time series available. The commands make use of the unique signal name that for
loaded signals has the form: "
If instead we want to retrieve a calculated signal that was stored previously then the unique signal name
takes the form: "
// For speed series use specific function, works the same for
// StdDev, Max and Min signals.
SpeedTimeSeries wspd_mean =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
SpeedTimeSeries wspd_stdev =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~StdDev");
// For direction time series use specific function, works the same for
// StdDev, Max and Min signals.
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// For other types use the generic function specifying the type
PressureTimeSeries press =
Toolbox.MeasurementCampaign.GetTimeSeries<PressureTimeSeries>("M2~P3~Mean");
TemperatureTimeSeries temp =
Toolbox.MeasurementCampaign.GetTimeSeries<TemperatureTimeSeries>("M2~T3~Mean");
After performing a calculation, the calculated series can be stored in the workbook for later use.
// Load the time series
SpeedTimeSeries wspd_mean = Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
// Perform a calculation on the time series, speed-up by a factor of 1.1
SpeedTimeSeries speedup_series = Toolbox.MeasurementCampaign.SpeedUpSeries(
wspd_mean,
1.1);
// Save the time series on a measurement site
Scripting.MeasurementSite site = Workbook.Climate.MeasurementSites["M2"];
Toolbox.MeasurementCampaign.SaveResultsTimeSeries(
speedup_series, site,
"SPEEDUP_SERIES",
true);
Or it can be removed when no longer is needed.
// Delete series names SPEEDUP_SERIES from Measurement Site M2
Toolbox.MeasurementCampaign.DeleteResultsTimeSeries(
Workbook.Climate.MeasurementSites["M2"],
"SPEEDUP_SERIES");
Signals
The following commands allow you to obtain a signal object from a unique signal name, obtain a measurement object from a signal object, a measurement site object from a measurement object.
Its also possible to get a list of all signals available for a given measurement or for a given measurement site.
Its possible to filter the returned signals using the where function to only obtain the signals that are means. The where function is part of the Linq capabilities of C# which are available to operate on List or IEnumerable type variables.
// Get the signal object.
Scripting.Signal wspd_mean =
Toolbox.MeasurementCampaign.FindSignal("M2~N60~Mean");
// Obtain the measurement from the signal
Scripting.Measurement n60 =
Toolbox.MeasurementCampaign.FindParentMeasurementForSignal(wspd_mean);
// Obtain the measurement site from the measurement
Scripting.MeasurementSite m2 =
Toolbox.MeasurementCampaign.FindParentMeasurementSiteForMeasurement(n60);
// Get list of signals in measurement
List<Scripting.Signal> signalsInMeasurement =
Toolbox.MeasurementCampaign
.GetSignals(n60)
.ToList();
// Get list of siganls in measurement site
List<Scripting.Signal> signalInSite =
Toolbox.MeasurementCampaign
.GetSignals(m2)
.ToList();
// Its also possible to filter by signal type and obtain only
// the mean signals in the measurement site
List<Scripting.Signal> meanSignalsInSite =
Toolbox.MeasurementCampaign
.GetSignals(m2)
.Where(s => s.SignalType == SignalTypeEnum.Mean)
.ToList();
Exclusions
The following command allow you to have access to the a list of the exclusion reasons available.
Its also possible to obtain the exclusions of a measurement via the MeasurementSites available in the Workbook. See the below example for accessing the first exclusion in the first measurement of site "M2".
// Get a list of the available exclusion reasons
List<Scripting.ExclusionReason> exclusionReasons =
Toolbox.MeasurementCampaign.ExclusionReasons.ToList();
// Access the first exclusion of the first measurement in measurement site "M2"
Scripting.Exclusion firstExclusion =
Workbook.Climate.MeasurementSites["M2"].Measurements
.First().Exclusions
.First();
Distributions
One of the most important features of the measurement campaign calculations is to create, load, manage distributions in the form of frequency or turbulence intensity distributions.
The following commands show the several options available to manipulate distributions in WindFarmer scripting.
Create a distribution
This shows how a frequency and a turbulence intensity distribution can be created. Note that both an existing or a calculated series can be used to create a distribution.
SpeedTimeSeries wspd_mean =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
SpeedTimeSeries wspd_stdev =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~StdDev");
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Create a frequency distribution
Scripting.FrequencyDistribution fd =
Toolbox.MeasurementCampaign.CreateFrequencyDistribution(
wspd_mean,
wdir,
false,
"FD_NAME");
// Create a turbulence distribution
Scripting.TurbulenceIntensityDistribution ti =
Toolbox.MeasurementCampaign.CreateTurbulenceIntensityDistribution(
wspd_mean,
wspd_stdev,
wdir,
"TI_NAME");
Load a distribution
A distribution can be loaded from .tab file or a wti file format.
// Load a tab file that is placed in a folder next to the workbook.
// The workbook cannot be temporary, i.e. not saved.
Scripting.FrequencyDistribution fd =
Toolbox.MeasurementCampaign.CreateFrequencyDistributionFromTabFile(
@".\Folder\MyTabFile.tab");
// Load a wti file that is places next to the workbook.
Scripting.TurbulenceIntensityDistribution ti =
Toolbox.MeasurementCampaign.CreateTurbulenceIntensityDistributionFromWtiFile(
"MyWtiFile.wti");
Save a distribution
In order for a distribution to be available for later calculations, flow modelling or the energy calculation, it needs to be saved and activated in the workbook.
Scripting.FrequencyDistribution fd = null;
Scripting.TurbulenceIntensityDistribution ti = null;
// Re-queries a loaded or calculated frequency or turbulence intensity distribution
// get the measurement site object where the distribution will be loaded to
Scripting.MeasurementSite site = Workbook.Climate.MeasurementSites["M2"];
// Optional. Default is false. True means will create a wind climate at that height.
// Can only be one active distribution at a given height.
bool activate = true;
// Optional. Default is true. It will overwrite a distribution with the same name.
bool overwrite = true;
Toolbox.MeasurementCampaign.SaveDistribution(
site,
fd,
"MY_FREQ_DIST",
80.0,
activate,
overwrite);
// Save a turbulence distribution and activate it later
Toolbox.MeasurementCampaign.SaveDistribution(
site, ti,
"MY_TI_DIST",
80,
false);
// Set the distribution to active after having stored it.
// See task Wind Climate Setup for created wind climate.
Toolbox.MeasurementCampaign.
ToggleActivationOfDistribution<Scripting.TurbulenceIntensityDistribution>(ti);
Manage existing distributions
Access the distributions stored in the project or delete a distribution stored.
// Requires the distribution to have been loaded via the UI or in a different script.
// Unique distribution name is formed with "<measurement site name>~<distribution name>"
Scripting.FrequencyDistribution fd =
Toolbox.MeasurementCampaign
.GetDistribution<Scripting.FrequencyDistribution>("M2~MY_UI_DIST");
Scripting.TurbulenceIntensityDistribution ti =
Toolbox.MeasurementCampaign
.GetDistribution<Scripting.TurbulenceIntensityDistribution>("M2~MY_UI_TI");
// Remove a distribution from a measurement site
Toolbox.MeasurementCampaign.DeleteDistribution(fd);
Export a distribution
A distribution can be exported to file. A frequency distribution can be exported to a tab file and a turbulence intensity distribution can be exported to wti format or gha format (12 monthly tables plus a 13th overall table). The selection is made by setting the file extension to ".wti" or ".gha".
string workbookFolderPath = System.IO.Path.GetDirectoryName(Toolbox.CurrentWorkbookPath);
Scripting.FrequencyDistribution fd = null;
Scripting.TurbulenceIntensityDistribution ti = null;
// Export frequency distribution to tab file format to a file next to the workbook
Toolbox.MeasurementCampaign.ExportFrequencyDistribution(
fd,
"OutputFrequencyDistribution.tab");
// Export turbulence intenisty distribution to wti file format.
// Can also be exported to GHI format specifying the extension to be .ghi
// Export file to folder placed next to the workbook.
// If folder doesnt exist it will be created
Toolbox.MeasurementCampaign.ExportTurbulenceIntensityDistribution(
ti,
@".\OutputFile\OutputTurbulenceDistribution.wti");
Report a distribution
Report a frequency or turbulence intensity distribution to the report or a frequency distribution wind rose and histogram.
It's also possible to report a list of distributions.
Scripting.FrequencyDistribution fd = null;
Scripting.TurbulenceIntensityDistribution ti = null;
// Report the distribution
Toolbox.MeasurementCampaign.ReportDistribution(fd);
Toolbox.MeasurementCampaign.ReportDistribution(ti);
// Report wind rose and histogram
Toolbox.MeasurementCampaign.ReportWindRose(fd);
Compare Two Frequency Distributions
Compare the energy content of two frequency distributions. Requires a power curve from a turbine type in the workbook. The generated report plots the two distribution in the same graph and a wind rose comparison.
FrequencyDistribution fd1 = null;
FrequencyDistribution fd2 = null;
// Get the first power curve from the first turbine type.
TurbineType turbineType = Workbook.TurbineTypes.First();
// Note this will generate a null reference if there are no turbine types in the workbook.
IPerformanceTable powerCurve = turbineType.NormalPerformanceTables.First();
// Compare the two frequency distributions using the above power curve
FrequencyDistributionComparison comparisonResult =
Toolbox.MeasurementCampaign.CompareFrequencyDistribution(fd1, fd2, powerCurve);
// Write the Energy Production and Mean Wind Speed from the result object to the log
Toolbox.Log(string.Format(
"FD1 Energy Production {0} GWh/yr",
comparisonResult.FdOneIndicitiveEnergyProduction));
Toolbox.Log(string.Format(
"FD2 Energy Production {0} GWh/yr",
comparisonResult.FdTwoIndicitiveEnergyProduction));
Toolbox.Log(string.Format(
"FD1 Mean WindSpeed {0} m/s ",
comparisonResult.FdOneMeanWindSpeed));
Toolbox.Log(string.Format(
"FD2 Mean WindSpeed {0} m/s ",
comparisonResult.FdTwoMeanWindSpeed));
Calculations
Time Series
In this section, we look at calculations that take time series as input or produce time series as outputs.
Correlation
Perform a correlation between speed and direction time series. A low speed filter can be specified for each of the series. Also, if fitting through the origin and the PCA (default) and Least Squares methods of fitting are available.
SpeedTimeSeries referenceWspd =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
DirectionTimeSeries referenceDir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
SpeedTimeSeries siteWspd =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean");
DirectionTimeSeries siteDir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd46~Mean");
CorrelationResult correlationResult =
Toolbox.MeasurementCampaign.Correlate(
referenceWspd,
referenceDir,
siteWspd,
siteDir,
3.0,
3.0,
false,
12,
CorrelationFittingMethod.PCA);
// The CorrelationResult object returned contains a SpeedTrend and a
// DirectionTrend that can be used in other calculations.
// Setting the name of the objects will identidy these in the report
correlationResult.SpeedTrend.Name = "MySpeedTrend";
correlationResult.DirectionTrend.Name = "MyDirectionTrend";
Splice Series
Splice will create a new time series and for each time stamp will take the value from the high priority series when its not available will take from the low priority one. The calculation can be applied to any type of series: speed, direction, temperature, etc.
SpeedTimeSeries lowPrioritySpeed =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N48~Mean");
SpeedTimeSeries highPrioritySpeed =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
// Splice series can also take direction, temperature or other type of series.
SpeedTimeSeries splicedSeries =
Toolbox.MeasurementCampaign.SpliceSeries(
lowPrioritySpeed,
highPrioritySpeed);
Directional Splice
The directional splice allows you to remove the mast shadow of parallel measurements. It will require the boom orientation for each of the speed measurement and the shadow exclusion width both in degrees.
SpeedTimeSeries wspd_n60 =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
SpeedTimeSeries wspd_s60 =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~S60~Mean");
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
SpeedTimeSeries splicedSeries =
Toolbox.MeasurementCampaign.DirectionalSplice(
wspd_n60,
322,
30,
wspd_s60,
199,
30,
wdir,
3.0);
Cut Series
The cut series command allows you to cut a series between two dates.
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Extract the year of 2010
DirectionTimeSeries wdir2010 =
Toolbox.MeasurementCampaign.CutSeries(
wdir,
new DateTime(2010, 1, 1, 0, 0, 0),
new DateTime(2010, 12, 31, 23, 50, 0));
Resample Series
Any type series can be resampled. The resampled period is specified using enum PeriodType and the available options are: Seconds, Minutes, Hours, Days, Months, Year along with a positive integer.
It's also possible to only resample a record if it meets a certain minimum coverage. A coverage series is calculated and can be exported.
SpeedTimeSeries wspd =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
// Resample to hourly data
SpeedTimeSeries wspd_hourly =
Toolbox.MeasurementCampaign.ResampleSeries(
wspd,
PeriodType.Hours,
1);
// Resample to daily
SpeedTimeSeries wspd_daily =
Toolbox.MeasurementCampaign.ResampleSeries(
wspd,
PeriodType.Days,
1);
// Resample with coverage, only resample records when coverage is equal or above 90%
CoverageTimeSeries wspd_coverage = null;
SpeedTimeSeries wspd_hourly2 =
Toolbox.MeasurementCampaign.ResampleSeries(wspd,
PeriodType.Hours,
1,
90.0,
out wspd_coverage);
Match Series
This command takes two input series of the same type or distinct types and produces a new series of the same type for each of the inputs where there are concurrent records between the two.
SpeedTimeSeries wspd_n60 =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
SpeedTimeSeries wspd_n37 =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean");
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Concurrent time series between n60 and n37
SpeedTimeSeries n60MatchedN37 = null;
SpeedTimeSeries n37MatchedN60 = null;
Toolbox.MeasurementCampaign.MatchSeries<SpeedTimeSeries, SpeedTimeSeries>(
wspd_n60,
wspd_n37,
out n60MatchedN37,
out n37MatchedN60);
// Concurrent time series between n60 and wdir
SpeedTimeSeries n60MatchedWdir = null;
DirectionTimeSeries wdirMatchedN60 = null;
Toolbox.MeasurementCampaign.MatchSeries<SpeedTimeSeries, DirectionTimeSeries>(
wspd_n60,
wdir,
out n60MatchedWdir,
out wdirMatchedN60);
Match Multiple Series
This command allows to match one time series with multiple ones. It will match the first time series in the list with all the subsequent ones.
// Create a list of time series to match
List<TimeSeries> seriesToMatch = new List<TimeSeries>()
{
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean"),
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean"),
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean")
};
// The match multiple series command to match the first time series in the list
// M2~N60~Mean with the subsequent ones.
// Returns the first time series matched will all other.
TimeSeries matchedSeries = Toolbox.MeasurementCampaign.MatchMultipleSeries(seriesToMatch);
Speedup Series
Speed up series operates on speed time series and allows you to apply an overall speed up value to apply to the whole series or use a speed trend obtained from a correlation or load from file Calculation Load Speed Ups.
SpeedTrend speedUps = null;
SpeedTimeSeries wspd_n60 =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Apply overall speedup
SpeedTimeSeries wspd_speedup =
Toolbox.MeasurementCampaign.SpeedUpSeries(wspd_n60, 1.1);
// Assuming a speed trend has been loaded
SpeedTimeSeries wspd_speedup2 =
Toolbox.MeasurementCampaign.SpeedUpSeries(wspd_n60, wdir, speedUps);
Load Speedups
A speedups file is tab separated text file with 13 lines which can contain 1 or 2 columns. The first columns contain the slope and the second the offset which if not included will be considered 0. Each line corresponds to a direction sector starting in 0 degrees in 30 degree intervals. The last row is for the overall speed up.
A speedups file can be manually generated or exported from a SpeedTrend object calculated from the correlate command Correlations.
string workbookFolderPath = System.IO.Path.GetDirectoryName(Toolbox.CurrentWorkbookPath);
string speedUpsFileName = "speedups.txt";
string filePath = System.IO.Path.Combine(workbookFolderPath, speedUpsFileName);
SpeedTrend speedUps = Toolbox.MeasurementCampaign.LoadSpeedUps(filePath);
Apply Direction Trend to Direction Series
A DirectionTrend object obtained from a correlation command Correlations can be applied to a direction time series.
It's also possible to apply a list of relative shifts. The width of the sector to which their applied is guided by the number of shifts to apply.
DirectionTrend directionTrend = null;
// Prerequisite: direction trend object obtained from a correlate command.
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
DirectionTimeSeries wdir_mod =
Toolbox.MeasurementCampaign.ApplyDirectionTrendToDirectionTimeSeries(
wdir,
directionTrend);
// It's also possible to apply a list of relative shifts.
// Example with 4 shifts means this will be applied in to each 90 degree sector.
List<double> relativeShifts = new List<double>() { -25.0, 12.2, 16.2, 5.4 };
DirectionTimeSeries wdir_mod2 =
Toolbox.MeasurementCampaign.ApplyDirectionTrendToDirectionTimeSeries(
wdir,
relativeShifts,
"DirMod");
Export Series
A series or a list of series can be exported to a file or a string. A TimeSeriesExportSettings object can be created when nonstandard settings for the export are needed. For the date time format consider the following:
* %Y : Year, full four digitd (2001) * %y : Year, last two digits (00-99)
* %m : Month as a decimal number (01-12)
* %d: Day of the month, zero-padded (01-31)
* %H : Hour in 24h format (00-23)
* %M : Minute (00-59)
For a complete reference, visit "http://www.cplusplus.com/reference/ctime/strftime/"
SpeedTimeSeries wspd_mean = null;
SpeedTimeSeries wspd_stdev = null;
DirectionTimeSeries wdir = null;
// Create a list of TimeSeries object types
// and add the series to export
List<TimeSeries> timeSeriesToExport =
new List<TimeSeries>() { wspd_mean, wspd_stdev, wdir };
// Export to file using default output settings.
// Place output file in folder next to the workbook
Toolbox.MeasurementCampaign.ExportTimeSeriesToFile(
timeSeriesToExport,
@".\Folder\output_series.tsv");
// Create a TimeSeriesExportSettings object if non default settings are needed.
string dateTimeFormat = "%Y.%m.%d %H:%M";
double paddingValue = -9999.0;
sbyte delimiter = (sbyte)'\t';
int decimalPlaces = 5;
TimeSeriesExportSettings exportSettings =
new TimeSeriesExportSettings(
dateTimeFormat,
paddingValue,
delimiter,
decimalPlaces);
// Place output file next to the workbook
Toolbox.MeasurementCampaign.ExportTimeSeriesToFile(
timeSeriesToExport,
"output_series.tsv",
exportSettings);
// Export to string instead
string exportedSeries =
Toolbox.MeasurementCampaign.ExportTimeSeriesToString(
timeSeriesToExport,
exportSettings);
Statistics
It's possible to generate statistics for a list of time series and then export them to file.
SpeedTimeSeries wspd_mean = null;
SpeedTimeSeries wspd_stdev = null;
DirectionTimeSeries wdir = null;
// Create a list of TimeSeries object types and
// add the series to generate the statistics for.
List<TimeSeries> timeSeriesForStatistics =
new List<TimeSeries>() { wspd_mean, wspd_stdev, wdir };
List<GeneratedStatistics> stats =
Toolbox.MeasurementCampaign.GenerateStatistics(timeSeriesForStatistics);
// Export stats to text file in folder next to the workbook
Toolbox.MeasurementCampaign.ExportStatistics(
stats,
@".\Folder\statistics.txt");
Distributions
In this section, we look at calculations that operate on distributions.
Speedup Frequency Distribution
Apply an overall value to the frequency distribution or apply a SpeedTrend object that can be obtained from a correlation Correlations or from a file 'Calculation Load Speed Ups'
CorrelationResult correlationResult = null;
Scripting.FrequencyDistribution fd = null;
// Apply an overall speed up value to the frequency distribution.
Scripting.FrequencyDistribution newFrequency =
Toolbox.MeasurementCampaign.SpeedUpFrequencyDistribution(fd, 1.06);
// Apply a speed trend obtained from a correlation to a frequency distribution
Scripting.FrequencyDistribution newFrequency1 =
Toolbox.MeasurementCampaign.SpeedUpFrequencyDistribution(
fd,
correlationResult.SpeedTrend);
Scale Frequency Distribution to Target Speed
Scripting.FrequencyDistribution fd = null;
double targetWindSpeed = 7.89;
Scripting.FrequencyDistribution newFrequency =
Toolbox.MeasurementCampaign.ScaleFrequencyDistributionToTargetSpeed(
fd,
targetWindSpeed);
Apply DirectionTrend to Frequency Distribution
Apply a DirectionTrend object obtained from a correlation Correlations. It's also possible to apply a list of relative shifts, similar to ['Apply Direction Trend to Direction Series'](#Apply Direction Trend to Direction Series) )
CorrelationResult correlationResult = null;
Scripting.FrequencyDistribution fd = null;
// Apply a DirectionTrend to a frequency distribution.
Scripting.FrequencyDistribution newFrequency =
Toolbox.MeasurementCampaign.ApplyDirectionTrendToFrequencyDistribution(
fd,
correlationResult.DirectionTrend);
// Its also possible to apply a list of relative shifts.
// Example with 4 shifts means this will be applied in to each 90 degree sector.
List<double> relativeShifts =
new List<double>() { -25.0, 12.2, 16.2, 5.4 };
Scripting.FrequencyDistribution newFrequency1 =
Toolbox.MeasurementCampaign.ApplyDirectionTrendToFrequencyDistribution(
fd,
relativeShifts);
Calculate Uncertainty
Scripting.FrequencyDistribution fd = null;
CorrelationResult correlationResult = null;
Toolbox.MeasurementCampaign.CalculateUncertainty(
fd,
correlationResult.SpeedTrend);
Shear
In this section, we look at the commands available to calculate a shear model, store it in the workbook for later re-usage and use it to extrapolate a wind speed series to a given hub height.
Calculate Shear
WindFarmer: Analyst supports three types of shear model:
Shear Model | Description |
---|---|
UserDefinedShearModel | Allows the user to set a power law or log law profile using a single alpha or roughness value respectively. |
AnnualShearModel | shear model calculated using the annual means of the specified time series. |
TimeSeriesShearModel | shear model that constructs a time series of alpha values and a look up table to fill gaps. Supports the DNV shear method of rescalling the extrapolated time series to the annual mean obtained from the annual shear model. |
User Defined Shear Model
// User defined power law profile with an alpha of 0.145
UserDefinedShearModel powerProfile =
new UserDefinedShearModel(
ShearFittingType.Power,
0.145);
// User defined log law profile with a roughness length of 1.1 m
UserDefinedShearModel logProfile =
new UserDefinedShearModel(
ShearFittingType.Log,
1.1);
Annual Shear Model
// Speeds by Height
List<SpeedTimeSeries> speedsByHeight = new List<SpeedTimeSeries>()
{
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N48~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean")}
};
// Specify the settings
double annualMinimumCoverageForMonthlyResamplingPercentage = 0.0;
double annualMinimumCoverageForMommUsePercentage = 80.0;
ShearFittingType annualFittingType = ShearFittingType.Power;
// Shear settings for getting the annual shear
AnnualShearSettings annualSettings = new AnnualShearSettings(
annualMinimumCoverageForMonthlyResamplingPercentage,
annualMinimumCoverageForMommUsePercentage,
annualFittingType);
// Calculate the annual shear model from the above speeds
// with a 2m displacement height and the specified settings.
AnnualShearModel annualShearModel =
Toolbox.MeasurementCampaign.CalculateAnnualShear(
speedsByHeight,
2.0,
annualSettings);
// Calculate the same shear model but perform a check
// of what would be the result of extrapolating a specified series.
double extrapolationHeight = 80.0;
SpeedTimeSeries speedForExtrapolationCheck =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
AnnualShearModel annualShearModelWithCheck =
Toolbox.MeasurementCampaign.CalculateAnnualShear(
speedsByHeight,
extrapolationHeight,
speedForExtrapolationCheck,
2.0, annualSettings);
Time Series Shear Model
Generate a time series shear model using a list of input speed series with the corresponding heights, a direction time series and the several settings available.
The low wind speed filter is applied to the top sensor. Use the cap values to set the maximum and minimum alpha exponent.
string workbookFolderPath = System.IO.Path.GetDirectoryName(Toolbox.CurrentWorkbookPath);
// Reference direction
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Speeds by Height
List<SpeedTimeSeries> speedsByHeight = new List<SpeedTimeSeries>()
{
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N48~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean")}
};
// Specify the settings
double lowSpeedCutOff = 3.0;
double minimumCapValue = -1.0;
double maximumCapValue = 1.0;
int numberOfDirectionSectors = 12;
ExtrapolationBinningRule defaultExtrapolationBinningRule =
ExtrapolationBinningRule.HourAndMonth;
double annualMinimumCoverageForMonthlyResamplingPercentage = 0.0;
double annualMinimumCoverageForMommUsePercentage = 80.0;
ShearFittingType annualFittingType = ShearFittingType.Power;
bool applyAnnualShearCorrectionInExtrapolation = false;
// Shear settings
TimeSeriesShearSettings settings = new TimeSeriesShearSettings(
lowSpeedCutOff,
minimumCapValue,
maximumCapValue,
numberOfDirectionSectors,
defaultExtrapolationBinningRule,
annualMinimumCoverageForMonthlyResamplingPercentage,
annualMinimumCoverageForMommUsePercentage,
annualFittingType,
applyAnnualShearCorrectionInExtrapolation);
// Calculate shear models using settings above
TimeSeriesShearModel timeSeriesShearModel =
Toolbox.MeasurementCampaign.CalculateTimeSeriesShear(
speedsByHeight,
wdir,
2.0,
settings);
Calculate the same shear model but using the DNV method with the annual shear correction with the following instructions and perform a check of the extrapolation result using a specified series.
// Reference direction
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Speeds by Height
List<SpeedTimeSeries> speedsByHeight = new List<SpeedTimeSeries>()
{
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N37~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N48~Mean")},
{Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean")}
};
// Specify the settings
double lowSpeedCutOff = 3.0;
double minimumCapValue = -1.0;
double maximumCapValue = 1.0;
int numberOfDirectionSectors = 12;
ExtrapolationBinningRule defaultExtrapolationBinningRule
= ExtrapolationBinningRule.HourAndMonth;
double annualMinimumCoverageForMonthlyResamplingPercentage = 0.0;
double annualMinimumCoverageForMommUsePercentage = 80.0;
ShearFittingType annualFittingType = ShearFittingType.Power;
bool applyAnnualShearCorrectionInExtrapolation = true;
// Shear settings
TimeSeriesShearSettings settings = new TimeSeriesShearSettings(
lowSpeedCutOff,
minimumCapValue,
maximumCapValue,
numberOfDirectionSectors,
defaultExtrapolationBinningRule,
annualMinimumCoverageForMonthlyResamplingPercentage,
annualMinimumCoverageForMommUsePercentage,
annualFittingType,
applyAnnualShearCorrectionInExtrapolation);
// Specify the values to the extrapolation check
double extrapolationHeight = 80.0;
SpeedTimeSeries speedForExtrapolationCheck =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
// Calculate shear models using settings above
TimeSeriesShearModel timeSeriesShearModel =
Toolbox.MeasurementCampaign.CalculateTimeSeriesShear(
speedsByHeight,
wdir,
2.0,
extrapolationHeight,
speedForExtrapolationCheck,
settings);
Store and Access Shear Model
After being calculated a shear model can be stored at a measurement site for later usage. Also, it can be calculated in the UI and accessed in scripting in order to be available for calculations.
Scripting.ShearModelBase shearModel = null;
// Store the previously calculated shear model in measurement site M2.
Toolbox.MeasurementCampaign.SaveShearModel(
shearModel,
Workbook.Climate.MeasurementSites["M2"]);
// A shear model can also be calculated in UI and then used in scripting.
// Get the shear model stored at measurement site M3.
Scripting.ShearModelBase storedShearModel =
Workbook.Climate.MeasurementSites["M3"].ShearModel;
Report Shear
Create a report for a calculated shear model or one that has been stored on a mast from a different script or calculated through the UI.
TimeSeriesShearModel timeSeriesShearModel = null;
// Report a shear model that has previously been calculated
Toolbox.MeasurementCampaign.ReportShear(timeSeriesShearModel);
// Or report a shear model that is stored on mast M2, e.g. was calculated in the UI
Toolbox.MeasurementCampaign.ReportShear(
Workbook.Climate.MeasurementSites["M2"].ShearModel);
Extrapolate Wind Speed to Hub Height
Any of the above shear models can be used to extrapolate a wind speed time series to target height.
Using a user defined shear model:
// Set up a power law profile with alpha value of 0.145
UserDefinedShearModel shearModel =
new UserDefinedShearModel(
ShearFittingType.Power,
0.145);
// Use the top wind speed for extrapolation
SpeedTimeSeries wspdToExtrapolate =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
double hubHeight = 80.0;
double displacementHeight = 0.0;
SpeedTimeSeries hubHeightSpeed =
Toolbox.MeasurementCampaign.ExtrapolateWindSpeedTimeSeriesToHubHeight(
shearModel,
wspdToExtrapolate,
displacementHeight,
hubHeight);
Using an annual shear model:
// Obtain the previously stored shear model at M2 that we know was calculated
// with the annual shear model.
AnnualShearModel shearModel = (AnnualShearModel)Workbook.Climate.MeasurementSites["M2"].ShearModel;
// Use the top wind speed for extrapolation
SpeedTimeSeries wspdToExtrapolate =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
double hubHeight = 80.0;
double displacementHeight = 0.0;
SpeedTimeSeries hubHeightSpeed =
Toolbox.MeasurementCampaign.ExtrapolateWindSpeedTimeSeriesToHubHeight(
shearModel,
wspdToExtrapolate,
displacementHeight,
hubHeight);
Using a time series shear model calculated previously to extrapolate a wind speed time series to hub height:
Scripting.TimeSeriesShearModel shearModel = null;
// Reference direction
DirectionTimeSeries wdir =
Toolbox.MeasurementCampaign.GetDirectionTimeSeries("M2~wd57~Mean");
// Use the top wind speed for extrapolation
SpeedTimeSeries wspdToExtrapolate =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
double hubHeight = 80.0;
double displacementHeight = 0.0;
SpeedTimeSeries hubHeightSpeed =
Toolbox.MeasurementCampaign.ExtrapolateWindSpeedTimeSeriesToHubHeight(
shearModel,
wspdToExtrapolate,
wdir,
ExtrapolationBinningRule.HourAndMonth,
displacementHeight,
hubHeight);
Long Term Analysis
In this section, we look at how to calculate a long term adjustment factor.
Analyse Long Term
Calculate the long term adjust and apply it to a series or a frequency distribution.
Scripting.FrequencyDistribution fd = null;
// The primary measurement for the site we're analysing
SpeedTimeSeries siteWspd =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60~Mean");
// The reference time series, a long term station or reanalysis data like MERRA or ERA
SpeedTimeSeries referenceWspd =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("Kohala Airport~WS15~Mean");
// Ideally, a time series at the primary measurement with some reconstruction.
// Some of the gaps in siteWspd closed.
SpeedTimeSeries siteWspdForLTMWS =
Toolbox.MeasurementCampaign.GetSpeedTimeSeries("M2~N60Spliced~Mean");
//Whether resampling should be monthly rather than days
bool isMonthly = false;
// Settings for long term adjustment factor
// resample to daily or monthly, can also be n-daily or n-monthly
int resamplePeriod = 1;
// 90% coverage for record to be used for correlation
double minimumCoverageForCorrelation = 90;
// Correlation force through origin
bool forceThroughOrigin = false;
// Minimum coverage ratio for usage in splice series
double minimumCoverageRatioForSpliceSeries = 0.80;
LongTermAnalysisSettings settings = new LongTermAnalysisSettings(
isMonthly,
resamplePeriod,
minimumCoverageForCorrelation,
forceThroughOrigin,
minimumCoverageRatioForSpliceSeries);
Scripting.TimeSeriesLongTermAdjustment longTermAdjustment =
Toolbox.MeasurementCampaign.AnalyseLongTermAdjustment(
siteWspd,
referenceWspd,
siteWspdForLTMWS,
settings);
// The long term adjustment can then be used to speed up
// a series or a frequency distribution
SpeedTimeSeries wspd =
Toolbox.MeasurementCampaign.SpeedUpSeries(
siteWspd,
longTermAdjustment.AdjustmentFactor);
Scripting.FrequencyDistribution longTermFreqDist =
Toolbox.MeasurementCampaign.SpeedUpFrequencyDistribution(
fd,
longTermAdjustment.AdjustmentFactor);
Save Long Term Adjustment
Similar to the saving a time series or shear model to a measurement site. Save a long term adjustment to a site.
SiteLongTermAdjustment longTermAdjustment = new SiteLongTermAdjustment(1.012);
// Create a user defined long term adjustment and save it to a measurement site
Toolbox.MeasurementCampaign.SaveLongTermAdjustment(
longTermAdjustment,
Workbook.Climate.MeasurementSites["M2"]);