mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-08-07 05:22:16 -04:00
JS: Added Atmosphere function.
This commit is contained in:
1 parent
5e2292dfa6
commit
66cd0147b5
14 files changed
+763
-119
No files matched your search
@@ -35,8 +35,8 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GeoEmbState = exports.GeoMoonState = exports.EclipticGeoMoon = exports.GeoMoon = exports.Ecliptic = exports.ObserverGravity = exports.VectorObserver = exports.ObserverState = exports.ObserverVector = exports.Equator = exports.SunPosition = exports.Observer = exports.Horizon = exports.EclipticCoordinates = exports.HorizontalCoordinates = exports.MakeRotation = exports.RotationMatrix = exports.EquatorialCoordinates = exports.Spherical = exports.StateVector = exports.Vector = exports.SiderealTime = exports.Libration = exports.LibrationInfo = exports.CalcMoonCount = exports.e_tilt = exports.MakeTime = exports.AstroTime = exports.SetDeltaTFunction = exports.DeltaT_JplHorizons = exports.DeltaT_EspenakMeeus = exports.PlanetOrbitalPeriod = exports.DefineStar = exports.Body = exports.AngleBetween = exports.MassProduct = exports.CALLISTO_RADIUS_KM = exports.GANYMEDE_RADIUS_KM = exports.EUROPA_RADIUS_KM = exports.IO_RADIUS_KM = exports.JUPITER_MEAN_RADIUS_KM = exports.JUPITER_POLAR_RADIUS_KM = exports.JUPITER_EQUATORIAL_RADIUS_KM = exports.RAD2HOUR = exports.RAD2DEG = exports.HOUR2RAD = exports.DEG2RAD = exports.AU_PER_LY = exports.KM_PER_AU = exports.C_AUDAY = void 0;
|
||||
exports.InverseRefraction = exports.Refraction = exports.VectorFromHorizon = exports.HorizonFromVector = exports.SphereFromVector = exports.EquatorFromVector = exports.VectorFromSphere = exports.Pivot = exports.IdentityMatrix = exports.CombineRotation = exports.InverseRotation = exports.NextPlanetApsis = exports.SearchPlanetApsis = exports.NextLunarApsis = exports.SearchLunarApsis = exports.Apsis = exports.ApsisKind = exports.SearchPeakMagnitude = exports.SearchMaxElongation = exports.Elongation = exports.ElongationEvent = exports.Seasons = exports.SeasonInfo = exports.HourAngle = exports.SearchHourAngle = exports.HourAngleEvent = exports.SearchAltitude = exports.SearchRiseSet = exports.NextMoonQuarter = exports.SearchMoonQuarter = exports.MoonQuarter = exports.SearchMoonPhase = exports.MoonPhase = exports.SearchRelativeLongitude = exports.Illumination = exports.IlluminationInfo = exports.EclipticLongitude = exports.AngleFromSun = exports.PairLongitude = exports.SearchSunLongitude = exports.Search = exports.HelioState = exports.BaryState = exports.GeoVector = exports.BackdatePosition = exports.CorrectLightTravel = exports.HelioDistance = exports.HelioVector = exports.JupiterMoons = exports.JupiterMoonsInfo = void 0;
|
||||
exports.GravitySimulator = exports.LagrangePointFast = exports.LagrangePoint = exports.RotationAxis = exports.AxisInfo = exports.NextMoonNode = exports.SearchMoonNode = exports.NodeEventInfo = exports.NodeEventKind = exports.NextTransit = exports.SearchTransit = exports.TransitInfo = exports.NextLocalSolarEclipse = exports.SearchLocalSolarEclipse = exports.LocalSolarEclipseInfo = exports.EclipseEvent = exports.NextGlobalSolarEclipse = exports.SearchGlobalSolarEclipse = exports.NextLunarEclipse = exports.GlobalSolarEclipseInfo = exports.SearchLunarEclipse = exports.LunarEclipseInfo = exports.EclipseKind = exports.Constellation = exports.ConstellationInfo = exports.Rotation_EQD_ECT = exports.Rotation_ECT_EQD = exports.Rotation_GAL_EQJ = exports.Rotation_EQJ_GAL = exports.Rotation_HOR_ECL = exports.Rotation_ECL_HOR = exports.Rotation_ECL_EQD = exports.Rotation_EQD_ECL = exports.Rotation_EQJ_HOR = exports.Rotation_HOR_EQJ = exports.Rotation_HOR_EQD = exports.Rotation_EQD_HOR = exports.Rotation_EQD_EQJ = exports.Rotation_ECT_EQJ = exports.Rotation_EQJ_ECT = exports.Rotation_EQJ_EQD = exports.Rotation_ECL_EQJ = exports.Rotation_EQJ_ECL = exports.RotateState = exports.RotateVector = void 0;
|
||||
exports.VectorFromHorizon = exports.HorizonFromVector = exports.SphereFromVector = exports.EquatorFromVector = exports.VectorFromSphere = exports.Pivot = exports.IdentityMatrix = exports.CombineRotation = exports.InverseRotation = exports.NextPlanetApsis = exports.SearchPlanetApsis = exports.NextLunarApsis = exports.SearchLunarApsis = exports.Apsis = exports.ApsisKind = exports.SearchPeakMagnitude = exports.SearchMaxElongation = exports.Elongation = exports.ElongationEvent = exports.Seasons = exports.SeasonInfo = exports.HourAngle = exports.SearchHourAngle = exports.HourAngleEvent = exports.SearchAltitude = exports.SearchRiseSet = exports.Atmosphere = exports.AtmosphereInfo = exports.NextMoonQuarter = exports.SearchMoonQuarter = exports.MoonQuarter = exports.SearchMoonPhase = exports.MoonPhase = exports.SearchRelativeLongitude = exports.Illumination = exports.IlluminationInfo = exports.EclipticLongitude = exports.AngleFromSun = exports.PairLongitude = exports.SearchSunLongitude = exports.Search = exports.HelioState = exports.BaryState = exports.GeoVector = exports.BackdatePosition = exports.CorrectLightTravel = exports.HelioDistance = exports.HelioVector = exports.JupiterMoons = exports.JupiterMoonsInfo = void 0;
|
||||
exports.GravitySimulator = exports.LagrangePointFast = exports.LagrangePoint = exports.RotationAxis = exports.AxisInfo = exports.NextMoonNode = exports.SearchMoonNode = exports.NodeEventInfo = exports.NodeEventKind = exports.NextTransit = exports.SearchTransit = exports.TransitInfo = exports.NextLocalSolarEclipse = exports.SearchLocalSolarEclipse = exports.LocalSolarEclipseInfo = exports.EclipseEvent = exports.NextGlobalSolarEclipse = exports.SearchGlobalSolarEclipse = exports.NextLunarEclipse = exports.GlobalSolarEclipseInfo = exports.SearchLunarEclipse = exports.LunarEclipseInfo = exports.EclipseKind = exports.Constellation = exports.ConstellationInfo = exports.Rotation_EQD_ECT = exports.Rotation_ECT_EQD = exports.Rotation_GAL_EQJ = exports.Rotation_EQJ_GAL = exports.Rotation_HOR_ECL = exports.Rotation_ECL_HOR = exports.Rotation_ECL_EQD = exports.Rotation_EQD_ECL = exports.Rotation_EQJ_HOR = exports.Rotation_HOR_EQJ = exports.Rotation_HOR_EQD = exports.Rotation_EQD_HOR = exports.Rotation_EQD_EQJ = exports.Rotation_ECT_EQJ = exports.Rotation_EQJ_ECT = exports.Rotation_EQJ_EQD = exports.Rotation_ECL_EQJ = exports.Rotation_EQJ_ECL = exports.RotateState = exports.RotateVector = exports.InverseRefraction = exports.Refraction = void 0;
|
||||
/**
|
||||
* @brief The speed of light in AU/day.
|
||||
*/
|
||||
@@ -4826,6 +4826,70 @@ function NextMoonQuarter(mq) {
|
||||
return SearchMoonQuarter(date);
|
||||
}
|
||||
exports.NextMoonQuarter = NextMoonQuarter;
|
||||
/**
|
||||
* @brief Information about idealized atmospheric variables at a given elevation.
|
||||
*
|
||||
* @property {number} pressure
|
||||
* Atmospheric pressure in pascals.
|
||||
*
|
||||
* @property {number} temperature
|
||||
* Atmospheric temperature in kelvins.
|
||||
*
|
||||
* @property {number} density
|
||||
* Atmospheric density relative to sea level.
|
||||
*/
|
||||
class AtmosphereInfo {
|
||||
constructor(pressure, temperature, density) {
|
||||
this.pressure = pressure;
|
||||
this.temperature = temperature;
|
||||
this.density = density;
|
||||
}
|
||||
}
|
||||
exports.AtmosphereInfo = AtmosphereInfo;
|
||||
/**
|
||||
* @brief Calculates U.S. Standard Atmosphere (1976) variables as a function of elevation.
|
||||
*
|
||||
* This function calculates idealized values of pressure, temperature, and density
|
||||
* using the U.S. Standard Atmosphere (1976) model.
|
||||
* 1. COESA, U.S. Standard Atmosphere, 1976, U.S. Government Printing Office, Washington, DC, 1976.
|
||||
* 2. Jursa, A. S., Ed., Handbook of Geophysics and the Space Environment, Air Force Geophysics Laboratory, 1985.
|
||||
* See:
|
||||
* https://hbcp.chemnetbase.com/faces/documents/14_12/14_12_0001.xhtml
|
||||
* https://ntrs.nasa.gov/api/citations/19770009539/downloads/19770009539.pdf
|
||||
* https://www.ngdc.noaa.gov/stp/space-weather/online-publications/miscellaneous/us-standard-atmosphere-1976/us-standard-atmosphere_st76-1562_noaa.pdf
|
||||
*
|
||||
* @param {number} elevationMeters
|
||||
* The elevation above sea level at which to calculate atmospheric variables.
|
||||
* Must be in the range -500 to +100000, or an exception will occur.
|
||||
*
|
||||
* @returns {AtmosphereInfo}
|
||||
*/
|
||||
function Atmosphere(elevationMeters) {
|
||||
const P0 = 101325.0; // pressure at sea level [pascals]
|
||||
const T0 = 288.15; // temperature at sea level [kelvins]
|
||||
const T1 = 216.65; // temperature between 20 km and 32 km [kelvins]
|
||||
if (!Number.isFinite(elevationMeters) || elevationMeters < -500.0 || elevationMeters > 100000.0)
|
||||
throw `Invalid elevation: ${elevationMeters}`;
|
||||
let temperature;
|
||||
let pressure;
|
||||
if (elevationMeters <= 11000.0) {
|
||||
temperature = T0 - 0.0065 * elevationMeters;
|
||||
pressure = P0 * Math.pow(T0 / temperature, -5.25577);
|
||||
}
|
||||
else if (elevationMeters <= 20000.0) {
|
||||
temperature = T1;
|
||||
pressure = 22632.0 * Math.exp(-0.00015768832 * (elevationMeters - 11000.0));
|
||||
}
|
||||
else {
|
||||
temperature = T1 + 0.001 * (elevationMeters - 20000.0);
|
||||
pressure = 5474.87 * Math.pow(T1 / temperature, 34.16319);
|
||||
}
|
||||
// The density is calculated relative to the sea level value.
|
||||
// Using the ideal gas law PV=nRT, we deduce that density is proportional to P/T.
|
||||
const density = (pressure / temperature) / (P0 / T0);
|
||||
return new AtmosphereInfo(pressure, temperature, density);
|
||||
}
|
||||
exports.Atmosphere = Atmosphere;
|
||||
function BodyRadiusAu(body) {
|
||||
// For the purposes of calculating rise/set times,
|
||||
// only the Sun and Moon appear large enough to an observer
|
||||
|
||||
Reference in new issue
Block a user