pymakeplots 0.2.3__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/PKG-INFO +1 -1
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots/pymakeplots.py +174 -65
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/PKG-INFO +1 -1
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/setup.py +1 -1
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/LICENSE.md +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/README.md +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots/__init__.py +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots/sauron_colormap.py +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/SOURCES.txt +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/dependency_links.txt +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/requires.txt +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/top_level.txt +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/pymakeplots.egg-info/zip-safe +0 -0
- {pymakeplots-0.2.3 → pymakeplots-0.2.5}/setup.cfg +0 -0
|
@@ -9,11 +9,12 @@ import matplotlib.pyplot as plt
|
|
|
9
9
|
import matplotlib
|
|
10
10
|
from pymakeplots.sauron_colormap import sauron
|
|
11
11
|
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
12
|
-
from matplotlib.patches import Ellipse,Rectangle
|
|
12
|
+
from matplotlib.patches import Ellipse,Rectangle, Arrow, FancyArrowPatch
|
|
13
13
|
from matplotlib import cm
|
|
14
|
+
from matplotlib.text import Text
|
|
14
15
|
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
|
|
15
16
|
from matplotlib.offsetbox import AnchoredText,AuxTransformBox, AnchoredOffsetbox
|
|
16
|
-
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
|
|
17
|
+
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar,AnchoredDirectionArrows
|
|
17
18
|
from astropy.coordinates import ICRS
|
|
18
19
|
import matplotlib.gridspec as gridspec
|
|
19
20
|
from astropy.table import Table
|
|
@@ -40,7 +41,7 @@ def rotateImage(img, angle, pivot):
|
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
class pymakeplots:
|
|
43
|
-
def __init__(self,cube_flat=None,pb=None,cube=None,rest_value=None,velocity_convention='radio'):
|
|
44
|
+
def __init__(self,cube_flat=None,pb=None,cube=None,rest_value=None,velocity_convention='radio',rotate=None):
|
|
44
45
|
self.galname=None
|
|
45
46
|
self.gal_distance=None
|
|
46
47
|
self.posang=None
|
|
@@ -58,6 +59,7 @@ class pymakeplots:
|
|
|
58
59
|
self.pbcorr_cube_trim=None
|
|
59
60
|
self.mask_trim=None
|
|
60
61
|
self.bmaj=None
|
|
62
|
+
self.rotate=rotate
|
|
61
63
|
self.smoothmask_spatial=1.5
|
|
62
64
|
self.bmin=None
|
|
63
65
|
self.bpa=None
|
|
@@ -93,6 +95,8 @@ class pymakeplots:
|
|
|
93
95
|
self.make_square=True
|
|
94
96
|
self.useallpixels = False
|
|
95
97
|
self.suppress_subbeam_artifacts=False
|
|
98
|
+
self.mom1_cmap=sauron
|
|
99
|
+
self.mom2_cmap=sauron
|
|
96
100
|
#self.wcs=None
|
|
97
101
|
|
|
98
102
|
if (cube != None)&(pb==None)&(cube_flat==None):
|
|
@@ -322,25 +326,48 @@ class pymakeplots:
|
|
|
322
326
|
def get_header_coord_arrays(self,hdr):
|
|
323
327
|
|
|
324
328
|
|
|
325
|
-
cd1=self.spectralcube.
|
|
326
|
-
cd2=self.spectralcube.
|
|
327
|
-
x1=((np.arange(1,hdr['NAXIS1']+1)-(hdr['NAXIS1']//2))*cd1)# + hdr['CRVAL1']
|
|
329
|
+
cd1=self.spectralcube.header['CDELT1']*3600.
|
|
330
|
+
cd2=self.spectralcube.header['CDELT2']*3600.
|
|
331
|
+
x1=((np.arange(1,hdr['NAXIS1']+1)-(hdr['NAXIS1']//2))*(cd1))# + hdr['CRVAL1']
|
|
328
332
|
y1=((np.arange(1,hdr['NAXIS2']+1)-(hdr['NAXIS1']//2))*cd2)# + hdr['CRVAL2']
|
|
329
333
|
|
|
330
334
|
v1=self.spectralcube.spectral_axis.value
|
|
331
335
|
|
|
332
336
|
cd3= np.median(np.diff(v1))
|
|
333
|
-
|
|
337
|
+
#breakpoint()
|
|
334
338
|
|
|
335
339
|
return x1,y1,v1,np.abs(cd1),cd3
|
|
336
340
|
|
|
337
341
|
def read_in_a_cube(self,path,rest_value=None,primary=False):
|
|
338
342
|
|
|
343
|
+
if self.rotate !=None:
|
|
344
|
+
try:
|
|
345
|
+
h=fits.getheader(path.split('.fits')[0]+'_rotated.fits')
|
|
346
|
+
if float(h['ROTANGLE']) == self.rotate:
|
|
347
|
+
path=path.split('.fits')[0]+'_rotated.fits'
|
|
348
|
+
alreadyrotated=True
|
|
349
|
+
else:
|
|
350
|
+
alreadyrotated=False
|
|
351
|
+
except:
|
|
352
|
+
alreadyrotated=False
|
|
353
|
+
|
|
354
|
+
|
|
339
355
|
scube=SpectralCube.read(path).with_spectral_unit(u.km/u.s, velocity_convention=self.velocity_convention,rest_value=rest_value)
|
|
340
356
|
|
|
357
|
+
hdr=scube.header
|
|
358
|
+
|
|
359
|
+
if self.rotate !=None:
|
|
360
|
+
if alreadyrotated == False:
|
|
361
|
+
hdr['CROTA2']=self.rotate
|
|
362
|
+
hdr['CROTA3']=0
|
|
363
|
+
scube=scube.reproject(hdr)
|
|
364
|
+
scube.meta['ROTANGLE']=self.rotate
|
|
365
|
+
scube.write(path.split('.fits')[0]+'_rotated.fits',overwrite=True)
|
|
366
|
+
|
|
341
367
|
hdr=scube.header
|
|
342
368
|
cube = np.squeeze(scube.filled_data[:,:,:].T).value #squeeze to remove singular stokes axis if present
|
|
343
369
|
cube[np.isfinite(cube) == False] = 0.0
|
|
370
|
+
|
|
344
371
|
try:
|
|
345
372
|
beamtab=scube.beam
|
|
346
373
|
except:
|
|
@@ -352,7 +379,13 @@ class pymakeplots:
|
|
|
352
379
|
beamvals=[scube.header['bmaj'],scube.header['bmin']]
|
|
353
380
|
beamtab=Beam(major=np.max(beamvals)*u.deg,minor=np.min(beamvals)*u.deg,pa=self.spectralcube.header['bpa']*u.deg)
|
|
354
381
|
except:
|
|
355
|
-
beamtab=False
|
|
382
|
+
beamtab=False
|
|
383
|
+
|
|
384
|
+
if beamtab.major.value ==0:
|
|
385
|
+
### MeerKAT style beams
|
|
386
|
+
beamvals=[np.mean([scube.header['bmaj1'],scube.header['bmaj3826']]),np.mean([scube.header['bmin1'],scube.header['bmin3826']])]
|
|
387
|
+
beamtab=Beam(major=np.max(beamvals)*u.deg,minor=np.min(beamvals)*u.deg,pa=np.mean([scube.header['bpa1'],scube.header['bpa3826']])*u.deg)
|
|
388
|
+
|
|
356
389
|
if primary:
|
|
357
390
|
self.spectralcube=scube
|
|
358
391
|
self.repfreq=np.median(self.spectralcube.with_spectral_unit(u.GHz).spectral_axis)
|
|
@@ -396,7 +429,6 @@ class pymakeplots:
|
|
|
396
429
|
return xpix,ypix,xoffsetarc,yoffsetarc
|
|
397
430
|
|
|
398
431
|
def prepare_cubes(self):
|
|
399
|
-
|
|
400
432
|
self.centskycoord=self.spectralcube.wcs.celestial.pixel_to_world(self.xcoord.size//2,self.ycoord.size//2).transform_to('icrs')
|
|
401
433
|
self.x_skycent=self.centskycoord.ra.value
|
|
402
434
|
self.y_skycent=self.centskycoord.dec.value
|
|
@@ -415,10 +447,10 @@ class pymakeplots:
|
|
|
415
447
|
pointingposes=SkyCoord(self.pointingsra,self.pointingsdec,frame='icrs',unit=(u.hourangle,u.deg))
|
|
416
448
|
_,_,pointoffsetx,pointoffsety=self.calc_offset(pointingposes.ra,pointingposes.dec)
|
|
417
449
|
self.points2plot=np.zeros((len(pointoffsetx),3))
|
|
418
|
-
self.points2plot[:,0]
|
|
450
|
+
self.points2plot[:,0]=-pointoffsetx+xoffsetarc
|
|
419
451
|
self.points2plot[:,1]=pointoffsety-yoffsetarc
|
|
420
452
|
self.points2plot[:,2]=self.pointingsdiam.value
|
|
421
|
-
|
|
453
|
+
#breakpoint()
|
|
422
454
|
self.clip_cube(xoffsetarc,yoffsetarc)
|
|
423
455
|
|
|
424
456
|
self.mask_trim=self.smooth_mask(self.flat_cube_trim)
|
|
@@ -563,7 +595,7 @@ class pymakeplots:
|
|
|
563
595
|
plt.show()
|
|
564
596
|
plt.close()
|
|
565
597
|
|
|
566
|
-
def
|
|
598
|
+
def scalebarlength(self):
|
|
567
599
|
barlength_pc = np.ceil((np.abs(self.xc[-1]-self.xc[0])*4.84*self.gal_distance)/1000.)*100
|
|
568
600
|
barlength_arc= barlength_pc/(4.84*self.gal_distance)
|
|
569
601
|
|
|
@@ -576,7 +608,11 @@ class pymakeplots:
|
|
|
576
608
|
barlength_arc= barlength_pc/(4.84*self.gal_distance)
|
|
577
609
|
|
|
578
610
|
|
|
611
|
+
return barlength_arc,barlength_pc
|
|
612
|
+
|
|
613
|
+
def scalebar(self,ax,loc='lower right'):
|
|
579
614
|
|
|
615
|
+
barlength_arc,barlength_pc=self.scalebarlength()
|
|
580
616
|
if np.log10(barlength_pc) > 3:
|
|
581
617
|
label=(barlength_pc/1e3).astype(str)+ " kpc"
|
|
582
618
|
else:
|
|
@@ -591,9 +627,6 @@ class pymakeplots:
|
|
|
591
627
|
|
|
592
628
|
def clip_cube(self,xoffsetarc,yoffsetarc):
|
|
593
629
|
|
|
594
|
-
#
|
|
595
|
-
|
|
596
|
-
|
|
597
630
|
|
|
598
631
|
if np.any(self.chans2do == None):
|
|
599
632
|
|
|
@@ -621,7 +654,6 @@ class pymakeplots:
|
|
|
621
654
|
if np.array(self.imagesize).size == 1:
|
|
622
655
|
self.imagesize=[self.imagesize,self.imagesize]
|
|
623
656
|
|
|
624
|
-
|
|
625
657
|
wx,=np.where(np.abs(self.xcoord-xoffsetarc) <= self.imagesize[0])
|
|
626
658
|
wy,=np.where(np.abs(self.ycoord-yoffsetarc) <= self.imagesize[1])
|
|
627
659
|
self.spatial_trim=[np.min(wx),np.max(wx),np.min(wy),np.max(wy)]
|
|
@@ -681,17 +713,103 @@ class pymakeplots:
|
|
|
681
713
|
|
|
682
714
|
def add_beam(self,ax):
|
|
683
715
|
aux_tr_box = AuxTransformBox(ax.transData)
|
|
684
|
-
|
|
716
|
+
if self.rotate!=None:
|
|
717
|
+
rotang=self.rotate
|
|
718
|
+
else:
|
|
719
|
+
rotang=0
|
|
685
720
|
if self.all_axes_physical:
|
|
686
|
-
aux_tr_box.add_artist(Ellipse((0, 0), width=self.ang2kpctrans(self.bmaj), height=self.ang2kpctrans(self.bmin), angle=self.bpa+90,edgecolor='black',facecolor='none',linewidth=1.5))
|
|
721
|
+
aux_tr_box.add_artist(Ellipse((0, 0), width=self.ang2kpctrans(self.bmaj), height=self.ang2kpctrans(self.bmin), angle=self.bpa+90+rotang,edgecolor='black',facecolor='none',linewidth=1.5))
|
|
687
722
|
else:
|
|
688
|
-
aux_tr_box.add_artist(Ellipse((0, 0), width=self.bmaj, height=self.bmin, angle=self.bpa+90,edgecolor='black',facecolor='none',linewidth=1.5))
|
|
723
|
+
aux_tr_box.add_artist(Ellipse((0, 0), width=self.bmaj, height=self.bmin, angle=self.bpa+90+rotang,edgecolor='black',facecolor='none',linewidth=1.5))
|
|
689
724
|
box = AnchoredOffsetbox(child=aux_tr_box, loc='lower left', pad=0.5, borderpad=0.4,frameon=False)
|
|
690
725
|
ax.add_artist(box)
|
|
691
726
|
|
|
692
727
|
|
|
693
|
-
|
|
728
|
+
def add_axis_labels(self,ax1,first=True):
|
|
729
|
+
if self.rotate !=None:
|
|
730
|
+
self._xlab='Offset'
|
|
731
|
+
self._ylab='Offset'
|
|
732
|
+
else:
|
|
733
|
+
self._xlab='RA Offset'
|
|
734
|
+
self._ylab='Dec Offset'
|
|
735
|
+
|
|
736
|
+
if self.all_axes_physical:
|
|
737
|
+
ax1.set_xlabel(self._xlab+' (kpc)')
|
|
738
|
+
if first: ax1.set_ylabel(self._ylab+' (kpc)')
|
|
739
|
+
else:
|
|
740
|
+
ax1.set_xlabel(self._xlab+' (")')
|
|
741
|
+
if first: ax1.set_ylabel(self._ylab+' (")')
|
|
742
|
+
|
|
743
|
+
def add_arrow(self,ax,first=True,last=True):
|
|
744
|
+
if first and last:
|
|
745
|
+
loc='upper right'
|
|
746
|
+
else:
|
|
747
|
+
loc="lower right"
|
|
748
|
+
# if self.all_axes_physical:
|
|
749
|
+
# length2use=self.ang2kpctrans(self.bmaj)
|
|
750
|
+
# else:
|
|
751
|
+
# length2use=self.bmaj
|
|
752
|
+
#
|
|
753
|
+
# rotated_arrow = AnchoredDirectionArrows(
|
|
754
|
+
# ax.transData,
|
|
755
|
+
# 'Dec', 'RA',
|
|
756
|
+
# loc=loc,
|
|
757
|
+
# length=-0.1,#length2use*2,
|
|
758
|
+
# aspect_ratio=-1,
|
|
759
|
+
# color='k',
|
|
760
|
+
# text_props={'ec': 'k', 'fc': 'k'},
|
|
761
|
+
# angle=self.rotate,
|
|
762
|
+
# )
|
|
763
|
+
# ax.add_artist(rotated_arrow)
|
|
764
|
+
|
|
694
765
|
|
|
766
|
+
aux_tr_box = AuxTransformBox(ax.transData)
|
|
767
|
+
barlength_arc,barlength_pc=self.scalebarlength()
|
|
768
|
+
if self.all_axes_physical:
|
|
769
|
+
length2use=self.ang2kpctrans(barlength_arc)
|
|
770
|
+
else:
|
|
771
|
+
length2use=barlength_arc
|
|
772
|
+
|
|
773
|
+
rotmat=np.array([[np.cos(np.deg2rad(self.rotate)),-np.sin(np.deg2rad(self.rotate))],[np.sin(np.deg2rad(self.rotate)),np.cos(np.deg2rad(self.rotate))]])
|
|
774
|
+
dx1,dx2=np.dot(rotmat,np.array([0,length2use]))
|
|
775
|
+
if (dx1 <0)&(dx2<0):
|
|
776
|
+
#lower left quadrant
|
|
777
|
+
startx,starty= np.abs(dx1), np.abs(dx2)
|
|
778
|
+
endx,endy=0,0
|
|
779
|
+
ha='right'
|
|
780
|
+
if (dx1 <0)&(dx2>0):
|
|
781
|
+
#upper left quadrant
|
|
782
|
+
startx,starty= 0,0
|
|
783
|
+
endx,endy= dx1,dx2
|
|
784
|
+
ha='right'
|
|
785
|
+
if (dx1 >0)&(dx2>0):
|
|
786
|
+
#upper right quadrant
|
|
787
|
+
startx,starty= 0,0
|
|
788
|
+
endx,endy= dx1, dx2
|
|
789
|
+
ha='left'
|
|
790
|
+
if (dx1 >0)&(dx2<0):
|
|
791
|
+
#lower right quadrant
|
|
792
|
+
startx,starty= -np.abs(dx1), np.abs(dx2)
|
|
793
|
+
endx,endy=0,0
|
|
794
|
+
ha='left'
|
|
795
|
+
|
|
796
|
+
aux_tr_box.add_artist(Text(endx,endy,'N',color='k',ha=ha,fontsize='small',va='center'))
|
|
797
|
+
aux_tr_box.add_artist(FancyArrowPatch((startx,starty), (endx,endy),
|
|
798
|
+
mutation_scale=100,color='k',arrowstyle='->,head_length=0.1, head_width=0.05'))
|
|
799
|
+
|
|
800
|
+
box = AnchoredOffsetbox(child=aux_tr_box, loc=loc, frameon=False)
|
|
801
|
+
ax.add_artist(box)
|
|
802
|
+
#ax.text(3, y + 0.05, bracketstyle, ha="center", va="bottom", fontsize=14)
|
|
803
|
+
|
|
804
|
+
def add_second_axis(self,ax1):
|
|
805
|
+
if np.log10(self.ang2pctrans(np.max([np.max(self.xc),np.max(self.yc)]))) > 3:
|
|
806
|
+
secax = ax1.secondary_yaxis('right', functions=(self.ang2kpctrans, self.ang2kpctrans_inv))
|
|
807
|
+
secax.set_ylabel(self._ylab+' (kpc)')
|
|
808
|
+
else:
|
|
809
|
+
secax = ax1.secondary_yaxis('right', functions=(self.ang2pctrans, self.ang2pctrans_inv))
|
|
810
|
+
secax.set_ylabel(self._ylab+' (pc)')
|
|
811
|
+
|
|
812
|
+
|
|
695
813
|
def mom0(self,ax1,first=True,last=True):
|
|
696
814
|
mom0=(self.pbcorr_cube_trim*self.mask_trim).sum(axis=2)*self.dv
|
|
697
815
|
|
|
@@ -714,17 +832,10 @@ class pymakeplots:
|
|
|
714
832
|
#breakpoint()
|
|
715
833
|
im1=ax1.contourf(self.xc,self.yc,mom0.T,levels=levs,cmap=newcmp)
|
|
716
834
|
#im1=ax1.pcolormesh(self.xc,self.yc,mom0.T,cmap=newcmp,vmin=minmom0,vmax=maxmom0)
|
|
717
|
-
|
|
718
|
-
if self.all_axes_physical:
|
|
719
|
-
ax1.set_xlabel('RA offset (kpc)')
|
|
720
|
-
if first: ax1.set_ylabel('Dec offset (kpc)')
|
|
721
|
-
else:
|
|
722
|
-
ax1.set_xlabel('RA offset (")')
|
|
723
|
-
if first: ax1.set_ylabel('Dec offset (")')
|
|
724
|
-
|
|
725
835
|
|
|
836
|
+
|
|
837
|
+
self.add_axis_labels(ax1,first=first)
|
|
726
838
|
|
|
727
|
-
|
|
728
839
|
|
|
729
840
|
if maxmom0 > 0:
|
|
730
841
|
vticks=np.linspace(0,(np.round((maxmom0 / 10**np.floor(np.log10(maxmom0))))*10**np.floor(np.log10(maxmom0))),4)
|
|
@@ -740,6 +851,8 @@ class pymakeplots:
|
|
|
740
851
|
|
|
741
852
|
|
|
742
853
|
self.add_beam(ax1)
|
|
854
|
+
if self.rotate != None and first:
|
|
855
|
+
self.add_arrow(ax1,first=first,last=last)
|
|
743
856
|
|
|
744
857
|
if np.any(self.points2plot != None):
|
|
745
858
|
naca=0
|
|
@@ -766,15 +879,14 @@ class pymakeplots:
|
|
|
766
879
|
if self.make_square:
|
|
767
880
|
ax1.set_xlim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
768
881
|
ax1.set_ylim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
882
|
+
else:
|
|
883
|
+
ax1.set_xlim(self.xc[0],self.xc[-1])
|
|
884
|
+
ax1.set_ylim(self.yc[0],self.yc[-1])
|
|
769
885
|
ax1.set_aspect('equal')
|
|
770
886
|
|
|
887
|
+
|
|
771
888
|
if last and not self.all_axes_physical:
|
|
772
|
-
|
|
773
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2kpctrans, self.ang2kpctrans_inv))
|
|
774
|
-
secax.set_ylabel(r'Dec offset (kpc)')
|
|
775
|
-
else:
|
|
776
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2pctrans, self.ang2pctrans_inv))
|
|
777
|
-
secax.set_ylabel(r'Dec offset (pc)')
|
|
889
|
+
self.add_second_axis(ax1)
|
|
778
890
|
|
|
779
891
|
|
|
780
892
|
if self.fits:
|
|
@@ -790,14 +902,9 @@ class pymakeplots:
|
|
|
790
902
|
|
|
791
903
|
vticks=np.linspace((-1)*np.ceil(np.max(np.abs(self.vcoord_trim-self.vsys))/10.)*10.,np.ceil(np.max(np.abs(self.vcoord_trim-self.vsys))/10.)*10.,5)
|
|
792
904
|
|
|
793
|
-
im1=ax1.contourf(self.xc,self.yc,mom1.T-self.vsys,levels=self.vcoord_trim-self.vsys,cmap=
|
|
905
|
+
im1=ax1.contourf(self.xc,self.yc,mom1.T-self.vsys,levels=self.vcoord_trim-self.vsys,cmap=self.mom1_cmap,vmin=vticks[0],vmax=vticks[-1])
|
|
794
906
|
|
|
795
|
-
|
|
796
|
-
ax1.set_xlabel('RA offset (kpc)')
|
|
797
|
-
if first: ax1.set_ylabel('Dec offset (kpc)')
|
|
798
|
-
else:
|
|
799
|
-
ax1.set_xlabel('RA offset (")')
|
|
800
|
-
if first: ax1.set_ylabel('Dec offset (")')
|
|
907
|
+
self.add_axis_labels(ax1,first=first)
|
|
801
908
|
|
|
802
909
|
|
|
803
910
|
cb=self.colorbar(im1,ticks=vticks)
|
|
@@ -808,14 +915,15 @@ class pymakeplots:
|
|
|
808
915
|
if self.make_square:
|
|
809
916
|
ax1.set_xlim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
810
917
|
ax1.set_ylim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
811
|
-
|
|
918
|
+
else:
|
|
919
|
+
ax1.set_xlim(self.xc[0],self.xc[-1])
|
|
920
|
+
ax1.set_ylim(self.yc[0],self.yc[-1])
|
|
921
|
+
|
|
922
|
+
if self.rotate != None and first:
|
|
923
|
+
self.add_arrow(ax1,first=first,last=last)
|
|
924
|
+
|
|
812
925
|
if last and not self.all_axes_physical:
|
|
813
|
-
|
|
814
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2kpctrans, self.ang2kpctrans_inv))
|
|
815
|
-
secax.set_ylabel(r'Dec offset (kpc)')
|
|
816
|
-
else:
|
|
817
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2pctrans, self.ang2pctrans_inv))
|
|
818
|
-
secax.set_ylabel(r'Dec offset (pc)')
|
|
926
|
+
self.add_second_axis(ax1)
|
|
819
927
|
|
|
820
928
|
if self.fits:
|
|
821
929
|
self.write_fits(mom1.T,1)
|
|
@@ -840,14 +948,9 @@ class pymakeplots:
|
|
|
840
948
|
self.maxvdisp=50.
|
|
841
949
|
#breakpoint()
|
|
842
950
|
mom2levs=np.linspace(0,self.maxvdisp,10)
|
|
843
|
-
im1=ax1.contourf(self.xc,self.yc,mom2.T,levels=mom2levs,cmap=
|
|
951
|
+
im1=ax1.contourf(self.xc,self.yc,mom2.T,levels=mom2levs,cmap=self.mom2_cmap,vmax=self.maxvdisp)
|
|
844
952
|
|
|
845
|
-
|
|
846
|
-
ax1.set_xlabel('RA offset (kpc)')
|
|
847
|
-
if first: ax1.set_ylabel('Dec offset (kpc)')
|
|
848
|
-
else:
|
|
849
|
-
ax1.set_xlabel('RA offset (")')
|
|
850
|
-
if first: ax1.set_ylabel('Dec offset (")')
|
|
953
|
+
self.add_axis_labels(ax1,first=first)
|
|
851
954
|
|
|
852
955
|
if self.maxvdisp < 50:
|
|
853
956
|
dvticks=10
|
|
@@ -868,14 +971,15 @@ class pymakeplots:
|
|
|
868
971
|
if self.make_square:
|
|
869
972
|
ax1.set_xlim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
870
973
|
ax1.set_ylim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
974
|
+
else:
|
|
975
|
+
ax1.set_xlim(self.xc[0],self.xc[-1])
|
|
976
|
+
ax1.set_ylim(self.yc[0],self.yc[-1])
|
|
871
977
|
|
|
978
|
+
if self.rotate != None and first:
|
|
979
|
+
self.add_arrow(ax1,first=first,last=last)
|
|
980
|
+
|
|
872
981
|
if last and not self.all_axes_physical:
|
|
873
|
-
|
|
874
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2kpctrans, self.ang2kpctrans_inv))
|
|
875
|
-
secax.set_ylabel(r'Dec offset (kpc)')
|
|
876
|
-
else:
|
|
877
|
-
secax = ax1.secondary_yaxis('right', functions=(self.ang2pctrans, self.ang2pctrans_inv))
|
|
878
|
-
secax.set_ylabel(r'Dec offset (pc)',rotation=270,labelpad=10)
|
|
982
|
+
self.add_second_axis(ax1)
|
|
879
983
|
|
|
880
984
|
|
|
881
985
|
if self.fits:
|
|
@@ -899,6 +1003,12 @@ class pymakeplots:
|
|
|
899
1003
|
newhdu.header['CRPIX2']=self.spectralcube.header['CRPIX2']
|
|
900
1004
|
newhdu.header['CRVAL2']=self.spectralcube.header['CRVAL2']
|
|
901
1005
|
newhdu.header['CDELT2']=self.spectralcube.header['CDELT2']
|
|
1006
|
+
if self.rotate!=None:
|
|
1007
|
+
newhdu.header['PC1_1']=self.spectralcube.header['PC1_1']
|
|
1008
|
+
newhdu.header['PC1_2']=self.spectralcube.header['PC1_2']
|
|
1009
|
+
newhdu.header['PC2_1']=self.spectralcube.header['PC2_1']
|
|
1010
|
+
newhdu.header['PC2_2']=self.spectralcube.header['PC2_2']
|
|
1011
|
+
|
|
902
1012
|
try:
|
|
903
1013
|
newhdu.header['PV2_1']=self.spectralcube.header['PV2_1']
|
|
904
1014
|
newhdu.header['PV2_2']=self.spectralcube.header['PV2_2']
|
|
@@ -1125,8 +1235,8 @@ class pymakeplots:
|
|
|
1125
1235
|
anchored_text = AnchoredText("PA: "+str(round(self.posang,1))+'$^{\\circ}$', loc=loc1,frameon=False)
|
|
1126
1236
|
axes.add_artist(anchored_text)
|
|
1127
1237
|
|
|
1128
|
-
if self.gal_distance != None and not self.all_axes_physical:
|
|
1129
|
-
|
|
1238
|
+
#if self.gal_distance != None and not self.all_axes_physical:
|
|
1239
|
+
# self.scalebar(axes,loc=loc2)
|
|
1130
1240
|
|
|
1131
1241
|
if self.fits:
|
|
1132
1242
|
self.write_pvd_fits(pvdaxis,vaxis,pvd.T)
|
|
@@ -1159,7 +1269,6 @@ class pymakeplots:
|
|
|
1159
1269
|
ylab="Unknown"
|
|
1160
1270
|
|
|
1161
1271
|
if (''.join(self.bunit.split())).lower() == "Jy/beam".lower():
|
|
1162
|
-
|
|
1163
1272
|
spec*=1/self.beam_area()
|
|
1164
1273
|
spec_mask*=1/self.beam_area()
|
|
1165
1274
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|