Giter Site home page Giter Site logo

jjs9's Introduction

JJS9

This is a small and in development wrapper for a front-end JS9 application which is a Javascript version of DS9.

It can be used to create any number of JS9 Displays windows running locally, i.e., loading JavaScript in the same notebook of the client or it can load any number of JS9 Displays running from the server via socket.io communication.

Create as many instances needed and display a JS9 windows and functionalities. See Demo for example use.

Installation

  • Server Side: For now it requires a python server with tornado running JS9 as a webpage and another node server running JS9 server-side helper.

    • Installing python server:
      • Clone JS9 from the original repository
      • Replace the file index.html with the index.html file from jjs9
      • Put the file js9_web.py from jjs9 in the same directory as the js9 files and index.html
      • Choose an available port (the default is 8000) to run the JS9 python server with
        python js9_web.py
        
    • Installing node server:
      • Follow the instructions from JS9 helper
      • js9Prefs.json is used to set the helper preferences. Change the helperport to an available port for the node server. This has to be different from the one used for the python server.
      • Start the node server-side helper with
        node js9Helper.js
        
  • Client Side: To run the JS9 inside jupyter you'd also need pyjs9 a nice python wrapper for the javascript functions in JS9. If you have JS9 server set up and a Jupyter notebook running on a local computer, you can start using jjs9 the following commands. All pyjs9 API's are compatible with jjs9.

    >>> import jjs9
    >>> jjs9.NewDiv()
    >>> J = jjs9.Js9Server(root='http://js9-server-running:my-port')
    >>> J.LoadProxy('url_fits_file.fits')
    >>> J.SetColorMap('red')
    >>> J.DelDiv()
    

    This opens a new JS9 iframe in a Jupyter notebook cell. Each NewDiv of JS9 requires a new socket connection with jjs9.Js9Server().

    Alternatively, there is an option without connecting to a JS9 remote server. This option is for users who only need the basic functionalities of JS9, or users who cannot connect to a remote JS9 server, or users who run Jupyter notebook remotely on a server. For now it needs the basic js and css files that contains everything. These can be found in JS9, in particular js9-allinone.css and js9-allinone.js need to be in same folder as the root of jupyter notebook. If JS9 does not load properly or Javascript gives error adding output, put these two files into /.jupyter/custom/ of the computer's home directory and rename them as custom.css and custom.js. Now if Jupyter notebook is restarted, JS9 should load with Js9Local.

    >>> import jjs9
    >>> jjs9.init_js9=True
    >>> J = jjs9.Js9Local(root='http://localhost:8888/')
    >>> J.NewDiv()
    >>> J.Load('local_file_in_server.fits')
    >>> J.SetColorMap('red')
    >>> J.DelDiv()
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.