vidavis 0.0.5__py3-none-any.whl → 0.0.6__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.
- vidavis/__version__.py +1 -1
- vidavis/apps/_ms_raster.py +6 -3
- vidavis/plot/ms_plot/_ms_plot.py +73 -50
- {vidavis-0.0.5.dist-info → vidavis-0.0.6.dist-info}/METADATA +3 -23
- {vidavis-0.0.5.dist-info → vidavis-0.0.6.dist-info}/RECORD +7 -7
- {vidavis-0.0.5.dist-info → vidavis-0.0.6.dist-info}/WHEEL +0 -0
- {vidavis-0.0.5.dist-info → vidavis-0.0.6.dist-info}/licenses/LICENSE +0 -0
vidavis/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.0.
|
|
1
|
+
__version__ = '0.0.6'
|
vidavis/apps/_ms_raster.py
CHANGED
|
@@ -244,10 +244,13 @@ class MsRaster(MsPlot):
|
|
|
244
244
|
Args:
|
|
245
245
|
filename (str): Name of file to save. Default '': the plot will be saved as {ms}_raster.{ext}.
|
|
246
246
|
If fmt is not set for extension, plot will be saved as .png.
|
|
247
|
-
fmt (str): Format of file to save ('png', '
|
|
247
|
+
fmt (str): Format of file to save ('png', 'svg', or 'html').
|
|
248
248
|
Default 'auto': inferred from filename extension.
|
|
249
|
-
width (int): width of exported plot.
|
|
250
|
-
height (int): height of exported plot.
|
|
249
|
+
width (int): width of exported plot in pixels.
|
|
250
|
+
height (int): height of exported plot in pixels.
|
|
251
|
+
|
|
252
|
+
If subplots defines a grid layout, width and height describe the size of each plot in the layout.
|
|
253
|
+
The layout plot size will be (width * columns, height * rows) pixels.
|
|
251
254
|
|
|
252
255
|
If iteration plots were created:
|
|
253
256
|
If subplots is a grid, the layout plot will be saved to a single file.
|
vidavis/plot/ms_plot/_ms_plot.py
CHANGED
|
@@ -5,11 +5,13 @@ Base class for ms plots
|
|
|
5
5
|
import os
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
from bokeh.
|
|
8
|
+
from bokeh.io import export_png, export_svg
|
|
9
|
+
from bokeh.plotting import save, show
|
|
9
10
|
import hvplot
|
|
10
11
|
import holoviews as hv
|
|
11
12
|
import numpy as np
|
|
12
13
|
import panel as pn
|
|
14
|
+
from selenium import webdriver
|
|
13
15
|
|
|
14
16
|
try:
|
|
15
17
|
from toolviper.utils.logger import get_logger, setup_logger
|
|
@@ -140,27 +142,21 @@ class MsPlot:
|
|
|
140
142
|
self._plots_locked = True
|
|
141
143
|
|
|
142
144
|
# Single plot or combine plots into layout using subplots (rows, columns)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
# Render to bokeh figure
|
|
148
|
-
if is_layout:
|
|
149
|
-
# Show plots in columns
|
|
150
|
-
plot = hv.render(layout_plot.cols(subplots[1]))
|
|
151
|
-
else:
|
|
152
|
-
# Show single plot
|
|
153
|
-
plot = hv.render(layout_plot)
|
|
145
|
+
layout_plot = self._layout_plots(self._plot_inputs['subplots'])
|
|
146
|
+
|
|
147
|
+
# Render plot as Bokeh Figure or GridPlot
|
|
148
|
+
bokeh_fig = hv.render(layout_plot)
|
|
154
149
|
|
|
155
150
|
self._plots_locked = False
|
|
156
151
|
if self._plot_params:
|
|
152
|
+
# Show plot and plot inputs in tabs
|
|
157
153
|
column = pn.Column()
|
|
158
154
|
for param in self._plot_params:
|
|
159
155
|
column.append(pn.pane.Str(param))
|
|
160
|
-
tabs = pn.Tabs(('Plot',
|
|
156
|
+
tabs = pn.Tabs(('Plot', bokeh_fig), ('Plot Inputs', column))
|
|
161
157
|
tabs.show(title=self._app_name, threaded=True)
|
|
162
158
|
else:
|
|
163
|
-
show(
|
|
159
|
+
show(bokeh_fig)
|
|
164
160
|
|
|
165
161
|
def save(self, filename='ms_plot.png', fmt='auto', width=900, height=600):
|
|
166
162
|
'''
|
|
@@ -175,51 +171,78 @@ class MsPlot:
|
|
|
175
171
|
|
|
176
172
|
start_time = time.time()
|
|
177
173
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
subplots = self._plot_inputs['subplots']
|
|
181
|
-
layout_plot, is_layout = self._layout_plots(subplots)
|
|
182
|
-
|
|
183
|
-
if is_layout:
|
|
184
|
-
# Save plots combined into one layout
|
|
185
|
-
hvplot.save(layout_plot.cols(subplots[1]), filename=filename, fmt=fmt)
|
|
186
|
-
self._logger.info("Saved plot to %s.", filename)
|
|
187
|
-
else:
|
|
188
|
-
# Save plots individually, with index appended if exprange='all' and multiple plots.
|
|
189
|
-
if self._plot_inputs['iter_axis'] is None:
|
|
190
|
-
hvplot.save(layout_plot.opts(width=width, height=height), filename=filename, fmt=fmt)
|
|
191
|
-
self._logger.info("Saved plot to %s.", filename)
|
|
192
|
-
else:
|
|
193
|
-
name, ext = os.path.splitext(filename)
|
|
194
|
-
iter_range = self._plot_inputs['iter_range'] # None or (start, end)
|
|
195
|
-
plot_idx = 0 if iter_range is None else iter_range[0]
|
|
174
|
+
name, ext = os.path.splitext(filename)
|
|
175
|
+
fmt = ext[1:] if fmt=='auto' else fmt
|
|
196
176
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
self._logger.info("Saved plot to %s.", exportname)
|
|
201
|
-
plot_idx += 1
|
|
177
|
+
# Combine plots into layout using subplots (rows, columns) if not single plot.
|
|
178
|
+
# Set fixed size for export.
|
|
179
|
+
layout_plot = self._layout_plots(self._plot_inputs['subplots'], (width, height))
|
|
202
180
|
|
|
181
|
+
if not isinstance(layout_plot, hv.Layout) and self._plot_inputs['iter_axis']:
|
|
182
|
+
# Save iterated plots individually, with index appended to filename
|
|
183
|
+
plot_idx = 0 if self._plot_inputs['iter_range'] is None else self._plot_inputs['iter_range'][0]
|
|
184
|
+
for plot in self._plots:
|
|
185
|
+
exportname = f"{name}_{plot_idx}{ext}"
|
|
186
|
+
self._save_plot(plot, exportname, fmt)
|
|
187
|
+
plot_idx += 1
|
|
188
|
+
else:
|
|
189
|
+
self._save_plot(layout_plot, filename, fmt)
|
|
203
190
|
self._logger.debug("Save elapsed time: %.2fs.", time.time() - start_time)
|
|
204
191
|
|
|
205
|
-
def _layout_plots(self, subplots):
|
|
192
|
+
def _layout_plots(self, subplots, fixed_size=None):
|
|
193
|
+
''' Combine plots in a layout, using fixed size for the layout if given '''
|
|
206
194
|
subplots = (1, 1) if subplots is None else subplots
|
|
207
|
-
num_plots = len(self._plots)
|
|
208
|
-
|
|
195
|
+
num_plots = min(len(self._plots), np.prod(subplots))
|
|
196
|
+
plot_width = fixed_size[0] if fixed_size else None
|
|
197
|
+
plot_height = fixed_size[1] if fixed_size else None
|
|
209
198
|
|
|
210
|
-
if
|
|
211
|
-
|
|
199
|
+
if num_plots == 1:
|
|
200
|
+
# Single plot, not layout
|
|
201
|
+
plot = self._plots[0]
|
|
202
|
+
if fixed_size:
|
|
203
|
+
plot = plot.opts(responsive=False, width=plot_width, height=plot_height, clone=True)
|
|
204
|
+
return plot
|
|
212
205
|
|
|
213
206
|
# Set plots in layout
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
for i in range(num_layout_plots):
|
|
207
|
+
layout_plot = None
|
|
208
|
+
for i in range(num_plots):
|
|
217
209
|
plot = self._plots[i]
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
210
|
+
if fixed_size:
|
|
211
|
+
plot = plot.opts(responsive=False, width=plot_width, height=plot_height, clone=True)
|
|
212
|
+
layout_plot = plot if layout_plot is None else layout_plot + plot
|
|
213
|
+
|
|
214
|
+
# Layout in columns
|
|
215
|
+
return layout_plot.cols(subplots[1])
|
|
216
|
+
|
|
217
|
+
def _save_plot(self, plot, filename, fmt):
|
|
218
|
+
''' Save plot using hvplot, else bokeh '''
|
|
219
|
+
# Remove toolbar unless html
|
|
220
|
+
toolbar = 'right' if fmt=='html' else None
|
|
221
|
+
plot = plot.opts(toolbar=toolbar, clone=True)
|
|
222
|
+
|
|
223
|
+
try:
|
|
224
|
+
hvplot.save(plot, filename=filename, fmt=fmt)
|
|
225
|
+
except (Exception, RuntimeError) as exc:
|
|
226
|
+
# Fails if hvplot cannot find web driver or fmt is svg.
|
|
227
|
+
# Render a Bokeh Figure or GridPlot, create webdriver, then use Bokeh to export.
|
|
228
|
+
fig = hv.render(plot)
|
|
229
|
+
if fmt=='html':
|
|
230
|
+
save(fig, filename)
|
|
231
|
+
elif fmt in ['png', 'svg']:
|
|
232
|
+
# Use Chrome web driver
|
|
233
|
+
service = webdriver.ChromeService()
|
|
234
|
+
options = webdriver.ChromeOptions()
|
|
235
|
+
options.add_argument('--headless')
|
|
236
|
+
options.add_argument('--no-sandbox')
|
|
237
|
+
|
|
238
|
+
with webdriver.Chrome(service=service, options=options) as driver:
|
|
239
|
+
if fmt=='png':
|
|
240
|
+
export_png(fig, filename=filename, webdriver=driver)
|
|
241
|
+
elif fmt=='svg':
|
|
242
|
+
export_svg(fig, filename=filename, webdriver=driver)
|
|
243
|
+
else:
|
|
244
|
+
raise ValueError(f"Invalid fmt or filename extension {fmt} for save()") from exc
|
|
245
|
+
self._logger.info("Saved plot to %s.", filename)
|
|
223
246
|
|
|
224
247
|
def _set_ms(self, ms_path):
|
|
225
248
|
''' Set MsData and update ms info for input ms filepath (MSv2 or zarr), if set.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vidavis
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Radio astronomy visibility data visualization
|
|
5
5
|
License: LGPL
|
|
6
6
|
Author-email: Darrell Schiebel <darrell@schiebel.us>,Pam Harris <pharris@nrao.edu>
|
|
@@ -8,6 +8,8 @@ Requires-Python: >=3.11, <3.14
|
|
|
8
8
|
Requires-Dist: bokeh==3.6.1
|
|
9
9
|
Requires-Dist: graphviper
|
|
10
10
|
Requires-Dist: hvplot
|
|
11
|
+
Requires-Dist: matplotlib
|
|
12
|
+
Requires-Dist: selenium
|
|
11
13
|
Description-Content-Type: text/x-rst
|
|
12
14
|
|
|
13
15
|
vidavis - VIsibility DAta VISualization
|
|
@@ -46,9 +48,6 @@ Requirements
|
|
|
46
48
|
- Optionally `python-casacore <https://pypi.org/project/python-casacore/>`_ or
|
|
47
49
|
`casatools <https://pypi.org/project/casatools/>`_ for MSv2 conversion
|
|
48
50
|
|
|
49
|
-
- Optionally `Selenium <https://www.selenium.dev/documentation/en/>`_ along with
|
|
50
|
-
a web driver to export to file using ``save()``
|
|
51
|
-
|
|
52
51
|
Install
|
|
53
52
|
```````
|
|
54
53
|
|
|
@@ -65,25 +64,6 @@ On macOS it is required to pre-install `python-casacore` using:
|
|
|
65
64
|
|
|
66
65
|
- :code:`conda install -c conda-forge python-casacore`
|
|
67
66
|
|
|
68
|
-
Exporting Plots
|
|
69
|
-
^^^^^^^^^^^^^^^
|
|
70
|
-
|
|
71
|
-
To enable exporting plots to file without showing the plot, using preferred web
|
|
72
|
-
driver:
|
|
73
|
-
|
|
74
|
-
**Selenium** with **geckodriver** and **Firefox** (to ensure compatible versions):
|
|
75
|
-
|
|
76
|
-
- :code:`conda install -c conda-forge selenium firefox geckodriver`
|
|
77
|
-
|
|
78
|
-
**Selenium** with **ChromeDriver** (Chrome), with the executable
|
|
79
|
-
**chromedriver** in your PATH:
|
|
80
|
-
|
|
81
|
-
- :code:`conda install -c conda-forge selenium python-chromedriver-binary`
|
|
82
|
-
|
|
83
|
-
or:
|
|
84
|
-
|
|
85
|
-
- :code:`pip install selenium chromedriver-binary`
|
|
86
|
-
|
|
87
67
|
Simple MsRaster Usage Example
|
|
88
68
|
`````````````````````````````
|
|
89
69
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
vidavis/LICENSE.rst,sha256=qzGpkvhDzf_MgF1PIn6rCmYPrcEhkfrBUchosLJj-U4,26371
|
|
2
2
|
vidavis/__init__.py,sha256=nhvlqlYhl4NzFO2WPTYfhyZkNdpfkBUTUOgJWKCK4Tc,1681
|
|
3
3
|
vidavis/apps/__init__.py,sha256=ZQ5v1VFtjn3ztmuOHLOk5WbC1uLNIgL9rbHQ4v0zJwY,87
|
|
4
|
-
vidavis/apps/_ms_raster.py,sha256=
|
|
4
|
+
vidavis/apps/_ms_raster.py,sha256=laZNFItWW5X2bvKlBI8WXfCegFQBVvxdcmDiR1mrqV4,45205
|
|
5
5
|
vidavis/bokeh/__init__.py,sha256=gdPPxBCe0enCSjvPFxkgMlhpVnAMFXKcw9GN28tVdXM,95
|
|
6
6
|
vidavis/bokeh/_palette.py,sha256=gzfJHuUgqxd8hJpZe-gQPFTCPq9f5I8uLEkHAK5FNDM,2480
|
|
7
7
|
vidavis/data/__init__.py,sha256=-RDRe0PYK6vPlhdRV2Dy1vGbnDGoXWDATmfxaR-gXcE,48
|
|
@@ -18,7 +18,7 @@ vidavis/data/measurement_set/processing_set/_ps_stats.py,sha256=4uLImKCANXLUM8jO
|
|
|
18
18
|
vidavis/data/measurement_set/processing_set/_xds_data.py,sha256=qLO2VkLINkSAQ7CGRFmpWQYpHrP4XoJJkwA4pp9DO8M,5253
|
|
19
19
|
vidavis/plot/__init__.py,sha256=thxe5vAGdpEiqoKPHLJoWUqKMVrUVx0ajpsGf5pVP98,95
|
|
20
20
|
vidavis/plot/ms_plot/__init__.py,sha256=wY0_7gY9M6K1D6tKQsr89L_uSs3seJlD-uicx7dx5Mo,74
|
|
21
|
-
vidavis/plot/ms_plot/_ms_plot.py,sha256=
|
|
21
|
+
vidavis/plot/ms_plot/_ms_plot.py,sha256=lf_9vSal2sMmSdp9BxjMat38T1SJ3ptF_8-UUZ5tGqw,12592
|
|
22
22
|
vidavis/plot/ms_plot/_ms_plot_constants.py,sha256=cX_TQhKJ3hJzPuRYmuRJxue1sjq82yl_ZN2_w6TshmI,930
|
|
23
23
|
vidavis/plot/ms_plot/_ms_plot_selectors.py,sha256=BZQwARvMPdk78n6Rh2tOaSc8GenZBrxHZb14oFD9gJM,10785
|
|
24
24
|
vidavis/plot/ms_plot/_raster_plot.py,sha256=lNa9i_eJ8F8Fc2zcHLRcaxKKOELk3x_QmXT__T76pg8,10999
|
|
@@ -29,8 +29,8 @@ vidavis/toolbox/__init__.py,sha256=jqFa-eziVz_frNnXxwjJFK36qNpz1H38s-VlpBcq-R8,1
|
|
|
29
29
|
vidavis/toolbox/_app_context.py,sha256=H7gtF8RrAH46FqDcMobv3KM1Osbnapgu6aTG-m3VCWA,3049
|
|
30
30
|
vidavis/toolbox/_logging.py,sha256=OEisrd8FM8VTNBMc7neLh9ekelf29ZILYB5pScebly0,2739
|
|
31
31
|
vidavis/toolbox/_static.py,sha256=HJLMtClppgOJXWAtV6Umn5EqN80u0oZiIouQ1JsB9PM,2346
|
|
32
|
-
vidavis/__version__.py,sha256=
|
|
33
|
-
vidavis-0.0.
|
|
34
|
-
vidavis-0.0.
|
|
35
|
-
vidavis-0.0.
|
|
36
|
-
vidavis-0.0.
|
|
32
|
+
vidavis/__version__.py,sha256=UwR0idQSHgdEemLAk-o2bPOXYWCj-lyyQzAPFRLbziA,21
|
|
33
|
+
vidavis-0.0.6.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
34
|
+
vidavis-0.0.6.dist-info/METADATA,sha256=u-RsO4qX6UALqttKxzQIatAw2CmEx8Elb2gY-NrakcI,2263
|
|
35
|
+
vidavis-0.0.6.dist-info/licenses/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
|
36
|
+
vidavis-0.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|