title: How to handle negative cosine of Solar Zenith Angle while calculating clear-sky UV Index?
body: <p>I'm using <a href="https://users.cs.jmu.edu/bernstdh/Web/CS159/pa1/Background_UltravioletIndex.pdf" rel="nofollow noreferrer">this</a> source to calculate the UVI value for every hour in a day (From 7am to 7pm). And using <a href="https://pysolar.readthedocs.io/en/latest/" rel="nofollow noreferrer">pysolar</a> module to get the <code>Solar Zenith Angle</code>. The equation is below:</p>
  
  <pre><code>from pysolar.solar import *
  from math import cos
  import datetime
  
  dobj = datetime.datetime(2017,7,1,8,0)
  sza = float(90)-get_altitude(42.57952, 1.65362, dobj)
  ozone = 300
  raw_uvi = 12.50*pow(cos(sza),2.42)*pow(float(ozone)/300,-1.23)
  print (raw_uvi)
  </code></pre>
  
  <p>The output is:
      0.4850283419701262+1.8890606693266203j</p>
  
  <p>My question is when cos(sza) becomes negative it will give a complex number as output, how can I handle this ? Also, at 7 am the uvi results in <code>9.232276464148745</code> which is wrong. Am I missing something ? Or my interpretation of the algorithm is wrong  ?</p>