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,49 @@
1
+ /*!
2
+ * Copyright (c) 2012 - 2021, Anaconda, Inc., and Bokeh Contributors
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
+ * are permitted provided that the following conditions are met:
7
+ *
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ * this list of conditions and the following disclaimer.
10
+ *
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * Neither the name of Anaconda nor the names of any contributors
16
+ * may be used to endorse or promote products derived from this software
17
+ * without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
+ * THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ (function(root, factory) {
32
+ factory(root["Bokeh"], undefined);
33
+ })(this, function(Bokeh, version) {
34
+ let define;
35
+ return (function(modules, entry, aliases, externals) {
36
+ const bokeh = typeof Bokeh !== "undefined" && (version != null ? Bokeh[version] : Bokeh);
37
+ if (bokeh != null) {
38
+ return bokeh.register_plugin(modules, entry, aliases);
39
+ } else {
40
+ throw new Error("Cannot find Bokeh " + version + ". You have to load it prior to loading plugins.");
41
+ }
42
+ })
43
+ ({
44
+ "988b553afa": function _(a,e,t,c,o){c();const r=a("d75d4bd830");o("DataPipe",r.DataPipe);const p=a("790a872eb0");o("ImagePipe",p.ImagePipe);const D=a("1fa92ac597");o("ImageDataSource",D.ImageDataSource);const S=a("e5ac72e4af");o("SpectraDataSource",S.SpectraDataSource);(0,a("@bokehjs/base").register_models)({DataPipe:r.DataPipe,ImagePipe:p.ImagePipe,ImageDataSource:D.ImageDataSource,SpectraDataSource:S.SpectraDataSource})},
45
+ "d75d4bd830": function _(e,i,s,t,n){t();const a=e("@bokehjs/models/sources/data_source"),d=e("@bokehjs/core/util/serialization");class c extends a.DataSource{constructor(e){super(e),this.send_queue={},this.pending={},this.incoming_callbacks={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("imagepipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const t in i){let n=i[t];if((0,d.is_NDArray_ref)(n)){const e=new Map;s[t]=(0,d.decode_NDArray)(n,e)}else s[t]="object"==typeof n&&null!==n?e(n):n}return s}(JSON.parse(e.data));if("id"in i&&"direction"in i&&"message"in i){let{id:e,message:s,direction:t}=i;if("j2p"==t)if(e in this.pending){let{cb:i}=this.pending[e];if(delete this.pending[e],e in this.send_queue&&this.send_queue[e].length>0){let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}i(s)}else console.log("message received but could not find id");else if(e in this.incoming_callbacks){let i=this.incoming_callbacks[e](s);this.websocket.send(JSON.stringify({id:e,direction:t,message:i}))}}else console.log(`datapipe received message without one of 'id', 'message' or 'direction': ${i}`)}else console.log("datapipe received binary data",e.data.byteLength,"bytes")}}initialize(){super.initialize()}register(e,i){this.incoming_callbacks[e]=i}send(e,i,s){let t={id:e,message:i,direction:"j2p"};if(e in this.pending)e in this.send_queue?this.send_queue[e].push({cb:s,msg:t}):this.send_queue[e]=[{cb:s,msg:t}];else if(e in this.send_queue&&this.send_queue[e].length>0){this.send_queue[e].push({cb:s,msg:t});{let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}}else this.pending[e]={cb:s},this.websocket.send(JSON.stringify(t))}static init_DataPipe(){this.define((({Tuple:e,String:i,Number:s})=>({address:[e(i,s)]})))}}s.DataPipe=c,c.__name__="DataPipe",c.init_DataPipe()},
46
+ "790a872eb0": function _(e,i,s,n,t){n();const a=e("@bokehjs/models/sources/data_source"),d=e("@bokehjs/core/util/serialization");class o extends a.DataSource{constructor(e){super(e),this.queue={},this.pending={},this.position={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("imagepipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const n in i){let t=i[n];if((0,d.is_NDArray_ref)(t)){const e=new Map;s[n]=(0,d.decode_NDArray)(t,e)}else s[n]="object"==typeof t&&null!==t?e(t):t}return s}(JSON.parse(e.data));if("id"in i&&"message"in i){let{id:e,message:s}=i,{cb:n,index:t}=this.pending[e];if(delete this.pending[e],e in this.queue){let{cb:i,message:s,index:n}=this.queue[e];delete this.queue[e],this.pending[e]={cb:i,index:n},this.websocket.send(JSON.stringify(s))}this.position[e]={index:t},n(s)}else console.log(`imagepipe received data without 'id' and/or 'message' field: ${i}`)}else console.log("imagepipe received binary data",e.data.byteLength,"bytes")}}initialize(){super.initialize()}channel(e,i,s){let n={action:"channel",index:e,id:s};s in this.pending?this.queue[s]={cb:i,message:n,index:e}:(this.websocket.send(JSON.stringify(n)),this.pending[s]={cb:i,index:e})}spectra(e,i,s){let n={action:"spectra",index:e,id:s};s in this.pending?this.queue[s]={cb:i,message:n,index:e}:(this.websocket.send(JSON.stringify(n)),this.pending[s]={cb:i,index:e})}refresh(e,i,s=[]){let{index:n}=i in this.position?this.position[i]:{index:s};if(2===n.length){let s={action:"channel",index:n,id:i};i in this.pending?this.queue[i]={cb:e,message:s,index:n}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:n})}else if(3===n.length){let s={action:"spectra",index:n,id:i};i in this.pending?this.queue[i]={cb:e,message:s,index:n}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:n})}}static init_ImagePipe(){this.define((({Tuple:e,String:i,Number:s})=>({address:[e(i,s)],shape:[e(s,s,s,s)]})))}}s.ImagePipe=o,o.__name__="ImagePipe",o.init_ImagePipe()},
47
+ "1fa92ac597": function _(i,e,t,a,s){a();const c=i("@bokehjs/models/sources/column_data_source"),n=i("@bokehjs/core/util/string"),r=i("790a872eb0");class u extends c.ColumnDataSource{constructor(i){super(i),this.imid=(0,n.uuid4)()}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}channel(i,e=0,t){this.image_source.channel([e,i],(a=>{this.cur_chan=[e,i],t&&t(a),this.data=a.chan}),this.imid)}refresh(i){this.image_source.refresh((e=>{i&&i(e),this.data=e.chan}),this.imid,[0,0])}static init_ImageDataSource(){this.define((({Tuple:i,Number:e,String:t,Ref:a,Any:s})=>({init_script:[s],image_source:[a(r.ImagePipe)],num_chans:[i(e,e)],cur_chan:[i(e,e)],init:[t]})))}}t.ImageDataSource=u,u.__name__="ImageDataSource",u.init_ImageDataSource()},
48
+ "e5ac72e4af": function _(e,i,t,s,a){s();const r=e("@bokehjs/models/sources/column_data_source"),c=e("@bokehjs/core/util/string"),o=e("790a872eb0");class u extends r.ColumnDataSource{constructor(e){super(e),this.imid=(0,c.uuid4)(),console.log("spectra data source id:",this.imid)}initialize(){super.initialize()}spectra(e,i,t=0){this.image_source.spectra([e,i,t],(e=>this.data=e.spectrum),this.imid)}refresh(){this.image_source.refresh((e=>this.data=e.spectrum),this.imid,[0,0,0])}static init_SpectraDataSource(){this.define((({Ref:e})=>({image_source:[e(o.ImagePipe)]})))}}t.SpectraDataSource=u,u.__name__="SpectraDataSource",u.init_SpectraDataSource()},
49
+ }, "988b553afa", {"index":"988b553afa","src/bokeh/sources/data_pipe":"d75d4bd830","src/bokeh/sources/image_pipe":"790a872eb0","src/bokeh/sources/image_data_source":"1fa92ac597","src/bokeh/sources/spectra_data_source":"e5ac72e4af"}, {});});
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * Copyright (c) 2012 - 2021, Anaconda, Inc., and Bokeh Contributors
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
+ * are permitted provided that the following conditions are met:
7
+ *
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ * this list of conditions and the following disclaimer.
10
+ *
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * Neither the name of Anaconda nor the names of any contributors
16
+ * may be used to endorse or promote products derived from this software
17
+ * without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
+ * THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ (function(root, factory) {
32
+ factory(root["Bokeh"], undefined);
33
+ })(this, function(Bokeh, version) {
34
+ let define;
35
+ return (function(modules, entry, aliases, externals) {
36
+ const bokeh = typeof Bokeh !== "undefined" && (version != null ? Bokeh[version] : Bokeh);
37
+ if (bokeh != null) {
38
+ return bokeh.register_plugin(modules, entry, aliases);
39
+ } else {
40
+ throw new Error("Cannot find Bokeh " + version + ". You have to load it prior to loading plugins.");
41
+ }
42
+ })
43
+ ({
44
+ "988b553afa": function _(a,e,t,c,o){c();const r=a("4e3e04a57f");o("DataPipe",r.DataPipe);const p=a("6eed1dd0c6");o("ImagePipe",p.ImagePipe);const D=a("20c0382ad2");o("ImageDataSource",D.ImageDataSource);const S=a("e5ac72e4af");o("SpectraDataSource",S.SpectraDataSource);(0,a("@bokehjs/base").register_models)({DataPipe:r.DataPipe,ImagePipe:p.ImagePipe,ImageDataSource:D.ImageDataSource,SpectraDataSource:S.SpectraDataSource})},
45
+ "4e3e04a57f": function _(e,i,s,t,n){t();const a=e("@bokehjs/models/sources/data_source"),c=e("@bokehjs/core/util/serialization");class d extends a.DataSource{constructor(e){super(e),this.send_queue={},this.pending={},this.incoming_callbacks={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("datapipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const t in i){let n=i[t];if((0,c.is_NDArray_ref)(n)){const e=new Map;s[t]=(0,c.decode_NDArray)(n,e)}else s[t]="object"==typeof n&&null!==n?e(n):n}return s}(JSON.parse(e.data));if("id"in i&&"direction"in i&&"message"in i){let{id:e,message:s,direction:t}=i;if("j2p"==t)if(e in this.pending){let{cb:i}=this.pending[e];if(delete this.pending[e],e in this.send_queue&&this.send_queue[e].length>0){let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}i(s)}else console.log("message received but could not find id");else if(e in this.incoming_callbacks){let i=this.incoming_callbacks[e](s);this.websocket.send(JSON.stringify({id:e,direction:t,message:i}))}}else console.log(`datapipe received message without one of 'id', 'message' or 'direction': ${i}`)}else console.log("datapipe received binary data",e.data.byteLength,"bytes")}}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}register(e,i){this.incoming_callbacks[e]=i}send(e,i,s){let t={id:e,message:i,direction:"j2p"};if(e in this.pending)e in this.send_queue?this.send_queue[e].push({cb:s,msg:t}):this.send_queue[e]=[{cb:s,msg:t}];else if(e in this.send_queue&&this.send_queue[e].length>0){this.send_queue[e].push({cb:s,msg:t});{let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}}else this.pending[e]={cb:s},this.websocket.send(JSON.stringify(t))}static init_DataPipe(){this.define((({Tuple:e,String:i,Number:s,Any:t})=>({init_script:[t],address:[e(i,s)]})))}}s.DataPipe=d,d.__name__="DataPipe",d.init_DataPipe()},
46
+ "6eed1dd0c6": function _(e,i,s,t,n){t();const a=e("@bokehjs/models/sources/data_source"),d=e("@bokehjs/core/util/serialization");class c extends a.DataSource{constructor(e){super(e),this.queue={},this.pending={},this.position={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("imagepipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const t in i){let n=i[t];if((0,d.is_NDArray_ref)(n)){const e=new Map;s[t]=(0,d.decode_NDArray)(n,e)}else s[t]="object"==typeof n&&null!==n?e(n):n}return s}(JSON.parse(e.data));if("id"in i&&"message"in i){let{id:e,message:s}=i,{cb:t,index:n}=this.pending[e];if(delete this.pending[e],e in this.queue){let{cb:i,message:s,index:t}=this.queue[e];delete this.queue[e],this.pending[e]={cb:i,index:t},this.websocket.send(JSON.stringify(s))}this.position[e]={index:n},t(s)}else console.log(`imagepipe received data without 'id' and/or 'message' field: ${i}`)}else console.log("imagepipe received binary data",e.data.byteLength,"bytes")}}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}channel(e,i,s){let t={action:"channel",index:e,id:s};s in this.pending?this.queue[s]={cb:i,message:t,index:e}:(this.websocket.send(JSON.stringify(t)),this.pending[s]={cb:i,index:e})}spectra(e,i,s){let t={action:"spectra",index:e,id:s};s in this.pending?this.queue[s]={cb:i,message:t,index:e}:(this.websocket.send(JSON.stringify(t)),this.pending[s]={cb:i,index:e})}refresh(e,i,s=[]){let{index:t}=i in this.position?this.position[i]:{index:s};if(2===t.length){let s={action:"channel",index:t,id:i};i in this.pending?this.queue[i]={cb:e,message:s,index:t}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:t})}else if(3===t.length){let s={action:"spectra",index:t,id:i};i in this.pending?this.queue[i]={cb:e,message:s,index:t}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:t})}}static init_ImagePipe(){this.define((({Tuple:e,String:i,Number:s,Any:t})=>({init_script:[t],address:[e(i,s)],shape:[e(s,s,s,s)]})))}}s.ImagePipe=c,c.__name__="ImagePipe",c.init_ImagePipe()},
47
+ "20c0382ad2": function _(i,e,t,a,s){a();const c=i("@bokehjs/models/sources/column_data_source"),n=i("@bokehjs/core/util/string"),r=i("6eed1dd0c6");class u extends c.ColumnDataSource{constructor(i){super(i),this.imid=(0,n.uuid4)()}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}channel(i,e=0,t){this.image_source.channel([e,i],(a=>{this.cur_chan=[e,i],t&&t(a),this.data=a.chan}),this.imid)}refresh(i){this.image_source.refresh((e=>{i&&i(e),this.data=e.chan}),this.imid,[0,0])}static init_ImageDataSource(){this.define((({Tuple:i,Number:e,Ref:t,Any:a})=>({init_script:[a],image_source:[t(r.ImagePipe)],num_chans:[i(e,e)],cur_chan:[i(e,e)]})))}}t.ImageDataSource=u,u.__name__="ImageDataSource",u.init_ImageDataSource()},
48
+ "e5ac72e4af": function _(e,i,t,s,a){s();const c=e("@bokehjs/models/sources/column_data_source"),r=e("@bokehjs/core/util/string"),o=e("6eed1dd0c6");class u extends c.ColumnDataSource{constructor(e){super(e),this.imid=(0,r.uuid4)(),console.log("spectra data source id:",this.imid)}initialize(){super.initialize()}spectra(e,i,t=0){this.image_source.spectra([e,i,t],(e=>this.data=e.spectrum),this.imid)}refresh(){this.image_source.refresh((e=>this.data=e.spectrum),this.imid,[0,0,0])}static init_SpectraDataSource(){this.define((({Ref:e})=>({image_source:[e(o.ImagePipe)]})))}}t.SpectraDataSource=u,u.__name__="SpectraDataSource",u.init_SpectraDataSource()},
49
+ }, "988b553afa", {"index":"988b553afa","src/bokeh/sources/data_pipe":"4e3e04a57f","src/bokeh/sources/image_pipe":"6eed1dd0c6","src/bokeh/sources/image_data_source":"20c0382ad2","src/bokeh/sources/spectra_data_source":"e5ac72e4af"}, {});});
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * Copyright (c) 2012 - 2021, Anaconda, Inc., and Bokeh Contributors
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
+ * are permitted provided that the following conditions are met:
7
+ *
8
+ * Redistributions of source code must retain the above copyright notice,
9
+ * this list of conditions and the following disclaimer.
10
+ *
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * Neither the name of Anaconda nor the names of any contributors
16
+ * may be used to endorse or promote products derived from this software
17
+ * without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
+ * THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+ (function(root, factory) {
32
+ factory(root["Bokeh"], undefined);
33
+ })(this, function(Bokeh, version) {
34
+ let define;
35
+ return (function(modules, entry, aliases, externals) {
36
+ const bokeh = typeof Bokeh !== "undefined" && (version != null ? Bokeh[version] : Bokeh);
37
+ if (bokeh != null) {
38
+ return bokeh.register_plugin(modules, entry, aliases);
39
+ } else {
40
+ throw new Error("Cannot find Bokeh " + version + ". You have to load it prior to loading plugins.");
41
+ }
42
+ })
43
+ ({
44
+ "988b553afa": function _(a,e,t,c,o){c();const r=a("989790dae8");o("DataPipe",r.DataPipe);const p=a("86e287dc15");o("ImagePipe",p.ImagePipe);const D=a("20c0382ad2");o("ImageDataSource",D.ImageDataSource);const S=a("e5ac72e4af");o("SpectraDataSource",S.SpectraDataSource);(0,a("@bokehjs/base").register_models)({DataPipe:r.DataPipe,ImagePipe:p.ImagePipe,ImageDataSource:D.ImageDataSource,SpectraDataSource:S.SpectraDataSource})},
45
+ "989790dae8": function _(e,i,s,t,n){t();const c=e("@bokehjs/models/sources/data_source"),o=e("@bokehjs/core/util/serialization");class a extends c.DataSource{constructor(e){super(e),this.send_queue={},this.pending={},this.incoming_callbacks={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("datapipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const t in i){let n=i[t];if((0,o.is_NDArray_ref)(n)){const e=new Map;s[t]=(0,o.decode_NDArray)(n,e)}else s[t]="object"==typeof n&&null!==n?e(n):n}return s}(JSON.parse(e.data));if("id"in i&&"direction"in i&&"message"in i){let{id:e,message:s,direction:t}=i;if("j2p"==t)if(e in this.pending){let{cb:i}=this.pending[e];if(delete this.pending[e],e in this.send_queue&&this.send_queue[e].length>0){let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}i(s)}else console.log("message received but could not find id");else if(e in this.incoming_callbacks){let i=this.incoming_callbacks[e](s);this.websocket.send(JSON.stringify({id:e,direction:t,message:i,session:object_id(this)}))}}else console.log(`datapipe received message without one of 'id', 'message' or 'direction': ${i}`)}else console.log("datapipe received binary data",e.data.byteLength,"bytes")};let s=object_id(this);this.websocket.onopen=()=>{this.websocket.send(JSON.stringify({id:"initialize",direction:"j2p",session:s}))}}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}register(e,i){this.incoming_callbacks[e]=i}send(e,i,s){let t={id:e,message:i,direction:"j2p",session:object_id(this)};if(e in this.pending)e in this.send_queue?this.send_queue[e].push({cb:s,msg:t}):this.send_queue[e]=[{cb:s,msg:t}];else if(e in this.send_queue&&this.send_queue[e].length>0){this.send_queue[e].push({cb:s,msg:t});{let{cb:i,msg:s}=this.send_queue[e].shift();this.pending[e]={cb:i},this.websocket.send(JSON.stringify(s))}}else this.pending[e]={cb:s},this.websocket.send(JSON.stringify(t))}static init_DataPipe(){this.define((({Tuple:e,String:i,Number:s,Any:t})=>({init_script:[t],address:[e(i,s)]})))}}s.DataPipe=a,a.__name__="DataPipe",a.init_DataPipe()},
46
+ "86e287dc15": function _(e,i,s,t,n){t();const d=e("@bokehjs/models/sources/data_source"),o=e("@bokehjs/core/util/serialization");class a extends d.DataSource{constructor(e){super(e),this.queue={},this.pending={},this.position={};let i=`ws://${this.address[0]}:${this.address[1]}`;console.log("imagepipe url:",i),this.websocket=new WebSocket(i),this.websocket.binaryType="arraybuffer",this.websocket.onmessage=e=>{if("string"==typeof e.data||e.data instanceof String){let i=function e(i){const s=Array.isArray(i)?new Array:{};for(const t in i){let n=i[t];if((0,o.is_NDArray_ref)(n)){const e=new Map;s[t]=(0,o.decode_NDArray)(n,e)}else s[t]="object"==typeof n&&null!==n?e(n):n}return s}(JSON.parse(e.data));if("id"in i&&"message"in i){let{id:e,message:s}=i,{cb:t,index:n}=this.pending[e];if(delete this.pending[e],e in this.queue){let{cb:i,message:s,index:t}=this.queue[e];delete this.queue[e],this.pending[e]={cb:i,index:t},this.websocket.send(JSON.stringify(s))}this.position[e]={index:n},t(s)}else console.log(`imagepipe received data without 'id' and/or 'message' field: ${i}`)}else console.log("imagepipe received binary data",e.data.byteLength,"bytes")};let s=object_id(this);this.websocket.onopen=()=>{this.websocket.send(JSON.stringify({action:"initialize",session:s}))}}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}channel(e,i,s){let t={action:"channel",index:e,id:s,session:object_id(this)};s in this.pending?this.queue[s]={cb:i,message:t,index:e}:(this.websocket.send(JSON.stringify(t)),this.pending[s]={cb:i,index:e})}spectra(e,i,s){let t={action:"spectra",index:e,id:s,session:object_id(this)};s in this.pending?this.queue[s]={cb:i,message:t,index:e}:(this.websocket.send(JSON.stringify(t)),this.pending[s]={cb:i,index:e})}refresh(e,i,s=[]){let{index:t}=i in this.position?this.position[i]:{index:s};if(2===t.length){let s={action:"channel",index:t,id:i,session:object_id(this)};i in this.pending?this.queue[i]={cb:e,message:s,index:t}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:t})}else if(3===t.length){let s={action:"spectra",index:t,id:i,session:object_id(this)};i in this.pending?this.queue[i]={cb:e,message:s,index:t}:(this.websocket.send(JSON.stringify(s)),this.pending[i]={cb:e,index:t})}}static init_ImagePipe(){this.define((({Tuple:e,String:i,Number:s,Any:t})=>({init_script:[t],address:[e(i,s)],shape:[e(s,s,s,s)]})))}}s.ImagePipe=a,a.__name__="ImagePipe",a.init_ImagePipe()},
47
+ "20c0382ad2": function _(i,e,t,a,s){a();const c=i("@bokehjs/models/sources/column_data_source"),n=i("@bokehjs/core/util/string"),r=i("86e287dc15");class u extends c.ColumnDataSource{constructor(i){super(i),this.imid=(0,n.uuid4)()}initialize(){super.initialize();(()=>{null!=this.init_script&&this.init_script.execute(this)})()}channel(i,e=0,t){this.image_source.channel([e,i],(a=>{this.cur_chan=[e,i],t&&t(a),this.data=a.chan}),this.imid)}refresh(i){this.image_source.refresh((e=>{i&&i(e),this.data=e.chan}),this.imid,[0,0])}static init_ImageDataSource(){this.define((({Tuple:i,Number:e,Ref:t,Any:a})=>({init_script:[a],image_source:[t(r.ImagePipe)],num_chans:[i(e,e)],cur_chan:[i(e,e)]})))}}t.ImageDataSource=u,u.__name__="ImageDataSource",u.init_ImageDataSource()},
48
+ "e5ac72e4af": function _(e,i,t,s,a){s();const c=e("@bokehjs/models/sources/column_data_source"),r=e("@bokehjs/core/util/string"),o=e("86e287dc15");class u extends c.ColumnDataSource{constructor(e){super(e),this.imid=(0,r.uuid4)(),console.log("spectra data source id:",this.imid)}initialize(){super.initialize()}spectra(e,i,t=0){this.image_source.spectra([e,i,t],(e=>this.data=e.spectrum),this.imid)}refresh(){this.image_source.refresh((e=>this.data=e.spectrum),this.imid,[0,0,0])}static init_SpectraDataSource(){this.define((({Ref:e})=>({image_source:[e(o.ImagePipe)]})))}}t.SpectraDataSource=u,u.__name__="SpectraDataSource",u.init_SpectraDataSource()},
49
+ }, "988b553afa", {"index":"988b553afa","src/bokeh/sources/data_pipe":"989790dae8","src/bokeh/sources/image_pipe":"86e287dc15","src/bokeh/sources/image_data_source":"20c0382ad2","src/bokeh/sources/spectra_data_source":"e5ac72e4af"}, {});});
@@ -0,0 +1 @@
1
+ (()=>{function n(t){if(typeof t._casagui_id_=="undefined"){let e=null;if(typeof window=="undefined"){if(typeof crypto!="undefined"){let a=crypto.randomBytes(8);e=new Uint32Array(a.buffer.slice(-4))}}else e=new Uint32Array(1),window.crypto.getRandomValues(e);let r=new Date,i=Math.floor(r.getTime()/1e3);t._casagui_id_=`${e?e[0]:i}-${i}`}return t._casagui_id_}window.object_id=n;})();
@@ -0,0 +1,31 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2023
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
+ '''Custom tools used within cubevis.'''
29
+
30
+ from ._drag_tool import DragTool
31
+ from ._cbreset_tool import CBResetTool
@@ -0,0 +1,52 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2023
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
+ '''Implementation of ``CBResetTool`` which is a version of the
29
+ ``ResetTool`` which resets a graph and calls a callback to allow
30
+ for resetting other state'''
31
+
32
+ from bokeh.models import ResetTool, Tool
33
+ from bokeh.core.properties import Instance, Nullable
34
+ from bokeh.models.callbacks import Callback
35
+
36
+ class CBResetTool(ResetTool):
37
+ '''Tool that emits press and pressup events to signal start and end of drag'''
38
+
39
+ precallback = Nullable(Instance(Callback), help="""
40
+ Callback to be called before resetting the graph.
41
+ """)
42
+
43
+ postcallback = Nullable(Instance(Callback), help="""
44
+ Callback to be called after resetting the graph.
45
+ """)
46
+
47
+ # explicit __init__ to support Init signatures
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ ### neither svg files nor SVGIcon are supported by the icon parameter to a tool
50
+ super().__init__(*args, **kwargs )
51
+
52
+ Tool.register_alias("cbreset", lambda: CBResetTool())
@@ -0,0 +1,61 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2023
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
+ '''Implementation of ``DragTool`` class which provides a events or
29
+ callbacks in response to dragging gestures on a figure. Unlike the
30
+ PanTool all screen points use the plot's frame of reference instead
31
+ of the figure's frame of reference, i.e. sx=0, sy=0 is the lower
32
+ left corner of the plot.'''
33
+
34
+ from bokeh.models import Drag, Tool
35
+ from bokeh.core.properties import Instance, Nullable
36
+ from bokeh.models.callbacks import Callback
37
+ from os.path import join,dirname
38
+ from pathlib import Path
39
+
40
+ class DragTool(Drag):
41
+ '''Tool that emits press and pressup events to signal start and end of drag'''
42
+
43
+ start = Nullable(Instance(Callback), help="""
44
+ JavaScript to be executed when dragging starts. If no start callback has been provided
45
+ a PanStart event will be triggered when dragging starts.
46
+ """)
47
+ move = Nullable(Instance(Callback), help="""
48
+ JavaScript to be executed as dragging progresses. If no move callback has been provided
49
+ a Pan event will be triggered when dragging progresses.
50
+ """)
51
+ end = Nullable(Instance(Callback), help="""
52
+ JavaScript to be executed when dragging ends. If no end callback has been provided
53
+ a PanEnd event will be triggered when dragging stops.
54
+ """)
55
+
56
+ # explicit __init__ to support Init signatures
57
+ def __init__(self, *args, **kwargs) -> None:
58
+ ### neither svg files nor SVGIcon are supported by the icon parameter to a tool
59
+ super().__init__(*args, icon=Path(join(dirname(dirname(dirname(__file__))),'__icons__','drag.png')), **kwargs )
60
+
61
+ Tool.register_alias("drag", lambda: DragTool())
@@ -0,0 +1,35 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2021,2022
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
+ '''Functions use in the implementation of cubevis's Bokeh extensions.'''
29
+
30
+ from ._svg_icon import svg_icon
31
+
32
+ ###
33
+ ### axes_labels has errors on import
34
+ ###
35
+ #from .axes_labels import get_world_coordinates
@@ -0,0 +1,94 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2021,2022
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
+ '''THIS IS PROBABLY NOT CURRENTLY IN ACTIVE USE. Functions for coordinate conversion and axis labeling using
29
+ the casacore coordsys object. This was added when regions were used for masking within interactive clean
30
+ instead of each user-drawn region being used to immediately change the mask cube on disk. This code may have
31
+ never actually been used in production. Note that coordtxl (https://www.npmjs.com/package/coordtxl) is used
32
+ for world coordinate axis labeling in JavaScript for interactive clean.'''
33
+ import numpy as np
34
+ from astropy.wcs import WCS
35
+ from casatools import image
36
+
37
+
38
+ def get_world_coordinates(ia):
39
+ """
40
+ .. todo::
41
+ Support different world coordiantes
42
+ Provide prettier string formatting
43
+
44
+ Get the mapping between pixel coordinates and world coordinates using casatools.coordsys
45
+
46
+ Parameters
47
+ -------
48
+ ia: casatools.image
49
+
50
+ Returns
51
+ -------
52
+ x_axes_labels, y_axes_labels : (dict, dict)
53
+ Dictionary mapping pixel coordinates to world coordinates
54
+ """
55
+ pix = np.zeros([len(ia.shape()), ia.shape()[0]])
56
+ pix[0, :] = range(ia.shape()[0])
57
+ csys = ia.coordsys()
58
+ world = csys.toworldmany(pix)['numeric']
59
+ x_axes_labels = {i: str(world[0][i]) for i in range(ia.shape()[0])}
60
+ y_axes_labels = {i: str(world[1][i]) for i in range(ia.shape()[0])}
61
+ return x_axes_labels, y_axes_labels
62
+
63
+
64
+ #--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
65
+ # This function has not been tested. pylint indicated that 'shp' is not defined. It seems like
66
+ # the intent was probably to have the image shape supplied as a parameter since it is not available
67
+ # from the coordsys object.
68
+ #--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
69
+ def get_world_coordinates_wcs(csys: image.coordsys, shp ) -> list():
70
+ """
71
+ .. todo::
72
+ Support different world coordiantes
73
+ Provide prettier string formatting
74
+
75
+ Get the mapping between pixel coordinates and world coordinates using astropy.wcs.WCS
76
+
77
+ Parameters
78
+ -------
79
+ csys: casatools.coordsys
80
+
81
+ Returns
82
+ -------
83
+ x_axes_labels, y_axes_labels : (dict, dict)
84
+ Dictionary mapping pixel coordinates to world coordinates
85
+ """
86
+ rad_to_deg = 180/np.pi
87
+ w = WCS(naxis=2)
88
+ w.wcs.crpix = csys.referencepixel()['numeric'][0:2]
89
+ w.wcs.cdelt = csys.increment()['numeric'][0:2]*rad_to_deg
90
+ w.wcs.crval = csys.referencevalue()['numeric'][0:2]*rad_to_deg
91
+ w.wcs.ctype = ['RA---SIN', 'DEC--SIN']
92
+ x_axes_labels = {i: w.pixel_to_world(0, i).ra.to_string() for i in range(shp[0] + 1)}
93
+ y_axes_labels = {i: w.pixel_to_world(i, 0).dec.to_string(decimal=True) for i in range(shp[0] + 1)}
94
+ return x_axes_labels, y_axes_labels