This method returns exact atmospheric data, using the same method that KSP uses, but re-created in kOS.
Temperature in particular was the missing data unobtainable with kOS, and this is the main focus of this method.
Put the folder 'atmoData' in your KSP/Ships/Script folder.
See the example:
- Run both Time.ks and AtmoData.ks.
- Init the function you want
- To change to a different planet, reset the function with the required planet
An example is provided, called 'useAtmoData.ks'. This should get you on your way.
Use it by runpath("atmoData/useAtmoData.ks").
A method that can be used to speed up the calculations even more, is by reducing the amount of latitude curve updates, since they do not change a lot over time.
The example provided will demonstrate how to do that.
It uses the same method that KSP uses for getting temperature:
- altTemp = altTemp.floatcurve(shipAltitude)
- latTemp = latTemp.floatcurve(shipLatitude)
- latVarTemp = latVarTemp.floatcurve(shipLatitude)
- altVarTemp = altVarTemp.floatcurve(shipAltitude)
- localTime = (vdot(upVector-45lng, sunVector)+1)/2
- atmosphereTemperatureOffset = latTemp + (latVarTemp * localTime)
- SAT = altTemp + (atmosphereTemperatureOffset * altVarTemp)
I have explained these curves in another project.