How close to Earth is your ELW? A scoring method

I created a basic custom criteria prototype (requires Observatory Core >= 1.x I suspect) that checks all the things in your sheet plus the items above (with somewhat arbitrary weights) -- except moons (which can't be reliably determined in Custom Criteria as currently implemented). When scanning nav beacons (like for Sol) stars are not guaranteed to be known before you encounter the body, and as such multiple stars here may not be properly detected either. Critique/comments welcome.

Earth checks out at least. :)
View attachment 409383

A good match from my main commander:
View attachment 409426

JSON:
{
  "timestamp": "2023-06-05T03:06:31Z",
  "event": "Scan",
  "ScanType": "Detailed",
  "BodyName": "Spliergh TA-K c23-0 1",
  "BodyID": 1,
  "Parents": [
    {
      "Star": 0
    }
  ],
  "StarSystem": "Spliergh TA-K c23-0",
  "SystemAddress": 97945749706,
  "DistanceFromArrivalLS": 412.520270,
  "TidalLock": false,
  "TerraformState": "",
  "PlanetClass": "Earthlike body",
  "Atmosphere": "",
  "AtmosphereType": "EarthLike",
  "AtmosphereComposition": [
    {
      "Name": "Nitrogen",
      "Percent": 81.502975
    },
    {
      "Name": "Oxygen",
      "Percent": 17.892630
    },
    {
      "Name": "Water",
      "Percent": 0.579138
    }
  ],
  "Volcanism": "",
  "MassEM": 0.428283,
  "Radius": 4706859.000000,
  "SurfaceGravity": 7.705092,
  "SurfaceTemperature": 315.724670,
  "SurfacePressure": 88490.554688,
  "Landable": false,
  "Composition": {
    "Ice": 0.000000,
    "Rock": 0.674102,
    "Metal": 0.325898
  },
  "SemiMajorAxis": 123599588871.002197,
  "Eccentricity": 0.000813,
  "OrbitalInclination": 0.001306,
  "Periapsis": 19.018218,
  "OrbitalPeriod": 26545828.580856,
  "AscendingNode": 74.184877,
  "MeanAnomaly": 225.194909,
  "RotationPeriod": 80044.520763,
  "AxialTilt": -0.365010,
  "WasDiscovered": false,
  "WasMapped": false
}

Using your sheet, I can get the same number:
View attachment 409425
Edited to add the extra checks, use exact same calculations/conversions from the CC and fixed a bug with calculating Oxygen PP from your sheet.

Code:
---@Global
-- For ELW Similarity Score
---@param factor number
---@param posWeight number
---@param negWeight number
---@return number
function WeightedScore(factor, posWeight, negWeight)
  if factor >= 0 then
    return factor * posWeight
  else
    return factor * negWeight * -1
  end
end
---@End

---@Complex ELW Similarity Score
local EarthG = gravityAsG(9.797759)
local EarthTemp = 288
local EarthPressure = pressureAsAtm(101231.656250)
local EarthNitrogenPct = 77.886406
local EarthOxygenPct = 20.892998
local EarthArgonPct = 0.931637
local EarthOrbitalPer = periodAsDay(31558150.649071)
local EarthRotationalPer = periodAsDay(86164.106590)
local EarthTilt = 0.401426 * 180 / math.pi
local EarthEccentricity = 0.016700

if isPlanet(scan) and scan.PlanetClass == "Earthlike body" then
  local starCount = 0 -- this is a naive count, not strictly parent stars.
  for body in bodies(system) do
    if isStar(body) then
      starCount = starCount + 1
    end
  end
  if (starCount == 0) then starCount = 1 end -- there needs to be at least 1 star. Nav beacon scans may send bodies out of order.

  local score = 0
  local gravityFactor = (gravityAsG(scan.SurfaceGravity) - EarthG) / EarthG
  score = score + WeightedScore(gravityFactor, 25, 20)

  local tempFactor = (scan.SurfaceTemperature - EarthTemp) / EarthTemp
  score = score + WeightedScore(tempFactor, 2, 1)

  local surfPressure = pressureAsAtm(scan.SurfacePressure)
  local pressureFactor = (surfPressure - EarthPressure) / EarthPressure
  score = score + WeightedScore(pressureFactor, 1, 2)

  local oxygenPPFactor = -1 -- not present
  local nitrogenPPFactor = -1 -- not present.
  local argonPPFactor = -1 -- not present.
  for atmoMat in materials(scan.AtmosphereComposition) do
    if atmoMat.name == "Nitrogen" then
      nitrogenPPFactor = ((surfPressure * atmoMat.percent) - (EarthPressure * EarthNitrogenPct)) / (EarthPressure * EarthNitrogenPct)
    elseif atmoMat.name == "Oxygen" then
      oxygenPPFactor = ((surfPressure * atmoMat.percent) - (EarthPressure * EarthOxygenPct)) / (EarthPressure * EarthOxygenPct)
    elseif atmoMat.name == "Argon" then
      argonPPFactor = ((surfPressure * atmoMat.percent) - (EarthPressure * EarthArgonPct)) / (EarthPressure * EarthArgonPct)
    end
  end
  score = score + WeightedScore(nitrogenPPFactor, 1, 1)
  score = score + WeightedScore(oxygenPPFactor, 3, 5)
  score = score + WeightedScore(argonPPFactor, 1, 1)

  --- The next three can have negative values to begin with. We really only want to look at absolute differences.
  local orbitalPeriodFactor = (math.abs(periodAsDay(scan.OrbitalPeriod)) - EarthOrbitalPer) / EarthOrbitalPer
  score = score + WeightedScore(orbitalPeriodFactor, 1, 1)

  local rotationPeriodFactor = (math.abs(periodAsDay(scan.RotationPeriod)) - EarthRotationalPer) / EarthRotationalPer
  score = score + WeightedScore(rotationPeriodFactor, 10, 15)

  local axialTiltFactor = (math.abs(scan.AxialTilt * 180 / math.pi) - EarthTilt) / EarthTilt
  score = score + WeightedScore(axialTiltFactor, 1, 1)

  local eccentricityFactor = (scan.Eccentricity - EarthEccentricity) / EarthEccentricity
  score = score + WeightedScore(eccentricityFactor, 20, 0)

  if (scan.TidalLock) then
    score = score + WeightedScore(1, 5, 0)
  end

  -- TODO: This is hard to count in custom criteria.
  --local moonFactor =
  --score = score + WeightedScore(moonFactor, 5, 20)

  local starFactor = (starCount - 1) / 1
  score = score + WeightedScore(starFactor, 5, 0)

  -- Lower score is better. Earth itself should score 0.0
  local extDetails = string.format("Score: %.2f", score)
  --local extDetails = string.format("score: %.2f; g: %.2f; t: %.2f; p: %.2f; sp: %.2f; Oxp: %.2f; Np: %.2f; Ap: %.2f; op: %.2f; rp: %.2f; at: %.2f; ecc: %.2f; star: %.2f",
  --    score, gravityFactor, tempFactor, pressureFactor, surfPressure, oxygenPPFactor, nitrogenPPFactor, orbitalPeriodFactor, argonPPFactor, rotationPeriodFactor, axialTiltFactor, eccentricityFactor, starFactor)
  return true, "ELW Similarity Score", extDetails
end
---@End
Interesting custom criteria here. Ran my journals through it, and my closest was -

2017-09-03 01:59:38 Phraa Pruae CL-Y d2313 4 ELW Similarity Score Score: 6.10

What could also be interesting is ELW's that still classify as an ELW with the biggest difference. My biggest score is 2989.74.
 
Back
Top Bottom