cubevis 0.5.2__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.
Files changed (132) hide show
  1. cubevis/LICENSE.rst +500 -0
  2. cubevis/__icons__/20px/fast-backward.svg +13 -0
  3. cubevis/__icons__/20px/fast-forward.svg +13 -0
  4. cubevis/__icons__/20px/step-backward.svg +12 -0
  5. cubevis/__icons__/20px/step-forward.svg +12 -0
  6. cubevis/__icons__/add-chan.png +0 -0
  7. cubevis/__icons__/add-chan.svg +84 -0
  8. cubevis/__icons__/add-cube.png +0 -0
  9. cubevis/__icons__/add-cube.svg +186 -0
  10. cubevis/__icons__/drag.png +0 -0
  11. cubevis/__icons__/drag.svg +109 -0
  12. cubevis/__icons__/mask-selected.png +0 -0
  13. cubevis/__icons__/mask.png +0 -0
  14. cubevis/__icons__/mask.svg +1 -0
  15. cubevis/__icons__/new-layer-sm-selected.png +0 -0
  16. cubevis/__icons__/new-layer-sm-selected.svg +88 -0
  17. cubevis/__icons__/new-layer-sm.png +0 -0
  18. cubevis/__icons__/new-layer-sm.svg +15 -0
  19. cubevis/__icons__/reset.png +0 -0
  20. cubevis/__icons__/reset.svg +11 -0
  21. cubevis/__icons__/sub-chan.png +0 -0
  22. cubevis/__icons__/sub-chan.svg +71 -0
  23. cubevis/__icons__/sub-cube.png +0 -0
  24. cubevis/__icons__/sub-cube.svg +95 -0
  25. cubevis/__icons__/zoom-to-fit.png +0 -0
  26. cubevis/__icons__/zoom-to-fit.svg +21 -0
  27. cubevis/__init__.py +58 -0
  28. cubevis/__js__/bokeh-3.6.1.min.js +728 -0
  29. cubevis/__js__/bokeh-tables-3.6.1.min.js +119 -0
  30. cubevis/__js__/bokeh-widgets-3.6.1.min.js +141 -0
  31. cubevis/__js__/casalib.min.js +1 -0
  32. cubevis/__js__/cubevisjs.min.js +62 -0
  33. cubevis/__version__.py +1 -0
  34. cubevis/apps/__init__.py +44 -0
  35. cubevis/apps/_createmask.py +461 -0
  36. cubevis/apps/_createregion.py +513 -0
  37. cubevis/apps/_interactiveclean.py +3260 -0
  38. cubevis/apps/_interactiveclean_wrappers.py +130 -0
  39. cubevis/apps/_ms_raster.py +815 -0
  40. cubevis/apps/_plotants.py +286 -0
  41. cubevis/apps/_plotbandpass.py +7 -0
  42. cubevis/bokeh/__init__.py +29 -0
  43. cubevis/bokeh/annotations/__init__.py +1 -0
  44. cubevis/bokeh/annotations/_ev_poly_annotation.py +6 -0
  45. cubevis/bokeh/components/__init__.py +28 -0
  46. cubevis/bokeh/format/__init__.py +31 -0
  47. cubevis/bokeh/format/_time_ticks.py +44 -0
  48. cubevis/bokeh/format/_wcs_ticks.py +45 -0
  49. cubevis/bokeh/models/__init__.py +4 -0
  50. cubevis/bokeh/models/_edit_span.py +7 -0
  51. cubevis/bokeh/models/_ev_text_input.py +6 -0
  52. cubevis/bokeh/models/_tip.py +37 -0
  53. cubevis/bokeh/models/_tip_button.py +50 -0
  54. cubevis/bokeh/sources/__init__.py +35 -0
  55. cubevis/bokeh/sources/_data_pipe.py +258 -0
  56. cubevis/bokeh/sources/_image_data_source.py +83 -0
  57. cubevis/bokeh/sources/_image_pipe.py +581 -0
  58. cubevis/bokeh/sources/_spectra_data_source.py +55 -0
  59. cubevis/bokeh/sources/_updatable_data_source.py +189 -0
  60. cubevis/bokeh/state/__init__.py +34 -0
  61. cubevis/bokeh/state/_initialize.py +164 -0
  62. cubevis/bokeh/state/_javascript.py +53 -0
  63. cubevis/bokeh/state/_palette.py +58 -0
  64. cubevis/bokeh/state/_session.py +44 -0
  65. cubevis/bokeh/state/js/bokeh-2.4.1.min.js +596 -0
  66. cubevis/bokeh/state/js/bokeh-gl-2.4.1.min.js +74 -0
  67. cubevis/bokeh/state/js/bokeh-tables-2.4.1.min.js +132 -0
  68. cubevis/bokeh/state/js/bokeh-widgets-2.4.1.min.js +118 -0
  69. cubevis/bokeh/state/js/casaguijs-v0.0.4.0-b2.4.min.js +49 -0
  70. cubevis/bokeh/state/js/casaguijs-v0.0.5.0-b2.4.min.js +49 -0
  71. cubevis/bokeh/state/js/casaguijs-v0.0.6.0-b2.4.min.js +49 -0
  72. cubevis/bokeh/state/js/casalib-v0.0.1.min.js +1 -0
  73. cubevis/bokeh/tools/__init__.py +31 -0
  74. cubevis/bokeh/tools/_cbreset_tool.py +52 -0
  75. cubevis/bokeh/tools/_drag_tool.py +61 -0
  76. cubevis/bokeh/utils/__init__.py +35 -0
  77. cubevis/bokeh/utils/_axes_labels.py +94 -0
  78. cubevis/bokeh/utils/_svg_icon.py +136 -0
  79. cubevis/data/__init__.py +1 -0
  80. cubevis/data/casaimage/__init__.py +114 -0
  81. cubevis/data/measurement_set/__init__.py +7 -0
  82. cubevis/data/measurement_set/_ms_data.py +178 -0
  83. cubevis/data/measurement_set/processing_set/__init__.py +30 -0
  84. cubevis/data/measurement_set/processing_set/_ps_concat.py +98 -0
  85. cubevis/data/measurement_set/processing_set/_ps_coords.py +78 -0
  86. cubevis/data/measurement_set/processing_set/_ps_data.py +213 -0
  87. cubevis/data/measurement_set/processing_set/_ps_io.py +55 -0
  88. cubevis/data/measurement_set/processing_set/_ps_raster_data.py +154 -0
  89. cubevis/data/measurement_set/processing_set/_ps_select.py +91 -0
  90. cubevis/data/measurement_set/processing_set/_ps_stats.py +218 -0
  91. cubevis/data/measurement_set/processing_set/_xds_data.py +149 -0
  92. cubevis/plot/__init__.py +1 -0
  93. cubevis/plot/ms_plot/__init__.py +29 -0
  94. cubevis/plot/ms_plot/_ms_plot.py +242 -0
  95. cubevis/plot/ms_plot/_ms_plot_constants.py +22 -0
  96. cubevis/plot/ms_plot/_ms_plot_selectors.py +348 -0
  97. cubevis/plot/ms_plot/_raster_plot.py +292 -0
  98. cubevis/plot/ms_plot/_raster_plot_inputs.py +116 -0
  99. cubevis/plot/ms_plot/_xds_plot_axes.py +110 -0
  100. cubevis/private/__java__/xml-casa-assembly-1.86.jar +0 -0
  101. cubevis/private/_gclean.py +798 -0
  102. cubevis/private/casashell/createmask.py +332 -0
  103. cubevis/private/casashell/iclean.py +4432 -0
  104. cubevis/private/casatasks/__init__.py +140 -0
  105. cubevis/private/casatasks/createmask.py +86 -0
  106. cubevis/private/casatasks/createregion.py +83 -0
  107. cubevis/private/casatasks/iclean.py +1831 -0
  108. cubevis/readme.rst +16 -0
  109. cubevis/remote/__init__.py +10 -0
  110. cubevis/remote/_gclean.py +61 -0
  111. cubevis/remote/_local.py +287 -0
  112. cubevis/remote/_remote_kernel.py +80 -0
  113. cubevis/toolbox/__init__.py +32 -0
  114. cubevis/toolbox/_app_context.py +74 -0
  115. cubevis/toolbox/_cube.py +3457 -0
  116. cubevis/toolbox/_region_list.py +197 -0
  117. cubevis/utils/_ResourceManager.py +86 -0
  118. cubevis/utils/__init__.py +620 -0
  119. cubevis/utils/_contextmgrchain.py +84 -0
  120. cubevis/utils/_conversion.py +93 -0
  121. cubevis/utils/_copydoc.py +55 -0
  122. cubevis/utils/_docenum.py +25 -0
  123. cubevis/utils/_import_protected_module.py +35 -0
  124. cubevis/utils/_logging.py +85 -0
  125. cubevis/utils/_pkgs.py +77 -0
  126. cubevis/utils/_regions.py +40 -0
  127. cubevis/utils/_static.py +66 -0
  128. cubevis/utils/_tiles.py +167 -0
  129. cubevis-0.5.2.dist-info/METADATA +151 -0
  130. cubevis-0.5.2.dist-info/RECORD +132 -0
  131. cubevis-0.5.2.dist-info/WHEEL +4 -0
  132. cubevis-0.5.2.dist-info/licenses/LICENSE +504 -0
@@ -0,0 +1,140 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2024
4
+ # Associated Universities, Inc. Washington DC, USA.
5
+ #
6
+ # This script is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Library General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
+ # License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Library General Public License
17
+ # along with this library; if not, write to the Free Software Foundation,
18
+ # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19
+ #
20
+ # Correspondence concerning AIPS++ should be adressed as follows:
21
+ # Internet email: casa-feedback@nrao.edu.
22
+ # Postal address: AIPS++ Project Office
23
+ # National Radio Astronomy Observatory
24
+ # 520 Edgemont Road
25
+ # Charlottesville, VA 22903-2475 USA
26
+ #
27
+ ########################################################################
28
+ '''casatasks provides on-the-fly creation of inp/go wrappers for tasks
29
+ https://bayesianbrad.github.io/posts/2017_loader-finder-python.html
30
+ '''
31
+
32
+ from importlib.abc import Loader as _Loader, MetaPathFinder as _MetaPathFinder
33
+
34
+ import subprocess
35
+ import re
36
+ import os
37
+ import sys
38
+
39
+ class CasaTasks_Loader(_Loader):
40
+
41
+ def __init__( self, java, jarpath, args, templ, xml ):
42
+ self.__java = java
43
+ self.__jarpath = jarpath
44
+ self.__args = args
45
+ self.__templ = templ
46
+ self.__xml = xml
47
+
48
+ def create_module(self, spec):
49
+ return None
50
+
51
+ def exec_module(self, module):
52
+ python_source = subprocess.run( [ self.__java, '-jar', self.__jarpath ] + self.__args + [self.__templ, self.__xml], stdout=subprocess.PIPE ).stdout.decode('utf-8')
53
+ exec( python_source, module.__dict__ )
54
+
55
+
56
+ class CasaTasks_Finder(_MetaPathFinder):
57
+
58
+ def __init__( self ):
59
+ super(CasaTasks_Finder, self).__init__( )
60
+ self.__java = None
61
+ self.__source_dir = os.path.dirname(__file__)
62
+ self.__jarpath = None
63
+ self.__jarfile_name = "xml-casa-assembly-1.86.jar"
64
+ self.__task_xml_files = None
65
+
66
+ def __which( self, program ):
67
+ def is_exe(fpath):
68
+ return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
69
+
70
+ fpath, fname = os.path.split(program)
71
+ if fpath:
72
+ if is_exe(program):
73
+ return os.path.realpath(program)
74
+ else:
75
+ os.environ.get("PATH", "")
76
+ for path in os.environ.get("PATH", "").split(os.pathsep):
77
+ exe_file = os.path.join(path, program)
78
+ if is_exe(exe_file):
79
+ return os.path.realpath(exe_file)
80
+ return None
81
+
82
+ def __find_parameters( self, taskname ):
83
+ templ = os.path.join( self.__source_dir, f'''{taskname}.mustache''' )
84
+ if os.path.isfile(templ):
85
+ ### <TASK>.mustache exists -------------------------------------------------------------------------------------------------------------
86
+ with open(templ) as f:
87
+ header = [ (m.group(1), m.group(2), m.group(0)) for m in [ re.match( "^\#+\s*TASK XML\s*>\s*(\S+)(.*)", next(f) ) for _ in range(5) ] if m ]
88
+ if len(header) == 1:
89
+ ### <TASK>.mustache has processing specification line --------------------------------------------------------------------------
90
+ task = os.path.splitext(header[0][0])[0]
91
+ if task in self.__task_xml_files:
92
+ ### <TASK>.mustache has processing specification line and includes valid CASA task name ------------------------------------
93
+ return templ, self.__task_xml_files[task], header[0][1].split( )
94
+ elif taskname in self.__task_xml_files:
95
+ ### <TASK>.mustache has processing specification line and <TASK> is a valid CASA task --------------------------------------
96
+ return templ, self.__task_xml_files[taskname], header[0][1].split( )
97
+ elif taskname in self.__task_xml_files:
98
+ ### <TASK>.mustache does not have a processing specification line but <TASK> is a valid CASA task-------------------------------
99
+ return templ, self.__task_xml_files[taskname], [ ]
100
+
101
+ if taskname in self.__task_xml_files:
102
+ ### <TASK>.mustache does not exist but <TASK> is a valid CASA task ---------------------------------------------------------------------
103
+ templ = os.path.join( self.__source_dir, f'''generic.mustache''' )
104
+ if os.path.isfile(templ):
105
+ ### <TASK> is a valid CASA task and generic.mustache exists ------------------------------------------------------------------------
106
+ with open(templ) as f:
107
+ header = [ (m.group(1), m.group(2), m.group(0)) for m in [ re.match( "^\#+\s*TASK XML\s*>\s*(\S+)(.*)", next(f) ) for _ in range(5) ] if m ]
108
+ if len(header) == 1:
109
+ ### <TASK> is a valid CASA task, generic.mustache exists and has a processing specification line ---------------------------
110
+ return templ, self.__task_xml_files[taskname], header[0][1].split( )
111
+ else:
112
+ ### <TASK> is a valid CASA task, generic.mustache exists but does not have a processing specification line -----------------
113
+ return templ, self.__task_xml_files[taskname], [ ]
114
+
115
+ return None, None, [ ]
116
+
117
+ def find_spec(self, fullname, path, target = None):
118
+
119
+ if fullname.startswith('cubevis.private.casatasks.'):
120
+ if self.__java is None:
121
+ self.__java = self.__which( "java" )
122
+ if self.__jarpath is None:
123
+ p = os.path.join( os.path.dirname(os.path.dirname(__file__)), "__java__", self.__jarfile_name )
124
+ if os.path.isfile(p):
125
+ self.__jarpath = p
126
+ if self.__task_xml_files is None:
127
+ try:
128
+ from casatasks import xml_interface_defs
129
+ self.__task_xml_files = { k:v for (k,v) in xml_interface_defs( ).items( ) if os.path.isfile(v) }
130
+ except: pass
131
+
132
+ module = fullname.split(sep='.')[-1]
133
+ templ, xml, args = self.__find_parameters( fullname.split(sep='.')[-1] )
134
+ if templ is not None and xml is not None:
135
+ from importlib.machinery import ModuleSpec
136
+ return ModuleSpec( fullname, CasaTasks_Loader( self.__java, self.__jarpath, args, templ, xml ) )
137
+
138
+ return None
139
+
140
+ sys.meta_path.append(CasaTasks_Finder( ))
@@ -0,0 +1,86 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2024
4
+ # Associated Universities, Inc. Washington DC, USA.
5
+ #
6
+ # This script is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Library General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
+ # License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Library General Public License
17
+ # along with this library; if not, write to the Free Software Foundation,
18
+ # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19
+ #
20
+ # Correspondence concerning AIPS++ should be adressed as follows:
21
+ # Internet email: casa-feedback@nrao.edu.
22
+ # Postal address: AIPS++ Project Office
23
+ # National Radio Astronomy Observatory
24
+ # 520 Edgemont Road
25
+ # Charlottesville, VA 22903-2475 USA
26
+ #
27
+ ########################################################################
28
+ ##################### generated by xml-casa (v2) from createmask.xml
29
+ ##################### 26fdebc4cbd4e58e368f393b9b7ccde7 ##############################
30
+ from __future__ import absolute_import
31
+ import numpy
32
+ from casatools.typecheck import CasaValidator as _val_ctor
33
+ _pc = _val_ctor( )
34
+ from casatools.coercetype import coerce as _coerce
35
+ from casatools.errors import create_error_string
36
+ from casatasks.private.task_logging import start_log as _start_log
37
+ from casatasks.private.task_logging import end_log as _end_log
38
+ from casatasks.private.task_logging import except_log as _except_log
39
+ from cubevis.apps import CreateMask
40
+
41
+ def _createmask_t( *args, **kwargs ):
42
+ cm = CreateMask( *args, **kwargs )
43
+ return cm( )
44
+
45
+ class _createmask:
46
+ """
47
+ createmask ---- Create mask cubes interactively with a GUI
48
+
49
+ Create a mask cube for one or more images using a GUI.
50
+ This task is based upon the same tools that are used to build
51
+ the interactive clean application so the same command keys are
52
+ used for both applications.
53
+
54
+
55
+ --------- parameter descriptions ---------------------------------------------
56
+
57
+ image
58
+ mask
59
+ create
60
+
61
+ --------- examples -----------------------------------------------------------
62
+
63
+
64
+
65
+
66
+ """
67
+
68
+ _info_group_ = """imaging"""
69
+ _info_desc_ = """Create mask cubes interactively with a GUI"""
70
+
71
+ def __call__( self, image=[ ], mask=[ ], create=True ):
72
+ schema = { 'image': {'anyof': [{'type': 'cReqPath', 'coerce': _coerce.expand_path}, {'type': 'cReqPathVec', 'coerce': [_coerce.to_list,_coerce.expand_pathvec]}]}, 'mask': {'anyof': [{'type': 'cPath', 'coerce': _coerce.expand_path}, {'type': 'cPathVec', 'coerce': [_coerce.to_list,_coerce.expand_pathvec]}]}, 'create': {'type': 'cBool'}, }
73
+ doc = { 'image': image, 'mask': mask, 'create': create, }
74
+ assert _pc.validate(doc,schema), create_error_string(_pc.errors)
75
+ _logging_state_ = _start_log( 'createmask', [ 'image=' + repr(_pc.document['image']), 'mask=' + repr(_pc.document['mask']), 'create=' + repr(_pc.document['create']), ] )
76
+ task_result = None
77
+ try:
78
+ task_result = _createmask_t( image=_pc.document['image'], mask=_pc.document['mask'], create=_pc.document['create'], )
79
+ except Exception as exc:
80
+ _except_log('createmask', exc)
81
+ raise
82
+ finally:
83
+ task_result = _end_log( _logging_state_, 'createmask', task_result )
84
+ return task_result
85
+
86
+ createmask = _createmask( )
@@ -0,0 +1,83 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2024
4
+ # Associated Universities, Inc. Washington DC, USA.
5
+ #
6
+ # This script is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Library General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
+ # License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Library General Public License
17
+ # along with this library; if not, write to the Free Software Foundation,
18
+ # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19
+ #
20
+ # Correspondence concerning AIPS++ should be adressed as follows:
21
+ # Internet email: casa-feedback@nrao.edu.
22
+ # Postal address: AIPS++ Project Office
23
+ # National Radio Astronomy Observatory
24
+ # 520 Edgemont Road
25
+ # Charlottesville, VA 22903-2475 USA
26
+ #
27
+ ########################################################################
28
+ ##################### generated by xml-casa (v2) from createregion.xml
29
+ ##################### e874c3dc805a7c790b9067fcbe4b97ef ##############################
30
+ from __future__ import absolute_import
31
+ import numpy
32
+ from casatools.typecheck import CasaValidator as _val_ctor
33
+ _pc = _val_ctor( )
34
+ from casatools.coercetype import coerce as _coerce
35
+ from casatools.errors import create_error_string
36
+ from casatasks.private.task_logging import start_log as _start_log
37
+ from casatasks.private.task_logging import end_log as _end_log
38
+ from casatasks.private.task_logging import except_log as _except_log
39
+ from cubevis.apps import CreateRegion
40
+
41
+ def _createregion_t( *args, **kwargs ):
42
+ cm = CreateRegion( *args, **kwargs )
43
+ return cm( )
44
+
45
+ class _createregion:
46
+ """
47
+ createregion ---- Create astropy regions interactively with a GUI
48
+
49
+ Create one or more regions for CASA images using a GUI.
50
+ Regions can be drawn on the image and upon completion a list of
51
+ regions is returned to python.
52
+
53
+
54
+ --------- parameter descriptions ---------------------------------------------
55
+
56
+ image
57
+
58
+ --------- examples -----------------------------------------------------------
59
+
60
+
61
+
62
+
63
+ """
64
+
65
+ _info_group_ = """imaging"""
66
+ _info_desc_ = """Create astropy regions interactively with a GUI"""
67
+
68
+ def __call__( self, image=[ ] ):
69
+ schema = { 'image': {'anyof': [{'type': 'cReqPath', 'coerce': _coerce.expand_path}, {'type': 'cReqPathVec', 'coerce': [_coerce.to_list,_coerce.expand_pathvec]}]}, }
70
+ doc = { 'image': image, }
71
+ assert _pc.validate(doc,schema), create_error_string(_pc.errors)
72
+ _logging_state_ = _start_log( 'createregion', [ 'image=' + repr(_pc.document['image']), ] )
73
+ task_result = None
74
+ try:
75
+ task_result = _createregion_t( image=_pc.document['image'], )
76
+ except Exception as exc:
77
+ _except_log('createregion', exc)
78
+ raise
79
+ finally:
80
+ task_result = _end_log( _logging_state_, 'createregion', task_result )
81
+ return task_result
82
+
83
+ createregion = _createregion( )