internal static void InitBiomeMap(PlanetData PD) { foreach (Cell cell in Cell.AtLevel(PD.gridLevel)) { PD.biomes[cell] = ScienceUtil.GetExperimentBiome(PD.body, WeatherFunctions.GetCellLatitude(cell), WeatherFunctions.GetCellLongitude(cell)); } }
internal static void InitTropopauseAlts(PlanetData PD) { //kerbin's default mean troposphere height is 8815.22 CelestialBody body = PD.body; if (body == null) { Logger("[PB]: Celestial Body supplied is null"); return; } foreach (Cell cell in Cell.AtLevel(PD.gridLevel)) { double latitude = WeatherFunctions.GetCellLatitude(cell); if (!PD.TropAlts.ContainsKey((float)latitude)) { double bodyRad = body.Radius; //changes: added brackets around bodyRad nad meanTropoHeight double tropHeight = Math.Sqrt(((bodyRad + PD.meanTropoHeight * 0.63) * Math.Sin(latitude * Mathf.Deg2Rad)) * ((bodyRad + PD.meanTropoHeight * 0.63) * Math.Sin(latitude * Mathf.Deg2Rad)) + ((bodyRad + PD.meanTropoHeight * 1.2) * Math.Cos(latitude * Mathf.Deg2Rad)) * ((bodyRad + PD.meanTropoHeight * 1.2) * Math.Cos(latitude * Mathf.Deg2Rad))) - bodyRad; PD.TropAlts.Add((float)latitude, (float)tropHeight); } } Logger("[PB]: Planet Tropopause Altitudes initialized for " + PD.body.name + "!"); }
public void mouseWindow(int windowID) { Cell cell = hoverCell.Value; float lat = WeatherFunctions.GetCellLatitude(cell); float lon = WeatherFunctions.GetCellLongitude(cell); GUILayout.BeginVertical(); GUILayout.Label(String.Format("Cell: {0:D5} cycle: {1:D}", cell.Index, CellUpdater.run)); GUILayout.Label("Lat: " + lat + " °"); GUILayout.Label("Lon: " + lon + " °"); GUILayout.Label(String.Format("Geodesic: {0:G}", Math.Sqrt(cell.Position.x * cell.Position.x + cell.Position.y * cell.Position.y + cell.Position.z * cell.Position.z))); GUILayout.Label(String.Format("ΔT(KSP-KWS): {0:+0.000;-0.000}°", (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)))); double DDD = 0.0; double DDD2 = 0.0; int n = 0; foreach (Cell neighbor in cell.GetNeighbors(PD.gridLevel)) { double DeltaDistance = WeatherFunctions.GetDistanceBetweenCells(PD.index, cell, neighbor, WeatherFunctions.GetCellAltitude(PD.index, currentLayer, cell)); DDD += DeltaDistance; DDD2 += DeltaDistance * DeltaDistance; n++; } DDD /= n; DDD2 /= n; GUILayout.Label(String.Format("ΔDistanceδ: {0:0.000000}", Math.Sqrt(Math.Abs(DDD2 - DDD * DDD)) / DDD)); GUILayout.Label(String.Format("flowPChange: {0:+00.000;-00.000}", PD.LiveMap[currentLayer][cell].flowPChange)); GUILayout.EndVertical(); }
internal static float GetInitTemperature(PlanetData PD, int AltLayer, Cell cell) { float Altitude = WeatherFunctions.GetCellAltitude(PD.index, AltLayer, cell); //get the proper f*****g temperature because the obvious answer f***s you over for 3 weeks float sunAxialDot = (float)(WeatherFunctions.GetSunriseFactor(PD.index, cell)); float latitude = Mathf.Abs(WeatherFunctions.GetCellLatitude(cell)); float diurnalRange = PD.body.latitudeTemperatureSunMultCurve.Evaluate(latitude); float latTempMod = PD.body.latitudeTemperatureBiasCurve.Evaluate(latitude); float axialTempMod = PD.body.axialTemperatureSunMultCurve.Evaluate(sunAxialDot); float atmoTempOffset = latTempMod + diurnalRange * sunAxialDot + axialTempMod; float altTempMult = PD.body.atmosphereTemperatureSunMultCurve.Evaluate(Altitude); float finalTempMod = atmoTempOffset * altTempMult; return((float)FlightGlobals.getExternalTemperature(Altitude, PD.body) + finalTempMod); }
public void mouseWindow(int windowID) { Cell cell = hoverCell.Value; float lat = WeatherFunctions.GetCellLatitude(cell); float lon = WeatherFunctions.GetCellLongitude(cell); GUILayout.BeginVertical(); GUILayout.Label(String.Format("Cell: {0:D5} cycle: {1:D}", cell.Index, CellUpdater.run)); GUILayout.Label("Lat: " + lat + " °"); GUILayout.Label("Lon: " + lon + " °"); GUILayout.Label(String.Format("Geodesic: {0:G}", Math.Sqrt(cell.Position.x * cell.Position.x + cell.Position.y * cell.Position.y + cell.Position.z * cell.Position.z))); GUILayout.Label(String.Format("ΔT(KSP-KWS): {0:+0.000;-0.000}°", (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)))); GUILayout.Label(String.Format("δ Temp: {0:+0.000000;-0.000000}°/s", currentLayer < PD.LiveMap.Count ? PD.LiveMap[currentLayer][cell].TempChange : PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].TempChange)); double DDD = 0.0; double DDD2 = 0.0; int n = 0; foreach (Cell neighbor in cell.GetNeighbors(PD.gridLevel)) { double DeltaDistance = WeatherFunctions.GetDistanceBetweenCells(PD.index, cell.Position, neighbor.Position, WeatherFunctions.GetCellAltitude(PD.index, currentLayer, cell)); DDD += DeltaDistance; DDD2 += DeltaDistance * DeltaDistance; n++; } DDD /= n; DDD2 /= n; GUILayout.Label(String.Format("ΔDistanceδ: {0:0.000000}", Math.Sqrt(Math.Abs(DDD2 - DDD * DDD)) / DDD)); GUILayout.Label(String.Format("CentroidΔ: {0:0.000000}", (cell.Position - PD.LiveSoilMap[cell].centroid).magnitude)); GUILayout.Label(String.Format("flowPChange: {0:+00.000;-00.000}", currentLayer < PD.LiveMap.Count ? PD.LiveMap[currentLayer][cell].flowPChange : PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].flowPChange)); GUILayout.Label(String.Format("Pressure Δ: {0:+000.00;-000.00}", currentLayer < PD.LiveMap.Count ? ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveMap[currentLayer][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveMap[currentLayer][cell].flowPChange) : ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].flowPChange))); GUILayout.EndVertical(); }