linked streams across dynamic maps











up vote
0
down vote

favorite












I have a set of hyperspectral data, a grid of X,Y,Energy where each point is a full spectrum. From those spectra I can create image stacks e.g. image stack 1= sum of counts from channel 600-650 across the grid, image stack 2 = 700-750 etc.



I would like to be able to display the image stacks and when a user clicks on a pixel or adjusts the kdim slider show the full spectrum at that X,Y, Energy point.



At the moment I can show a single image stack and update the spectrum on a click or when changing kdim using the proof of principle code example below.
That's already pretty good but if I increases the number of images (nimages variable in the code) and try and create multiple SingleTap streams I get an error due to the multiple clash on the ['x', 'y'] parameters. I looked at the link_inputs in the "responding to events" section but that operates on a clone and I've tried and failed to set it up across dynamic maps. Could someome provide an example or point me in the right direction on how to do this ?



import holoviews as hv
import numpy as np
hv.extension('bokeh')

def image_extract(energy=0):
# create a random image as a substitute for looking up the
# real data
return hv.Image(np.random.rand(10,10))

def extract_curve(x=0,y=0,energy=0):
# create a random curve as a substitute for looking up
# the real data
x=np.arange(1000)
return hv.Curve((x,np.random.rand(1000)),"Counts","channels")

# number of images
nimages = 1

dmap_list=
pointer_list=
for i in range(nimages):
img_dmap = hv.DynamicMap(image_extract, kdims=['energy']).redim.range(energy=(0,90))
pointer = hv.streams.SingleTap(x=0,y=0, source=img_dmap,subscribers=,transient=False)
pointer_list.append(pointer)
pointer_dmap = hv.DynamicMap(lambda x,y: hv.Points([(x, y)]), streams=[pointer])
img =img_dmap*pointer_dmap
dmap_list.append(img)
dmap_list.append(hv.DynamicMap(extract_curve,kdims=['energy'],streams=pointer_list).redim.range(energy=(0,90)))

layout = hv.Layout(tuple(dmap_list)).cols(2)
layout









share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a set of hyperspectral data, a grid of X,Y,Energy where each point is a full spectrum. From those spectra I can create image stacks e.g. image stack 1= sum of counts from channel 600-650 across the grid, image stack 2 = 700-750 etc.



    I would like to be able to display the image stacks and when a user clicks on a pixel or adjusts the kdim slider show the full spectrum at that X,Y, Energy point.



    At the moment I can show a single image stack and update the spectrum on a click or when changing kdim using the proof of principle code example below.
    That's already pretty good but if I increases the number of images (nimages variable in the code) and try and create multiple SingleTap streams I get an error due to the multiple clash on the ['x', 'y'] parameters. I looked at the link_inputs in the "responding to events" section but that operates on a clone and I've tried and failed to set it up across dynamic maps. Could someome provide an example or point me in the right direction on how to do this ?



    import holoviews as hv
    import numpy as np
    hv.extension('bokeh')

    def image_extract(energy=0):
    # create a random image as a substitute for looking up the
    # real data
    return hv.Image(np.random.rand(10,10))

    def extract_curve(x=0,y=0,energy=0):
    # create a random curve as a substitute for looking up
    # the real data
    x=np.arange(1000)
    return hv.Curve((x,np.random.rand(1000)),"Counts","channels")

    # number of images
    nimages = 1

    dmap_list=
    pointer_list=
    for i in range(nimages):
    img_dmap = hv.DynamicMap(image_extract, kdims=['energy']).redim.range(energy=(0,90))
    pointer = hv.streams.SingleTap(x=0,y=0, source=img_dmap,subscribers=,transient=False)
    pointer_list.append(pointer)
    pointer_dmap = hv.DynamicMap(lambda x,y: hv.Points([(x, y)]), streams=[pointer])
    img =img_dmap*pointer_dmap
    dmap_list.append(img)
    dmap_list.append(hv.DynamicMap(extract_curve,kdims=['energy'],streams=pointer_list).redim.range(energy=(0,90)))

    layout = hv.Layout(tuple(dmap_list)).cols(2)
    layout









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a set of hyperspectral data, a grid of X,Y,Energy where each point is a full spectrum. From those spectra I can create image stacks e.g. image stack 1= sum of counts from channel 600-650 across the grid, image stack 2 = 700-750 etc.



      I would like to be able to display the image stacks and when a user clicks on a pixel or adjusts the kdim slider show the full spectrum at that X,Y, Energy point.



      At the moment I can show a single image stack and update the spectrum on a click or when changing kdim using the proof of principle code example below.
      That's already pretty good but if I increases the number of images (nimages variable in the code) and try and create multiple SingleTap streams I get an error due to the multiple clash on the ['x', 'y'] parameters. I looked at the link_inputs in the "responding to events" section but that operates on a clone and I've tried and failed to set it up across dynamic maps. Could someome provide an example or point me in the right direction on how to do this ?



      import holoviews as hv
      import numpy as np
      hv.extension('bokeh')

      def image_extract(energy=0):
      # create a random image as a substitute for looking up the
      # real data
      return hv.Image(np.random.rand(10,10))

      def extract_curve(x=0,y=0,energy=0):
      # create a random curve as a substitute for looking up
      # the real data
      x=np.arange(1000)
      return hv.Curve((x,np.random.rand(1000)),"Counts","channels")

      # number of images
      nimages = 1

      dmap_list=
      pointer_list=
      for i in range(nimages):
      img_dmap = hv.DynamicMap(image_extract, kdims=['energy']).redim.range(energy=(0,90))
      pointer = hv.streams.SingleTap(x=0,y=0, source=img_dmap,subscribers=,transient=False)
      pointer_list.append(pointer)
      pointer_dmap = hv.DynamicMap(lambda x,y: hv.Points([(x, y)]), streams=[pointer])
      img =img_dmap*pointer_dmap
      dmap_list.append(img)
      dmap_list.append(hv.DynamicMap(extract_curve,kdims=['energy'],streams=pointer_list).redim.range(energy=(0,90)))

      layout = hv.Layout(tuple(dmap_list)).cols(2)
      layout









      share|improve this question













      I have a set of hyperspectral data, a grid of X,Y,Energy where each point is a full spectrum. From those spectra I can create image stacks e.g. image stack 1= sum of counts from channel 600-650 across the grid, image stack 2 = 700-750 etc.



      I would like to be able to display the image stacks and when a user clicks on a pixel or adjusts the kdim slider show the full spectrum at that X,Y, Energy point.



      At the moment I can show a single image stack and update the spectrum on a click or when changing kdim using the proof of principle code example below.
      That's already pretty good but if I increases the number of images (nimages variable in the code) and try and create multiple SingleTap streams I get an error due to the multiple clash on the ['x', 'y'] parameters. I looked at the link_inputs in the "responding to events" section but that operates on a clone and I've tried and failed to set it up across dynamic maps. Could someome provide an example or point me in the right direction on how to do this ?



      import holoviews as hv
      import numpy as np
      hv.extension('bokeh')

      def image_extract(energy=0):
      # create a random image as a substitute for looking up the
      # real data
      return hv.Image(np.random.rand(10,10))

      def extract_curve(x=0,y=0,energy=0):
      # create a random curve as a substitute for looking up
      # the real data
      x=np.arange(1000)
      return hv.Curve((x,np.random.rand(1000)),"Counts","channels")

      # number of images
      nimages = 1

      dmap_list=
      pointer_list=
      for i in range(nimages):
      img_dmap = hv.DynamicMap(image_extract, kdims=['energy']).redim.range(energy=(0,90))
      pointer = hv.streams.SingleTap(x=0,y=0, source=img_dmap,subscribers=,transient=False)
      pointer_list.append(pointer)
      pointer_dmap = hv.DynamicMap(lambda x,y: hv.Points([(x, y)]), streams=[pointer])
      img =img_dmap*pointer_dmap
      dmap_list.append(img)
      dmap_list.append(hv.DynamicMap(extract_curve,kdims=['energy'],streams=pointer_list).redim.range(energy=(0,90)))

      layout = hv.Layout(tuple(dmap_list)).cols(2)
      layout






      holoviews






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 at 16:36









      pdq

      11




      11
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          It uses hover rather than clicking, but it sounds like you want to do what's in http://datashader.org/topics/landsat.html :



          tap = hv.streams.PointerXY(source=true_color)
          spectrum_curve = hv.DynamicMap(spectrum, streams=[tap]).redim.range(Luminance=(0, 30000))

          tiles * regrid(true_color) + spectrum_curve





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416670%2flinked-streams-across-dynamic-maps%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            It uses hover rather than clicking, but it sounds like you want to do what's in http://datashader.org/topics/landsat.html :



            tap = hv.streams.PointerXY(source=true_color)
            spectrum_curve = hv.DynamicMap(spectrum, streams=[tap]).redim.range(Luminance=(0, 30000))

            tiles * regrid(true_color) + spectrum_curve





            share|improve this answer

























              up vote
              0
              down vote













              It uses hover rather than clicking, but it sounds like you want to do what's in http://datashader.org/topics/landsat.html :



              tap = hv.streams.PointerXY(source=true_color)
              spectrum_curve = hv.DynamicMap(spectrum, streams=[tap]).redim.range(Luminance=(0, 30000))

              tiles * regrid(true_color) + spectrum_curve





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                It uses hover rather than clicking, but it sounds like you want to do what's in http://datashader.org/topics/landsat.html :



                tap = hv.streams.PointerXY(source=true_color)
                spectrum_curve = hv.DynamicMap(spectrum, streams=[tap]).redim.range(Luminance=(0, 30000))

                tiles * regrid(true_color) + spectrum_curve





                share|improve this answer












                It uses hover rather than clicking, but it sounds like you want to do what's in http://datashader.org/topics/landsat.html :



                tap = hv.streams.PointerXY(source=true_color)
                spectrum_curve = hv.DynamicMap(spectrum, streams=[tap]).redim.range(Luminance=(0, 30000))

                tiles * regrid(true_color) + spectrum_curve






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 29 at 6:54









                James A. Bednar

                62625




                62625






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416670%2flinked-streams-across-dynamic-maps%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Sphinx de Gizeh

                    Dijon

                    Guerrita