Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit c48b116

Browse files
committed
nans
1 parent 8574236 commit c48b116

File tree

6 files changed

+3057
-32
lines changed

6 files changed

+3057
-32
lines changed

AltitudeProfile.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
p.add_argument('--f107a',type=float,default=200.)
1616
p.add_argument('--ap',type=int,default=4)
1717
p = p.parse_args()
18-
18+
# %% user parameters
1919
altkm = np.arange(p.alt[0], p.alt[1], p.alt[2])
2020
dtime = parse(p.time)
21-
#%%
21+
# %% run IRI90 across altitude
2222
iono = pyiri90.runiri(dtime,altkm,p.latlon,p.f107, p.f107a, ap=p.ap)
23-
23+
# %% plots
2424
pyiri90.plots.plotiono(iono,dtime,p.latlon,p.f107,p.f107a,p.ap)
2525
show()

TimeProfile.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
from dateutil.parser import parse
3+
from datetime import timedelta
4+
from matplotlib.pyplot import show
5+
#
6+
import pyiri90, pyiri90.plots
7+
8+
if __name__ == '__main__':
9+
from argparse import ArgumentParser
10+
p = ArgumentParser()
11+
p.add_argument('-t','--trange',help='START STOP STEP (hours) time [UTC]',nargs=3,
12+
default=('2017-08-01','2017-08-02',1.))
13+
p.add_argument('--alt',help='altitude [km]',type=float, default=150.)
14+
p.add_argument('-c','--latlon',help='geodetic coordinates of simulation',
15+
type=float,default=(65,-147.5))
16+
p.add_argument('--f107',type=float,default=200.)
17+
p.add_argument('--f107a', type=float,default=200.)
18+
p.add_argument('--ap', type=int, default=4)
19+
p = p.parse_args()
20+
# %% user parameters
21+
tlim = (parse(p.trange[0]), parse(p.trange[1]))
22+
dt = timedelta(hours=p.trange[2])
23+
# %% run IRI90 across time
24+
iono = pyiri90.timeprofile(tlim, dt, p.altkm, p.latlon, p.f107, p.f107a, ap=p.ap)
25+
# %% plots
26+
pyiri90.plots.plottime(iono)
27+
show()

fortran/iri90.f

+15-16
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,12 @@ SUBROUTINE IRI90(JF,JMAG,ALATI,ALONG,RZ12,MMDD,DHOUR,
160160

161161
logical, intent(in) :: JF(12)
162162
integer,intent(in) :: JMAG,MMDD
163-
real,intent(in) :: alati,along,rz12
163+
real,intent(in) :: alati,along,rz12, dhour, zkm(nz)
164164
real,intent(out) :: outf(11,nz),oarr(30)
165165

166-
dimension zkm(nz)
167-
character*(*) drect
168-
character*50 path
169-
character*10 filename
166+
character(*) drect
167+
character(50) path
168+
character(10) filename
170169
INTEGER DAYNR,DDO,DO2,SEASON,SEADAY
171170
REAL LATI,LONGI,MO2,MO,MODIP,NMF2,MAGBR
172171
REAL NMF1,NME,NMD,MM,MLAT,MLONG,NOBO2
@@ -432,7 +431,7 @@ SUBROUTINE IRI90(JF,JMAG,ALATI,ALONG,RZ12,MMDD,DHOUR,
432431

433432
8448 write(monito,8449) path
434433
8449 format(' IRI90: File ',A50,'not found')
435-
stop
434+
error stop
436435
C
437436
C LINEAR INTERPOLATION IN SOLAR ACTIVITY
438437
C
@@ -2548,10 +2547,10 @@ SUBROUTINE LNGLSN ( N, A, B, AUS)
25482547
A(N,K) = ( B(K) - AMAX ) / A(K,K)
25492548
ENDIF
25502549
6 CONTINUE
2551-
RETURN
2552-
END
2553-
C
2554-
C
2550+
2551+
END SUBROUTINE LNGLSN
2552+
2553+
25552554
SUBROUTINE LSKNM ( N, M, M0, M1, HM, SC, HX, W, X, Y, VAR, SING)
25562555
C --------------------------------------------------------------------
25572556
C DETERMINES LAY-FUNCTIONS AMPLITUDES FOR A NUMBER OF CONSTRAINTS:
@@ -2999,10 +2998,10 @@ SUBROUTINE CIRA86(IDAY,SEC,GLAT,GLONG,STL,F107A,TINF,TLB,SIGMA)
29992998
TLB = 386.0 * ( 1. + T1+T4+T5+T7+T8 ) * 0.976619
30002999
C Sigma [Eq. A5]
30013000
SIGMA = G0 / ( TINF - TLB )
3002-
RETURN
3003-
END
3004-
C
3005-
C
3001+
3002+
END SUBROUTINE CIRA86
3003+
3004+
30063005
pure real FUNCTION TN(H,TINF,TLBD,S)
30073006
implicit none
30083007

@@ -3016,8 +3015,8 @@ pure real FUNCTION TN(H,TINF,TLBD,S)
30163015
TN = TINF - TLBD * EXP ( - S * ZG2 )
30173016

30183017
END function TN
3019-
C
3020-
C
3018+
3019+
30213020
pure real FUNCTION DTNDH(H,TLBD,S)
30223021
implicit None
30233022

pyiri90/__init__.py

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
IRI-90 international reference ionosphere in Python
33
"""
4+
from datetime import datetime,timedelta
45
from pathlib import Path
56
import numpy as np
67
from xarray import DataArray
@@ -10,23 +11,39 @@
1011
rdir = Path(__file__).parent
1112
Ts = ['Tn','Ti','Te']
1213

13-
def runiri(dt,z,glatlon,f107,f107a,ap):
14+
15+
def datetimerange(start:datetime, end:datetime, step:timedelta) -> list:
16+
"""like range() for datetime!"""
17+
assert isinstance(start, datetime)
18+
assert isinstance(end, datetime)
19+
assert isinstance(step, timedelta)
20+
21+
return [start + i*step for i in range((end-start) // step)]
22+
23+
24+
def runiri(t, altkm:float, glatlon:tuple, f107:float, f107a:float, ap:int):
1425
glat,glon = glatlon
1526
jmag=0 # coordinates are: 0:geographic 1: magnetic
1627

1728
JF = np.array((1,1,1,1,0,1,1,1,1,1,1,0),bool) #Solomon 1993 version of IRI
1829
#JF = (1,1,1) + (0,0,0) +(1,)*14 + (0,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,1,1) #for 2013 version of IRI
1930

31+
monthday = (t.strftime('%m%d'))
32+
hourfrac = t.hour + t.minute//60+ t.second//3600
2033
#%% call IRI
21-
outf,oarr = iri90.iri90(JF,jmag,glat,glon % 360., -f107,
22-
dt.strftime('%m%d'),
23-
dt.hour+dt.minute//60+dt.second//3600,
24-
z,str(rdir/'data')+'/')
34+
outf,oarr = iri90.iri90(JF,jmag,
35+
glat,glon % 360.,
36+
-f107,
37+
monthday,
38+
hourfrac,
39+
altkm,
40+
str(rdir/'data')+'/')
2541
#%% arrange output
2642
iono = DataArray(outf[:9,:].T,
27-
coords={'alt_km':z,
43+
coords={'alt_km':altkm,
2844
'sim':['ne','Tn','Ti','Te','nO+','nH+','nHe+','nO2+','nNO+']},
29-
dims=['alt_km','sim'])
45+
dims=['alt_km','sim'],
46+
attrs={'f107':f107, 'f107a':f107a, 'ap':ap, 'glatlon':glatlon})
3047

3148
# i=(iono['Ti']<iono['Tn']).values
3249
# iono.ix[i,'Ti'] = iono.ix[i,'Tn']
@@ -41,7 +58,12 @@ def runiri(dt,z,glatlon,f107,f107a,ap):
4158
#iono['nN+'] = iono['ne'] * outf[10,:]/100.
4259
# %% negative indicates undefined
4360
for c in iono.sim:
44-
4561
iono.loc[iono.loc[:,c]<= 0., c] = np.nan
4662

4763
return iono
64+
65+
def timeprofile(tlim:tuple, dt:timedelta, altkm:float, glatlon:tuple, f107:float, f107a:float, ap:int):
66+
"""compute IRI90 at a single altiude, over time range"""
67+
68+
t = datetimerange(tlim[0], tlim[1], dt)
69+

0 commit comments

Comments
 (0)