Esempio n. 1
0
def plot_station_map(show_names=True, mag_list=std_mags):
    '''
    Plot a map of magnetometer stations and radar stations.
    '''

    import matplotlib.pyplot as plt
    from matplotlib.image import imread
    from cartopy import crs

    # Get radar station info:
    radars = load_radar_info()

    # Load magnetometer info:
    mag_info = supermag.read_statinfo()

    # Set up plot of North America:
    #proj = crs.AlbersEqualArea(central_longitude=275,
    #                           standard_parallels=(25.0, 45.0))
    proj = crs.PlateCarree()

    fig = plt.figure(figsize=(10,8.13))
    ax = fig.add_subplot(111, projection=proj)

    # Add map to figure:
    fname = os.path.join(install_dir, 'data', 'NE1_50M_SR_W.tif')
    ax.imshow(imread(fname), origin='upper', transform=crs.PlateCarree(),
              extent=[-180, 180, -90, 90])

    # Add radar stations to figure:
    for r in radars:
        lat,lon=radars[r]
        ax.plot(lon, lat, 'ko', mfc='red', transform=proj)
        if show_names:
            ax.text(lon+.5, lat, r, ha='left', va='top', transform=proj, size=8)
    # Add magnetometers:
    for m in std_mags:
        if m in mag_list:
            mfc = 'blue'
        else:
            mfc = 'grey'
        lon, lat = mag_info[m]['geolon'], mag_info[m]['geolat']
        ax.plot(lon, lat, 'k^', mfc=mfc, transform=proj)
        if show_names:
            ax.text(lon-.5, lat, m, ha='right', va='top', transform=proj, size=8)

    # Customize axes:
    ax.set_extent([-125, -63, 9, 60])
    l1 = ax.plot(0,0, 'ko', mfc='red', transform=proj)
    l2 = ax.plot(0,0, 'k^', mfc='blue')
    l3 = ax.plot(0,0, 'k^', mfc='grey')
    ax.legend(l1+l2+l3, ['Radars', 'Magnetometers', 'Mags: No Data'],
              loc='upper left')
    fig.tight_layout()
    fig.tight_layout()

    return fig
Esempio n. 2
0
def make_Dict(file_name):
    '''
    Make supermagfile, which takes the pickle Dr. Welling created and appends station information
    '''

    #load the pickle information
    supermagfile = pickle.load(open(file_name, 'rb'))

    #load station info
    info = supermag.read_statinfo()
    for s in supermagfile:
        if s in info:
            supermagfile[s]['geolon'] = info[s]['geolon']
            supermagfile[s]['geolat'] = info[s]['geolat']
            supermagfile[s]['name'] = info[s]['station-name']

    return supermagfile
Esempio n. 3
0
iFile
files[iFile]

#get keys from supermag dictionary
mags = supermag.SuperMag(files[iFile])
mags.keys()

#compile a list of stations which were active at the time of the event chosen above
stations = list(mags.keys())[1:]

#determine the time of the event (GMT)
start_time = mags['time'][0]
GMT = start_time + timedelta(hours=5)

#read longitude of stations
stat_info = supermag.read_statinfo()
counter = 0
longitudes = []
while counter < len(stations):
    longitudes.append(stat_info[stations[counter]]['geolon'])
    counter += 1

#for each magentometer in stations list, determine the time of the event at the station
counter = 0
mg_time = []
while counter < len(stations):
    mg_time.append(GMT + timedelta(hours=(longitudes[counter] / 360) * 24))
    counter += 1

#creates a dictionary that maps magnetometers to their respective times
mag_time_dict = dict(zip(stations, mg_time))
Esempio n. 4
0
parser.add_argument("-o", "--outdir", default='mag_compares', help="Set " +
                    "output directory for plots.  Defaults to ./mag_compares")
args = parser.parse_args()


# Post-argument imports:
from spacepy.pybats import bats
from spacepy.plot import style, applySmartTimeTicks

from supermag import SuperMag, read_statinfo

# Turn on Spacepy plot styles:
style()

# Load station info:
mag_info = read_statinfo()

def comp_mag(name, obs, mod, interactive=False):
    '''
    Given a magnetometer with station name "name", compare the
    data and model together and save the plot.
    '''
    import matplotlib.pyplot as plt

    # Create a figure with 3 subplots
    fig = plt.figure(figsize=(10, 10))
    a1, a2, a3 = fig.subplots(3, 1)

    # Loop over field component; plot data v. model for each
    for x1, x2, ax in zip('ned', 'xyz', (a1, a2, a3)):
        # Plot model & data: