pymakeplots 0.2.2__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymakeplots
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Home-page: https://github.com/TimothyADavis/pymakeplots
5
5
  Author: Timothy A. Davis
6
6
  Author-email: DavisT@cardiff.ac.uk
@@ -40,7 +40,7 @@ def rotateImage(img, angle, pivot):
40
40
 
41
41
 
42
42
  class pymakeplots:
43
- def __init__(self,cube_flat=None,pb=None,cube=None,rest_value=None):
43
+ def __init__(self,cube_flat=None,pb=None,cube=None,rest_value=None,velocity_convention='radio'):
44
44
  self.galname=None
45
45
  self.gal_distance=None
46
46
  self.posang=None
@@ -58,6 +58,7 @@ class pymakeplots:
58
58
  self.pbcorr_cube_trim=None
59
59
  self.mask_trim=None
60
60
  self.bmaj=None
61
+ self.smoothmask_spatial=1.5
61
62
  self.bmin=None
62
63
  self.bpa=None
63
64
  self.xcoord,self.ycoord,self.vcoord = None, None, None
@@ -67,6 +68,7 @@ class pymakeplots:
67
68
  self.silent=False # rig for silent running if true
68
69
  self.bardist=None
69
70
  self.rmsfac=3
71
+ self.velocity_convention=velocity_convention
70
72
  self.restfreq=None
71
73
  self.repfreq=None
72
74
  self.obj_ra=None
@@ -103,7 +105,7 @@ class pymakeplots:
103
105
 
104
106
  if (cube_flat != None)&(pb!=None):
105
107
  # flat cube and pb given
106
- if np.any(self.pbcorr_cube) == None: #check if the user gave all three cubes, in which case this call is redundant
108
+ if np.any(self.pbcorr_cube == None): #check if the user gave all three cubes, in which case this call is redundant
107
109
  self.input_cube_flat(cube_flat,pb,rest_value=rest_value)
108
110
 
109
111
  if (cube != None)&(pb==None)&(cube_flat!=None):
@@ -177,7 +179,7 @@ class pymakeplots:
177
179
  Apply a Gaussian blur, using sigma = 4 in the velocity direction (seems to work best), to the uncorrected cube.
178
180
  :return: (ndarray) mask to apply to the un-clipped cube
179
181
  """
180
- sigma = 1.5 * self.bmaj / self.cellsize
182
+ sigma = self.smoothmask_spatial * self.bmaj / self.cellsize
181
183
  smooth_cube = ndimage.uniform_filter(cube, size=[sigma, sigma,4], mode='constant') # mode='nearest'
182
184
  newrms= self.rms_estimate(smooth_cube,0,1)
183
185
  self.cliplevel=self.rms*self.rmsfac
@@ -334,7 +336,7 @@ class pymakeplots:
334
336
 
335
337
  def read_in_a_cube(self,path,rest_value=None,primary=False):
336
338
 
337
- scube=SpectralCube.read(path).with_spectral_unit(u.km/u.s, velocity_convention='radio',rest_value=rest_value)
339
+ scube=SpectralCube.read(path).with_spectral_unit(u.km/u.s, velocity_convention=self.velocity_convention,rest_value=rest_value)
338
340
 
339
341
  hdr=scube.header
340
342
  cube = np.squeeze(scube.filled_data[:,:,:].T).value #squeeze to remove singular stokes axis if present
@@ -519,14 +521,14 @@ class pymakeplots:
519
521
  def make_moments(self,axes=None,mom=[0,1,2],pdf=False,fits=False):
520
522
  mom=np.array(mom)
521
523
  self.fits=fits
522
-
523
- if np.any(self.xc) == None:
524
+
525
+ if np.any(self.xc == None):
524
526
  self.prepare_cubes()
525
527
 
526
528
  self.set_rc_params()
527
529
 
528
530
  nplots=mom.size
529
- if np.any(axes) == None:
531
+ if np.any(axes == None):
530
532
  if self.make_square:
531
533
  fig,axes=plt.subplots(1,nplots,sharey=True,figsize=(7*nplots,7), gridspec_kw = {'wspace':0, 'hspace':0})
532
534
  else:
@@ -968,10 +970,10 @@ class pymakeplots:
968
970
 
969
971
  def make_pvd(self,axes=None,fits=False,pdf=False):
970
972
  self.fits=fits
971
- if np.any(self.xc) == None:
973
+ if np.any(self.xc == None):
972
974
  self.prepare_cubes()
973
975
 
974
- if np.any(axes) == None:
976
+ if np.any(axes == None):
975
977
  self.set_rc_params(mult=0.75)
976
978
  fig,axes=plt.subplots(1,figsize=(7,5))
977
979
  outsideaxis=0
@@ -1137,19 +1139,25 @@ class pymakeplots:
1137
1139
 
1138
1140
  def make_spec(self,axes=None,fits=False,pdf=False,onlydata=False,nsum=False,highlight=False):
1139
1141
  self.fits=fits
1140
- if np.any(self.xc) == None:
1142
+ if np.any(self.xc == None):
1141
1143
  self.prepare_cubes()
1142
1144
 
1143
- if axes == None:
1145
+ if np.any(axes == None):
1144
1146
  self.set_rc_params(mult=0.75)
1145
1147
  fig,axes=plt.subplots(1,figsize=(7,5))
1146
1148
  outsideaxis=0
1147
1149
  else:
1148
1150
  outsideaxis=1
1149
- 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)
1151
+ #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)
1152
+
1153
+ mask2d=self.mask_trim.sum(axis=2).reshape((self.mask_trim.shape[0],self.mask_trim.shape[1],1)).astype(bool)
1154
+ mask2d=ndimage.binary_dilation(mask2d,iterations=2)
1155
+ spec=(self.pbcorr_cube[self.spatial_trim[0]:self.spatial_trim[1],self.spatial_trim[2]:self.spatial_trim[3],:]*mask2d).sum(axis=0).sum(axis=0)
1156
+
1157
+
1150
1158
  spec_mask=(self.pbcorr_cube_trim*self.mask_trim).sum(axis=0).sum(axis=0)
1151
1159
  ylab="Unknown"
1152
- #breakpoint()
1160
+
1153
1161
  if (''.join(self.bunit.split())).lower() == "Jy/beam".lower():
1154
1162
 
1155
1163
  spec*=1/self.beam_area()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymakeplots
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Home-page: https://github.com/TimothyADavis/pymakeplots
5
5
  Author: Timothy A. Davis
6
6
  Author-email: DavisT@cardiff.ac.uk
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
 
7
7
  setup(name='pymakeplots',
8
- version='0.2.2',
8
+ version='0.2.3',
9
9
  description='',
10
10
  url='https://github.com/TimothyADavis/pymakeplots',
11
11
  author='Timothy A. Davis',
File without changes
File without changes
File without changes