|
12 | 12 | 'plot_ca_summary', |
13 | 13 | 'plot_bplane', |
14 | 14 | 'plot_earth_impact', |
| 15 | + 'compare_earth_impact', |
15 | 16 | ] |
16 | 17 |
|
17 | 18 | earth_obliq = 84381.448/3600.0*np.pi/180.0 |
@@ -904,3 +905,95 @@ def plot_earth_impact(impact_list, print_ellipse_params=False, sigma_points=None |
904 | 905 | y=0.93) |
905 | 906 | plt.show() |
906 | 907 | return None |
| 908 | + |
| 909 | +def compare_earth_impact(coord1, coord2, sig1, sig2, labels, zoom_size=5.0e3, save_name=None): |
| 910 | + """ |
| 911 | + Show two impact circumstances and compare them. |
| 912 | +
|
| 913 | + Parameters |
| 914 | + ---------- |
| 915 | + coord1 : np.ndarray |
| 916 | + [time, lon, lat] of the first impact |
| 917 | + coord2 : np.ndarray |
| 918 | + [time, lon, lat] of the second impact |
| 919 | + sig1 : np.ndarray |
| 920 | + [time, lon, lat] uncertainty of the first impact |
| 921 | + sig2 : np.ndarray |
| 922 | + [time, lon, lat] uncertainty of the second impact |
| 923 | + labels : list |
| 924 | + List of labels for the two impacts |
| 925 | + zoom_size : float, optional |
| 926 | + Size of the zoomed in plot, in km, by default 5.0e3. |
| 927 | + save_name : str, optional |
| 928 | + Name to save the plots as, by default None. |
| 929 | +
|
| 930 | + Returns |
| 931 | + ------- |
| 932 | + None : NoneType |
| 933 | + None |
| 934 | + """ |
| 935 | + _, lon1, lat1 = coord1 |
| 936 | + _, lon2, lat2 = coord2 |
| 937 | + fig, ax = plt.subplots(1, 3, figsize=(10, 4), dpi=150, gridspec_kw={'width_ratios': [4, 3, 1]}) |
| 938 | + size = zoom_size*1e3 |
| 939 | + m = Basemap(width=size,height=size, |
| 940 | + rsphere=(6378137.00,6356752.3142), |
| 941 | + resolution='i',area_thresh=size/100,projection='lcc', |
| 942 | + lat_0=lat1,lon_0=lon1,ax=ax[0]) |
| 943 | + m.bluemarble() |
| 944 | + m.drawcountries() |
| 945 | + lat_step = lon_step = 3 if zoom_size <= 1e3 else 10 |
| 946 | + if zoom_size <= 500: |
| 947 | + lat_step = lon_step = 1 |
| 948 | + if zoom_size <= 100: |
| 949 | + lat_step = lon_step = 0.5 |
| 950 | + if zoom_size > 5e3: |
| 951 | + lon_step = 20 |
| 952 | + lat_step = 20 |
| 953 | + # draw parallels and meridians. |
| 954 | + parallels = np.arange(-90, 91, lat_step) |
| 955 | + # labels = [left,right,top,bottom] |
| 956 | + m.drawparallels(parallels,labels=[True,False,False,False], color='gray') |
| 957 | + meridians = np.arange(0, 361, lon_step) |
| 958 | + m.drawmeridians(meridians,labels=[False,False,False,True], color='gray') |
| 959 | + x_lon1,y_lat1 = m(lon1,lat1) |
| 960 | + m.plot(x_lon1,y_lat1,'b.') |
| 961 | + x_lon2,y_lat2 = m(lon2,lat2) |
| 962 | + m.plot(x_lon2,y_lat2,'r.') |
| 963 | + # draw line between two points |
| 964 | + m.plot([x_lon1,x_lon2], [y_lat1,y_lat2], 'g--') |
| 965 | + |
| 966 | + # plot error bars for grss solution, and plot GRSS solution |
| 967 | + n_sig = 1 |
| 968 | + deg2m = np.pi/180*6378137.0 |
| 969 | + sig1[1:] *= deg2m |
| 970 | + sig2[1:] *= deg2m |
| 971 | + diff = coord2 - coord1 |
| 972 | + # diff[0] *= 86400*1e3 |
| 973 | + diff[1:] *= deg2m |
| 974 | + diff[1] *= np.cos(lat1*np.pi/180) |
| 975 | + |
| 976 | + # add two subplots |
| 977 | + ax[1].set_xlabel('Longitude Difference [m]') |
| 978 | + ax[1].set_ylabel('Latitude Difference [m]') |
| 979 | + ax[1].errorbar(0.0, 0.0, xerr=sig1[1]*n_sig, yerr=sig1[2]*n_sig, |
| 980 | + fmt='s', capsize=6, markeredgewidth=1.5, lw=1.5, label=labels[0]) |
| 981 | + ax[1].errorbar(diff[1], diff[2], xerr=sig2[1]*n_sig, yerr=sig2[2]*n_sig, |
| 982 | + fmt='o', capsize=6, markeredgewidth=1.5, lw=1.5, label=labels[1]) |
| 983 | + ax[1].legend(ncol=1) |
| 984 | + |
| 985 | + ax[2].set_ylabel('Time Difference [ms]') |
| 986 | + ax[2].errorbar(0.0, 0.0, yerr=sig1[0]*n_sig, |
| 987 | + fmt='s', capsize=6, markeredgewidth=1.5, lw=1.5, label=labels[0]) |
| 988 | + ax[2].errorbar(0.0, diff[0], yerr=sig2[0]*n_sig, |
| 989 | + fmt='o', capsize=6, markeredgewidth=1.5, lw=1.5, label=labels[1]) |
| 990 | + ax[2].set_xticks([]) |
| 991 | + ax[2].yaxis.tick_right() |
| 992 | + ax[2].yaxis.set_label_position('right') |
| 993 | + |
| 994 | + fig.tight_layout() |
| 995 | + if save_name is not None: |
| 996 | + plt.savefig(save_name, bbox_inches='tight') |
| 997 | + plt.suptitle(f'Impact Circumstance Comparison ({n_sig}$\\sigma$)', y=1.05) |
| 998 | + plt.show() |
| 999 | + return None |
0 commit comments