Skip to content

Commit

Permalink
Merge pull request #35 from james-m-osborn/master
Browse files Browse the repository at this point in the history
added seeing to cn2 in atmos conversions
  • Loading branch information
matthewtownson committed Jan 12, 2018
2 parents c34c48f + 7b7655b commit b2368a3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
42 changes: 42 additions & 0 deletions aotools/turbulence/atmos_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ def cn2_to_seeing(cn2,lamda=500.E-9):
seeing = r0_to_seeing(r0,lamda)
return seeing

def seeing_to_cn2(seeing,lamda=500.E-9):
"""
Calculates the integrated Cn2 value from the seeing
Parameters:
seeing (float): seeing in arcseconds
lamda : wavelength
Returns:
integrated Cn2 value in m^2/3
"""
r0 = seeing_to_r0(seeing,lamda)
cn2 = r0_to_cn2(r0,lamda)
return cn2

def cn2_to_r0(cn2,lamda=500.E-9):
"""
Calculates r0 from the integrated Cn2 value
Expand All @@ -29,6 +44,20 @@ def cn2_to_r0(cn2,lamda=500.E-9):
r0=(0.423*(2*numpy.pi/lamda)**2*cn2)**(-3./5.)
return r0

def r0_to_cn2(r0,lamda=500.E-9):
"""
Calculates integrated Cn2 value from r0
Parameters:
r0 (float): r0 in cm
lamda : wavelength
Returns:
cn2 (float): integrated Cn2 value in m^2/3
"""
cn2 = r0**(-5./3.)/(0.423*(2*numpy.pi/lamda)**2)
return cn2

def r0_to_seeing(r0,lamda=500.E-9):
"""
Calculates the seeing angle from r0
Expand All @@ -42,6 +71,19 @@ def r0_to_seeing(r0,lamda=500.E-9):
"""
return (0.98*lamda/r0)*180.*3600./numpy.pi

def seeing_to_r0(seeing,lamda=500.E-9):
"""
Calculates r0 from seeing
Parameters:
seeing (float): seeing angle in arcseconds
lamda : wavelength
Returns:
r0 (float): Freid's parameter in cm
"""
return 0.98*lamda/(seeing*numpy.pi/(180.*3600.))

def coherenceTime(cn2,v,lamda=500.E-9):
"""
Calculates the coherence time from profiles of the Cn2 and wind velocity
Expand Down
11 changes: 11 additions & 0 deletions test/test_atmos_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ def test_r0_to_seeing():


def test_conversion_consistency():
"""
Test internal consistency of conversion by comparing with intermediate steps
"""
cn2 = 5e-13
r0 = atmos_conversions.cn2_to_r0(cn2)
seeing_1 = atmos_conversions.r0_to_seeing(r0)
seeing_2 = atmos_conversions.cn2_to_seeing(cn2)
assert seeing_1 == seeing_2

def test_conversion_consistency_inverse():
"""
Test that the conversions invert correctly
"""
seeing1 = 1.0
cn2 = atmos_conversions.seeing_to_cn2(seeing1)
seeing2 = atmos_conversions.cn2_to_seeing(cn2)
assert seeing1 == seeing2

def test_coherenceTime():
cn2 = numpy.array((5e-13, 1e-14))
Expand Down

0 comments on commit b2368a3

Please sign in to comment.