EarthStandardAtmosphereRefraction.java

  1. /* Copyright 2013 Applied Defense Solutions, Inc.
  2.  * Licensed to CS Communication & Systèmes (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.models.earth;

  18. import org.hipparchus.util.FastMath;
  19. import org.orekit.models.AtmosphericRefractionModel;

  20. /** Implementation of refraction model for Earth standard atmosphere.
  21.  * <p>Refraction angle is 0 at zenith, about 1 arcminute at 45°, and 34 arcminutes at the
  22.  *  horizon for optical wavelengths.</p>
  23.  * <p>Refraction angle is computed according to Saemundssen formula quoted by Meeus.
  24.  *  For reference, see <b>Astronomical Algorithms</b> (1998), 2nd ed,
  25.  *  (ISBN 0-943396-61-1), chap. 15.</p>
  26.  * <p>This formula is about 30 arcseconds of accuracy very close to the horizon, as
  27.  *  variable atmospheric effects become very important.</p>
  28.  * <p>Local pressure and temperature can be set to correct refraction at the viewpoint.</p>
  29.  * @since 6.1
  30.  */
  31. public class EarthStandardAtmosphereRefraction implements AtmosphericRefractionModel {


  32.     /** Default correction factor value. */
  33.     public static final double DEFAULT_CORRECTION_FACTOR = 1.0;

  34.     /** Default local pressure at viewpoint (Pa). */
  35.     public static final double DEFAULT_PRESSURE = 101000.0;

  36.     /** Default local temperature at viewpoint (K). */
  37.     public static final double DEFAULT_TEMPERATURE = 283.0;

  38.     /** NIST standard atmospheric pressure (Pa). */
  39.     public static final double STANDARD_ATM_PRESSURE = 101325.0;

  40.     /** NIST standard atmospheric temperature (K). */
  41.     public static final double STANDARD_ATM_TEMPERATURE = 293.15;

  42.     /** Elevation min value to compute refraction (under the horizon). */
  43.     private static final double MIN_ELEVATION = -2.0;

  44.     /** Elevation max value to compute refraction (zenithal). */
  45.     private static final double MAX_ELEVATION = 89.89;

  46.     /** Serializable UID. */
  47.     private static final long serialVersionUID = 6001744143210742620L;

  48.     /** Refraction correction from local pressure and temperature. */
  49.     private double correfrac;

  50.     /** Local pressure. */
  51.     private double pressure;

  52.     /** Local temperature. */
  53.     private double temperature;

  54.     /**
  55.      * Creates a new default instance.
  56.      */
  57.     public EarthStandardAtmosphereRefraction() {
  58.         correfrac   = DEFAULT_CORRECTION_FACTOR;
  59.         pressure    = DEFAULT_PRESSURE;
  60.         temperature = DEFAULT_TEMPERATURE;
  61.     }

  62.     /**
  63.      * Creates an instance given a specific pressure and temperature.
  64.      * @param pressure in Pascals (Pa)
  65.      * @param temperature in Kelvin (K)
  66.      */
  67.     public EarthStandardAtmosphereRefraction(final double pressure, final double temperature) {
  68.         setTemperature(temperature);
  69.         setPressure(pressure);
  70.     }

  71.     /** Get the local pressure at the evaluation location.
  72.      * @return the pressure (Pa)
  73.      */
  74.     public double getPressure() {
  75.         return pressure;
  76.     }

  77.     /** Set the local pressure at the evaluation location
  78.      * <p>Otherwise the default value for the local pressure is set to {@link #DEFAULT_PRESSURE}.</p>
  79.      * @param pressure the pressure to set (Pa)
  80.      */
  81.     public void setPressure(final double pressure) {
  82.         this.pressure = pressure;
  83.         this.correfrac = (pressure / DEFAULT_PRESSURE) * (DEFAULT_TEMPERATURE / temperature);
  84.     }

  85.     /** Get the local temperature at the evaluation location.
  86.      * @return the temperature (K)
  87.      */
  88.     public double getTemperature() {
  89.         return temperature;
  90.     }

  91.     /** Set the local temperature at the evaluation location
  92.      * <p>Otherwise the default value for the local temperature is set to {@link #DEFAULT_TEMPERATURE}.</p>
  93.      * @param temperature the temperature to set (K)
  94.      */
  95.     public void setTemperature(final double temperature) {
  96.         this.temperature = temperature;
  97.         this.correfrac = (pressure / DEFAULT_PRESSURE) * (DEFAULT_TEMPERATURE / temperature);
  98.     }

  99.     @Override
  100.     /** {@inheritDoc} */
  101.     public double getRefraction(final double trueElevation) {
  102.         double refraction = 0.0;
  103.         final double eld = FastMath.toDegrees(trueElevation);
  104.         if (eld > MIN_ELEVATION && eld < MAX_ELEVATION) {
  105.             final double tmp = eld + 10.3 / (eld + 5.11);
  106.             final double ref = 1.02 / FastMath.tan(FastMath.toRadians(tmp)) / 60.;
  107.             refraction = FastMath.toRadians(correfrac * ref);
  108.         }
  109.         return refraction;
  110.     }
  111. }