worldwidetelescope / pywwt Goto Github PK
View Code? Open in Web Editor NEWPython interface to WorldWide Telescope :milky_way:
Home Page: https://pywwt.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
Python interface to WorldWide Telescope :milky_way:
Home Page: https://pywwt.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
The SkyCoord class allows vectors of coordinates to be represented:
In [1]: from astropy.coordinates import SkyCoord
In [2]: c1 = SkyCoord.from_name('M31')
In [3]: c2 = SkyCoord([1, 2, 3], [3, 4, 5], unit='deg')
In [4]: c1.isscalar
Out[4]: True
In [5]: c2.isscalar
Out[5]: False
In [6]: c2.icrs.ra
Out[6]: <Longitude [ 1., 2., 3.] deg>
In [7]: c2.icrs.ra.degree
Out[7]: array([ 1., 2., 3.])
We should make add_point
for polygons and lines accept vector SkyCoords so that many points can be added in one go.
We should write some documentation and host it on ReadTheDocs. In particular this could include a notebook to demo the Jupyter widget and a link to open it in Binder.
We need a way to provide a table with 3D coordinates/parameters for an orbit or trajectory and have those show up in WWT.
Similar to my suggestion in #85, I think we should make it so that load_fits_data
returns some kind of Image object on which we can set the current slice for data cubes.
Upon startup while using the Qt version, the error libpng warning: gAMA: gamma value out of range
is printed several times.
(libpng warning: iCCP: known incorrect sRGB profile
also appears from time to time while in solar system mode.)
It seems to be caused by the loading of the images used for the showConstellationPictures setting, and from some Googling it seems like the error is a problem with Qt, though I don't know exactly what. If it's not fixable, we could at least hide it by using the javaScriptConsoleMessage()
function qt.py
by adding libpng not in message
to the if
condition.
At the moment we can load FITS files into WWT via pywwt, but we have no control over the limits/stretch. We should make it so that users can set this. It might be nice for load_fits_data
to return some kind of Image object that users can interact with.
There are methods here:
to load, play, and stop tours. We should add these to BaseWWTWidget
(see center_on_coordinates
for how to do this) and also add a corresponding handler in pywwt_web/wwt_json_api.js
http://pywwt.readthedocs.io/en/latest/settings.html
Screenshots like the one above are saved through a widget method that takes your desired file name its argument:
wwt.render('stgo_view.png')
AttributeError: 'WWTJupyterWidget' object has no attribute 'render'
Currently the WWT viewer is only shown the first time, and executing the cell that initializes the viewer again causes WebGL context-related errors
It would be useful when using pywwt as a script (for example) to bound the interactive space to a specific area. For example, if you were showing M31 with overlays and annotations, someone wouldn't zoom too far away or pan so far M31 is out of FOV.
(This may take iteration with core wwt developers)
The center_on_coordinates
method currently takes ra/dec/fov, but we should modify this to instead take Astropy SkyCoord objects and a FOV value as an Astropy Quantity.
When initializing a polygon or line, it would be nice to be able to specify the points, e.g.
circle = wwt.add_polygon(points=SkyCoord(...))
this could internally just call add_point
.
it would be useful to have an available view modes list (Earth, Solar System, etc.) in a similar way as we have available_layers.
At the moment the size of the canvas is hard-coded, but this should be adjusted to match the available space in the output notebook cell.
In Python 2, this fails with unicode strings:
if isinstance(value, str) or (isinstance(value, tuple) and len(value) == 3):
(this is in the color trait code). We should use isinstance(value, six.string_types)
instead of isinstance(value, str)
so that unicode strings work.
I think the HasTraits class makes it possible to set traits during the class initialization - this means we should modify:
class BaseWWTWidget(HasTraits):
def __init__(self):
super(BaseWWTWidget, self).__init__()
to be:
class BaseWWTWidget(HasTraits):
def __init__(self, **kwargs):
super(BaseWWTWidget, self).__init__(**kwargs)
and we should also modify:
class WWTQtWidget(BaseWWTWidget):
def __init__(self, block_until_ready=False, size=None):
...
super(WWTQtWidget, self).__init__()
to be:
class WWTQtWidget(BaseWWTWidget):
def __init__(self, block_until_ready=False, size=None, **kwargs):
...
super(WWTQtWidget, self).__init__(**kwargs)
With this you can then do e.g.
wwt = WWTQtWidget(crosshairs=True)
I'm not sure yet how one does this within WorldWideTelescope, but we need to have a way for users to provide e.g. FITS files or RGB images with AVM meta-data and easily overlay these in WorldWideTelescope. This includes automatically dealing with images that are >2048 pixels and need to be (I think) converted to TOAST format.
There is an undocumented setting called galacticMode
in WWT that can be set to True/False and determines whether the galactic plane should be horizontal in the viewer. This is a really useful option, and we should add it even though it isn't the official API docs.
I'm not sure how feasible this is going to be in terms of how the rendering might be different on different machines, but worth the try.
It isn't possible to give an arbitrary URL to loadFITS, which is going to make it difficult/impossible to use in pywwt at the moment. Error when trying to give a URL in the official web client:
Failed to load http://astropy.stsci.edu/data/photometry/irac_ch1_flight.fits: Redirect from 'http://astropy.stsci.edu/data/photometry/irac_ch1_flight.fits' to 'https://astropy.stsci.edu/data/photometry/irac_ch1_flight.fits' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://worldwidetelescope.org' is therefore not allowed access.
wwtsdk.min.js:33 Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.
at kd._readFromBlob$1 (wwtsdk.min.js:33)
at kd.fileStateChange (wwtsdk.min.js:33)
at Cc.e [as onStateChange] (wwtsdk.min.js:11)
at Cc.set_state (wwtsdk.min.js:28)
at Cc._loadBlob (wwtsdk.min.js:28)
at XMLHttpRequest._xhr.onreadystatechange (wwtsdk.min.js:28)
This is just a note that when we release 0.3 we should make sure we understand how to properly do this so that the package works seamlessly as a Jypyter notebook plugin.
We should investigate how to make the Jupyter widgets work for Jupyter lab.
Once #1 is done, we should add some further validation to the traits. For colors, we could use e.g. matplotlib to understand different ways of specifying the color and converting it to hex. For other kinds of values we should test e.g numerical value ranges. See http://traitlets.readthedocs.io/en/stable/using_traitlets.html#validation for information on adding validation to traits.
This request came up during the Hack Together Day at the 2018 Winter AAS meeting.
Use cases:
I think the web client does have support for the solar system mode - if so, we should add support for it in pywwt.
There are a number of WWT settings, most of them boolean or related to colors:
At the moment the code just includes an example of how to implement showConstellationFigures
in core.py
constellation_figures = Bool(False, help='Whether to show the constellations').tag(wwt='showConstellationFigures', sync=True)
Adding a setting just means adding a line here. For string settings we should use the Unicode
traitlet class. We should use PEP8-friendly names for the Python side, and the wwt
name indicates the WWT setting name.
set date, pause time in solar_system mode (so when zooming on Earth, the planet is not rotating under the field of view).
We could make a Jupyter widget to control the background/foreground layer and transparency.
This is a little bit more advanced, but down the road, if a javascript command fails, we should pass this back to Python so that a proper exception can be raised.
I think this would be most easily done on the Qt widget for now
At the moment the WebGL annotations work somewhat but there are important differences compared to the previous HTML5 SDK:
There are several separate issues here:
The other esthetic differences in the appearance of the grid lines, planets, and stars are fine.
We should add some tests of the existing functionality, and set up the CI services to automatically run them.
There should be a way to select the different earth maps available in planet mode.
This might be related to Mars not being available in set_view.
At the moment, two-finger scrolling both zooms and moves up and down on the page, which is confusing. We should disable scrolling up/down while zooming in/out.
A 1-3 minute video on how to use pywwt in Jupyter lab would be very useful!
Currently the radius of the circle annotations is in display units but I think there is a way to specify it in arcsec (need to check WWT SDK docs)
I think the following properties should accept astropy quantities:
location_altitude = Float(0, help='Assigns altitude (in meters) for view location').tag(wwt='locationAltitude', sync=True)
location_latitude = Float(47.633, help='Assigns latitude for view location').tag(wwt='locationLat', sync=True)
location_longitude = Float(122.133333, help='Assigns longitude for view location').tag(wwt='locationLng', sync=True)
I think the way to do that is to add a @validate
for each of these (see e.g. the one for foreground_opacity) that converts the given values to the required units above and then returns the plain scalar in the right units.
Annotation Objects
Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Circle Objects
Circle
class in annotation.py
)Circle
class in annotation.py
)Circle
class in annotation.py
)Circle
class in annotation.py
)Circle
class in annotation.py
)Circle
class in annotation.py
)Circle
class in annotation.py
)Poly Objects
Poly
class in annotation.py
)Poly
class in annotation.py
)Poly
class in annotation.py
)Poly
class in annotation.py
)Poly
class in annotation.py
)PolyLine Objects
PolyLine
class in annotation.py
)PolyLine
class in annotation.py
)PolyLine
class in annotation.py
)Settings Objects
BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
) (unable to test due to XML permission problems)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
) **validatedBaseWWTWidget
class in core.py
) **validatedBaseWWTWidget
class in core.py
) **validatedBaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
) (unable to test due to XML permission problems)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)WWTControl Objects
-WWTControl Fov Property
wwt.[relevant setting]
and see that setting's current value.)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)get_center
method of BaseWWTWidget
in core.py
)get_center
method of BaseWWTWidget
in core.py
)center_on_coordinates
method of Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)Annotation
class in annotation.py
)annotation.py
)BaseWWTWidget
class in core.py
)BaseWWTWidget
class in core.py
)Annotation
class in annotation.py
)I need to copy over the functionality from the original package before a real 0.3 release.
We should set up an infrastructure to make it possible to add annotations and get back Python objects that can then be further modified and have their changes reflected in the WWT viewer.
It would be nice to add text with the other annotations for example, following matplotlib.text
wwt.add_circle(center, radius=radius)
wwt.add_text(string, xy=center, xytext=None, size=size, xycoords=canvas)
where xycoords would specify to tie the text to the WWT base layer or to the monitor.
Once #2 is implemented, we could add a high-level method that takes an Astropy table and plots the positions of all the points.
It would be nice to have a way to provide a catalog of longitudes/latitudes on the surface of one of the planets and have those show up in WWT.
I install the pywwt by code on github, then run the sample pywwt\examples\jupyter\example.ipynb, but the wwt widget does not show
The jupyter shows logs below:
[W 08:08:01.728 NotebookApp] 404 GET /static/ipyevents.js?v=20180124080622 (::1) 2.01ms referer=http://localhost:8888/notebooks/wwt/example.ipynb
[W 08:08:01.730 NotebookApp] 404 GET /static/pywwt.js?v=20180124080622 (::1) 1.01ms referer=http://localhost:8888/notebooks/wwt/example.ipynb
where can I download the ipyevents.js & pywwt.js? then where should I put them?
thanks
jupyter
, jupyter_client
, jupyter_console
, jupyter_core
, jupyterlab
, jupyterlab_launcher
, and notebook
should be somewhere within the following ranges:
jupyter: 1.0.0-py36h9896ce5_0 --> 1.0.0-py36_4
jupyter_client: 5.1.0-py36h614e9ea_0 --> 5.2.3-py36_0
jupyter_core: 4.3.0-py36h357a921_0 --> 4.4.0-py36h7c827e3_0
jupyterlab: 0.27.0-py36h86377d0_2 --> 0.31.12-py36_0
jupyterlab_launcher: 0.4.0-py36h4d8058d_0 --> 0.10.5-py36_0
notebook: 5.0.0-py36h0b20546_2 --> 5.4.1-py36_0
Perhaps not all of them, but a nice subset. Beyond this being useful for Qt/Jupyter folks, this should expose issues on with the merging of the original pywwt Windows into this repo.
We should make it so that the central position of the view is a trait, as this will ensure that the current target will be preserved when splitting the output to a panel in Jupyter Lab, or saving the widget state in either Jupyter Lab or Notebooks.
I'm not sure the best way to do it, but when there are relevant example notebooks, they should probably go here: https://github.com/WorldWideTelescope/pywwt-notebooks
The should also probably get referenced in the documentation:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.