import math


def atmcorr(radiance, perihelion, day_of_year):
  """
  Atmospherically corrects radiance using correction coefficients
  at perihelion adjusted for Earth's ellipitcal orbit
  """
    
  # elliptical orbit correction
  elliptical_orbit_correction = 0.03275104*math.cos(math.radians(day_of_year/1.04137484)) + 0.96804905
  
  # correction coefficients
  a = perihelion[0] * elliptical_orbit_correction
  b = perihelion[1] * elliptical_orbit_correction

  # surface reflectance
  try:
    SR = (radiance - a) / b
  except:
    SR = None

  return SR