-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmspPlot_40.py
131 lines (94 loc) · 5.08 KB
/
dmspPlot_40.py
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
# -*- coding: utf-8 -*-
#Code used for finding RFEs and making the plots used in the Master Theisis of Kristian Reed
#Written by Kristian Reed 10.06.2017
from __future__ import print_function, division
import datetime as dt
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import netcdf
from matplotlib import patheffects as pe
import matplotlib as mpl
import basemag
import cvdm
from davitpy import utils
from davitpy import pydarn
from fanRfe import *
from tools import *
sz = cvdm.journal_sizes.agu(baseFontSize=7)
plt.figure(figsize=(sz.maxwidth, sz.maxwidth*11/8.5), dpi=sz.dpi(sz.maxwidth*11/8.5))
fig=plt.figure()
ax = fig.add_subplot(111)
plt.subplots_adjust(bottom=0.1, left=0.02, top=0.95, right=0.92, wspace=0.01)
map_date_ = dt.datetime(2014, 12, 04, 07, 14)
#f ='./files/dmsp/rfe21_PS.APL_V0116S024CE0008_SC.U_DI.A_GP.F17-SSUSI_PA.APL-SDR-DISK_DD.20141203_SN.41685-00_DF.NC' #my file
f ='./files/dmsp/rfe40_PS.APL_V0116S024CE0008_SC.U_DI.A_GP.F17-SSUSI_PA.APL-SDR-DISK_DD.20141217_SN.41881-00_DF.NC' #my file
map_ = basemag.Basemag(datetime=map_date_, lon_0='mlt', lat_0=90,
width=5e6, height=5e6, resolution='l', ax=ax)
#map_ = utils.mapObj(boundinglat=65., lon_0=270, coords='mlt',datetime=map_date_)
#plt.figure(figsize=(9,9))
title = 'RFE:40 DMSP F17 and SuperDARN 04.12.2014 07:14'
map_.drawcoastlines(linewidth=0.5, zorder=4, color='.7')
map_.fillcontinents(color='0.95')
map_.drawparallels(range(0, 90, 5), color='0.6', coords='mlt', lonlabel=0.5,
lonlabel_kwargs=dict(color='0.6', fontweight='bold',
path_effects=[pe.withStroke(foreground='w', linewidth=sz.lw*4)]))
map_.drawmeridians(range(0, 24, 1), coords='mlt', color='0.6', latmax=85)
ax.set_title(title, loc='left', fontsize='medium')
# SSUSI
fh = netcdf.netcdf_file(f, mmap=False)
lats = fh.variables['PIERCEPOINT_DAY_LATITUDE'].data
lons = fh.variables['PIERCEPOINT_DAY_LONGITUDE'].data
alts = fh.variables['PIERCEPOINT_DAY_ALTITUDE'].data
sc_lat = fh.variables['DMSP_LATITUDE'].data.ravel()
sc_lon = fh.variables['DMSP_LONGITUDE'].data.ravel()
sc_alt = fh.variables['DMSP_ALTITUDE'].data.ravel()
sc_time = [dt.datetime(2014, 12, 04) + dt.timedelta(seconds=x) for x in fh.variables['DMSP_COORDS_TIME'].data.ravel()]
data0 = fh.variables['DISK_INTENSITY_DAY'].data[:, :, 1]
data1 = fh.variables['DISK_INTENSITY_DAY'].data[:, :, 2]
data2 = fh.variables['DISK_INTENSITY_DAY'].data[:, :, 3]
data3 = fh.variables['DISK_INTENSITY_DAY'].data[:, :, 4]
uselats = np.nanmin(lats, axis=0) > 60
N = 1
#for data in [data1, data2, data3]:
for data in [data2]:
p = map_.pcolormesh(lons[:, uselats], lats[:, uselats], data[:, uselats], latlon=True, coords='geo', zorder=1.9,
vmin=0, vmax=1000,
ax=ax, alpha=1/(1*N), cmap='Greens')
p.set_rasterized(True)
N += 1
#===================================================
#Satellite Trajectory
#===================================================
#Add Time tag
for i, time in enumerate(sc_time):
if time.minute % 5 == 0 and time.second == 0:
x, y = map_(sc_lon[i], sc_lat[i], coords='geo')#, height=sc_alt[i])
if map_.llcrnrx < x < map_.urcrnrx and map_.llcrnry < y < map_.urcrnry:
map_.plot(x, y, marker='o', markersize=6, color='b', markeredgecolor='w', zorder=7, ax=ax)
ax.text(x, y, 'DMSP '+'{:%H:%M}'.format(time), color='k', zorder=7, fontsize=3, fontweight='bold',
path_effects=[pe.withStroke(foreground='w', linewidth=2)])
#Add sircle for every minute
for i, time in enumerate(sc_time):
if time.second == 0:
x, y = map_(sc_lon[i], sc_lat[i], coords='geo')#, height=sc_alt[i])
if map_.llcrnrx < x < map_.urcrnrx and map_.llcrnry < y < map_.urcrnry:
map_.plot(x, y, marker='o', markersize=3, color='b', markeredgecolor='w', zorder=7, ax=ax)
#Add satellite track
map_.plot(sc_lon, sc_lat, latlon=True, coords='geo', color='b',# height=sc_alt,
zorder=6, ax=ax, path_effects=[pe.withStroke(foreground='w', linewidth=2)])
#===================================================
#Add SuperDARN Scan
#===================================================
sTime=dt.datetime(2014, 12, 04, 7, 19)
data = pydarn.sdio.radDataRead.radDataOpen(sTime, 'inv', eTime=sTime+dt.timedelta(seconds=60))
scan = data.readScan(firstBeam=0,useEvery=1,showBeams=True)
#fov = pydarn.radar.radFov.fov(site='inv',ngates=scan[0].prm.nrang,coords='mag')
ax2 = fig.add_subplot(111)
intensities,pcoll=overlayFanRfe(scan, map_, fig, 'velocity', coords='mag', gsct=False, site=None,
fov=None, gs_flg=[], fill=True, velscl=500., dist=500.,
cmap='seismic', norm=plt.Normalize(vmin=-500, vmax=500), alpha=0.6)
#Colorbars
cvdm.cbar_below(ax, mappable=p, topOffset=0.01, height=0.015, rasterize=True, ticks=[0, 250, 500, 750, 1000], label='Radiance [R]')
cvdm.cbar_right(ax2, use_ColorbarBase=True, cmap='seismic', norm=plt.Normalize(vmin=-500, vmax=500),
ticks=[-500, -250, 0, 250, 500], label='Velocity [m/s]')
plt.savefig('./dmsp40.pdf', dpi=600)