pymakeplots 0.1.7__py3-none-any.whl → 0.2.1__py3-none-any.whl
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/pymakeplots.py +130 -82
- {pymakeplots-0.1.7.dist-info → pymakeplots-0.2.1.dist-info}/METADATA +3 -3
- pymakeplots-0.2.1.dist-info/RECORD +9 -0
- {pymakeplots-0.1.7.dist-info → pymakeplots-0.2.1.dist-info}/WHEEL +1 -1
- pymakeplots-0.1.7.dist-info/RECORD +0 -9
- {pymakeplots-0.1.7.dist-info → pymakeplots-0.2.1.dist-info}/LICENSE.md +0 -0
- {pymakeplots-0.1.7.dist-info → pymakeplots-0.2.1.dist-info}/top_level.txt +0 -0
- {pymakeplots-0.1.7.dist-info → pymakeplots-0.2.1.dist-info}/zip-safe +0 -0
pymakeplots/pymakeplots.py
CHANGED
|
@@ -47,6 +47,8 @@ class pymakeplots:
|
|
|
47
47
|
self.moment1=None
|
|
48
48
|
self.rms=None
|
|
49
49
|
self.flat_cube=None
|
|
50
|
+
self.obj_ra_pix=None
|
|
51
|
+
self.obj_dec_pix=None
|
|
50
52
|
self.pbcorr_cube=None
|
|
51
53
|
self.spectralcube=None
|
|
52
54
|
self.mask=None
|
|
@@ -64,6 +66,7 @@ class pymakeplots:
|
|
|
64
66
|
self.bardist=None
|
|
65
67
|
self.rmsfac=3
|
|
66
68
|
self.restfreq=None
|
|
69
|
+
self.repfreq=None
|
|
67
70
|
self.obj_ra=None
|
|
68
71
|
self.obj_dec=None
|
|
69
72
|
self.imagesize=None
|
|
@@ -76,6 +79,10 @@ class pymakeplots:
|
|
|
76
79
|
self.spatial_trim = None
|
|
77
80
|
self.maxvdisp=None
|
|
78
81
|
self.cliplevel=None
|
|
82
|
+
self.points2plot=None
|
|
83
|
+
self.pointingsra=None
|
|
84
|
+
self.pointingsdec=None
|
|
85
|
+
self.pointingsdiam=None
|
|
79
86
|
self.fits=False
|
|
80
87
|
self.pvdthick=5.
|
|
81
88
|
self.flipped=False
|
|
@@ -168,8 +175,9 @@ class pymakeplots:
|
|
|
168
175
|
sigma = 1.5 * self.bmaj / self.cellsize
|
|
169
176
|
smooth_cube = ndimage.uniform_filter(cube, size=[sigma, sigma,4], mode='constant') # mode='nearest'
|
|
170
177
|
newrms= self.rms_estimate(smooth_cube,0,1)
|
|
171
|
-
self.cliplevel=
|
|
172
|
-
|
|
178
|
+
self.cliplevel=self.rms*self.rmsfac
|
|
179
|
+
self.maskcliplevel=newrms*self.rmsfac
|
|
180
|
+
mask=(smooth_cube > self.maskcliplevel)
|
|
173
181
|
# print("Clip level:",((3e20*1.6014457E-20*91.9)/(self.bmaj*self.bmin))*self.cliplevel*self.dv)
|
|
174
182
|
# import ipdb
|
|
175
183
|
# ipdb.set_trace()
|
|
@@ -300,22 +308,19 @@ class pymakeplots:
|
|
|
300
308
|
return np.nanstd(cube[quarterx*1:3*quarterx,1*quartery:3*quartery,chanstart:chanend])
|
|
301
309
|
|
|
302
310
|
def get_header_coord_arrays(self,hdr):
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
cd1=self.spectralcube.wcs.pixel_scale_matrix[0,0]*3600
|
|
314
|
+
cd2=self.spectralcube.wcs.pixel_scale_matrix[1,1]*3600
|
|
315
|
+
x1=((np.arange(1,hdr['NAXIS1']+1)-(hdr['NAXIS1']//2))*cd1)# + hdr['CRVAL1']
|
|
316
|
+
y1=((np.arange(1,hdr['NAXIS2']+1)-(hdr['NAXIS1']//2))*cd2)# + hdr['CRVAL2']
|
|
303
317
|
|
|
304
|
-
y,x=self.spectralcube.spatial_coordinate_map
|
|
305
|
-
|
|
306
|
-
x1=np.median(x[0:hdr['NAXIS2'],0:hdr['NAXIS1']],0).value
|
|
307
|
-
y1=np.median(y[0:hdr['NAXIS2'],0:hdr['NAXIS1']],1).value
|
|
308
318
|
v1=self.spectralcube.spectral_axis.value
|
|
309
319
|
|
|
310
320
|
cd3= np.median(np.diff(v1))
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if np.any(np.diff(x1) > 359):
|
|
314
|
-
# we have RA=0 wrap issue
|
|
315
|
-
x1[x1 > 180]-=360
|
|
316
|
-
|
|
321
|
+
|
|
317
322
|
|
|
318
|
-
return x1,y1,v1,np.abs(cd1
|
|
323
|
+
return x1,y1,v1,np.abs(cd1),cd3
|
|
319
324
|
|
|
320
325
|
def read_in_a_cube(self,path):
|
|
321
326
|
self.spectralcube=SpectralCube.read(path).with_spectral_unit(u.km/u.s, velocity_convention='radio')#, rest_value=self.restfreq)
|
|
@@ -335,8 +340,10 @@ class pymakeplots:
|
|
|
335
340
|
beamtab=Beam(major=np.max(beamvals)*u.deg,minor=np.min(beamvals)*u.deg,pa=self.spectralcube.header['bpa']*u.deg)
|
|
336
341
|
except:
|
|
337
342
|
beamtab=False
|
|
338
|
-
|
|
343
|
+
self.repfreq=np.median(self.spectralcube.with_spectral_unit(u.GHz).spectral_axis)
|
|
339
344
|
return cube, hdr, beamtab
|
|
345
|
+
|
|
346
|
+
|
|
340
347
|
|
|
341
348
|
def read_primary_cube(self,cube):
|
|
342
349
|
|
|
@@ -356,23 +363,10 @@ class pymakeplots:
|
|
|
356
363
|
|
|
357
364
|
|
|
358
365
|
self.xcoord,self.ycoord,self.vcoord,self.cellsize,self.dv = self.get_header_coord_arrays(hdr)
|
|
366
|
+
#breakpoint()
|
|
359
367
|
|
|
360
368
|
|
|
361
|
-
|
|
362
|
-
try:
|
|
363
|
-
self.obj_ra=hdr['OBSRA']
|
|
364
|
-
self.obj_dec=hdr['OBSDEC']
|
|
365
|
-
if (self.obj_ra > np.max(self.xcoord)) or (self.obj_ra < np.min(self.xcoord)) or (self.obj_dec < np.min(self.ycoord)) or (self.obj_dec > np.max(self.ycoord)):
|
|
366
|
-
# obsra/dec given in the headers arent in the observed field! Fall back on medians.
|
|
367
|
-
if not self.silent: print("OBSRA/OBSDEC keywords dont seem correct! Assuming galaxy centre is at pointing centre")
|
|
368
|
-
self.obj_ra=np.median(self.xcoord)
|
|
369
|
-
self.obj_dec=np.median(self.ycoord)
|
|
370
|
-
except:
|
|
371
|
-
self.obj_ra=np.median(self.xcoord)
|
|
372
|
-
self.obj_dec=np.median(self.ycoord)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
369
|
+
|
|
376
370
|
|
|
377
371
|
if self.dv < 0:
|
|
378
372
|
datacube = np.flip(datacube,axis=2)
|
|
@@ -383,26 +377,45 @@ class pymakeplots:
|
|
|
383
377
|
|
|
384
378
|
self.rms= self.rms_estimate(datacube,self.linefree_chans_start,self.linefree_chans_end)
|
|
385
379
|
return datacube
|
|
386
|
-
|
|
380
|
+
|
|
381
|
+
def calc_offset(self,ra,dec):
|
|
382
|
+
refpos=SkyCoord(ra,dec)
|
|
383
|
+
xpix,ypix=self.spectralcube.wcs.celestial.world_to_pixel(refpos)
|
|
384
|
+
#self.xcentpix,self.ycentpix= xpix,ypix
|
|
385
|
+
xoffsetarc=np.interp(xpix,np.arange(self.xcoord.size),self.xcoord)
|
|
386
|
+
yoffsetarc=np.interp(ypix,np.arange(self.ycoord.size),self.ycoord)
|
|
387
|
+
return xpix,ypix,xoffsetarc,yoffsetarc
|
|
388
|
+
|
|
387
389
|
def prepare_cubes(self):
|
|
388
390
|
|
|
389
|
-
self.
|
|
391
|
+
self.centskycoord=self.spectralcube.wcs.celestial.pixel_to_world(self.xcoord.size//2,self.ycoord.size//2).transform_to('icrs')
|
|
392
|
+
self.x_skycent=self.centskycoord.ra.value
|
|
393
|
+
self.y_skycent=self.centskycoord.dec.value
|
|
394
|
+
if self.obj_ra == None:
|
|
395
|
+
self.obj_ra=self.x_skycent
|
|
396
|
+
if self.obj_dec == None:
|
|
397
|
+
self.obj_dec=self.y_skycent
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
xpix,ypix,xoffsetarc,yoffsetarc=self.calc_offset(self.obj_ra*u.deg,self.obj_dec*u.deg)
|
|
401
|
+
self.xcentpix,self.ycentpix= xpix,ypix
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
### want to overplot the pointings
|
|
405
|
+
if self.pointingsra != None:
|
|
406
|
+
pointingposes=SkyCoord(self.pointingsra,self.pointingsdec,frame='icrs',unit=(u.hourangle,u.deg))
|
|
407
|
+
_,_,pointoffsetx,pointoffsety=self.calc_offset(pointingposes.ra,pointingposes.dec)
|
|
408
|
+
self.points2plot=np.zeros((len(pointoffsetx),3))
|
|
409
|
+
self.points2plot[:,0]=pointoffsetx-xoffsetarc
|
|
410
|
+
self.points2plot[:,1]=pointoffsety-yoffsetarc
|
|
411
|
+
self.points2plot[:,2]=self.pointingsdiam.value
|
|
412
|
+
|
|
413
|
+
self.clip_cube(xoffsetarc,yoffsetarc)
|
|
390
414
|
|
|
391
415
|
self.mask_trim=self.smooth_mask(self.flat_cube_trim)
|
|
392
416
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
#sk=SkyCoord(x,y)
|
|
396
|
-
# refpos=SkyCoord(self.obj_ra*u.deg,self.obj_dec*u.deg)
|
|
397
|
-
# sx=SkyCoord(self.xcoord*u.deg,self.obj_dec*u.deg)
|
|
398
|
-
# self.xc=sx.separation(refpos).to(u.arcsec).value #* np.cos(np.deg2rad(self.obj_dec)) + self.obj_ra
|
|
399
|
-
# sy=SkyCoord(self.obj_ra*u.deg,self.ycoord*u.deg)
|
|
400
|
-
# self.yc=sy.separation(refpos).to(u.arcsec).value #+ self.obj_dec
|
|
401
|
-
#
|
|
402
|
-
#
|
|
403
|
-
# breakpoint()
|
|
404
|
-
self.xc=(self.xcoord_trim-self.obj_ra)*(-1) * 3600. * np.cos(np.deg2rad(self.obj_dec))
|
|
405
|
-
self.yc=(self.ycoord_trim-self.obj_dec) * 3600.
|
|
417
|
+
|
|
418
|
+
|
|
406
419
|
|
|
407
420
|
|
|
408
421
|
|
|
@@ -414,6 +427,8 @@ class pymakeplots:
|
|
|
414
427
|
if self.all_axes_physical:
|
|
415
428
|
self.xc=self.ang2kpctrans(self.xc)
|
|
416
429
|
self.yc=self.ang2kpctrans(self.yc)
|
|
430
|
+
if self.pointingsra != None:
|
|
431
|
+
self.points2plot=self.ang2kpctrans(self.points2plot)
|
|
417
432
|
|
|
418
433
|
|
|
419
434
|
|
|
@@ -451,15 +466,16 @@ class pymakeplots:
|
|
|
451
466
|
self.make_spec(axes=ax5,fits=fits)
|
|
452
467
|
|
|
453
468
|
### plotting PA on mom1
|
|
454
|
-
ypv=self.yc
|
|
455
|
-
xpv=
|
|
469
|
+
ypv=np.arange(-np.max(self.yc),np.max(self.yc),self.cellsize)
|
|
470
|
+
xpv=ypv*0.0
|
|
456
471
|
ang=self.posang
|
|
457
472
|
c = np.cos(np.deg2rad(ang))
|
|
458
473
|
s = np.sin(np.deg2rad(ang))
|
|
459
474
|
x2 = c*xpv - s*ypv
|
|
460
475
|
y2 = s*xpv + c*ypv
|
|
476
|
+
ax2.scatter(0,0,facecolors='none',edgecolors='k')
|
|
461
477
|
ax2.plot(x2,y2,'k--')
|
|
462
|
-
|
|
478
|
+
#breakpoint()
|
|
463
479
|
|
|
464
480
|
###### make summary box
|
|
465
481
|
|
|
@@ -478,7 +494,7 @@ class pymakeplots:
|
|
|
478
494
|
|
|
479
495
|
|
|
480
496
|
at2 = AnchoredText(thetext,
|
|
481
|
-
loc='upper right', prop=dict(size=
|
|
497
|
+
loc='upper right', prop=dict(size=25,multialignment='right'), frameon=False,
|
|
482
498
|
bbox_transform=textaxes.transAxes
|
|
483
499
|
)
|
|
484
500
|
textaxes.add_artist(at2)
|
|
@@ -531,7 +547,7 @@ class pymakeplots:
|
|
|
531
547
|
|
|
532
548
|
|
|
533
549
|
if pdf:
|
|
534
|
-
plt.savefig(self.galname+"_moment"+"".join(mom.astype(
|
|
550
|
+
plt.savefig(self.galname+"_moment"+"".join(mom.astype(str))+".pdf", bbox_inches = 'tight')
|
|
535
551
|
plt.close()
|
|
536
552
|
else:
|
|
537
553
|
if not outsideaxis:
|
|
@@ -553,9 +569,9 @@ class pymakeplots:
|
|
|
553
569
|
|
|
554
570
|
|
|
555
571
|
if np.log10(barlength_pc) > 3:
|
|
556
|
-
label=(barlength_pc/1e3).astype(
|
|
572
|
+
label=(barlength_pc/1e3).astype(str)+ " kpc"
|
|
557
573
|
else:
|
|
558
|
-
label=barlength_pc.astype(int).astype(
|
|
574
|
+
label=barlength_pc.astype(int).astype(str)+ " pc"
|
|
559
575
|
|
|
560
576
|
asb = AnchoredSizeBar(ax.transData, barlength_arc, label, loc=loc, pad=0.25, borderpad=0.5, sep=5, frameon=False)
|
|
561
577
|
ax.add_artist(asb)
|
|
@@ -564,7 +580,11 @@ class pymakeplots:
|
|
|
564
580
|
|
|
565
581
|
|
|
566
582
|
|
|
567
|
-
def clip_cube(self):
|
|
583
|
+
def clip_cube(self,xoffsetarc,yoffsetarc):
|
|
584
|
+
|
|
585
|
+
#
|
|
586
|
+
|
|
587
|
+
|
|
568
588
|
|
|
569
589
|
if self.chans2do == None:
|
|
570
590
|
# use the mask to try and guess the channels with signal.
|
|
@@ -585,18 +605,19 @@ class pymakeplots:
|
|
|
585
605
|
self.imagesize=[self.imagesize,self.imagesize]
|
|
586
606
|
|
|
587
607
|
|
|
588
|
-
wx,=np.where(
|
|
589
|
-
wy,=np.where(
|
|
590
|
-
self.spatial_trim=[np.min(wx),np.max(wx),np.min(wy),np.max(wy)]
|
|
608
|
+
wx,=np.where(np.abs(self.xcoord-xoffsetarc) <= self.imagesize[0])
|
|
609
|
+
wy,=np.where(np.abs(self.ycoord-yoffsetarc) <= self.imagesize[1])
|
|
610
|
+
self.spatial_trim=[np.min(wx),np.max(wx),np.min(wy),np.max(wy)]
|
|
611
|
+
|
|
591
612
|
|
|
592
613
|
if self.spatial_trim == None:
|
|
593
614
|
|
|
594
615
|
mom0=(self.pbcorr_cube > self.rmsfac*self.rms).sum(axis=2)
|
|
595
616
|
mom0[mom0>0]=1
|
|
596
617
|
|
|
597
|
-
cumulative_x = np.nancumsum(mom0.sum(axis=1),dtype=
|
|
618
|
+
cumulative_x = np.nancumsum(mom0.sum(axis=1),dtype=float)
|
|
598
619
|
cumulative_x /= np.nanmax(cumulative_x)
|
|
599
|
-
cumulative_y = np.nancumsum(mom0.sum(axis=0),dtype=
|
|
620
|
+
cumulative_y = np.nancumsum(mom0.sum(axis=0),dtype=float)
|
|
600
621
|
cumulative_y /= np.nanmax(cumulative_y)
|
|
601
622
|
|
|
602
623
|
wx_low,=np.where(cumulative_x < 0.02)
|
|
@@ -616,7 +637,6 @@ class pymakeplots:
|
|
|
616
637
|
self.spatial_trim = [np.clip(np.max(wx_low) - 2*beam_in_pix,0,self.xcoord.size),np.clip(np.min(wx_high) + 2*beam_in_pix,0,self.xcoord.size)\
|
|
617
638
|
, np.clip(np.max(wy_low) - 2*beam_in_pix,0,self.ycoord.size), np.clip(np.min(wy_high) + 2*beam_in_pix,0,self.ycoord.size)]
|
|
618
639
|
|
|
619
|
-
#breakpoint()
|
|
620
640
|
#print(np.where(np.isclose(self.xcoord-self.obj_ra,0,atol=self.cellsize/3600)))
|
|
621
641
|
self.flat_cube_trim=self.flat_cube[self.spatial_trim[0]:self.spatial_trim[1],self.spatial_trim[2]:self.spatial_trim[3],self.chans2do[0]:self.chans2do[1]]
|
|
622
642
|
self.pbcorr_cube_trim=self.pbcorr_cube[self.spatial_trim[0]:self.spatial_trim[1],self.spatial_trim[2]:self.spatial_trim[3],self.chans2do[0]:self.chans2do[1]]
|
|
@@ -625,7 +645,8 @@ class pymakeplots:
|
|
|
625
645
|
self.xcoord_trim=self.xcoord[self.spatial_trim[0]:self.spatial_trim[1]]
|
|
626
646
|
self.ycoord_trim=self.ycoord[self.spatial_trim[2]:self.spatial_trim[3]]
|
|
627
647
|
self.vcoord_trim=self.vcoord[self.chans2do[0]:self.chans2do[1]]
|
|
628
|
-
|
|
648
|
+
self.xc=(self.xcoord_trim-xoffsetarc)*(-1)
|
|
649
|
+
self.yc=(self.ycoord_trim-yoffsetarc)
|
|
629
650
|
|
|
630
651
|
|
|
631
652
|
|
|
@@ -643,11 +664,11 @@ class pymakeplots:
|
|
|
643
664
|
|
|
644
665
|
def add_beam(self,ax):
|
|
645
666
|
if self.all_axes_physical:
|
|
646
|
-
ae = AnchoredEllipse(ax.transData, width=self.ang2kpctrans(self.bmaj), height=self.ang2kpctrans(self.bmin), angle=self.bpa,
|
|
667
|
+
ae = AnchoredEllipse(ax.transData, width=self.ang2kpctrans(self.bmaj), height=self.ang2kpctrans(self.bmin), angle=self.bpa+90,
|
|
647
668
|
loc='lower left', pad=0.5, borderpad=0.4,
|
|
648
669
|
frameon=False)
|
|
649
670
|
else:
|
|
650
|
-
ae = AnchoredEllipse(ax.transData, width=self.bmaj, height=self.bmin, angle=self.bpa,
|
|
671
|
+
ae = AnchoredEllipse(ax.transData, width=self.bmaj, height=self.bmin, angle=self.bpa+90,
|
|
651
672
|
loc='lower left', pad=0.5, borderpad=0.4,
|
|
652
673
|
frameon=False)
|
|
653
674
|
ae.ellipse.set_edgecolor('black')
|
|
@@ -675,10 +696,10 @@ class pymakeplots:
|
|
|
675
696
|
levs=np.linspace(0,1,10)
|
|
676
697
|
mom0-=1
|
|
677
698
|
|
|
678
|
-
|
|
679
|
-
|
|
699
|
+
#mom0[mom0<minmom0]=np.nan
|
|
700
|
+
#breakpoint()
|
|
680
701
|
im1=ax1.contourf(self.xc,self.yc,mom0.T,levels=levs,cmap=newcmp)
|
|
681
|
-
|
|
702
|
+
#im1=ax1.pcolormesh(self.xc,self.yc,mom0.T,cmap=newcmp,vmin=minmom0,vmax=maxmom0)
|
|
682
703
|
|
|
683
704
|
if self.all_axes_physical:
|
|
684
705
|
ax1.set_xlabel('RA offset (kpc)')
|
|
@@ -705,6 +726,29 @@ class pymakeplots:
|
|
|
705
726
|
|
|
706
727
|
|
|
707
728
|
self.add_beam(ax1)
|
|
729
|
+
|
|
730
|
+
if np.any(self.points2plot != None):
|
|
731
|
+
naca=0
|
|
732
|
+
nalma=0
|
|
733
|
+
for xp,yp,diam in self.points2plot:
|
|
734
|
+
if diam/np.min(self.points2plot[:,2])>1.7:
|
|
735
|
+
ls=':' #aca
|
|
736
|
+
if naca ==0:
|
|
737
|
+
label='ACA'
|
|
738
|
+
else:
|
|
739
|
+
label=None
|
|
740
|
+
naca+=1
|
|
741
|
+
else:
|
|
742
|
+
ls='--' #12m
|
|
743
|
+
if nalma ==0:
|
|
744
|
+
label='12m'
|
|
745
|
+
else:
|
|
746
|
+
label=None
|
|
747
|
+
nalma+=1
|
|
748
|
+
circle2 = plt.Circle((xp, yp), diam/2., color='k',ls=ls, fill=False,alpha=0.2,label=label)
|
|
749
|
+
ax1.add_patch(circle2)
|
|
750
|
+
ax1.legend(frameon=False,loc='upper left',fontsize='x-small',markerscale=0.5)
|
|
751
|
+
|
|
708
752
|
if self.make_square:
|
|
709
753
|
ax1.set_xlim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
710
754
|
ax1.set_ylim(np.min([self.xc[0],self.yc[0]]),np.max([self.xc[-1],self.yc[-1]]))
|
|
@@ -729,7 +773,7 @@ class pymakeplots:
|
|
|
729
773
|
mom1=mom0.copy()*np.nan
|
|
730
774
|
mom1[mom0 != 0.0] = (((self.pbcorr_cube_trim*self.mask_trim)*self.vcoord_trim).sum(axis=2))[mom0 != 0.0]/mom0[mom0 != 0.0]
|
|
731
775
|
|
|
732
|
-
|
|
776
|
+
|
|
733
777
|
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)
|
|
734
778
|
|
|
735
779
|
im1=ax1.contourf(self.xc,self.yc,mom1.T-self.vsys,levels=self.vcoord_trim-self.vsys,cmap=sauron,vmin=vticks[0],vmax=vticks[-1])
|
|
@@ -825,9 +869,9 @@ class pymakeplots:
|
|
|
825
869
|
|
|
826
870
|
def write_fits(self,array,whichmoment):
|
|
827
871
|
if self.fits == True:
|
|
828
|
-
filename=self.galname+"_mom"+"".join(np.array([whichmoment]).astype(
|
|
872
|
+
filename=self.galname+"_mom"+"".join(np.array([whichmoment]).astype(str))+".fits"
|
|
829
873
|
else:
|
|
830
|
-
filename=self.fits+"_mom"+"".join(np.array([whichmoment]).astype(
|
|
874
|
+
filename=self.fits+"_mom"+"".join(np.array([whichmoment]).astype(str))+".fits"
|
|
831
875
|
|
|
832
876
|
|
|
833
877
|
newhdu = fits.PrimaryHDU(array)
|
|
@@ -864,8 +908,8 @@ class pymakeplots:
|
|
|
864
908
|
newhdu.header['CUNIT2']=self.spectralcube.header['CUNIT2']
|
|
865
909
|
newhdu.header['BMAJ']=self.bmaj/3600.
|
|
866
910
|
newhdu.header['BMIN']=self.bmin/3600.
|
|
867
|
-
newhdu.header['BPA']=self.bpa
|
|
868
|
-
newhdu.header['MOMCLIP']=(self.
|
|
911
|
+
newhdu.header['BPA']=self.bpa
|
|
912
|
+
newhdu.header['MOMCLIP']=(self.maskcliplevel, self.bunit+' km/s')
|
|
869
913
|
newhdu.header['VSYS']=(self.vsys,'km/s')
|
|
870
914
|
newhdu.header['comment'] = 'Moment map created with pymakeplots'
|
|
871
915
|
|
|
@@ -885,7 +929,7 @@ class pymakeplots:
|
|
|
885
929
|
filename=self.galname+"_pvd.fits"
|
|
886
930
|
else:
|
|
887
931
|
filename=self.fits+"_pvd.fits"
|
|
888
|
-
|
|
932
|
+
|
|
889
933
|
newhdu = fits.PrimaryHDU(pvd)
|
|
890
934
|
newhdu.header['CRPIX1']=1
|
|
891
935
|
newhdu.header['CRVAL1']=xx[0]
|
|
@@ -899,10 +943,10 @@ class pymakeplots:
|
|
|
899
943
|
newhdu.header['CUNIT2']='km/s'
|
|
900
944
|
newhdu.header['BMAJ']=self.bmaj/3600.
|
|
901
945
|
newhdu.header['BMIN']=self.bmin/3600.
|
|
902
|
-
newhdu.header['BPA']=self.bpa
|
|
946
|
+
newhdu.header['BPA']=self.bpa
|
|
903
947
|
newhdu.header['PVDANGLE']=(self.posang,'deg')
|
|
904
948
|
newhdu.header['PVDTHICK']=(self.pvdthick,'pixels')
|
|
905
|
-
newhdu.header['MOMCLIP']=(self.
|
|
949
|
+
newhdu.header['MOMCLIP']=(self.maskcliplevel, self.bunit+' km/s')
|
|
906
950
|
newhdu.header['VSYS']=(self.vsys,'km/s')
|
|
907
951
|
newhdu.header['comment'] = 'Moment map created with pymakeplots'
|
|
908
952
|
newhdu.header['BUNIT'] = self.bunit+' km/s'
|
|
@@ -910,7 +954,7 @@ class pymakeplots:
|
|
|
910
954
|
newhdu.writeto(filename,overwrite=True)
|
|
911
955
|
|
|
912
956
|
def make_pvd(self,axes=None,fits=False,pdf=False):
|
|
913
|
-
|
|
957
|
+
self.fits=fits
|
|
914
958
|
if np.any(self.xc) == None:
|
|
915
959
|
self.prepare_cubes()
|
|
916
960
|
|
|
@@ -938,13 +982,14 @@ class pymakeplots:
|
|
|
938
982
|
else:
|
|
939
983
|
print("Downsampling the observed moment one in PA estimate for speed. Set `useallpixels` to override.")
|
|
940
984
|
mom1[np.isfinite(mom1) == False] = self.vsys
|
|
941
|
-
|
|
985
|
+
#breakpoint()
|
|
986
|
+
interper = interpolate.RegularGridInterpolator((self.xc,self.yc),(mom1-self.vsys).T,bounds_error=False,fill_value=np.nan)
|
|
942
987
|
x=np.linspace(np.min(self.xc),np.max(self.xc),50)
|
|
943
988
|
y=np.linspace(np.min(self.yc),np.max(self.yc),50)
|
|
944
|
-
v= interper(x,y)
|
|
945
989
|
xv, yv = np.meshgrid(x,y)
|
|
990
|
+
v= interper((xv,yv))
|
|
946
991
|
x,y,v = xv.flatten(),yv.flatten(),v.flatten()
|
|
947
|
-
|
|
992
|
+
|
|
948
993
|
self.posang,_,_ = fit_kinematic_pa(x[np.isfinite(v)],y[np.isfinite(v)],v[np.isfinite(v)],nsteps=36,plot=False,quiet=True)
|
|
949
994
|
|
|
950
995
|
if np.sin(np.deg2rad((self.posang+45)*2)) > 0:
|
|
@@ -1008,13 +1053,16 @@ class pymakeplots:
|
|
|
1008
1053
|
|
|
1009
1054
|
if self.all_axes_physical:
|
|
1010
1055
|
axes.set_xlabel('Offset (kpc)')
|
|
1056
|
+
secaxy = axes.secondary_xaxis('top', functions=(self.ang2kpctrans_inv, self.ang2kpctrans))
|
|
1057
|
+
secaxy.set_xlabel('Offset (")')
|
|
1011
1058
|
else:
|
|
1012
1059
|
axes.set_xlabel('Offset (")')
|
|
1013
|
-
|
|
1060
|
+
secaxy = axes.secondary_xaxis('top', functions=(self.ang2kpctrans, self.ang2kpctrans_inv))
|
|
1061
|
+
secaxy.set_xlabel('Offset (kpc)')
|
|
1062
|
+
|
|
1014
1063
|
axes.set_ylabel('Velocity (km s$^{-1}$)')
|
|
1015
1064
|
|
|
1016
|
-
|
|
1017
|
-
secaxy.set_xlabel('Offset (kpc)')
|
|
1065
|
+
|
|
1018
1066
|
|
|
1019
1067
|
secax = axes.secondary_yaxis('right', functions=(self.vsystrans, self.vsystrans_inv))
|
|
1020
1068
|
secax.set_ylabel(r'V$_{\rm offset}$ (km s$^{-1}$)')
|
|
@@ -1024,7 +1072,7 @@ class pymakeplots:
|
|
|
1024
1072
|
|
|
1025
1073
|
if self.gal_distance != None and not self.all_axes_physical:
|
|
1026
1074
|
self.scalebar(axes,loc=loc2)
|
|
1027
|
-
|
|
1075
|
+
|
|
1028
1076
|
if self.fits:
|
|
1029
1077
|
self.write_pvd_fits(pvdaxis,vaxis,pvd.T)
|
|
1030
1078
|
|
|
@@ -1046,7 +1094,7 @@ class pymakeplots:
|
|
|
1046
1094
|
outsideaxis=1
|
|
1047
1095
|
spec=self.pbcorr_cube[self.spatial_trim[0]:self.spatial_trim[1],self.spatial_trim[2]:self.spatial_trim[3],:].sum(axis=0).sum(axis=0)
|
|
1048
1096
|
spec_mask=(self.pbcorr_cube_trim*self.mask_trim).sum(axis=0).sum(axis=0)
|
|
1049
|
-
|
|
1097
|
+
ylab="Unknown"
|
|
1050
1098
|
#breakpoint()
|
|
1051
1099
|
if (''.join(self.bunit.split())).lower() == "Jy/beam".lower():
|
|
1052
1100
|
|
|
@@ -1121,4 +1169,4 @@ class pymakeplots:
|
|
|
1121
1169
|
|
|
1122
1170
|
|
|
1123
1171
|
|
|
1124
|
-
|
|
1172
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pymakeplots
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Home-page: https://github.com/TimothyADavis/pymakeplots
|
|
5
5
|
Author: Timothy A. Davis
|
|
6
6
|
Author-email: DavisT@cardiff.ac.uk
|
|
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE.md
|
|
14
14
|
Requires-Dist: numpy
|
|
15
|
-
Requires-Dist: matplotlib
|
|
16
|
-
Requires-Dist: scipy
|
|
15
|
+
Requires-Dist: matplotlib >3.3.1
|
|
16
|
+
Requires-Dist: scipy >=1.14.0
|
|
17
17
|
Requires-Dist: astropy
|
|
18
18
|
Requires-Dist: spectral-cube
|
|
19
19
|
Requires-Dist: radio-beam
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pymakeplots/__init__.py,sha256=PLKnIm6rIKYjH_b6L9UBCFtv1lKt5GItdBKDbSOhuMU,87
|
|
2
|
+
pymakeplots/pymakeplots.py,sha256=EIeZH1brAg5d9QM9QqaViXFBBDDVCRDWnK1hKZ6ofXg,45950
|
|
3
|
+
pymakeplots/sauron_colormap.py,sha256=8APka-_L432wyICcHcySjk3qmjNOynb3iDjjlMuUTU0,4448
|
|
4
|
+
pymakeplots-0.2.1.dist-info/LICENSE.md,sha256=qtvmvajOPCad_5HMY5u49hldzBIXz7tbHbuGSG_HE5o,1077
|
|
5
|
+
pymakeplots-0.2.1.dist-info/METADATA,sha256=GGL0jJnyhIuv9bmggds2jNoWRTPbXyPU-cQ4jlJJ_3M,1847
|
|
6
|
+
pymakeplots-0.2.1.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
|
7
|
+
pymakeplots-0.2.1.dist-info/top_level.txt,sha256=KgG17vI_D6BsiKRe_81UU5709tXc6Ha7gx1IwjA7ur8,12
|
|
8
|
+
pymakeplots-0.2.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
9
|
+
pymakeplots-0.2.1.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pymakeplots/__init__.py,sha256=PLKnIm6rIKYjH_b6L9UBCFtv1lKt5GItdBKDbSOhuMU,87
|
|
2
|
-
pymakeplots/pymakeplots.py,sha256=WVHqfd0sqlvFFhY42Y96uC4M9xtgy33G_32bRFB4Gko,43998
|
|
3
|
-
pymakeplots/sauron_colormap.py,sha256=8APka-_L432wyICcHcySjk3qmjNOynb3iDjjlMuUTU0,4448
|
|
4
|
-
pymakeplots-0.1.7.dist-info/LICENSE.md,sha256=qtvmvajOPCad_5HMY5u49hldzBIXz7tbHbuGSG_HE5o,1077
|
|
5
|
-
pymakeplots-0.1.7.dist-info/METADATA,sha256=-nB_iIFkHnO4HgAn4Nv1TYBZSXkmISWxUmFa8NtiU0Q,1840
|
|
6
|
-
pymakeplots-0.1.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
7
|
-
pymakeplots-0.1.7.dist-info/top_level.txt,sha256=KgG17vI_D6BsiKRe_81UU5709tXc6Ha7gx1IwjA7ur8,12
|
|
8
|
-
pymakeplots-0.1.7.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
9
|
-
pymakeplots-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|