Ejemplo n.º 1
0
def run(table_type):
    """
    For each entry in validation table, compute sTEC
    Validation run takes a few minutes to complete so results are saved to file.
    :param table_type: (str)
    :return:
    """
    print "Validating against", table_type, "Solar Activity data table"

    # Hard coded solar indices
    if table_type == "High":
        BX = GalileoBroadcast(236.831641, -0.39362878, 0.00402826613)
    elif table_type == "Medium":
        BX = GalileoBroadcast(121.129893, 0.351254133, 0.0134635348)
    elif table_type == "Low":
        BX = GalileoBroadcast(2.580271, 0.127628236, 0.0252748384)
    else:
        raise ValueError(
            'table_type argument must be either "High", "Medium" or "Low"')

    # output variables
    sTECs_expected = []
    sTECs_computed = []

    with open(os.path.join('Validation',
                           table_type + '_reference.dat')) as infile:
        with file(os.path.join('Validation', table_type + '_output.dat'),
                  'w') as outfile:
            writer = csv.writer(outfile, delimiter=' ')
            reader = csv.reader(infile, delimiter=' ')
            for row in reader:
                row = map(float, row)

                mth = int(row[0])
                UT = int(row[1])

                lon1 = row[2]
                lat1 = row[3]
                h1 = row[4] / 1000  # change m to km

                lon2 = row[5]
                lat2 = row[6]
                h2 = row[7] / 1000  # change m to km

                time = NEQTime(mth, UT)
                NEQ_global = NequickG_global(time, BX)
                ray = Ray(h1, lat1, lon1, h2, lat2, lon2)
                stec = NEQ_global.sTEC(ray) / 10**16

                sTECs_computed.append(stec)
                sTECs_expected.append(row[8])
                row.append(stec)

                writer.writerow(row)

                print "Input: ", row[:7]
                print "---Expected: ", row[8], "---Obtained: ", row[9]
    return sTECs_expected, sTECs_computed
Ejemplo n.º 2
0
def plotparameters(TX, BX, path):
    # processing parameters to visualise
    attrs = [
        'foF1', 'foF2', 'foE', 'M3000F2', 'NmF2', 'NmF1', 'NmE', 'hmE', 'hmF1',
        'hmF2', 'modip', 'Az', 'Azr', 'solarsine', 'solarcosine', 'chi',
        'chi_eff', 'H0', 'B1bot', 'B1top', 'B2bot', 'BEtop', 'BEbot', 'A1',
        'A2', 'A3', 'k', 'vTEC', 'seasp'
    ]

    NEQ_global = NequickG_global(TX, BX)

    latlat, lonlon, outs = NEQ_global.map_parameters(attrs,
                                                     -70,
                                                     -180,
                                                     70,
                                                     180,
                                                     resolution=150)

    for i in range(len(outs)):
        plt.figure()
        mapp = Basemap(projection='cyl',llcrnrlat= -90.,urcrnrlat= 90.,\
                  resolution='c',  llcrnrlon=-180.,urcrnrlon=180.)
        #-- draw coastlines, state and country boundaries, edge of map
        mapp.drawcoastlines()
        mapp.drawstates()
        mapp.drawcountries()

        #-- create and draw meridians and parallels grid lines
        mapp.drawparallels(np.arange(-90., 90., 30.),
                           labels=[1, 0, 0, 0],
                           fontsize=10)
        mapp.drawmeridians(np.arange(-180., 180., 30.),
                           labels=[0, 0, 0, 1],
                           fontsize=10)
        xx, yy = mapp(lonlon, latlat)

        # filled contour
        cs = mapp.contourf(xx, yy, outs[i])

        plt.title(attrs[i])
        mapp.colorbar(cs)

        if not os.path.exists(path):
            os.makedirs(path)

        plt.savefig(os.path.join(path, attrs[i] + '.png'))
        plt.close()
Ejemplo n.º 3
0
""" Input Parameters here """
mth = 4
UT = 12
lat = 40
lon = 100
Az = 64

""" Processing Below """
# Create input objects
TX = NEQTime(mth,UT)
BX = GalileoBroadcast(Az,0,0)
RX = Position(lat,lon)

# Create Nequick models
NEQ_global = NequickG_global(TX,BX)
NEQ, Para = NEQ_global.get_Nequick_local(RX)

# Extract information from model
hmin = 100
hmax = 1000
hs = np.arange(hmin, hmax)
N = NEQ.electrondensity(hs)
Azr = Para.Azr

# Plotting
label = ' lat:' + str(lat) + ' lon:' + str(lon)
plt.plot(hs, N, label = label)
plt.plot(Para.hmF2,Para.NmF2 * 10 ** 11, marker = 'o', markersize=5, linestyle='None', label = 'F2 anchor pt')
plt.plot(Para.hmF1,Para.NmF1* 10 ** 11, marker = 'o', markersize=5, linestyle='None', label = 'F1 anchor pt')
plt.plot(Para.hmE,Para.NmE* 10 ** 11, marker = 'o', markersize=5, linestyle='None', label = 'E anchor pt')
Ejemplo n.º 4
0
"""This task demonstrates how to compute slant total electron count"""
from NequickG import NEQTime, Position, GalileoBroadcast
from NequickG_global import NequickG_global, Ray

# Input objects
TX = NEQTime(10,12)
BX = GalileoBroadcast(80,0,0)

# Nequick objects
NEQ_global = NequickG_global(TX, BX)
ray = Ray(100,40,0,1000,40,0)

print NEQ_global.sTEC(ray)
print NEQ_global.sTEC2(ray)

NEQ_global.slant_table(91,ray, 'slant_ray.dat', ex_attr=['foF1', 'foF2', 'foE'])