Importing Tracker Positions
This mini-tutorial will show you how to import tracker positions from a file and add them to a site layout.
It can be used in conjunction with the Using custom tracker rotations mini-tutorial that uses custom rotations (that you provide) for these imported trackers - which are then used in the energy calculation rather than the automatically calculations rotation values.
Requirements
In order to use this functionality you need:
- the location data for each of the trackers in your site layout (see below for details)
- a PAN file for the module specification to be used
- an OND file for the inverter specification to be used
- to define a tracker template and a transformer specification
Tip
Please get in touch (send an email to solarfarmer@dnv.com) if you need assistance as this can be quite complex, especially if you're not familiar with C# scripting.
1. Add the TrackerShared library to your workbook
Various functions used in the sample scripts below use helper functions that are provided in the TrackerShared C# user library. This is a file supplied in the SolarFarmer installation folder.
You'll need to add this user library to your workbook.
To do this:
- Open the Scripting Editor and click on the 'Import Scripts from Files' button:
- Find the folder you installed SolarFarmer and select the file
"C:\Program Files\DNV\SolarFarmer
version number
\Scripts\Trackers\TrackerShared.cslib"
- The 'TrackerShared' User Library script should be loaded into the workbook and appear on the left-hand side. You don't need to look at the contents (but it is recommended if you want to learn!).
2. Read tracker information from a file
The example assumes the tracker information (their geographical locations) comes in a CSV file with the following 7 column headers:
Name, X (north), Y (north), Z (north), X (south), Y (south), Z (south)
followed by one row for each tracker.
It is important that the X and Y coordinates of the trackers are in metres and are in the same projection (e.g. UTM Zone 30) as the projection in your workbook. Note that the Z coordinate corresponds to the trackers height, not to the ground level.
Create a new script (default type) and use the supplied UserLibs.TrackerShared.IO.ReadTrackerCoordinates()
function to read the file:
// Read the tracker coordinates from the csv file
List<TrackerInfo> trackerInfos = UserLibs.TrackerShared.Utils.ReadTrackerCoordinates(csvFilePath);
This gives you a list of TrackerInfo objects, one for each tracker.
Note
If your input file is in a different format to the example you will need to copy the ReadTrackerCoordinates()
function code, paste it to your own script and customise it for your specific file format. Make sure that the
IDs given to the TrackerInfo objects start from 0 and increment by 1 for each subsequent tracker.
3. Create an .xyz terrain file and import it
If you have specific tracker locations (including the height) you may not have specific terrain files to go with them. They probably won't align properly with the default SRTM terrain.
Instead you can generate an .xyz file (a file containing a list of x, y, z positions that SolarFarmer can read in and generate terrain from). The utility function Toolbox.Export.WriteXyzHeightFileFromTrackerInfos() is provided for you to do this. The function Toolbox.Export.ImportElevationGrid() can then be used to import it into the workbook.
const string xyzHeightFilePath = @"C:\Data\TerrainFromTrackers.xyz";
const double trackerHeightFromGround = 2.0;
const double marginAroundTrackerExtentsInMetres = 50;
// Create an .xyz file from the tracker coordinates (north and south positions)
Toolbox.Export.WriteXyzHeightFileFromTrackerInfos(xyzHeightFilePath, trackerInfos, trackerHeightFromGround, marginAroundTrackerExtentsInMetres);
// Import this .xyz terrain file into the workbook
Toolbox.ImportElevationGrid(xyzHeightFilePath, Workbook.Domain.Geography.WorkbookProjection);
4. Create and populate a new layout region
Important
Before being able to add new trackers, inverters and modules to your site layout you will need to define their specifications in your SolarFarmer workbook. Do this now.
- If not already done, set the site's location (and map projection) in the workbook for the site
- Import a PAN file
- Import an OND file
- Define a tracker template that is the same size and dimensions as the one in your input file
- Define a transformer specification
The following code snippet selects the module, inverter, tracker template and transformer specifications to use in the layout region, then fills it with the trackers, adds a transformer and assigns inverters and strings.
// Create a new layout region and use generic layout to fill it.
SiteLayout siteLayout = Workbook.Domain.VisibleSiteLayout;
ModuleSpecification moduleSpecification = Workbook.ComponentLibrary.ModuleSpecifications.First();
InverterSpecification inverterSpecification = Workbook.ComponentLibrary.InverterSpecifications.First();
TrackerSystemSpecification trackerSystemSpecification = Workbook.ComponentLibrary.TrackerSystemSpecifications.First();
TrackerTemplateSpecification trackerTemplateSpecification = Workbook.ComponentLibrary.TrackerTemplateSpecifications.First(t => t.TrackerSystemSpecification == trackerSystemSpecification);
TransformerSpecification transformerSpecification = Workbook.ComponentLibrary.TransformerSpecifications.First();
const int stringLength = 29;
const double dcAcRatio = 1.2;
const double Uc = 31.0; // (constant heat transfer)
const double Uv = 1.6; // (convective heat transfer)
UserLibs.TrackerShared.Utils.CreateAndFillLayoutRegion(
trackerInfos,
siteLayout,
stringLength,
dcAcRatio,
Uc,
Uv,
moduleSpecification,
inverterSpecification,
trackerTemplateSpecification,
transformerSpecification);
At this point, when you run the script you should see a layout region filled with the trackers from your input file. Each tracker should be placed on a row, inverters should be added and strings should be placed on the trackers. View the site in 3D to see how it looks.
A few useful scripting classes and functions
It's worth bringing to your attention some useful scripting classes and functions that are used in the scripts above:
Class/Function | Description |
---|---|
TrackerInfo | Encapsulates information about an individual tracker taken from the input file (name, ID, north and south locations). |
TrackerGroup | Represents a group of trackers that share a common X value (typically a north-south row). |
Point3D |
Represents a 3D Point (X, Y and Z coordinates) |
UserLibs.TrackerShared.Utils.CreateAndFillLayoutRegion() |
Creates and fills a layout region with your trackers, adding inverters and strings. |
Toolbox.TrackerImport.GetMinMaxValuesFromTrackers() | Utility function for getting the min and max X,Y values from all your trackers |
Toolbox.TrackerImport.GenerateTrackerGroupsFromTrackerInfos() | Utility function for grouping your trackers into north/south rows |
Toolbox.Export.WriteXyzHeightFileFromTrackerInfos() | Writes an XYZ height terrain file from your tracker locations |
Toolbox.Export.ImportElevationGrid() | Imports an elevation grid from an XYZ height terrain file |
Using custom tracker rotations
If you have custom tracker rotations to go with your tracker positions, then follow the Using custom tracker rotations mini-tutorial for instructions on how to import and use these.