plotastrodata 1.4.10__tar.gz → 1.4.12__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.
Files changed (23) hide show
  1. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/PKG-INFO +1 -1
  2. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/analysis_utils.py +24 -14
  4. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/fft_utils.py +1 -1
  5. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/fitting_utils.py +2 -2
  6. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/plot_utils.py +6 -6
  7. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/PKG-INFO +1 -1
  8. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/LICENSE +0 -0
  9. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/README.md +0 -0
  10. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/const_utils.py +0 -0
  11. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/coord_utils.py +0 -0
  12. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/ext_utils.py +0 -0
  13. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/los_utils.py +0 -0
  15. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/matrix_utils.py +0 -0
  16. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata/other_utils.py +0 -0
  17. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/SOURCES.txt +0 -0
  18. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/dependency_links.txt +0 -0
  19. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/not-zip-safe +0 -0
  20. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/requires.txt +0 -0
  21. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/plotastrodata.egg-info/top_level.txt +0 -0
  22. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/setup.cfg +0 -0
  23. {plotastrodata-1.4.10 → plotastrodata-1.4.12}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plotastrodata
3
- Version: 1.4.10
3
+ Version: 1.4.12
4
4
  Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
5
5
  Home-page: https://github.com/yusukeaso-astron/plotastrodata
6
6
  Download-URL: https://github.com/yusukeaso-astron/plotastrodata
@@ -1,4 +1,4 @@
1
1
  import warnings
2
2
 
3
3
  warnings.simplefilter('ignore', UserWarning)
4
- __version__ = '1.4.10'
4
+ __version__ = '1.4.12'
@@ -199,7 +199,7 @@ class AstroData():
199
199
  self.rotate(-bpa)
200
200
  nx = len(self.x) if len(self.x) % 2 == 1 else len(self.x) - 1
201
201
  ny = len(self.y) if len(self.y) % 2 == 1 else len(self.y) - 1
202
- y = np.linspace(-(ny-1) / 2, (ny-1) / 2, ny) * (self.y[1]-self.y[0])
202
+ y = np.linspace(-(ny-1) / 2, (ny-1) / 2, ny) * np.abs(self.dy)
203
203
  g1 = np.exp(-4*np.log(2) * y**2 / (bmaj**2 - bmin**2))
204
204
  g1 /= np.sqrt(np.pi/4/np.log(2) * bmin * np.sqrt(1 - bmin**2/bmaj**2))
205
205
  g = np.zeros((ny, nx))
@@ -256,10 +256,8 @@ class AstroData():
256
256
  d = self.data if chan is None else self.data[chan]
257
257
  x, y = np.meshgrid(self.x, self.y)
258
258
  if None not in self.beam:
259
- dx = self.x[1] - self.x[0]
260
- dy = self.y[1] - self.y[0]
261
259
  Omega = np.pi * self.beam[0] * self.beam[1] / 4 / np.log(2)
262
- pixelperbeam = Omega / np.abs(dx * dy)
260
+ pixelperbeam = Omega / np.abs(self.dx * self.dy)
263
261
  else:
264
262
  pixelperbeam = 1.
265
263
 
@@ -296,7 +294,7 @@ class AstroData():
296
294
  d = self.data if chan is None else self.data[chan]
297
295
  x = self.x
298
296
  y = self.y
299
- ds = np.min([np.abs(x[1] - x[0]), np.abs(y[1] - y[0])])
297
+ ds = np.min([np.abs(self.dx), np.abs(self.dy)])
300
298
  p0 = (np.max(d), np.median(x), np.median(y), 5 * ds, 5 * ds, 0)
301
299
  amax = np.max(np.abs(d))
302
300
  xmin = np.min(x)
@@ -377,6 +375,7 @@ class AstroData():
377
375
  xlist, ylist = coord2xy(coords, self.center) * 3600.
378
376
  nprof = len(xlist)
379
377
  v = self.v
378
+ dv = self.dv
380
379
  data, xf, yf = filled2d(self.data, self.x, self.y, ninterp)
381
380
  x, y = np.meshgrid(xf, yf)
382
381
  prof = np.empty((nprof, len(v)))
@@ -397,13 +396,12 @@ class AstroData():
397
396
  prof[i] = [np.mean(d[r <= 1]) for d in data]
398
397
  if flux and (None not in self.beam):
399
398
  Omega = np.pi * self.beam[0] * self.beam[1] / 4. / np.log(2.)
400
- dxdy = np.abs((yf[1]-yf[0]) * (xf[1]-xf[0]))
401
- prof *= dxdy / Omega
399
+ prof *= np.abs(self.dx * self.dy) / Omega
402
400
  gfitres = {}
403
401
  if gaussfit:
404
402
  xmin, xmax = np.min(v), np.max(v)
405
403
  ymin, ymax = np.min(prof), np.max(prof)
406
- bounds = [[ymin, xmin, v[1] - v[0]], [ymax, xmax, xmax - xmin]]
404
+ bounds = [[ymin, xmin, np.abs(dv)], [ymax, xmax, xmax - xmin]]
407
405
 
408
406
  def gauss(x, p, c, w):
409
407
  return p * np.exp(-4. * np.log(2.) * ((x - c) / w)**2)
@@ -443,7 +441,7 @@ class AstroData():
443
441
  np.ndarray: [x, data]. If self.data is 3D, the output data are in the shape of (len(v), len(x)).
444
442
  """
445
443
  if dx is None:
446
- dx = np.abs(self.x[1] - self.x[0])
444
+ dx = np.abs(self.dx)
447
445
  n = int(np.ceil(length / 2 / dx))
448
446
  r = np.linspace(-n, n, 2 * n + 1) * dx
449
447
  pa_rad = np.radians(pa)
@@ -476,7 +474,7 @@ class AstroData():
476
474
  h['NAXIS1'] = len(self.x)
477
475
  h['CRPIX1'] = np.argmin(np.abs(self.x)) + 1
478
476
  h['CRVAL1'] = cx
479
- h['CDELT1'] = self.x[1] - self.x[0]
477
+ h['CDELT1'] = self.dx
480
478
  if fhd is not None and isdeg(fhd['CUNIT1']):
481
479
  h['CDELT1'] = h['CDELT1'] / 3600
482
480
  vaxis = '2' if self.pv else '3'
@@ -484,12 +482,12 @@ class AstroData():
484
482
  k_vmin = np.argmin(np.abs(self.v))
485
483
  h[f'CRPIX{vaxis}'] = k_vmin + 1
486
484
  h[f'CRVAL{vaxis}'] = (1 - self.v[k_vmin]/cu.c_kms) * self.restfreq
487
- h[f'CDELT{vaxis}'] = (self.v[0]-self.v[1]) / cu.c_kms * self.restfreq
485
+ h[f'CDELT{vaxis}'] = -self.dv / cu.c_kms * self.restfreq
488
486
  if not self.pv:
489
487
  h['NAXIS2'] = len(self.y)
490
488
  h['CRPIX2'] = np.argmin(np.abs(self.y)) + 1
491
489
  h['CRVAL2'] = cy
492
- h['CDELT2'] = self.y[1] - self.y[0]
490
+ h['CDELT2'] = self.dy
493
491
  if fhd is not None and isdeg(fhd['CUNIT2']):
494
492
  h['CDELT2'] = h['CDELT2'] / 3600
495
493
  if None not in self.beam:
@@ -683,6 +681,10 @@ class AstroFrame():
683
681
  d.data[i], grid[2] = d.data[i][::-1], grid[2][::-1]
684
682
  print('Velocity has been inverted.')
685
683
  d.v = grid[2]
684
+ if d.v is not None and len(d.v) > 1:
685
+ d.dv = d.v[1] - d.v[0]
686
+ else:
687
+ d.dv = None
686
688
  grid = grid[:3:2] if self.pv else grid[:2]
687
689
  if self.swapxy:
688
690
  grid = [grid[1], grid[0]]
@@ -695,6 +697,14 @@ class AstroFrame():
695
697
  a = np.moveaxis(a, [0, 1], [-2, -1])
696
698
  d.data[i] = a
697
699
  d.x, d.y = grid
700
+ if d.x is not None and len(d.x) > 1:
701
+ d.dx = d.x[1] - d.x[0]
702
+ else:
703
+ d.dx = None
704
+ if d.y is not None and len(d.y) > 1:
705
+ d.dy = d.y[1] - d.y[0]
706
+ else:
707
+ d.dy = None
698
708
  if self.quadrants is not None:
699
709
  d.data[i], d.x, d.y \
700
710
  = quadrantmean(d.data[i], d.x, d.y, self.quadrants)
@@ -702,7 +712,7 @@ class AstroFrame():
702
712
  if d.sigma[i] is not None:
703
713
  d.sigma[i] = d.sigma[i] * d.cfactor[i]
704
714
  if d.Tb[i]:
705
- dx = d.y[1] - d.y[0] if self.swapxy else d.x[1] - d.x[0]
715
+ dx = d.dy if self.swapxy else d.dx
706
716
  header = {'CDELT1': dx / 3600,
707
717
  'CUNIT1': 'DEG',
708
718
  'RESTFREQ': d.restfreq[i]}
@@ -718,7 +728,7 @@ class AstroFrame():
718
728
  print('pvpa is not specified. pvpa=bmaj is assumed.')
719
729
  p = np.radians(bpa - d.pvpa[i])
720
730
  b = 1 / np.hypot(np.cos(p) / bmaj, np.sin(p) / bmin)
721
- d.beam[i] = np.array([d.v[1] - d.v[0], b, 0])
731
+ d.beam[i] = np.array([np.abs(d.dv), b, 0])
722
732
  d.Tb[i] = False
723
733
  d.cfactor[i] = 1
724
734
  if d.fitsimage[i] is not None:
@@ -154,7 +154,7 @@ def ifftcentering2(F: np.ndarray,
154
154
  if y0 is not None:
155
155
  y = y - y[0] + y0
156
156
  dx, dy = x[1] - x[0], y[1] - y[0]
157
- F = shiftphase(F, u, v, x[-1] + dx - xcenter, y[-1] + dy - ycenter)
157
+ F = shiftphase2(F, u, v, x[-1] + dx - xcenter, y[-1] + dy - ycenter)
158
158
  f = np.fft.ifft2(np.fft.ifftshift(F))
159
159
  if outreal:
160
160
  f = np.real(f)
@@ -249,8 +249,8 @@ class EmceeCorner():
249
249
  if type(log) is bool:
250
250
  log = [log] * self.dim
251
251
  pargrid = []
252
- for start, stop, num, uselog \
253
- in zip(self.bounds[:, 0], self.bounds[:, 1], ngrid, log):
252
+ inzip = [self.bounds[:, 0], self.bounds[:, 1], ngrid, log]
253
+ for start, stop, num, uselog in zip(*inzip):
254
254
  args = [start, stop, num]
255
255
  pargrid.append(np.geomspace(*args) if uselog else np.linspace(*args))
256
256
  p = np.exp(self.logl(np.meshgrid(*pargrid[::-1], indexing='ij')[::-1]))
@@ -379,7 +379,7 @@ class PlotAstroData(AstroFrame):
379
379
  nv = len(v := v[::vskip])
380
380
  npages = int(np.ceil(nv / nrows / ncols))
381
381
  nchan = npages * nrows * ncols
382
- v = np.r_[v, v[-1] + (np.arange(nchan-nv)+1) * (v[1] - v[0])]
382
+ v = np.r_[v, v[-1] + (np.arange(nchan - nv) + 1) * dv]
383
383
  if type(channelnumber) is int:
384
384
  nchan = npages = 1
385
385
 
@@ -1303,7 +1303,7 @@ def plot3d(levels: list[float] = [3, 6, 12],
1303
1303
  d = kwargs2AstroData(kwargs)
1304
1304
  f.read(d, xskip, yskip)
1305
1305
  volume, x, y, v, sigma = d.data, d.x, d.y, d.v, d.sigma
1306
- dx, dy, dv = x[1] - x[0], y[1] - y[0], v[1] - v[0]
1306
+ dx, dy, dv = d.dx, d.dy, d.dv
1307
1307
  volume[np.isnan(volume)] = 0
1308
1308
  if dx < 0:
1309
1309
  x, dx, volume = x[::-1], -dx, volume[:, :, ::-1]
@@ -1376,11 +1376,11 @@ def plot3d(levels: list[float] = [3, 6, 12],
1376
1376
  a = int(sign == -1)
1377
1377
  b = int(sign == 1)
1378
1378
  volume = np.moveaxis([volume * a, volume * b], 0, axis)
1379
- if d.x[1] - d.x[0] < 0:
1379
+ if d.dx < 0:
1380
1380
  volume = volume[:, :, ::-1]
1381
- if d.y[1] - d.y[0] < 0:
1381
+ if d.dy < 0:
1382
1382
  volume = volume[:, ::-1, :]
1383
- if d.v[1] - d.v[0] < 0:
1383
+ if d.dv < 0:
1384
1384
  volume = volume[::-1, :, :]
1385
1385
  for lev in levels:
1386
1386
  if lev * sigma > np.max(volume):
@@ -1414,4 +1414,4 @@ def plot3d(levels: list[float] = [3, 6, 12],
1414
1414
  return {'data': data, 'layout': layout}
1415
1415
  else:
1416
1416
  fig = go.Figure(data=data, layout=layout)
1417
- fig.write_html(file=outname + '.html', auto_play=show)
1417
+ fig.write_html(file=outname.replace('.html', '') + '.html', auto_play=show)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plotastrodata
3
- Version: 1.4.10
3
+ Version: 1.4.12
4
4
  Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
5
5
  Home-page: https://github.com/yusukeaso-astron/plotastrodata
6
6
  Download-URL: https://github.com/yusukeaso-astron/plotastrodata
File without changes
File without changes
File without changes
File without changes