-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support time-series layers #187
Conversation
aaac92a
to
00c845a
Compare
The first three of the new commits are focused on making what I hope are small improvements in trait functionality by expanding the docstrings for TableLayer traits, making the error messages in @pkgw, the most notable development is that I got time series layers to show up in the Qt version. I was also able to get decay working, so, if the user wants, they can make it so points disappear after a specific amount of time. (I also added I hear the concern in #175 about parsing dates from strings, but I don't think there's another way to do it that works for the Qt version. My solution verifies that those strings all conform to the ISOT standard before passing them to WWT. ISOT is browser-independent and should hopefully then be friendly with WebKit, Chromium, and Firefox. As for time zones in Qt, I used Other questions I have are marked in comments beginning with ' Would resolve #175 once merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the general approach here, and have left some comments below.
I don't fully understand why time zones are relevant, so this could do with some more explaining in the code. I think we should just assume that the times passed to us are in UTC, and WWT should interpret them as such (not as local times). However, I just realized that I had an issue for another project that was related to this, and the problem was that the time strings should have a 'Z' added at the end to indicate UTC, otherwise Javascript gets confused.
However, most users don't know to add the 'Z', and astropy doesn't, so I think this is something we should probably do when we serialize and send the table to WWT. Can you try that and see if the hacks related to time zones are still needed?
OK, I changed If this looks close to the implementation we'll use going forward, I can go ahead and update the docs (for both table and image layers) and update the change log.
|
I went ahead and added a method to After reinstalling the directory with I also made more edits to All that's left out is ISOT strings with time zones (e.g. I also corrected some tests in the validation of |
@ojustino OK, the CI is now getting a bit farther. It's now erroring out because it thinks that some of your test files are pytest tests and tries to run them as such, which doesn't work. If you're ready to remove your test files, doing so would help the CI make more progress. |
@pkgw OK, I guess they'll still be there in the old commits. Did you get a chance to test out the time series functionality or |
OK, I've been exploring this and am seeing some weird stuff that I think is a lot more about how the WWT engine works than the pywwt layer. For reference, here's the outline of a test notebook I'm using: # ---- new cell ----
from pywwt.jupyter import WWTJupyterWidget
import numpy as np
from astropy import units as u
from astropy.table import Table
from astropy.time import Time
# ---- new cell ----
wwt = WWTJupyterWidget()
wwt.pause_time()
t0 = wwt.get_current_time()
wwt
# ---- new cell ----
n = 30
TIMESPAN = 100
ra_deg = np.linspace(0, 40, n)
dec_deg = np.zeros(n)
unix_times = t0.unix + np.linspace(0, TIMESPAN, n)
iso_times = [Time(ut, format='unix').isot for ut in unix_times]
table = Table({'ra': ra_deg, 'dec': dec_deg, 'time': iso_times})
layer = wwt.layers.add_data_layer(
table,
lon_att = 'ra', lat_att = 'dec', lon_unit = u.deg,
time_att = 'time', time_series = True,
size_scale = 60
)
# ---- new cell ----
wwt.set_current_time(t0)
wwt.play_time() I'll see a dot show up, but in clumps instead of uniformly ... does WWT's time system lose precision at the few-second level? I'd be surprised. Still trying to understand what's going on, but I wanted to write down the example that I'm looking at. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of miscellaneous comments, but as per my previous comment I'm having trouble getting this feature to work reliably and I'm still trying to track down what's going on — I think it might be more about WWT and not this PR so much, but need to investigate.
@pkgw I went over the results of I also updated the change log and moved the entry under 0.6.2 to 0.7.0 since it looks like we're going to skip the former. EDIT: I didn't see your review until after I wrote this, but I'll follow up tomorrow if I can. |
|
Actually, your test now works as intended for me. Did you use |
A CI failure revealed a weakness in the Jupyter validation code: if there's a problem, the code will crash if you haven't passed it a logger, causing the true error message to be lost. So, let's provide a logger.
Document that, and other recently-added requirements as well.
6294ed4
to
f6bb986
Compare
|
f6bb986
to
7371224
Compare
OK, I was able to track down my problem. It is in fact a precision issue in the WebGL shader implementation in the WWT SDK; the date calculations in SpreadSheetLayer are done relative to a # ---- new cell ----
from pywwt.jupyter import WWTJupyterWidget
import numpy as np
from astropy import units as u
from astropy.table import Table
from astropy.time import Time
t0 = Time('2010-01-01T12:00:00.000', format='isot')
# ---- new cell ----
wwt = WWTJupyterWidget()
wwt.pause_time()
wwt
# ---- new cell ----
n = 30
TIMESPAN = 100
ra_deg = np.linspace(0, 40, n)
dec_deg = np.zeros(n)
unix_times = t0.unix + np.linspace(0, TIMESPAN, n)
iso_times = [Time(ut, format='unix').isot for ut in unix_times]
table = Table({'ra': ra_deg, 'dec': dec_deg, 'time': iso_times})
layer = wwt.layers.add_data_layer(
table,
lon_att = 'ra', lat_att = 'dec', lon_unit = u.deg,
time_att = 'time', time_series = True,
size_scale = 60
)
# ---- new cell ----
wwt.set_current_time(t0)
wwt.play_time() We could reduce these issues by wiring up something to change |
The previous time implementation had a bug where `set_current_time()` was off by a month, because JavaScript has the *amazing* thing where the constructor `Date(year, month, day)` uses zero-based month numbers, but 1-based everything else. This PR uses a different approach that should fix this issue, but that has the side effect of changing the images generated during the CI process. Make the problem go away by altering the reference date to be 2017 Feb 1, which was not what was intended before, but was what was actually being used.
The mean data would definitely be better than the lower date especially if we can remove outliers that are effectively null dates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, there are definitely things to tighten up here — including writing up docs and adding test coverage — but the core functionality seems to be working, and this PR is getting a little unwieldy. So I'm going to make the call to merge it and do the tightening-up in separate follow-up PRs.
@astrojonathan Here is an environment where you can test pywwt directly to figure out what's going on. I've added
console.log
statements to thewwt_json_api.js
file from earlier that should print messages to the console to let you know what's being passed to the SDK. The instructions to set it the time series test are as follows.Install the developer version of pywwt in terminal (if you don't have it already):
Clone this pull request branch to your machine:
It's possible to run pywwt via script, but it might be better to troubleshoot interactively on this one, so go to the
pywwt/nbextension/static
directory, open IPython on the command line, and then copy/paste as instructed fromtime_test.py
.A Qt window running the same
wwt.html
file we worked from last week will pop up once you've copied, pasted, and run the code block with the imports fromtime_test.py
.