4
4
from astropy import constants as const
5
5
from astropy .coordinates import SkyCoord
6
6
from astropy .io import fits
7
- from astropy .time import Time
8
7
from astropy import units as u
9
- import astropy .wcs
10
8
from astropy .wcs import WCS
11
9
from matplotlib import colors
12
10
from matplotlib .patches import Ellipse
@@ -117,8 +115,7 @@ def make_overlay_usr(source, src_basename, cube_params, patch, opt, base_contour
117
115
# Plot negative contours
118
116
if np .nanmin (hdulist_hi [0 ].data ) < - base_contour and np .isfinite (base_contour ):
119
117
ax1 .contour (hdulist_hi [0 ].data , cmap = 'BuPu_r' , linewidths = 1.2 , linestyles = 'dashed' ,
120
- levels = - base_contour * 2 ** np .arange (10 , - 1 , - 1 ),
121
- transform = ax1 .get_transform (cubew ))
118
+ levels = - base_contour * 2 ** np .arange (10 , - 1 , - 1 ), transform = ax1 .get_transform (cubew ))
122
119
ax1 .text (0.5 , 0.05 , nhi_labels , ha = 'center' , va = 'center' , transform = ax1 .transAxes ,
123
120
color = 'white' , fontsize = 22 )
124
121
ax1 .add_patch (Ellipse ((0.92 , 0.9 ), height = patch ['height' ], width = patch ['width' ], angle = cube_params ['bpa' ],
@@ -190,8 +187,6 @@ def make_overlay(source, src_basename, cube_params, patch, opt, base_contour, sp
190
187
ax1 = fig .add_subplot (111 , projection = owcs )
191
188
if survey == 'hst' :
192
189
plot_labels (source , ax1 , cube_params ['default_beam' ], x_color = 'w' )
193
- # ax1.imshow(opt[0].data, origin='lower', cmap='twilight', norm=LogNorm(vmax=5))
194
- # ax1.imshow(opt[0].data, origin='lower', cmap='Greys', norm=LogNorm(vmin=-0.003, vmax=30))
195
190
ax1 .imshow (opt [0 ].data , origin = 'lower' , cmap = 'Greys' ,
196
191
norm = PowerNorm (gamma = 0.4 , vmin = np .percentile (opt [0 ].data , 20 ),
197
192
vmax = np .percentile (opt [0 ].data , 99.5 )))
@@ -295,10 +290,10 @@ def make_mom0(source, src_basename, cube_params, patch, opt_head, base_contour,
295
290
ax1 .text (0.5 , 0.05 , nhi_labels , ha = 'center' , va = 'center' , transform = ax1 .transAxes , fontsize = 22 )
296
291
ax1 .add_patch (Ellipse ((0.92 , 0.9 ), height = patch ['height' ], width = patch ['width' ], angle = cube_params ['bpa' ],
297
292
transform = ax1 .transAxes , facecolor = 'darkorange' , edgecolor = 'black' , linewidth = 1 ))
298
- cb_ax = fig .add_axes ([0.91 , 0.11 , 0.02 , 0.76 ])
293
+ cb_ax = fig .add_axes ([0.915 , 0.11 , 0.02 , 0.76 ])
299
294
cbar = fig .colorbar (im , cax = cb_ax )
300
295
cbar .set_label ("Total Intensity [{}]" .format (hdulist_hi [0 ].header ['bunit' ]), fontsize = 22 )
301
- cbar .ax .tick_params (labelsize = 22 )
296
+ cbar .ax .tick_params (labelsize = 22 , length = 6 , width = 2 )
302
297
# Prevent cbar label from getting too wide e.g. when in Jy/beam Hz units
303
298
cbar .formatter .set_powerlimits ((0 , 3 ))
304
299
ot = cbar .ax .yaxis .get_offset_text ()
@@ -375,7 +370,6 @@ def make_snr(source, src_basename, cube_params, patch, opt_head, base_contour, s
375
370
norm = colors .BoundaryNorm (boundaries , wa_cmap .N , clip = True )
376
371
fig = plt .figure (figsize = (8 , 8 ))
377
372
ax1 = fig .add_subplot (111 , projection = owcs )
378
- # ax1 = fig.add_subplot(111, projection=hiwcs)
379
373
plot_labels (source , ax1 , cube_params ['default_beam' ])
380
374
ax1 .set (facecolor = "white" ) # Doesn't work with the color im
381
375
im = ax1 .imshow (np .abs (snr ), cmap = wa_cmap , origin = 'lower' , norm = norm , transform = ax1 .get_transform (cubew ))
@@ -384,10 +378,10 @@ def make_snr(source, src_basename, cube_params, patch, opt_head, base_contour, s
384
378
ax1 .text (0.5 , 0.05 , nhi_label , ha = 'center' , va = 'center' , transform = ax1 .transAxes , fontsize = 22 )
385
379
ax1 .add_patch (Ellipse ((0.92 , 0.9 ), height = patch ['height' ], width = patch ['width' ], angle = cube_params ['bpa' ],
386
380
transform = ax1 .transAxes , facecolor = 'gold' , edgecolor = 'indigo' , linewidth = 1 ))
387
- cb_ax = fig .add_axes ([0.91 , 0.11 , 0.02 , 0.76 ])
381
+ cb_ax = fig .add_axes ([0.915 , 0.11 , 0.02 , 0.76 ])
388
382
cbar = fig .colorbar (im , cax = cb_ax )
389
383
cbar .set_label ("Pixel SNR" , fontsize = 22 )
390
- cbar .ax .tick_params (labelsize = 22 )
384
+ cbar .ax .tick_params (labelsize = 22 , length = 6 , width = 2 )
391
385
392
386
ax1 .set_xlim (0 , opt_head ['NAXIS1' ])
393
387
ax1 .set_ylim (0 , opt_head ['NAXIS2' ])
@@ -538,11 +532,11 @@ def make_mom1(source, src_basename, cube_params, patch, opt_head, opt_view, base
538
532
levels = [v_sys - 3 * vunit , v_sys - 2 * vunit , v_sys - 1 * vunit , v_sys , v_sys + 1 * vunit , v_sys + 2 * vunit , v_sys + 3 * vunit ]
539
533
clevels = ['white' , 'lightgray' , 'dimgrey' , 'black' , 'dimgrey' , 'lightgray' , 'white' ]
540
534
if not singlechansource :
541
- cf = ax1 .contour (mom1_d , colors = clevels , levels = levels , linewidths = 0.6 , transform = ax1 .get_transform (cubew ))
535
+ cf = ax1 .contour (mom1_d , colors = clevels , levels = levels , linewidths = 1.0 , transform = ax1 .get_transform (cubew ))
542
536
543
537
v_sys_label = "$v_{{center}}$ = {} km/s" .format (int (v_sys ))
544
538
if source ['id' ] != 0 :
545
- v_sys_label = "$v_ {{sys}}$ = {} km/s" .format (int (v_sys ))
539
+ v_sys_label = "$cz_ {{sys}}$ = {} km/s" .format (int (v_sys ))
546
540
547
541
if source ['id' ] != 0 :
548
542
# Plot kin_pa from HI center of galaxy; calculate end points of line
@@ -581,12 +575,12 @@ def make_mom1(source, src_basename, cube_params, patch, opt_head, opt_view, base
581
575
transform = ax1 .transAxes , color = 'black' , fontsize = 22 , rotation = 90 )
582
576
ax1 .add_patch (Ellipse ((0.92 , 0.9 ), height = patch ['height' ], width = patch ['width' ], angle = cube_params ['bpa' ],
583
577
transform = ax1 .transAxes , edgecolor = 'darkred' , linewidth = 1 ))
584
- cb_ax = fig .add_axes ([0.91 , 0.11 , 0.02 , 0.76 ])
578
+ cb_ax = fig .add_axes ([0.915 , 0.11 , 0.02 , 0.76 ])
585
579
cbar = fig .colorbar (im , cax = cb_ax )
586
580
if not singlechansource :
587
581
cbar .add_lines (cf )
588
582
cbar .set_label (cbar_label , fontsize = 22 )
589
- cbar .ax .tick_params (labelsize = 22 )
583
+ cbar .ax .tick_params (labelsize = 22 , length = 6 , width = 2 )
590
584
591
585
ax1 .set_xlim (0 , opt_head ['NAXIS1' ])
592
586
ax1 .set_ylim (0 , opt_head ['NAXIS2' ])
@@ -684,18 +678,18 @@ def make_mom2(source, src_basename, cube_params, patch, opt_head, base_contour,
684
678
levels = np .arange (vunit ,vel_max ,vunit )
685
679
# clevels = ['white', 'lightgray', 'dimgrey', 'black', 'dimgrey', 'lightgray', 'white']
686
680
if not singlechansource :
687
- cf = ax1 .contour (mom2_d , levels = levels , colors = ['k' , ], linewidths = 0.6 , transform = ax1 .get_transform (cubew ))
681
+ cf = ax1 .contour (mom2_d , levels = levels , colors = ['k' , ], linewidths = 1.0 , transform = ax1 .get_transform (cubew ))
688
682
v_disp_label = r"$\Delta \sigma_{{contours}}$ = {} km/s" .format (int (vunit ))
689
683
690
684
ax1 .text (0.5 , 0.05 , v_disp_label , ha = 'center' , va = 'center' , transform = ax1 .transAxes , color = 'black' , fontsize = 22 )
691
685
ax1 .add_patch (Ellipse ((0.92 , 0.9 ), height = patch ['height' ], width = patch ['width' ], angle = cube_params ['bpa' ],
692
686
transform = ax1 .transAxes , facecolor = '#4199B5' , edgecolor = '#D8424D' , linewidth = 1 ))
693
- cb_ax = fig .add_axes ([0.91 , 0.11 , 0.02 , 0.76 ])
687
+ cb_ax = fig .add_axes ([0.915 , 0.11 , 0.02 , 0.76 ])
694
688
cbar = fig .colorbar (im , cax = cb_ax )
695
689
if not singlechansource :
696
690
cbar .add_lines (cf )
697
691
cbar .set_label (cbar_label , fontsize = 22 )
698
- cbar .ax .tick_params (labelsize = 22 )
692
+ cbar .ax .tick_params (labelsize = 22 , length = 6 , width = 2 )
699
693
700
694
ax1 .set_xlim (0 , opt_head ['NAXIS1' ])
701
695
ax1 .set_ylim (0 , opt_head ['NAXIS2' ])
@@ -856,7 +850,6 @@ def make_pv(source, src_basename, cube_params, opt_view=6*u.arcmin, spec_line=No
856
850
all_colors = np .vstack ((colors_noise , colors_galaxy ))
857
851
pvd_map = colors .LinearSegmentedColormap .from_list ('pvd_map' , all_colors )
858
852
divnorm = colors .TwoSlopeNorm (vmin = - 3 * pvd_rms , vcenter = + 3 * pvd_rms , vmax = 15 * pvd_rms )
859
- # ax1.imshow(pvd, cmap='gray', aspect='auto', vmin=-3*pvd_rms, vmax=+3*pvd_rms)
860
853
ax1 .imshow (pvd , cmap = pvd_map , aspect = 'auto' , norm = divnorm )
861
854
862
855
if np .all (np .isnan (pv [0 ].data )):
@@ -890,7 +883,7 @@ def make_pv(source, src_basename, cube_params, opt_view=6*u.arcmin, spec_line=No
890
883
ax1 .plot ([0.0 , 0.0 ], [freq1 , freq2 ], c = 'orange' , linestyle = '--' , linewidth = 1.0 ,
891
884
transform = ax1 .get_transform ('world' ))
892
885
ax1 .set_title (source ['name' ], fontsize = 24 )
893
- ax1 .tick_params (axis = 'both' , which = 'major' , labelsize = 22 )
886
+ ax1 .tick_params (axis = 'both' , which = 'major' , labelsize = 22 , length = 6 , width = 2 )
894
887
ax1 .coords [0 ].set_format_unit (u .arcmin )
895
888
ax1 .coords [0 ].set_major_formatter ('x.xx' ) # Prevent crowding on x-axis
896
889
ax1 .set_xlabel ('Angular Offset [arcmin]' , fontsize = 22 )
@@ -920,7 +913,7 @@ def make_pv(source, src_basename, cube_params, opt_view=6*u.arcmin, spec_line=No
920
913
vel2 = (const .c * (source ['freq' ] - freq2 )/ source ['freq' ]).to (u .km / u .s ).value
921
914
ax2 .set_ylim (vel1 , vel2 )
922
915
ax2 .set_ylabel ('Rest Frame Velocity [km/s]' , fontsize = 22 )
923
- ax2 .tick_params (labelsize = 22 )
916
+ ax2 .tick_params (labelsize = 22 , length = 6 , width = 2 )
924
917
else :
925
918
print ("\t WARNING: Input cube is in velocity units--no correction to source rest frame velocity has been applied!" )
926
919
if ('v_rad' in source .colnames ) or (cube_params ['spec_axis' ] == 'VRAD' ):
@@ -1090,6 +1083,7 @@ def main(source, src_basename, opt_view=6*u.arcmin, suffix='png', sofia=2, beam=
1090
1083
# For CHILES: plot HI contours on HST image if desired.
1091
1084
if ('hst' in surveys ) | ('HST' in surveys ):
1092
1085
hst_opt_view = np .array ([40 ,]) * u .arcsec
1086
+ if opt_view < hst_opt_view : hst_opt_view = opt_view .to (u .arcsec )
1093
1087
if np .any (Xsize > hst_opt_view .to (u .arcmin ).value / 2 ) | np .any (Ysize > hst_opt_view .to (u .arcmin ).value / 2 ):
1094
1088
hst_opt_view = (np .max ([Xsize , Ysize ]) * 2 * 1.05 * u .arcmin ).to (u .arcsec )
1095
1089
hst_opt = get_hst_cosmos (source , opt_view = hst_opt_view )
0 commit comments