Skip to content
Snippets Groups Projects
Commit 6da733b7 authored by Debolskiy Andrey's avatar Debolskiy Andrey :bicyclist_tone5:
Browse files

Dummy tested files added. data from external files casted to prmwind class...

Dummy tested files added. data from external files casted to prmwind  class (didn't wrote casting it back yet). Graph algorithm reworked to take into account dummy stations i.e. "poles" for future compability with linelayer data.
parent dd2e75c1
No related branches found
No related tags found
No related merge requests found
Showing
with 274 additions and 42 deletions
No preview for this file type
File added
File added
File added
File added
File added
<MapWinGIS OcxVersion="4.8" FileType="LayerFile" FileVersion="0" Description="">
<Layer LayerType="Shapefile" LayerName="powerstations" LayerVisible="1" LayerKey="" Filename="">
<ShapefileClass>
<DefaultDrawingOptions FillColor="4286521" LineColor="9868950" />
<ShapefileCategoriesClass ClassificationField="3" FieldType="0">
<ShapefileCategoryClass Name="First" Expression="[Name] = &quot;First&quot;" Value="First">
<ShapeDrawingOptionsClass LineColor="9868950" />
</ShapefileCategoryClass>
<ShapefileCategoryClass Name="Joint" Expression="[Name] = &quot;Joint&quot;" Value="Joint">
<ShapeDrawingOptionsClass FillColor="53759" LineColor="9868950" />
</ShapefileCategoryClass>
<ShapefileCategoryClass Name="lePole" Expression="[Name] = &quot;lePole&quot;" Value="lePole">
<ShapeDrawingOptionsClass FillColor="9498256" LineColor="9868950" />
</ShapefileCategoryClass>
<ShapefileCategoryClass Name="Nowhere" Expression="[Name] = &quot;Nowhere&quot;" Value="Nowhere">
<ShapeDrawingOptionsClass FillColor="15887447" LineColor="9868950" />
</ShapefileCategoryClass>
<ShapefileCategoryClass Name="Second" Expression="[Name] = &quot;Second&quot;" Value="Second">
<ShapeDrawingOptionsClass FillColor="14822282" LineColor="9868950" />
</ShapefileCategoryClass>
</ShapefileCategoriesClass>
<LabelsClass Alignment="5" Generated="0" AvoidCollisions="0" Positioning="0" TextRenderingHint="5" />
<ChartsClass ValuesFontName="" />
</ShapefileClass>
</Layer>
</MapWinGIS>
File added
MES_Wind/MES_test_new/u_test.bmp

7.82 KiB

11166.74500000000100
0.00000000000000
0.00000000000000
-11166.74500000000100
3608169.24349999990000
6065519.13949999960000
[tkImageCom]
ImageFile C:\gitlab_wind\MES_Wind\MES_test_new\u_test.bmp
<ColoringScheme SchemeType="Grid" GridName="u_test" GroupName="Data Layers">
<GridColoringScheme AmbientIntensity="0,7" Key="" LightSourceAzimuth="90" LightSourceElevation="45" LightSourceIntensity="0,7" NoDataColor="-16777216" ImageLayerFillTransparency="1" ImageUpsamplingMethod="None" ImageDownsamplingMethod="None">
<Break Caption="" LowValue="-16,646" HighValue="11,677" LowColor="-9851936" HighColor="-6100240" ColoringType="0" GradientModel="1" />
<Break Caption="" LowValue="11,677" HighValue="40" LowColor="-6100240" HighColor="-1" ColoringType="0" GradientModel="1" />
</GridColoringScheme>
</ColoringScheme>
\ No newline at end of file
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",3857]]
\ No newline at end of file
......@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MES_Wind
namespace MES_Wind_prm
{
public class PRM_index
{
......@@ -59,17 +60,27 @@ namespace MES_Wind
{
public double width;
public double height;
public PRM_cell_size(double wdh, double hgh)
{
this.width = wdh;
this.height = hgh;
}
}
class PRM_Line
public class PRM_Line
{
public int identifier { get; private set; }
public int identifier { get; set; }
public int year;
public double height;
public int power;
public List<PRM_coordinate> coords { get; private set; }
public List<PRM_coordinate> coords { get; set; }
public int pointFromID;
public int pointToID;
public bool isbroken;
public bool ison;
public PRM_Line(List<PRM_coordinate> coord, int id, int yer, double h, int pw, bool isbrkn)
public PRM_Line(List<PRM_coordinate> coord, int id, int yer, double h, int pw, bool isbrkn, bool ison, int toID, int fromID)
{
this.coords = coord;
this.identifier = id;
......@@ -77,15 +88,33 @@ namespace MES_Wind
this.height = h;
this.power = pw;
this.isbroken = isbrkn;
this.ison = ison;
this.pointFromID = fromID;
this.pointToID = toID;
}
public PRM_Line() : base() { }
}
public class PRM_Station
{
int identifier;
public int identifier;
public PRM_coordinate coords;
string name;
int power;
public string name;
public int power;
public string type;
public bool issource;
public bool ison;
public List<PRM_Line> linelist;
public PRM_Station(PRM_coordinate crds, int id,string stname, int stpower, string sttype, bool issource, bool ison)
{
this.coords = crds;
this.identifier = id;
this.name = stname;
this.power = stpower;
this.type = sttype;
this.issource = issource;
this.ison = ison;
}
public PRM_Station() : base() { }
}
......@@ -97,28 +126,132 @@ namespace MES_Wind
PRMFunctionClimate10 = 3,
PRMFunctionClimate15 = 4
}
class PRM_wind
public class PRM_wind
{
//prognistic raster info
List<List<PRM_raster_cell_prognostic>> prognostic_cells;
PRM_cell_size prognostic_cellsize;
double[] prognostic_AffineCoefficients;
public List<List<PRM_raster_cell_prognostic>> prognostic_cells;
public PRM_cell_size prognostic_cellsize;
public double[] prognostic_AffineCoefficients;
//climate raster info
List<List<PRM_raster_cell_climate>> climate_cells;
PRM_cell_size climate_cellsize;
double[] climate_AffineCoefficients;
public List<List<PRM_raster_cell_climate>> climate_cells;
public PRM_cell_size climate_cellsize;
public double[] climate_AffineCoefficients;
//lines collection
List<PRM_Line> powerlines;
public List<PRM_Line> powerlines;
//station collection
public List<PRM_Station> powerstations;
//broken stations and lines
public List<PRM_Station> disabledstations = new List<PRM_Station>();
public List<PRM_Line> disabledlines = new List<PRM_Line>();
#region "control parameters"
public double dist_threshold=500;
#endregion
//Main function for power graph algorithm
public void mainpowercheck()
{
//get the graph
Powerprep();
//start from source points
foreach (PRM_Station pwstation in powerstations)
{
if (pwstation.issource) { Chekpwpoints(pwstation); }
}
foreach (PRM_Line lin in powerlines)
{
if (lin.isbroken) { disabledlines.Add(lin); }
}
foreach (PRM_Station pw in powerstations)
{
if(!pw.ison && !(pw.type.ToUpperInvariant().Trim() == "POLE"))
{ disabledstations.Add(pw); }
}
return;
}
//search function for power graph
public void Chekpwpoints(PRM_Station sourcepoint)
{
if (!sourcepoint.ison)
{
MessageBox.Show("Checkpwpoints is called from disabled sourcepoint");
return;
}
List<PRM_Line> brokenPowerLinesAfterCheck()
// if the point is not a pole - i.e. we know
// it can redistribute power within connected lines
// we turn it ON if any of the connected lines are powered
foreach (PRM_Line line in sourcepoint.linelist)
{
if (!line.isbroken && !line.ison)
{
line.ison = true;
foreach (PRM_Station pwst in powerstations)
{
if (pwst.identifier != sourcepoint.identifier && (pwst.identifier == line.pointFromID || pwst.identifier == line.pointToID))
{
if (!(sourcepoint.type.Trim().ToUpperInvariant() == "POLE"))
{
pwst.ison = true;
Chekpwpoints(pwst);
}
else
{
// if line is a pole we have to check if it's actually able to
// get electricity to other points i.e. no connected lines are broken
bool polcheck = false;
foreach (PRM_Line poline in pwst.linelist)
{
if (poline.isbroken) { polcheck = true; }
}
if (!polcheck)
{
pwst.ison = true;
Chekpwpoints(pwst);
}
}
}
}
}
//else we have broken line or already switched ON powerpoint
}
}
//preparing powerstations and lists of lines for them to get a graph-like structure
public void Powerprep()
{
//First we make sure that all the sources are ON
//and all non sources are OFF
foreach (PRM_Station pwstat in powerstations)
{
if (pwstat.issource == true)
{ pwstat.ison = true; }
else { pwstat.ison = false; }
// for each power station we create a list of powerlines it is attached to
List<PRM_Line> lines = new List<PRM_Line>();
foreach (PRM_Line line in powerlines)
{
//we also switch OFF all lines
line.ison = false;
if (line.pointFromID == pwstat.identifier || line.pointToID == pwstat.identifier)
{
lines.Add(line);
}
}
pwstat.linelist = lines;
}
}
public List<PRM_Line> brokenPowerLinesAfterCheck()
{
List<PRM_Line> brklines = new List<PRM_Line>();
foreach (PRM_Line curve in powerlines)
{
// get coordinates list
......@@ -128,12 +261,11 @@ namespace MES_Wind
// cycle throw all points in line
for (int i = 1; i < points.Count; i++)
{
List<CheckPoint> segmentCheckList = new List<CheckPoint>();
double x1 = points[i - 1].X;
double y1 = points[i - 1].Y;
double x2 = points[i].X;
double y2 = points[i].Y;
bool result = linearLineIsBroken(points[i - 1], points[i], curve.height, curve.power, curve.power > 5 && curve.power < 330);
bool result = linearLineIsBroken(points[i - 1], points[i], curve.height, curve.power);
checkList.Add(result);
}
foreach (bool chkpnt in checkList)
......@@ -143,19 +275,21 @@ namespace MES_Wind
curve.isbroken = true;
}
}
if (curve.isbroken)
{
brklines.Add(curve);
}
}
if (powerlines.Count == 0)
{
throw new Exception("shit you trying to feed it is not a simple line");
//return null;
}
return null;
return brklines;
}
bool linearLineIsBroken(PRM_coordinate coord1, PRM_coordinate coord2, double heightLine, int powerLine, bool useClimate10)
bool linearLineIsBroken(PRM_coordinate coord1, PRM_coordinate coord2, double heightLine, int power)
{
double distance = Math.Sqrt((coord2.X - coord1.X) * (coord2.X - coord1.X) + (coord2.Y - coord1.Y) * (coord2.Y - coord1.Y));
double distpropD = distance / dist_threshold;
List<PRM_coordinate> pointlist = new List<PRM_coordinate>();
PRM_coordinate midpoint = new PRM_coordinate();
int distpropI = Convert.ToInt32(distpropD);
if (distpropI > 1)
{
......@@ -163,28 +297,50 @@ namespace MES_Wind
double constYdiff = (coord2.Y - coord1.Y) / distpropI;
PRM_coordinate subCoord1 = new PRM_coordinate(coord1.X, coord1.Y);
PRM_coordinate subCoord2 = new PRM_coordinate(coord1.X + constXdiff, coord1.Y + constXdiff);
for (int j = 0; j < distpropI; j++)
{
if (j > 0)
if (j == 0)
{
midpoint.X = (subCoord1.X + subCoord2.X) / 2;
midpoint.Y = (subCoord1.Y + subCoord2.Y) / 2;
pointlist.Add(midpoint);
}
else
{
// move to next center
subCoord1.X = subCoord2.X;
subCoord1.Y = subCoord2.Y;
subCoord2.X = subCoord1.X + constXdiff;
subCoord2.Y = subCoord1.Y + constYdiff;
}
bool result = linearLineIsBroken(subCoord1, subCoord2, heightLine, powerLine, useClimate10);
if (result)
{
return result;
midpoint.X = (subCoord1.X + subCoord2.X) / 2;
midpoint.Y = (subCoord1.Y + subCoord2.Y) / 2;
pointlist.Add(midpoint);
}
}
}
else
{
// TODO Implement climate15
PRMFunctionType climateType = useClimate10 ? PRMFunctionType.PRMFunctionClimate10 : PRMFunctionType.PRMFunctionClimate5;
PRM_coordinate coords = new PRM_coordinate((coord1.X + coord2.X) / 2, (coord1.Y + coord2.Y) / 2);
midpoint.X = (coord1.X + coord2.X)/2;
midpoint.Y = (coord1.Y + coord2.Y)/2;
pointlist.Add(midpoint);
}
PRMFunctionType climateType;
//PRMFunctionType climateType = useClimate10 ? PRMFunctionType.PRMFunctionClimate10 : PRMFunctionType.PRMFunctionClimate5;
if (power > 5 && power < 330)
{
climateType = PRMFunctionType.PRMFunctionClimate10;
}
else
{
if (power <= 5) { climateType = PRMFunctionType.PRMFunctionClimate5; }
else { climateType = PRMFunctionType.PRMFunctionClimate15; }
}
List<bool> checkbool = new List<bool>();
foreach (PRM_coordinate coords in pointlist)
{
bool res = false;
double uwind = interpol(coords, PRMFunctionType.PRMFunctionVelocityX);
double vwind = interpol(coords, PRMFunctionType.PRMFunctionVelocityY);
double climwind = interpol(coords, climateType);
......@@ -195,7 +351,7 @@ namespace MES_Wind
double C_height = 1.0;
if (umod < 20)
{ //wind is too low
return false;
res = false;
}
else
{ // calculate prognostic and threshold windstress
......@@ -210,11 +366,18 @@ namespace MES_Wind
if (Ppr >= Pcl)
{
// here line is broken
return true;
res=true;
}
}
checkbool.Add(res);
}
bool result = false;
foreach (bool lastcheck in checkbool)
{
if (lastcheck == true) { result = true; }
}
return false;
return result;
}
double[] affineCoefficients(PRMFunctionType functionType)
......
No preview for this file type
No preview for this file type
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">27</MDI>
<MDI key="STATISTICS_MEAN">27</MDI>
<MDI key="STATISTICS_MINIMUM">27</MDI>
<MDI key="STATISTICS_STDDEV">0</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">31</MDI>
<MDI key="STATISTICS_MEAN">31</MDI>
<MDI key="STATISTICS_MINIMUM">31</MDI>
<MDI key="STATISTICS_STDDEV">0</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">25</MDI>
<MDI key="STATISTICS_MEAN">25</MDI>
<MDI key="STATISTICS_MINIMUM">25</MDI>
<MDI key="STATISTICS_STDDEV">0</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment