-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflare_param.pro
187 lines (123 loc) · 4.93 KB
/
flare_param.pro
1
2
3
4
5
6
7
8
9
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
; Flare Parameterization for 3D model
;1st method- assuming photoionisation= photoabsoprtion
; sec(zenith angle)=1
;#########################################################################################
;Dave's values
z0=0
n0=2.E19
;maximum absoprtion cross-section equation
; sigmax=(1/no)*exp((zmax-z0)/H)
H=7.e5 ;in cm(=7 km for now)
;##########################################################################################
;MSIS model inputs..............NOT REQUIRED FOR NOW
idate=20031104
i=6.
hour=float(i)+6.
utsec=3600.*hour
z0=40. ;reference altitude
zz=findgen(56)*2.+z0 ;40-150 km
lat=0.
lon=0.
localhour=(((utsec/240. + lon)/15. + 24. ) mod 24.)
f107a=70.
f107=70.
ap=15.
;
;; ##############################################################################################
; Calling the MSIS model for neutral density
;#1 make an file with the inputs to the MSIS model
openw, lun_msisinp,'C:\Users\srimo\Desktop\nrl_files\sav_files\msis_inputs.dat',/get_lun
printf,lun_msisinp,'iyd', 'sec', 'number of altitudes','alt','glat','glong',$
'stl','f107a','f107','ap','mass'
printf,lun_msisinp,idate
printf,lun_msisinp,utsec
printf,lun_msisinp,n_elements(zz)
printf,lun_msisinp,zz
printf,lun_msisinp,lat
printf,lun_msisinp,lon
printf,lun_msisinp,localhour
printf,lun_msisinp,f107a
printf,lun_msisinp,f107
printf,lun_msisinp,ap
printf,lun_msisinp,1.
close, lun_msisinp
;#2 call the fortran wrapper using spawn command
msis_filename='msis_idl_interface.exe' ; fortran executable file/wrapper. KEEP The MSIS files in the same directory as localpe
spawn,msis_filename,result,/noshell
;#3 open the output file generated by fortran MSIS to get the varibles
msis_outdata=dblarr(4,n_elements(zz)) ;4 columns: O, O2 and N2 densitiy and temperature
msis_outfile='C:\Users\srimo\Desktop\nrl_files\sav_files\msis_outputs.dat'
openr, lun_msis, msis_outfile, /get_lun
skip_lun, lun_msis, 1, /lines ; 2 header lines
readf, lun_msis , msis_outdata
free_lun, lun_msis
;#4 save the file data into the local variables
zt=msis_outdata(3,*)
zo=msis_outdata(0,*)
zo2=msis_outdata(1,*)
zn2=msis_outdata(2,*)
;##################################################################################################################################
;n0=zn2[0];reference maximum N2 density
;###################################################################################################################################
;sigmax=(1/no)*exp((zmax-z0)/H) in cm^2
;+> zmax=H*ln[sigmax*n0*H]+z0
;solving for altitude of maximum ionization
; Using the Henke and Fennely cross-section data for cross-sections sigmax
restore, 'C:\Users\srimo\Desktop\nrl_files\sav_files\ion&abs_cross_files.sav' ;from Henke & Fennely
;NOTE file has:
;wave_o,wave_o2,wave_n2
;totionz_o,totionz_o2,totionz_n2
;totabs_o,totabs_o2,totabs_n2
ii_n2=where(totionz_n2 gt 0.0,/null)
sigmax=totionz_n2[ii_n2]
wavemax=wave_n2[ii_n2]
;Theoritical Maximum absorption cross-section for N2 for overhead sun
zmax=(H*alog(sigmax*n0*H)+z0)/(10.^5) ; in km
enermax=12397./wavemax
for i=0, n_elements(zmax)-1 do $
print, zmax[i],wavemax[i],sigmax[i]
; grid vertical resolution =10 km
;ratio of sigma2/sigma1=exp(10/7)=4.01273
;################################################################################################
;zz=58+findgen(7)*7
zz=58+findgen(13)*3.5
;From the actual cross section numbers versus wavelength, what wavelengths should we pick if we want absorption centered at:
;65 km, 72 km, 79 km, 86 km, 93 km and 100 km?
zz_i=fltarr(n_elements(zz))
wave_i=fltarr(n_elements(zz))
sigma_i=fltarr(n_elements(zz))
;Finding the calculated altitude closest to the altitude of interest
for i=0, n_elements(zz)-1 do begin
min_zz=min(abs(zmax-zz[i]),min_ii)
zz_i[i]=zmax[min_ii]
wave_i[i]=wavemax[min_ii]
sigma_i[i]=sigmax[min_ii]
endfor
si=sort(zz_i)
zz_i=zz_i[si]
sigma_i=sigma_i[si]
wave_i=wave_i[si]
ratio_sigma=fltarr(n_elements(zz_i)-1)
print,'Given Altitude','Calculated Altitude ','Wavelength(A)','Cross-section','sigma2/sigma1'
for i=1,n_elements(zz_i)-1 do begin
ratio_sigma[i-1]=sigma_i[i]/sigma_i[i-1]
print, zz[i],zz_i[i],wave_i[i],sigma_i[i], ratio_sigma[i-1]
endfor
;
;#################################################################################################################
;Plots
window, xsize=800, ysize=800,/free
plot, sigmax,zmax,xtitle='cross-sections cm2', ytitle='altitude (km)',psym=2
window, xsize=800, ysize=800,/free
plot, wavemax,zmax,xtitle='wavelength', ytitle='altitude (km)',xr=[0.,100.],/xs,/ys
;##############################################################################################################
;P4: resolution
; 10 km vertical resolution
; starting
;zz_10=z0+findgen(12)*10. ;40-150 km
;sigmax_10=(1./(n0*H))*exp((zz-z0)*(10.^5)/H)
;
;
;
;
end