examples.py 4.98 KB
Newer Older
1
2
3
4
#!/usr/bin/env Python3
from .ciddorModel import Observatory
from .refractionModels import refraction
from .dispersionModels import dispersion
5

6
'''
7
8
9
@ Author: 		Joost van den Born
@ Contact: 		born@astron.nl
@ Description: 	Some functions for quick testing.
10
11
12
'''


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325, 
							H=0.0, xc=450, lat=0, h=0):
	'''
		Function to quickly calculate the refractive index
		of atmospheric air at reference conditions, given 
		a wavelength l.

		Parameters
		----------
		l 	: float
			Wavelength in microns
		conditions: string
			'STANDARD' or 'CERRO_ARMAZONES', refers
			to the standard atmospheric conditions.
		T 	: float (optional)
			Temperature in Kelvin
		p 	: float (optional)
			Atmospheric pressure in Pa
		H 	: float (optional)
			Relative humidity
		xc 	: float (optional)
			CO2 density in parts per million
		lat : float (optional)
			Latitude of the observer in degrees
		h 	: float (optional)
			Altitude of the observer in meters
	
		Returns
		-------
		n 	: 	float
			Refractive index for the given conditions.
	'''
45
46
47
	if conditions == 'STANDARD':
		# Parameters at Cerro Armazones
		T   = 288.15    # k
48
		p   = 101325    # Pa
49
50
51
52
53
54
55
56
		H   = 0.0
		xc  = 450       # ppm
		lat = 0  		# degrees
		h   = 0     	# m
		
	elif conditions == 'CERRO_ARMAZONES':
		# Parameters at Cerro Armazones
		T   = 279.65    # k
57
		p   = 71200     # Pa
58
59
60
61
62
63
64
65
66
		H   = 0.22
		xc  = 450       # ppm
		lat = -24.5983  # degrees
		h   = 3064      # m

	# Initializing dispersion model
	at  = Observatory()

	# Calculating indices of refraction for l
67
	n 	= at.n_tph(l=l, T=T, p=p, RH=H, xc=xc)
68
69
	return n

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

def quick_refraction(l, z, conditions='STANDARD', T=288.15, p=101325, 
							H=0.0, xc=450, lat=0, h=0):
	'''
		Function to quickly calculate the refraction
		of atmospheric air at reference conditions, 
		given a wavelength l.

		Parameters
		----------
		l  	: 	float 
			Wavelength in microns
		z  	: 	float 
			Zenith angle of the observation
		conditions 	: string
			'STANDARD' or 'CERRO_ARMAZONES', refers
			to the standard atmospheric conditions.
		T  	: 	float (optional)
			Temperature in Kelvin
		p  	: 	float (optional)
			Atmospheric pressure in Pa
		H  	: 	float (optional)
			Relative humidity
		xc  : 	float (optional)
			CO2 density in parts per million
		lat : 	float (optional)
			Latitude of the observer in degrees
		h  	: 	float (optional)
			Altitude of the observer in meters
	
		Returns
		-------
		R 	: 	float
			Refraction in degrees
	'''
105
106
107
	if conditions == 'STANDARD':
		# Parameters at Cerro Armazones
		T   = 288.15    # k
108
		p   = 101325    # Pa
109
110
111
112
113
114
115
116
		H   = 0.0
		xc  = 450       # ppm
		lat = 0  		# degrees
		h   = 0     	# m
		
	elif conditions == 'CERRO_ARMAZONES':
		# Parameters at Cerro Armazones
		T   = 279.65    # k
117
		p   = 71200     # Pa
118
119
120
121
122
123
124
125
126
		H   = 0.22
		xc  = 450       # ppm
		lat = -24.5983  # degrees
		h   = 3064      # m

	# Initializing dispersion model
	at  = Observatory()

	# Calculating indices of refraction for l
127
	n 	= at.n_tph(l=l, T=T, p=p, RH=H, xc=xc)
128
129

	# Density of the atmosphere (following CIPM-81/91 equations)
130
	rho = at.rho(p=p, T=T, RH=H, xc=xc)
131
132
133

	# Initializing refraction model and setting the reduced height
	ref = refraction(lat, h)
134
	ref.setReducedHeight(p, rho)
135
136
	return ref.cassini(n, z)

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173

def quick_dispersion(l1, l2, z, conditions='STANDARD', T=288.15, 
						p=101325, H=0.0, xc=450, lat=0, h=0):
	'''
		Function to quickly calculate the dispersion
		of atmospheric air at reference conditions, 
		given a wavelength l.

		Parameters
		----------
		l1 	: 	float
			Shortest wavelength of interest in micron.
		l2 	: 	float
			Longest wavelength of interest in micron.
		z 	: 	float
			Zenith angle of the observation
		conditions 	: string
			'STANDARD' or 'CERRO_ARMAZONES', refers
			to the standard atmospheric conditions.
		T 	: 	float (optional)
			Temperature in Kelvin
		p 	: 	float (optional)
			Atmospheric pressure in Pa
		H 	: 	float (optional)
			Relative humidity
		xc 	: 	float (optional)
			CO2 density in parts per million
		lat : 	float (optional)
			Latitude of the observer in degrees
		h 	: 	float (optional)
			Altitude of the observer in meters
	
		Returns
		-------
		dR 	: float
		 	Atmospheric dispersion in degrees
	'''
174
175
176
	if conditions == 'STANDARD':
		# Parameters at Cerro Armazones
		T   = 288.15    # k
177
		p   = 101325    # Pa
178
179
180
181
182
183
184
185
		H   = 0.0
		xc  = 450       # ppm
		lat = 0  		# degrees
		h   = 0     	# m
		
	elif conditions == 'CERRO_ARMAZONES':
		# Parameters at Cerro Armazones
		T   = 279.65    # k
186
		p   = 71200     # Pa
187
188
189
190
191
192
193
194
195
		H   = 0.22
		xc  = 450       # ppm
		lat = -24.5983  # degrees
		h   = 3064      # m

	# Initializing dispersion model
	at  = Observatory()

	# Calculating indices of refraction for l1 and l2
196
197
	n1 	= at.n_tph(l=l1, T=T, p=p, RH=H, xc=xc)
	n2 	= at.n_tph(l=l2, T=T, p=p, RH=H, xc=xc)
198
199

	# Density of the atmosphere (following CIPM-81/91 equations)
200
	rho = at.rho(p=p, T=T, RH=H, xc=xc)
201
202
203

	# Initializing refraction model and setting the reduced height
	disp = dispersion(lat, h)
204
	disp.setReducedHeight(p, rho)
205
	return disp.cassini(n1, n2, z)