///<summary> Add environment sub-panel, including tooltips </summary> private static void AddSubPanelEnvironment(Panel p) { string flux_tooltip = Lib.BuildString ( "<align=left />" + String.Format("<b>{0,-14}\t{1,-15}\t{2}</b>\n", Local.Planner_Source, Local.Planner_Flux, Local.Planner_Temp), //"Source""Flux""Temp" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_solar, env_analyzer.solar_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.solar_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.solar_flux))), //"solar""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_albedo, env_analyzer.albedo_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.albedo_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.albedo_flux))), //"albedo""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_body, env_analyzer.body_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.body_flux) : Local.Generic_NONE, Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.body_flux))), //"body""none" String.Format("{0,-14}\t{1,-15}\t{2}\n", Local.Planner_background, Lib.HumanReadableFlux(Sim.BackgroundFlux()), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(Sim.BackgroundFlux()))), //"background" String.Format("{0,-14}\t\t{1,-15}\t{2}", Local.Planner_total, Lib.HumanReadableFlux(env_analyzer.total_flux), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.total_flux))) //"total" ); string atmosphere_tooltip = Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", Local.BodyInfo_breathable, Sim.Breathable(env_analyzer.body) ? Local.BodyInfo_breathable_yes : Local.BodyInfo_breathable_no), //"breathable""yes""no" String.Format("{0,-14}\t<b>{1}</b>\n", Local.Planner_pressure, Lib.HumanReadablePressure(env_analyzer.body.atmospherePressureSeaLevel)), //"pressure" String.Format("{0,-14}\t<b>{1}</b>\n", Local.BodyInfo_lightabsorption, Lib.HumanReadablePerc(1.0 - env_analyzer.atmo_factor)), //"light absorption" String.Format("{0,-14}\t<b>{1}</b>", Local.BodyInfo_gammaabsorption, Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(env_analyzer.body, 0.0))) //"gamma absorption" ); string shadowtime_str = Lib.HumanReadableDuration(env_analyzer.shadow_period) + " (" + (env_analyzer.shadow_time * 100.0).ToString("F0") + "%)"; p.AddSection(Local.TELEMETRY_ENVIRONMENT, string.Empty, //"ENVIRONMENT" () => { p.Prev(ref environment_index, panel_environment.Count); enforceUpdate = true; }, () => { p.Next(ref environment_index, panel_environment.Count); enforceUpdate = true; }); p.AddContent(Local.Planner_temperature, Lib.HumanReadableTemp(env_analyzer.temperature), env_analyzer.body.atmosphere && env_analyzer.landed ? Local.Planner_atmospheric : flux_tooltip); //"temperature""atmospheric" p.AddContent(Local.Planner_difference, Lib.HumanReadableTemp(env_analyzer.temp_diff), Local.Planner_difference_desc); //"difference""difference between external and survival temperature" p.AddContent(Local.Planner_atmosphere, env_analyzer.body.atmosphere ? Local.Planner_atmosphere_yes : Local.Planner_atmosphere_no, atmosphere_tooltip); //"atmosphere""yes""no" p.AddContent(Local.Planner_shadowtime, shadowtime_str, Local.Planner_shadowtime_desc); //"shadow time""the time in shadow\nduring the orbit" }
///<summary> Add environment sub-panel, including tooltips </summary> private static void AddSubPanelEnvironment(Panel p) { string flux_tooltip = Lib.BuildString ( "<align=left />" + String.Format("<b>{0,-14}\t{1,-15}\t{2}</b>\n", "Source", "Flux", "Temp"), String.Format("{0,-14}\t{1,-15}\t{2}\n", "solar", env_analyzer.solar_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.solar_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.solar_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "albedo", env_analyzer.albedo_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.albedo_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.albedo_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "body", env_analyzer.body_flux > 0.0 ? Lib.HumanReadableFlux(env_analyzer.body_flux) : "none", Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.body_flux))), String.Format("{0,-14}\t{1,-15}\t{2}\n", "background", Lib.HumanReadableFlux(Sim.BackgroundFlux()), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(Sim.BackgroundFlux()))), String.Format("{0,-14}\t\t{1,-15}\t{2}", "total", Lib.HumanReadableFlux(env_analyzer.total_flux), Lib.HumanReadableTemp(Sim.BlackBodyTemperature(env_analyzer.total_flux))) ); string atmosphere_tooltip = Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", "breathable", Sim.Breathable(env_analyzer.body) ? "yes" : "no"), String.Format("{0,-14}\t<b>{1}</b>\n", "pressure", Lib.HumanReadablePressure(env_analyzer.body.atmospherePressureSeaLevel)), String.Format("{0,-14}\t<b>{1}</b>\n", "light absorption", Lib.HumanReadablePerc(1.0 - env_analyzer.atmo_factor)), String.Format("{0,-14}\t<b>{1}</b>", "gamma absorption", Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(env_analyzer.body, 0.0))) ); string shadowtime_str = Lib.HumanReadableDuration(env_analyzer.shadow_period) + " (" + (env_analyzer.shadow_time * 100.0).ToString("F0") + "%)"; p.AddSection("ENVIRONMENT", string.Empty, () => { p.Prev(ref environment_index, panel_environment.Count); update = true; }, () => { p.Next(ref environment_index, panel_environment.Count); update = true; }); p.AddContent("temperature", Lib.HumanReadableTemp(env_analyzer.temperature), env_analyzer.body.atmosphere && env_analyzer.landed ? "atmospheric" : flux_tooltip); p.AddContent("difference", Lib.HumanReadableTemp(env_analyzer.temp_diff), "difference between external and survival temperature"); p.AddContent("atmosphere", env_analyzer.body.atmosphere ? "yes" : "no", atmosphere_tooltip); p.AddContent("shadow time", shadowtime_str, "the time in shadow\nduring the orbit"); }
public void Analyze(CelestialBody body, double altitude_mult, bool sunlight) { // shortcuts CelestialBody sun = FlightGlobals.Bodies[0]; this.body = body; altitude = body.Radius * altitude_mult; landed = altitude <= double.Epsilon; breathable = Sim.Breathable(body) && landed; atmo_factor = Sim.AtmosphereFactor(body, 0.7071); sun_dist = Sim.Apoapsis(Lib.PlanetarySystem(body)) - sun.Radius - body.Radius; Vector3d sun_dir = (sun.position - body.position).normalized; solar_flux = sunlight ? Sim.SolarFlux(sun_dist) * (landed ? atmo_factor : 1.0) : 0.0; albedo_flux = sunlight ? Sim.AlbedoFlux(body, body.position + sun_dir * (body.Radius + altitude)) : 0.0; body_flux = Sim.BodyFlux(body, altitude); total_flux = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux(); temperature = !landed || !body.atmosphere ? Sim.BlackBodyTemperature(total_flux) : body.GetTemperature(0.0); temp_diff = Sim.TempDiff(temperature, body, landed); orbital_period = Sim.OrbitalPeriod(body, altitude); shadow_period = Sim.ShadowPeriod(body, altitude); shadow_time = shadow_period / orbital_period; zerog = !landed && (!body.atmosphere || body.atmosphereDepth < altitude); RadiationBody rb = Radiation.Info(body); RadiationBody sun_rb = Radiation.Info(sun); gamma_transparency = Sim.GammaTransparency(body, 0.0); extern_rad = PreferencesStorm.Instance.ExternRadiation; heliopause_rad = extern_rad + sun_rb.radiation_pause; magnetopause_rad = heliopause_rad + rb.radiation_pause; inner_rad = magnetopause_rad + rb.radiation_inner; outer_rad = magnetopause_rad + rb.radiation_outer; surface_rad = magnetopause_rad * gamma_transparency; storm_rad = heliopause_rad + PreferencesStorm.Instance.StormRadiation * (solar_flux > double.Epsilon ? 1.0 : 0.0); }
public static void Body_Info(this Panel p) { // only show in mapview if (!MapView.MapIsEnabled) { return; } // only show if there is a selected body and that body is not the sun CelestialBody body = Lib.SelectedBody(); if (body == null || (body.flightGlobalsIndex == 0 && !Features.Radiation)) { return; } // shortcut CelestialBody sun = FlightGlobals.Bodies[0]; // for all bodies except the sun if (body != sun) { // calculate simulation values double atmo_factor = Sim.AtmosphereFactor(body, 0.7071); double gamma_factor = Sim.GammaTransparency(body, 0.0); double sun_dist = Sim.Apoapsis(Lib.PlanetarySystem(body)) - sun.Radius - body.Radius; Vector3d sun_dir = (sun.position - body.position).normalized; double solar_flux = Sim.SolarFlux(sun_dist) * atmo_factor; double albedo_flux = Sim.AlbedoFlux(body, body.position + sun_dir * body.Radius); double body_flux = Sim.BodyFlux(body, 0.0); double total_flux = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux(); double temperature = body.atmosphere ? body.GetTemperature(0.0) : Sim.BlackBodyTemperature(total_flux); // calculate night-side temperature double total_flux_min = Sim.AlbedoFlux(body, body.position - sun_dir * body.Radius) + body_flux + Sim.BackgroundFlux(); double temperature_min = Sim.BlackBodyTemperature(total_flux_min); // calculate radiation at body surface double radiation = Radiation.ComputeSurface(body, gamma_factor); // surface panel string temperature_str = body.atmosphere ? Lib.HumanReadableTemp(temperature) : Lib.BuildString(Lib.HumanReadableTemp(temperature_min), " / ", Lib.HumanReadableTemp(temperature)); p.SetSection("SURFACE"); p.SetContent("temperature", temperature_str); p.SetContent("solar flux", Lib.HumanReadableFlux(solar_flux)); if (Features.Radiation) { p.SetContent("radiation", Lib.HumanReadableRadiation(radiation)); } // atmosphere panel if (body.atmosphere) { p.SetSection("ATMOSPHERE"); p.SetContent("breathable", Sim.Breathable(body) ? "yes" : "no"); p.SetContent("light absorption", Lib.HumanReadablePerc(1.0 - Sim.AtmosphereFactor(body, 0.7071))); if (Features.Radiation) { p.SetContent("gamma absorption", Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(body, 0.0))); } } } // rendering panel if (Features.Radiation) { p.SetSection("RENDERING"); p.SetContent("inner belt", Radiation.show_inner ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_inner)); p.SetContent("outer belt", Radiation.show_outer ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_outer)); p.SetContent("magnetopause", Radiation.show_pause ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_pause)); } // explain the user how to toggle the BodyInfo window p.SetContent(string.Empty); p.SetContent("<i>Press <b>B</b> to open this window again</i>"); // set metadata p.Title(Lib.BuildString(Lib.Ellipsis(body.bodyName, 24), " <color=#cccccc>BODY INFO</color>")); }
public void Analyze(CelestialBody body, double altitude_mult, Planner.SunlightState sunlight) { this.body = body; CelestialBody mainSun; Vector3d sun_dir; solar_flux = Sim.SolarFluxAtBody(body, true, out mainSun, out sun_dir, out sun_dist); altitude = body.Radius * altitude_mult; landed = altitude <= double.Epsilon; atmo_factor = Sim.AtmosphereFactor(body, 0.7071); solar_flux = sunlight == Planner.SunlightState.Shadow ? 0.0 : solar_flux * (landed ? atmo_factor : 1.0); breathable = Sim.Breathable(body) && landed; albedo_flux = sunlight == Planner.SunlightState.Shadow ? 0.0 : Sim.AlbedoFlux(body, body.position + sun_dir * (body.Radius + altitude)); body_flux = Sim.BodyFlux(body, altitude); total_flux = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux(); temperature = !landed || !body.atmosphere ? Sim.BlackBodyTemperature(total_flux) : body.GetTemperature(0.0); temp_diff = Sim.TempDiff(temperature, body, landed); orbital_period = Sim.OrbitalPeriod(body, altitude); shadow_period = Sim.ShadowPeriod(body, altitude); shadow_time = shadow_period / orbital_period; zerog = !landed && (!body.atmosphere || body.atmosphereDepth < altitude); RadiationBody rb = Radiation.Info(body); RadiationBody sun_rb = Radiation.Info(mainSun); // TODO Kopernicus support: not sure if/how this work with multiple suns/stars gamma_transparency = Sim.GammaTransparency(body, 0.0); // add gamma radiation emitted by body and its sun var gamma_radiation = Radiation.DistanceRadiation(rb.radiation_r0, altitude) / 3600.0; #if DEBUG_RADIATION Lib.Log("Planner/EA: " + body + " sun " + mainSun + " alt " + altitude + " sol flux " + solar_flux + " aalbedo flux " + albedo_flux + " body flux " + body_flux + " total flux " + total_flux); Lib.Log("Planner/EA: body surface radiation " + Lib.HumanReadableRadiation(gamma_radiation, false)); #endif var b = body; while (b != null && b.orbit != null && b != mainSun) { if (b == b.referenceBody) { break; } var dist = b.orbit.semiMajorAxis; b = b.referenceBody; gamma_radiation += Radiation.DistanceRadiation(Radiation.Info(b).radiation_r0, dist) / 3600.0; #if DEBUG_RADIATION Lib.Log("Planner/EA: with gamma radiation from " + b + " " + Lib.HumanReadableRadiation(gamma_radiation, false)); Lib.Log("Planner/EA: semi major axis " + dist); #endif } extern_rad = Settings.ExternRadiation / 3600.0; heliopause_rad = gamma_radiation + extern_rad + sun_rb.radiation_pause; magnetopause_rad = gamma_radiation + heliopause_rad + rb.radiation_pause; inner_rad = gamma_radiation + magnetopause_rad + rb.radiation_inner; outer_rad = gamma_radiation + magnetopause_rad + rb.radiation_outer; surface_rad = magnetopause_rad * gamma_transparency + rb.radiation_surface / 3600.0; storm_rad = heliopause_rad + PreferencesRadiation.Instance.StormRadiation * (solar_flux > double.Epsilon ? 1.0 : 0.0); #if DEBUG_RADIATION Lib.Log("Planner/EA: extern_rad " + Lib.HumanReadableRadiation(extern_rad, false)); Lib.Log("Planner/EA: heliopause_rad " + Lib.HumanReadableRadiation(heliopause_rad, false)); Lib.Log("Planner/EA: magnetopause_rad " + Lib.HumanReadableRadiation(magnetopause_rad, false)); Lib.Log("Planner/EA: inner_rad " + Lib.HumanReadableRadiation(inner_rad, false)); Lib.Log("Planner/EA: outer_rad " + Lib.HumanReadableRadiation(outer_rad, false)); Lib.Log("Planner/EA: surface_rad " + Lib.HumanReadableRadiation(surface_rad, false)); Lib.Log("Planner/EA: storm_rad " + Lib.HumanReadableRadiation(storm_rad, false)); #endif }