pymakeplots 0.2.5__tar.gz → 0.2.6__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.5
3
+ Version: 0.2.6
4
4
  Home-page: https://github.com/TimothyADavis/pymakeplots
5
5
  Author: Timothy A. Davis
6
6
  Author-email: DavisT@cardiff.ac.uk
@@ -19,6 +19,9 @@ Requires-Dist: spectral-cube
19
19
  Requires-Dist: radio-beam
20
20
  Requires-Dist: pafit
21
21
 
22
+ # pymakeplots
23
+ <img style="float:top,right" src="https://github.com/TimothyADavis/pymakeplots/blob/master/NGC1684_allplots.png">
24
+
22
25
  [![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-382/) [![PyPI version](https://badge.fury.io/py/pymakeplots.svg)](https://badge.fury.io/py/pymakeplots)
23
26
 
24
27
  A python module for making publication quality plots and output datafiles (including moment zero, one, two, PVD's and spectra) from interferometric datacubes.
@@ -1,3 +1,6 @@
1
+ # pymakeplots
2
+ <img style="float:top,right" src="https://github.com/TimothyADavis/pymakeplots/blob/master/NGC1684_allplots.png">
3
+
1
4
  [![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-382/) [![PyPI version](https://badge.fury.io/py/pymakeplots.svg)](https://badge.fury.io/py/pymakeplots)
2
5
 
3
6
  A python module for making publication quality plots and output datafiles (including moment zero, one, two, PVD's and spectra) from interferometric datacubes.
@@ -55,12 +55,16 @@ class pymakeplots:
55
55
  self.pbcorr_cube=None
56
56
  self.spectralcube=None
57
57
  self.mask=None
58
+ self.masksmoothing=0
59
+ self.maskdilating=0
58
60
  self.flat_cube_trim=None
59
61
  self.pbcorr_cube_trim=None
60
62
  self.mask_trim=None
63
+ self.pbcliplevel=None
61
64
  self.bmaj=None
62
65
  self.rotate=rotate
63
66
  self.smoothmask_spatial=1.5
67
+ self.smoothmask_velocity=4
64
68
  self.bmin=None
65
69
  self.bpa=None
66
70
  self.xcoord,self.ycoord,self.vcoord = None, None, None
@@ -97,6 +101,7 @@ class pymakeplots:
97
101
  self.suppress_subbeam_artifacts=False
98
102
  self.mom1_cmap=sauron
99
103
  self.mom2_cmap=sauron
104
+ self.pb_radial_cut=False
100
105
  #self.wcs=None
101
106
 
102
107
  if (cube != None)&(pb==None)&(cube_flat==None):
@@ -184,11 +189,25 @@ class pymakeplots:
184
189
  :return: (ndarray) mask to apply to the un-clipped cube
185
190
  """
186
191
  sigma = self.smoothmask_spatial * self.bmaj / self.cellsize
187
- smooth_cube = ndimage.uniform_filter(cube, size=[sigma, sigma,4], mode='constant') # mode='nearest'
192
+ smooth_cube = ndimage.uniform_filter(cube, size=[sigma, sigma,self.smoothmask_velocity], mode='constant') # mode='nearest'
188
193
  newrms= self.rms_estimate(smooth_cube,0,1)
189
- self.cliplevel=self.rms*self.rmsfac
194
+ self.cliplevel=self.rms*self.rmsfac
195
+
196
+ if self.pb_radial_cut or self.pbcliplevel!=None:
197
+ np.seterr(all='ignore')
198
+ pb=np.divide(self.flat_cube_trim,self.pbcorr_cube_trim)#,where=self.pbcorr_cube_trim!=0)
199
+
190
200
  self.maskcliplevel=newrms*self.rmsfac
191
- mask=(smooth_cube > self.maskcliplevel)
201
+
202
+ if self.pb_radial_cut:
203
+ mask=(smooth_cube > np.divide(self.maskcliplevel,np.abs(pb),where=pb!=0))
204
+ else:
205
+ mask=(np.abs(smooth_cube) > self.maskcliplevel)
206
+
207
+
208
+
209
+ if self.pbcliplevel!=None:
210
+ mask[pb<self.pbcliplevel]=False
192
211
 
193
212
  if self.suppress_subbeam_artifacts:
194
213
  label,cnt=ndimage.label(mask)#.sum(axis=2))
@@ -196,6 +215,52 @@ class pymakeplots:
196
215
  beampix=(self.bmaj*self.bmin)/(self.cellsize**2)
197
216
  for thelabel in lab[0:-1][hist<(beampix*self.suppress_subbeam_artifacts)]:
198
217
  mask[label == thelabel]=False
218
+ #maskorig=mask.copy()
219
+ if self.masksmoothing>0:
220
+ expand_by_npix=self.masksmoothing
221
+ print(expand_by_npix)
222
+ # structure = np.zeros([3, expand_by_npix * 2 + 1, expand_by_npix * 2 + 1])
223
+ # Y, X = np.ogrid[:expand_by_npix * 2 + 1, :expand_by_npix * 2 + 1]
224
+ # R = np.sqrt((X - expand_by_npix) ** 2 + (Y - expand_by_npix) ** 2)
225
+ # structure[1, :] = R <= expand_by_npix
226
+ # mask = ndimage.binary_dilation(mask, iterations=1, structure=structure)
227
+ #breakpoint()
228
+ mask = ndimage.binary_dilation(mask, iterations=expand_by_npix,axes=(0,1,2))
229
+
230
+ '''
231
+ r=np.linspace(1,0,self.masksmoothing+1,endpoint=False)[1:]
232
+ facs=np.exp(-((r-1)**2/(2*(0.33)**2)))
233
+
234
+ maskorig=mask.copy()
235
+ struct1 = ndimage.generate_binary_structure(2, 1)
236
+ for i,fac in enumerate(facs):
237
+ mask2 = ndimage.grey_dilation(maskorig.astype(float), (int(i+1),int(i+1),0), mode='constant') #
238
+ mask=np.fmax(mask,mask2*facs[i])
239
+ '''
240
+ #
241
+ #
242
+ #from kinms import KinMS
243
+ #from astropy.convolution import convolve
244
+ #psf=KinMS.makebeam(1,32, 32, [self.masksmoothing,self.masksmoothing,0])
245
+
246
+ #for i in range(0,mask.shape[2]):
247
+ # mask[:, :, i] = convolve(mask[:, :, i], psf) #binary
248
+ #mask=mask.astype(float)
249
+ #for i in range(0,mask.shape[2]):
250
+ # mask[:, :, i] = convolve(mask[:, :, i], psf) #smooth
251
+ #mask[mask<maskorig]=maskorig[mask<maskorig]
252
+ #mask=np.fmax(mask,maskorig)
253
+ #mask = ndimage.uniform_filter(mask.astype(float), size=[self.masksmoothing,self.masksmoothing,0], mode='constant') #
254
+ #print(mask.sum())
255
+
256
+
257
+
258
+ #mask = ndimage.gaussian_filter(mask.astype(float), [self.masksmoothing,self.masksmoothing,0], mode='constant') #
259
+ #if self.maskdilating != 0:
260
+ # mask=ndimage.grey_dilation(mask.astype(float), size=(np.round(self.maskdilating).astype(int),np.round(self.maskdilating).astype(int),0))
261
+
262
+
263
+ #breakpoint()
199
264
 
200
265
  return mask
201
266
 
@@ -1174,9 +1239,10 @@ class pymakeplots:
1174
1239
  centpix_y=np.where(np.isclose(self.yc,0.0,atol=self.cellsize/1.9))[0]
1175
1240
 
1176
1241
 
1177
-
1178
- rotcube= rotateImage(self.pbcorr_cube_trim*self.mask_trim,90-self.posang,[centpix_x[0],centpix_y[0]])
1179
-
1242
+ if self.posang!=0:
1243
+ rotcube= rotateImage(self.pbcorr_cube_trim*self.mask_trim,90-self.posang,[centpix_x[0],centpix_y[0]])
1244
+ else:
1245
+ rotcube=self.pbcorr_cube_trim*self.mask_trim
1180
1246
 
1181
1247
  pvd=rotcube[:,np.array(rotcube.shape[1]//2-self.pvdthick).astype(int):np.array(rotcube.shape[1]//2+self.pvdthick).astype(int),:].sum(axis=1)
1182
1248
 
@@ -1262,10 +1328,14 @@ class pymakeplots:
1262
1328
 
1263
1329
  mask2d=self.mask_trim.sum(axis=2).reshape((self.mask_trim.shape[0],self.mask_trim.shape[1],1)).astype(bool)
1264
1330
  mask2d=ndimage.binary_dilation(mask2d,iterations=2)
1265
- 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)
1266
-
1331
+ if self.bunit == "K":
1332
+ spec=np.nanmean(self.pbcorr_cube[self.spatial_trim[0]:self.spatial_trim[1],self.spatial_trim[2]:self.spatial_trim[3],:],axis=(0,1))*1e3
1333
+ spec_mask=np.nanmean((self.pbcorr_cube_trim*self.mask_trim),axis=(0,1))*1e3
1334
+ else:
1335
+ 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)
1336
+ spec_mask=(self.pbcorr_cube_trim*self.mask_trim).sum(axis=0).sum(axis=0)
1267
1337
 
1268
- spec_mask=(self.pbcorr_cube_trim*self.mask_trim).sum(axis=0).sum(axis=0)
1338
+
1269
1339
  ylab="Unknown"
1270
1340
 
1271
1341
  if (''.join(self.bunit.split())).lower() == "Jy/beam".lower():
@@ -1279,7 +1349,7 @@ class pymakeplots:
1279
1349
  else:
1280
1350
  ylab="Flux Density (Jy)"
1281
1351
  if self.bunit == "K":
1282
- ylab="Brightness Temp. (K)"
1352
+ ylab="Brightness Temp. (mK)"
1283
1353
 
1284
1354
  if nsum:
1285
1355
  spec=np.append(running_mean(spec,nsum),spec[-1])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymakeplots
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Home-page: https://github.com/TimothyADavis/pymakeplots
5
5
  Author: Timothy A. Davis
6
6
  Author-email: DavisT@cardiff.ac.uk
@@ -19,6 +19,9 @@ Requires-Dist: spectral-cube
19
19
  Requires-Dist: radio-beam
20
20
  Requires-Dist: pafit
21
21
 
22
+ # pymakeplots
23
+ <img style="float:top,right" src="https://github.com/TimothyADavis/pymakeplots/blob/master/NGC1684_allplots.png">
24
+
22
25
  [![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-382/) [![PyPI version](https://badge.fury.io/py/pymakeplots.svg)](https://badge.fury.io/py/pymakeplots)
23
26
 
24
27
  A python module for making publication quality plots and output datafiles (including moment zero, one, two, PVD's and spectra) from interferometric datacubes.
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
 
7
7
  setup(name='pymakeplots',
8
- version='0.2.5',
8
+ version='0.2.6',
9
9
  description='',
10
10
  url='https://github.com/TimothyADavis/pymakeplots',
11
11
  author='Timothy A. Davis',
File without changes
File without changes