PyGCPM 0.2.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. PyGCPM/GCPM.py +73 -0
  2. PyGCPM/PlotEqSlice.py +118 -0
  3. PyGCPM/PlotMLTSlice.py +129 -0
  4. PyGCPM/PlotPlanet.py +82 -0
  5. PyGCPM/_CFunctions.py +52 -0
  6. PyGCPM/__data/libgcpm/gcpm.py +49 -0
  7. PyGCPM/__data/libgcpm/iri/00readme.txt +114 -0
  8. PyGCPM/__data/libgcpm/iri/IMAZ/00readme_imaz.txt +44 -0
  9. PyGCPM/__data/libgcpm/iri/IMAZ/chapman.prn +361 -0
  10. PyGCPM/__data/libgcpm/iri/IMAZ/press_60deg.txt +111 -0
  11. PyGCPM/__data/libgcpm/iri/IMAZ/press_70deg.txt +111 -0
  12. PyGCPM/__data/libgcpm/iri/ap.dat +17106 -0
  13. PyGCPM/__data/libgcpm/iri/ccir11.asc +715 -0
  14. PyGCPM/__data/libgcpm/iri/ccir12.asc +715 -0
  15. PyGCPM/__data/libgcpm/iri/ccir13.asc +715 -0
  16. PyGCPM/__data/libgcpm/iri/ccir14.asc +715 -0
  17. PyGCPM/__data/libgcpm/iri/ccir15.asc +715 -0
  18. PyGCPM/__data/libgcpm/iri/ccir16.asc +715 -0
  19. PyGCPM/__data/libgcpm/iri/ccir17.asc +715 -0
  20. PyGCPM/__data/libgcpm/iri/ccir18.asc +715 -0
  21. PyGCPM/__data/libgcpm/iri/ccir19.asc +715 -0
  22. PyGCPM/__data/libgcpm/iri/ccir20.asc +715 -0
  23. PyGCPM/__data/libgcpm/iri/ccir21.asc +715 -0
  24. PyGCPM/__data/libgcpm/iri/ccir22.asc +715 -0
  25. PyGCPM/__data/libgcpm/iri/dgrf00.dat +67 -0
  26. PyGCPM/__data/libgcpm/iri/dgrf45.dat +67 -0
  27. PyGCPM/__data/libgcpm/iri/dgrf50.dat +67 -0
  28. PyGCPM/__data/libgcpm/iri/dgrf55.dat +67 -0
  29. PyGCPM/__data/libgcpm/iri/dgrf60.dat +67 -0
  30. PyGCPM/__data/libgcpm/iri/dgrf65.dat +67 -0
  31. PyGCPM/__data/libgcpm/iri/dgrf70.dat +67 -0
  32. PyGCPM/__data/libgcpm/iri/dgrf75.dat +67 -0
  33. PyGCPM/__data/libgcpm/iri/dgrf80.dat +67 -0
  34. PyGCPM/__data/libgcpm/iri/dgrf85.dat +67 -0
  35. PyGCPM/__data/libgcpm/iri/dgrf90.dat +67 -0
  36. PyGCPM/__data/libgcpm/iri/dgrf95.dat +68 -0
  37. PyGCPM/__data/libgcpm/iri/ig_rz.dat +113 -0
  38. PyGCPM/__data/libgcpm/iri/igrf05.dat +68 -0
  39. PyGCPM/__data/libgcpm/iri/igrf05s.dat +47 -0
  40. PyGCPM/__data/libgcpm/iri/ursi11.asc +494 -0
  41. PyGCPM/__data/libgcpm/iri/ursi12.asc +494 -0
  42. PyGCPM/__data/libgcpm/iri/ursi13.asc +494 -0
  43. PyGCPM/__data/libgcpm/iri/ursi14.asc +494 -0
  44. PyGCPM/__data/libgcpm/iri/ursi15.asc +494 -0
  45. PyGCPM/__data/libgcpm/iri/ursi16.asc +494 -0
  46. PyGCPM/__data/libgcpm/iri/ursi17.asc +494 -0
  47. PyGCPM/__data/libgcpm/iri/ursi18.asc +494 -0
  48. PyGCPM/__data/libgcpm/iri/ursi19.asc +494 -0
  49. PyGCPM/__data/libgcpm/iri/ursi20.asc +494 -0
  50. PyGCPM/__data/libgcpm/iri/ursi21.asc +494 -0
  51. PyGCPM/__data/libgcpm/iri/ursi22.asc +494 -0
  52. PyGCPM/__data/libgcpm/libgcpm.dll +0 -0
  53. PyGCPM/__init__.py +36 -0
  54. pygcpm-0.2.0.dist-info/DELVEWHEEL +2 -0
  55. pygcpm-0.2.0.dist-info/METADATA +124 -0
  56. pygcpm-0.2.0.dist-info/RECORD +63 -0
  57. pygcpm-0.2.0.dist-info/WHEEL +5 -0
  58. pygcpm-0.2.0.dist-info/licenses/LICENSE +21 -0
  59. pygcpm.libs/.load-order-pygcpm-0.2.0 +4 -0
  60. pygcpm.libs/libgcc_s_seh-1-f624cec5b9fb488a28f2f75d1732b4c4.dll +0 -0
  61. pygcpm.libs/libgfortran-5-3bdb0dceb16cbf81b3d0a5303ff0ad13.dll +0 -0
  62. pygcpm.libs/libquadmath-0-40baf13904f2d9ff6151bc9f1fc060ca.dll +0 -0
  63. pygcpm.libs/libwinpthread-1-55774e39fda420143ea05738f4fc22a3.dll +0 -0
PyGCPM/GCPM.py ADDED
@@ -0,0 +1,73 @@
1
+ import numpy as np
2
+ from ._CFunctions import _Cgcpm
3
+ import DateTimeTools as TT
4
+
5
+ def GCPM(x,y,z,Date,ut,Kp=1.0,Verbose=False):
6
+ '''
7
+ Calculates the Global Core Plasma Model at some given position(s)
8
+ and time(s).
9
+
10
+ Inputs
11
+ ======
12
+ x : float
13
+ scalar or array of x_SM (Solar Magnetic coordinates) component
14
+ of the position, where units are in R_E.
15
+ y : float
16
+ scalar or array of y_SM
17
+ z : float
18
+ scalar or array of z_SM
19
+ Date : int
20
+ Date(s) in format yyyymmdd
21
+ ut : float
22
+ Time(s) in hours from beginning of day where
23
+ ut = hh + mm/60.0 + ss/3600.0
24
+ Kp : float
25
+ Kp index (or indices)
26
+ Verbose : bool
27
+ If True, model calculation progress will be displayed
28
+
29
+ Returns
30
+ =======
31
+ ne : float32
32
+ Array of electron densities in 1/cm^3
33
+ nH : float32
34
+ Array of proton densities in 1/cm^3
35
+ nHe : float32
36
+ Array of helium ion densities in 1/cm^3
37
+ nO : float 32
38
+ Array of Oxygen densities in 1/cm^3
39
+ '''
40
+
41
+ #reformat the positions
42
+ _x = np.array([x]).flatten().astype('float32')
43
+ _y = np.array([y]).flatten().astype('float32')
44
+ _z = np.array([z]).flatten().astype('float32')
45
+ _n = np.int32(_x.size)
46
+
47
+
48
+ #sort out the dates
49
+ dates = np.zeros(_n,dtype='int32') + Date
50
+ _years = np.int32(dates//10000)
51
+ _dayno = np.int32(TT.DayNo(dates))
52
+
53
+ #times
54
+ _ut = np.zeros(_n,dtype='float32') + ut
55
+
56
+ #Kp indices
57
+ _kp = np.zeros(_n,dtype='float32') + Kp
58
+
59
+ #Verbose flag
60
+ _verb = np.int32(Verbose)
61
+
62
+ #output arrays
63
+ ne = np.zeros(_n,dtype='float32')
64
+ nH = np.zeros(_n,dtype='float32')
65
+ nHe = np.zeros(_n,dtype='float32')
66
+ nO = np.zeros(_n,dtype='float32')
67
+
68
+
69
+ #call the C wrapper
70
+ _Cgcpm(_x,_y,_z,_years,_dayno,_ut,_kp,_n,ne,nH,nHe,nO,_verb)
71
+
72
+ return ne,nH,nHe,nO
73
+
PyGCPM/PlotEqSlice.py ADDED
@@ -0,0 +1,118 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import matplotlib.colors as colors
4
+ from mpl_toolkits.axes_grid1 import make_axes_locatable
5
+ from .PlotPlanet import PlotPlanetXY
6
+ from .GCPM import GCPM
7
+
8
+ def PlotEqSlice(Date,ut,Parameter='ne',Rmax=10.0,dR=0.5,Kp=1.0,fig=None,
9
+ maps=[1,1,0,0],zlog=True,cmap='gnuplot',scale=None,Verbose=False):
10
+ '''
11
+ Plots the GCPM model in the equatorial plane.
12
+
13
+ Inputs
14
+ ======
15
+ Date : int
16
+ Date(s) in format yyyymmdd
17
+ ut : float
18
+ Time(s) in hours from beginning of day where
19
+ ut = hh + mm/60.0 + ss/3600.0
20
+ Parameter : str
21
+ 'ne'|'nH'|'nHe'|'nO'
22
+ Rmax : float
23
+ Limits of the plot
24
+ dR : float
25
+ Size of bins on plot
26
+ Kp : float
27
+ Kp index (or indices)
28
+ fig : object
29
+ This should be either None (to create a new figure), a matplotlib.pyplot
30
+ object (to add a new set of axes to an existing plot) or an
31
+ instance of matplotlib.pyplot.Axes in order to add to an existing
32
+ set of axes.
33
+ maps : list/tuple
34
+ This will determine the position of the subplot on the figure.
35
+ zlog : bool
36
+ If True - the color scale will be logarithmic
37
+ cmap : str
38
+ String to say which colormap to use.
39
+ scale : None or list/tuple
40
+ If None - scale will be generated automatically, otherwise set
41
+ scale = [minimum,maximum]
42
+ Verbose : bool
43
+ If True, model calculation progress will be displayed
44
+
45
+
46
+
47
+ '''
48
+
49
+ #create a grid of points to calculate the model at
50
+ nR = 2*np.int32(Rmax/dR)
51
+ xe = np.linspace(-Rmax,Rmax,nR+1)
52
+ ye = xe
53
+ xc = xe[:-1] + 0.5*dR
54
+ yc = ye[:-1] + 0.5*dR
55
+ xe,ye = np.meshgrid(xe,ye)
56
+ xc,yc = np.meshgrid(xc,yc)
57
+ zc = np.zeros(xc.shape)
58
+
59
+ #calculate the model
60
+ m = GCPM(xc,yc,zc,Date,ut,Kp=Kp,Verbose=Verbose)
61
+
62
+ #get the color bar label
63
+ inf = { 'ne' : (m[0],'$n_e$ (cm$^{-3}$)'),
64
+ 'nH' : (m[0],'$n_H$ (cm$^{-3}$)'),
65
+ 'nHe' : (m[0],'$n_He$ (cm$^{-3}$)'),
66
+ 'nO' : (m[0],'$n_O$ (cm$^{-3}$)')}
67
+ data,zlabel = inf[Parameter]
68
+ data = data.reshape(xc.shape)
69
+
70
+ #get the scale limits
71
+ if scale is None:
72
+ if zlog:
73
+ scale = [np.nanmin(data[data > 0]),np.nanmax(data)]
74
+ else:
75
+ scale = [np.nanmin(data),np.nanmax(data)]
76
+
77
+ if zlog:
78
+ norm = colors.LogNorm(vmin=scale[0],vmax=scale[1])
79
+ else:
80
+ norm = colors.Normalize(vmin=scale[0],vmax=scale[1])
81
+
82
+
83
+
84
+
85
+
86
+
87
+ #create the plot window
88
+ if fig is None:
89
+ fig = plt
90
+ fig.figure()
91
+ if hasattr(fig,'Axes'):
92
+ ax = fig.subplot2grid((maps[1],maps[0]),(maps[3],maps[2]))
93
+ ax.set_xlim([Rmax,-Rmax])
94
+ ax.set_ylim([-Rmax,Rmax])
95
+ ax.set_aspect(1.0)
96
+ else:
97
+ ax = fig
98
+
99
+ #plot the mesh
100
+ sm = ax.pcolormesh(ye,xe,data,cmap=cmap,norm=norm)
101
+
102
+ #plot the planet
103
+ PlotPlanetXY(ax)
104
+
105
+
106
+ #sort the axis labels
107
+ ax.set_ylabel('$x_{SM}$ ($R_E$)')
108
+ ax.set_xlabel('$y_{SM}$ ($R_E$)')
109
+
110
+
111
+
112
+ #colorbar
113
+ divider = make_axes_locatable(ax)
114
+ cax = divider.append_axes("right", size="5%", pad=0.05)
115
+ cbar = plt.colorbar(sm,cax=cax)
116
+ cbar.set_label(zlabel)
117
+
118
+ return ax
PyGCPM/PlotMLTSlice.py ADDED
@@ -0,0 +1,129 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import matplotlib.colors as colors
4
+ from mpl_toolkits.axes_grid1 import make_axes_locatable
5
+ from .PlotPlanet import PlotPlanetXZ
6
+ from .GCPM import GCPM
7
+
8
+ def PlotMLTSlice(MLT,Date,ut,Parameter='ne',Rmax=4.0,dR=0.5,Kp=1.0,fig=None,
9
+ maps=[1,1,0,0],zlog=True,cmap='gnuplot',scale=None,Verbose=False):
10
+ '''
11
+ Plots the GCPM model in the equatorial plane.
12
+
13
+ Inputs
14
+ ======
15
+ MLT: float
16
+ local time to calculate for
17
+ Date : int
18
+ Date(s) in format yyyymmdd
19
+ ut : float
20
+ Time(s) in hours from beginning of day where
21
+ ut = hh + mm/60.0 + ss/3600.0
22
+ Parameter : str
23
+ 'ne'|'nH'|'nHe'|'nO'
24
+ Rmax : float
25
+ Limits of the plot
26
+ dR : float
27
+ Size of bins on plot
28
+ Kp : float
29
+ Kp index (or indices)
30
+ fig : object
31
+ This should be either None (to create a new figure), a matplotlib.pyplot
32
+ object (to add a new set of axes to an existing plot) or an
33
+ instance of matplotlib.pyplot.Axes in order to add to an existing
34
+ set of axes.
35
+ maps : list/tuple
36
+ This will determine the position of the subplot on the figure.
37
+ zlog : bool
38
+ If True - the color scale will be logarithmic
39
+ cmap : str
40
+ String to say which colormap to use.
41
+ scale : None or list/tuple
42
+ If None - scale will be generated automatically, otherwise set
43
+ scale = [minimum,maximum]
44
+ Verbose : bool
45
+ If True, model calculation progress will be displayed
46
+
47
+
48
+
49
+ '''
50
+
51
+ #create a grid of points to calculate the model at
52
+ nR = 2*np.int32(Rmax/dR)
53
+ ze = np.linspace(-Rmax,Rmax,nR+1)
54
+ rhoe = ze
55
+ zc = ze[:-1] + 0.5*dR
56
+ rhoc = rhoe[:-1] + 0.5*dR
57
+ mlt = (MLT - 12.0)* np.pi/12.0
58
+ rhoe,ze = np.meshgrid(rhoe,ze)
59
+ rhoc,zc = np.meshgrid(rhoc,zc)
60
+
61
+ xc = rhoc*np.cos(mlt)
62
+ yc = rhoc*np.sin(mlt)
63
+
64
+ #work out which side the MLT is on the plot
65
+ leftlab = '{:4.1f} MLT'.format(MLT + 12.0 % 24.0)
66
+ rightlab = '{:4.1f} MLT'.format(MLT % 24.0)
67
+
68
+
69
+ #calculate the model
70
+ m = GCPM(xc,yc,zc,Date,ut,Kp=Kp,Verbose=Verbose)
71
+
72
+ #get the color bar label
73
+ inf = { 'ne' : (m[0],'$n_e$ (cm$^{-3}$)'),
74
+ 'nH' : (m[1],'$n_H$ (cm$^{-3}$)'),
75
+ 'nHe' : (m[2],'$n_He$ (cm$^{-3}$)'),
76
+ 'nO' : (m[3],'$n_O$ (cm$^{-3}$)')}
77
+ data,zlabel = inf[Parameter]
78
+ data = data.reshape(xc.shape)
79
+
80
+
81
+ #get the scale limits
82
+ if scale is None:
83
+ if zlog:
84
+ scale = [np.nanmin(data[data > 0]),np.nanmax(data)]
85
+ else:
86
+ scale = [np.nanmin(data),np.nanmax(data)]
87
+
88
+
89
+ if zlog:
90
+ norm = colors.LogNorm(vmin=scale[0],vmax=scale[1])
91
+ else:
92
+ norm = colors.Normalize(vmin=scale[0],vmax=scale[1])
93
+
94
+
95
+
96
+
97
+
98
+ #create the plot window
99
+ if fig is None:
100
+ fig = plt
101
+ fig.figure()
102
+ if hasattr(fig,'Axes'):
103
+ ax = fig.subplot2grid((maps[1],maps[0]),(maps[3],maps[2]))
104
+ ax.set_ylim([Rmax,-Rmax])
105
+ ax.set_xlim([-Rmax,Rmax])
106
+ ax.set_aspect(1.0)
107
+ else:
108
+ ax = fig
109
+
110
+ #plot the mesh
111
+ sm = ax.pcolormesh(rhoe,ze,data,cmap=cmap,norm=norm)
112
+
113
+ #plot the planet
114
+ PlotPlanetXZ(ax,NoBlack=True)
115
+
116
+
117
+ #sort the axis labels
118
+ ax.set_xlabel(r'$\rho_{SM}$ ($R_E$)')
119
+ ax.set_ylabel('$z_{SM}$ ($R_E$)')
120
+
121
+
122
+
123
+ #colorbar
124
+ divider = make_axes_locatable(ax)
125
+ cax = divider.append_axes("right", size="5%", pad=0.05)
126
+ cbar = plt.colorbar(sm,cax=cax)
127
+ cbar.set_label(zlabel)
128
+
129
+ return ax,xc,yc,zc,m
PyGCPM/PlotPlanet.py ADDED
@@ -0,0 +1,82 @@
1
+ import numpy as np
2
+
3
+ def PlotPlanetXZ(fig,R=1.0,Center=[0.0,0.0,0.0],zorder=10,NoBlack=False,NoonTop=True):
4
+
5
+
6
+ a = 2*np.pi*np.arange(361,dtype='float32')/360
7
+ x = R*np.sin(a) + Center[0]
8
+ z = R*np.cos(a) + Center[2]
9
+
10
+ if NoonTop:
11
+ fig.fill(z,x,color=[1.0,1.0,1.0],zorder=zorder)
12
+ fig.plot(z,x,color=[0,0,0],zorder=zorder+1)
13
+ if NoBlack == False:
14
+ fig.fill(z[180:360],x[180:360],color=[0.0,0.0,0.0],zorder=zorder+1)
15
+ else:
16
+ fig.fill(x,z,color=[1.0,1.0,1.0],zorder=zorder)
17
+ fig.plot(x,z,color=[0,0,0],zorder=zorder+1)
18
+ if NoBlack == False:
19
+ fig.fill(x[180:360],z[180:360],color=[0.0,0.0,0.0],zorder=zorder+1)
20
+
21
+
22
+ def PlotPlanetXY(fig,R=1.0,Center=[0.0,0.0,0.0],zorder=10,NoBlack=False,NoonTop=True):
23
+ a = 2*np.pi*np.arange(361,dtype='float32')/360
24
+ x = R*np.sin(a) + Center[0]
25
+ y = R*np.cos(a) + Center[1]
26
+
27
+ if NoonTop:
28
+ fig.fill(y,x,color=[1.0,1.0,1.0],zorder=zorder)
29
+ fig.plot(y,x,color=[0,0,0],zorder=zorder+1)
30
+ if NoBlack == False:
31
+ fig.fill(y[180:360],x[180:360],color=[0.0,0.0,0.0],zorder=zorder+1)
32
+ else:
33
+ fig.fill(x,y,color=[1.0,1.0,1.0],zorder=zorder)
34
+ fig.plot(x,y,color=[0,0,0],zorder=zorder+1)
35
+ if NoBlack == False:
36
+ fig.fill(x[180:360],y[180:360],color=[0.0,0.0,0.0],zorder=zorder+1)
37
+
38
+ def PlotPlanetYZ(fig,R=1.0,Center=[0.0,0.0,0.0],Side='day',zorder=10,NoFill=False,Color=[0.0,0.0,0.0],linestyle='-'):
39
+
40
+ a = 2*np.pi*np.arange(361,dtype='float32')/360
41
+ y = R*np.sin(a) + Center[1]
42
+ z = R*np.cos(a) + Center[2]
43
+
44
+ if NoFill == False:
45
+ if Side == 'day':
46
+ fig.fill(y,z,color=[1.0,1.0,1.0],zorder=zorder)
47
+ else:
48
+ fig.fill(y,z,color=[0.0,0.0,0.0],zorder=zorder)
49
+ fig.plot(y,z,color=Color,zorder=zorder+1,linestyle='-')
50
+
51
+ def PlotPlanetCoreXZ(ax,R=1.0,Center=[0.0,0.0,0.0],Colors=([1.0,0.7,0.0,0.5],[1.0,0.2,0.0,0.5],[0.5,0.5,0.5,0.5]),Layers=(0.0,0.832,1.0),zorder=1.0,NoFill=False,linestyle='-',linewidth=2.0):
52
+ '''
53
+ Plots the different layers of hte planet
54
+ '''
55
+
56
+ a = 2*np.pi*np.arange(361,dtype='float32')/360
57
+
58
+ nl = len(Layers)
59
+ if NoFill:
60
+ for i in range(0,nl):
61
+ x = Layers[i]*R*np.sin(a) + Center[0]
62
+ z = Layers[i]*R*np.cos(a) + Center[2]
63
+ ax.plot(x,z,color=Colors[i],zorder=zorder,linestyle=linestyle,linewidth=linewidth)
64
+ else:
65
+ for i in range(0,nl-1):
66
+ l0 = Layers[i]
67
+ l1 = Layers[i+1]
68
+ x0 = l0*R*np.sin(a) + Center[0]
69
+ z0 = l0*R*np.cos(a) + Center[2]
70
+ x1 = l1*R*np.sin(a) + Center[0]
71
+ z1 = l1*R*np.cos(a) + Center[2]
72
+
73
+ if l0 == 0.0:
74
+ ax.fill(x1,z1,color=Colors[i],zorder=zorder,linewidth=0.0)
75
+ else:
76
+ x = np.append(x0,x1[::-1])
77
+ z = np.append(z0,z1[::-1])
78
+ ax.fill(x,z,color=Colors[i],zorder=zorder,linewidth=0.0)
79
+
80
+ x = R*np.sin(a) + Center[0]
81
+ z = R*np.cos(a) + Center[2]
82
+ ax.plot(x,z,color=Colors[-1],linestyle=linestyle,linewidth=linewidth,zorder=zorder)
PyGCPM/_CFunctions.py ADDED
@@ -0,0 +1,52 @@
1
+ import numpy as np
2
+ import ctypes as ct
3
+ from pathlib import Path
4
+ import sys
5
+
6
+ #some ctypes
7
+ c_str = ct.c_char_p
8
+ c_bool = ct.c_bool
9
+ c_int = ct.c_int
10
+ c_float = ct.c_float
11
+ c_double = ct.c_double
12
+ c_int_ptr = np.ctypeslib.ndpointer(ct.c_int,flags="C_CONTIGUOUS")
13
+ c_float_ptr = np.ctypeslib.ndpointer(ct.c_float,flags="C_CONTIGUOUS")
14
+ c_double_ptr = np.ctypeslib.ndpointer(ct.c_double,flags="C_CONTIGUOUS")
15
+
16
+ #get the path of the library
17
+ libpath = Path(__file__).resolve().parent / "__data" / "libgcpm"
18
+ if sys.platform == "win32":
19
+ library = libpath / "libgcpm.dll"
20
+ elif sys.platform == "darwin":
21
+ library = libpath / "libgcpm.dylib"
22
+ else:
23
+ library = libpath / "libgcpm.so"
24
+
25
+ libgcpm = ct.CDLL(str(library))
26
+
27
+
28
+
29
+ #define the functions and their arguments
30
+ #This is the model wrapper function
31
+ _Cgcpm = libgcpm.GCPM
32
+ _Cgcpm.restype = None
33
+ _Cgcpm.argtypes = [ c_float_ptr, #x
34
+ c_float_ptr, #y
35
+ c_float_ptr, #z
36
+ c_int_ptr, #year
37
+ c_int_ptr, #day number
38
+ c_float_ptr, #ut in hours
39
+ c_float_ptr, #kp index
40
+ c_int, #number of positions to calculate density
41
+ c_float_ptr, #electron density
42
+ c_float_ptr, #proton density
43
+ c_float_ptr, #helium density
44
+ c_float_ptr, #oxygen density
45
+ c_int] #verbosity flag
46
+
47
+ #This will set the path of the model so it can find the data files
48
+ _Csetpath = libgcpm.setLibPath
49
+ _Csetpath.restype = None
50
+ _Csetpath.argtypes = [c_str]
51
+
52
+ _Csetpath(c_str((str(libpath) + "/").encode("utf-8")))
@@ -0,0 +1,49 @@
1
+ import numpy as np
2
+ import ctypes as ct
3
+ import DateTimeTools as TT
4
+
5
+ c_str = ct.c_char_p
6
+ c_bool = ct.c_bool
7
+ c_int = ct.c_int
8
+ c_float = ct.c_float
9
+ c_double = ct.c_double
10
+ c_int_ptr = np.ctypeslib.ndpointer(ct.c_int,flags="C_CONTIGUOUS")
11
+ c_float_ptr = np.ctypeslib.ndpointer(ct.c_float,flags="C_CONTIGUOUS")
12
+ c_double_ptr = np.ctypeslib.ndpointer(ct.c_double,flags="C_CONTIGUOUS")
13
+
14
+ lib = ct.CDLL('./libgcpm.so')
15
+ _Fgcpm = lib.gcpm_v24_
16
+ _Fgcpm.restype = None
17
+ _Fgcpm.argtypes = [ c_int_ptr,
18
+ c_float_ptr,
19
+ c_float_ptr,
20
+ c_float_ptr,
21
+ c_float_ptr,
22
+ c_float_ptr]
23
+
24
+ _Csetpath = lib.setLibPath
25
+ _Csetpath.restype = None
26
+ _Csetpath.argtypes = [c_str]
27
+
28
+ def gcpm(x,y,z,Date,ut,kp=1.0):
29
+
30
+ #set the path
31
+ path = '/home/matt/gcpm/src/'
32
+ c_path = ct.c_char_p(path.encode('utf-8'))
33
+ _Csetpath(c_path)
34
+
35
+ #convert date and time
36
+ doy = TT.DayNo(Date)
37
+ h,m,s = TT.DectoHHMM(ut,Split=True,ss=True)
38
+
39
+ itime = np.array([(Date // 10000)*1000 + doy,1000*(h*3600 + m*60 + s)],dtype='int32')
40
+ r = np.array([np.sqrt(x**2 + y**2 + z**2)],dtype='float32')
41
+ rho = np.sqrt(x**2 + y**2)
42
+ amlt = ((np.array([np.arctan2(-y,-x)*12/np.pi],dtype='float32') + 24.0) % 24.0)
43
+ alatr = np.array([np.arcsin(z/rho)],dtype='float32')
44
+ akp = np.array([kp],dtype='float32')
45
+
46
+ out = np.zeros(4,dtype='float32')
47
+ _Fgcpm(itime,r,amlt,alatr,akp,out)
48
+
49
+ return out
@@ -0,0 +1,114 @@
1
+ International Reference Ionosphere 2007 (IRI2007) Software
2
+ ----------------------------------------------------------
3
+
4
+ ================================================================================
5
+ IMPORTANT: Updates and new versions of the IRI programs will be reported through
6
+ the IRInfo electronic mailer distribution. To subscribe send e-mail to
7
+ Majordomo@nssdc.gsfc.nasa.gov with the following text in the body of the
8
+ message: subscribe iri (use 'unsubscribe' to remove yourself from the list)
9
+ ================================================================================
10
+
11
+ The IRI is a joined project of the Committee on Space Research (COSPAR) and the
12
+ International Union of Radio Science (URSI). IRI is an empirical model specifying
13
+ monthly averages of electron density, ion composition, electron temperature, and
14
+ ion temperature in the altitude range from 50 km to 1500 km.
15
+
16
+ This directory includes the FORTRAN program, coefficients, and indices files for
17
+ the latest version of the International Reference Ionosphere model: IRI2007. This
18
+ version includes several options for different parts and parameters. A logical
19
+ array JF(30) is used to set these options. The IRI-recommended set of options
20
+ can be found in the COMMENT section at the beginning of IRISUB.FOR. IRITEST.FOR
21
+ sets these options as the default.
22
+
23
+ The compilation/link command in Fortran 77 is:
24
+ f77 -o iri iritest.for irisub.for irifun.for iritec.for iridreg.for igrf.for cira.for
25
+
26
+ ================================================================================
27
+ IMPORTANT: Please note that the following files have NOT been changed and are the
28
+ same as for IRI2001: CCIR%%, URSI%%, DGRF45-DGRF95,
29
+ ================================================================================
30
+
31
+ Directory Contents:
32
+ -----------------------------------------------------------------------------------
33
+
34
+ 00_iri2007.tar TAR file that includes all files from this directory. Was created
35
+ in UNIX using 'tar -cvf 00_iri2007.tar *'. UNIX command to unpack
36
+ is "tar -xvf 00_iri2007.tar".
37
+
38
+ irisub.for This file contains the main subroutine iri_sub. It computes
39
+ height profiles if IRI output parameters (Ne, Te, Ti, Ni, vi)
40
+ for specified date and location. Also included is the
41
+ subroutine iri_web that computes output parameters versus
42
+ latitude, longitude (geog. or geom.), year, day of year, hour
43
+ (LT or UT), and month. An example of how to call and use iri_web
44
+ is shown in iritest.for. Compilation of iritest.for requires
45
+ irisub.for, irifun.for, iritec.for, iridreg.for, igrf.for, and
46
+ cira.for.
47
+
48
+ irifun.for This file contains the subroutines and functions that are
49
+ required for running IRI.
50
+
51
+ iridreg.for Subroutines for the D region models of Friedrich-Torkar
52
+ and of Danilov et al.
53
+
54
+ iritec.for This file includes the subroutines for computing the ionospheric
55
+ electron content from 60km up to a specified upper limit.
56
+
57
+ cira.for This file includes the subroutines and functions for computing
58
+ the COSPAR International Reference Ionosphere 1986 (CIRA-86)
59
+ neutral temperature.
60
+
61
+ igrf.for This file includes the subroutines for the International
62
+ Geomagnetic Reference Field (IGRF).
63
+
64
+ dgrf%%.dat Definitive IGRF coefficients for the years 1945 to 2000 in steps
65
+ of 5 years (%%=45, 50, etc.)(ASCII).
66
+ igrf05.dat IGRF coefficients for 2005 (ASCII).
67
+ igrf05s.dat IGRF coefficients for 2005-2010 (ASCII).
68
+
69
+ iritest.for Test program indicating how to use of the IRI subroutines.
70
+ Requires irisub, irifun, iritec, iridreg, igrf,and cira.
71
+
72
+ input.txt Input parameters for a few examples using the iritest.for program.
73
+ output.txt Output from the test program for the input.txt input parameters.
74
+
75
+ ig_rz.dat This file contains the solar and ionospheric indices (IG12, Rz12)
76
+ for the time period from Jan 1958 onward. The file is updated
77
+ quarterly. It is read by subroutine tcon in irifun.for (ASCII).
78
+
79
+ ap.dat This file provides the 3-hour ap magnetic index and F10.7 daily
80
+ index from 1960 onward (ASCII).
81
+
82
+ CCIR%%.ASC, Coefficient files for the global representation of the F2 peak
83
+ URSI%%.ASC peak parameters (foF2, M3000) where %% = Month+10 (ASCII). CCIR is
84
+ the model recommended by the International Committee Consultative
85
+ on Radiocommunication (CCIR) of the International Union of
86
+ Telecommunication (ITU). URSI is the model recommended by the
87
+ International Union of Radio Science. IRI recommends the CCIR
88
+ model for the continents and the URSI model for the ocean areas.
89
+ If a single model is needed globally URSI is recommended.
90
+
91
+ Stand-alone Programs:
92
+
93
+ IMAZ The Ionospheric model for the Auroral Zone (IMAZ) specifies the
94
+ electron density in the auroral E-region using a NeuralNet
95
+ approach and expecting as input (auroral) latitude, longitude, year,
96
+ day of year, hour, 3-hourly Ap, daily F10.7, and riometer
97
+ absoprtion as an optional input if available. Consist of the
98
+ following files iri_imaz.for, imaztest.for, chapman.prn,
99
+ press_60deg.txt, press_70deg.txt, and 00readme_imaz.txt.
100
+
101
+ akebono_te.for Model for the plasmspheric electron temperature based on Akebono
102
+ measurements. The file includes the model subroutines and
103
+ coefficients and a simple driver program to illustrate its usage.
104
+ -----------------------------------------------------------------------------------
105
+
106
+ Please consult the 'listing of changes' in the comments section at the top
107
+ of each one of these programs for recent corrections and improvements.
108
+
109
+ More information about the IRI project can be found at
110
+ http://modelweb.gsfc.nasa.gov/ionos/iri.html
111
+ IRI parameters can be calculated and plotted online at
112
+ http://modelweb.gsfc.nasa.gov/models/iri.html
113
+
114
+ ------------------------ dieter bilitza ------------------ May 2007
@@ -0,0 +1,44 @@
1
+ README FILE
2
+
3
+ IMAZ � Ionospheric Model for the Auroral Zone
4
+
5
+ Lee-Anne McKinnell, April 2007
6
+
7
+ (1) IMAZ has been developed for the purpose of obtaining prediction for the
8
+ electron density in the auroral zone. It is implemented as a
9
+ separate option within IRI.
10
+
11
+ (2) IMAZ is valid for the Auroral Zone latitudes (around 70 degrees), and for
12
+ the altitude range from 50 km to about 150 km.
13
+
14
+ (3) A program, called IMAZTEST.FOR, has been provided for testing the implementation.
15
+
16
+ (4) The main IMAZ subroutines are contained in a file called IRI_IMAZ.FOR, which
17
+ should be linked to IMAZTEST.FOR when compiling.
18
+
19
+ (5) The following files are required by IRI_IMAZ.FOR: a) nighttruequiet.txt �
20
+ which is required for determining the rest absorption in the case where absorption
21
+ is considered as an input; b) chapman.prn � the chapman function is also required
22
+ for determining the rest absorption; c) press_70deg.txt & press_60deg.txt �
23
+ required for converting from pressure to altitude and back again, the model is
24
+ developed using the pressure levels as an input, but the user friendly output is by
25
+ altitude level;
26
+
27
+ (6) The following inputs to the model are required: a) Geographic
28
+ Latitude; b) Geographic Longitude; c) Year; d) day number; e) hour, in universal
29
+ time (UT); f) the riometer absorption (if this is not available, enter -1 and
30
+ the version that does not require this input will be used); g) the 3-hourly
31
+ planetary magnetic A index; h) the daily F10.7 solar flux value; i) the altitude
32
+ for which the electron density is required (if the entire profile from 50 km to
33
+ about 150 km is required, then enter -1);
34
+
35
+ (7) The output file contains 11 columns, the first 8 being the inputs,
36
+ then the altitude in km, the predicted electron density and the error on the log
37
+ of the predicted electron density. The density is
38
+
39
+ (8) Note that the electron density is given as the logarithm (to base 10) of the
40
+ electron density in [cm-3].
41
+
42
+ Reference:
43
+ McKinnel, L.A. and M. Friedrich, Results from a new lower ionosphere model,
44
+ Adv. Space Res., 37, #5, 1045-1050, 2006.