Commit 7b5642aef428cd0ec598497637ddbe162dfa5f9c

Authored by Goutte
1 parent 58bfe281

Normalize time interval for time series.

@@ -6,11 +6,9 @@ @@ -6,11 +6,9 @@
6 - [ ] Set the log level to _error_ in production (see `web/run.py`) 6 - [ ] Set the log level to _error_ in production (see `web/run.py`)
7 - [ ] CRON statements to call the cache cleanup and warmup 7 - [ ] CRON statements to call the cache cleanup and warmup
8 - [ ] Cache warmup (generate for today's default interval) `/cache/warmup` 8 - [ ] Cache warmup (generate for today's default interval) `/cache/warmup`
9 -- [ ] Normalize time interval for time series  
10 - [ ] Give the future data another color 9 - [ ] Give the future data another color
11 - [ ] Sort times series by closeness to the sun 10 - [ ] Sort times series by closeness to the sun
12 - [ ] Generate a CDF file (not NetCDF) 11 - [ ] Generate a CDF file (not NetCDF)
13 -- [ ] Move the link to the source in the footer  
14 12
15 An heliospheric propagation 1D MHD model for solar wind prediction at planets, probes and comets. 13 An heliospheric propagation 1D MHD model for solar wind prediction at planets, probes and comets.
16 14
@@ -18,6 +16,7 @@ An heliospheric propagation 1D MHD model for solar wind prediction at planets, p @@ -18,6 +16,7 @@ An heliospheric propagation 1D MHD model for solar wind prediction at planets, p
18 16
19 ## 1.0.0-rc4 17 ## 1.0.0-rc4
20 18
  19 +- [x] Normalize time interval for time series
21 - [x] Make the footer images clickable 20 - [x] Make the footer images clickable
22 - [x] Highlight the visits counter 21 - [x] Highlight the visits counter
23 - [x] Use a default interval up to 3 weeks in the future 22 - [x] Use a default interval up to 3 weeks in the future
web/static/js/swapp.js
@@ -299,7 +299,10 @@ @@ -299,7 +299,10 @@
299 if (!(id in data)) { 299 if (!(id in data)) {
300 console.error("No data for id '" + id + "'.", data); 300 console.error("No data for id '" + id + "'.", data);
301 } 301 }
302 - return this$.time_series.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container)); 302 + return this$.time_series.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container, {
  303 + 'started_at': this$.started_at,
  304 + 'stopped_at': this$.stopped_at
  305 + }));
303 }); 306 });
304 this.time_series.forEach(function(ts){ 307 this.time_series.forEach(function(ts){
305 ts.options['onMouseOver'] = function(){ 308 ts.options['onMouseOver'] = function(){
@@ -445,6 +448,7 @@ @@ -445,6 +448,7 @@
445 this.parameter = parameter; 448 this.parameter = parameter;
446 this.title = title; 449 this.title = title;
447 this.target = target; 450 this.target = target;
  451 + this.data = data;
448 this.visible = visible; 452 this.visible = visible;
449 this.container = container; 453 this.container = container;
450 this.options = options != null 454 this.options = options != null
@@ -455,24 +459,26 @@ @@ -455,24 +459,26 @@
455 this.onMouseOut = bind$(this, 'onMouseOut', prototype); 459 this.onMouseOut = bind$(this, 'onMouseOut', prototype);
456 this.onMouseOver = bind$(this, 'onMouseOver', prototype); 460 this.onMouseOver = bind$(this, 'onMouseOver', prototype);
457 this.onMouseMove = bind$(this, 'onMouseMove', prototype); 461 this.onMouseMove = bind$(this, 'onMouseMove', prototype);
458 - this.setData(data);  
459 this.init(); 462 this.init();
460 } 463 }
461 TimeSeries.prototype.toString = function(){ 464 TimeSeries.prototype.toString = function(){
462 return this.title + " of " + this.target.name; 465 return this.title + " of " + this.target.name;
463 }; 466 };
464 - TimeSeries.prototype.setData = function(data){  
465 - this.data = data; 467 + TimeSeries.prototype.init = function(){
  468 + var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, dx, this$ = this;
  469 + console.info("Initializing plot of " + this + "…");
466 this.xDataExtent = d3.extent(this.data, function(d){ 470 this.xDataExtent = d3.extent(this.data, function(d){
467 return d.x; 471 return d.x;
468 }); 472 });
469 - return this.yDataExtent = d3.extent(this.data, function(d){ 473 + this.yDataExtent = d3.extent(this.data, function(d){
470 return d.y; 474 return d.y;
471 }); 475 });
472 - };  
473 - TimeSeries.prototype.init = function(){  
474 - var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, dx, this$ = this;  
475 - console.info("Initializing plot of " + this + "…"); 476 + if (this.options['started_at']) {
  477 + this.xDataExtent[0] = this.options['started_at'];
  478 + }
  479 + if (this.options['stopped_at']) {
  480 + this.xDataExtent[1] = this.options['stopped_at'];
  481 + }
476 this.margin = { 482 this.margin = {
477 top: 30, 483 top: 30,
478 right: 20, 484 right: 20,
web/static/js/swapp.ls
@@ -251,7 +251,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @@ -251,7 +251,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE
251 id = parameter['id'] ; title = parameter['title'] 251 id = parameter['id'] ; title = parameter['title']
252 if id not of data then console.error("No data for id '#{id}'.", data) 252 if id not of data then console.error("No data for id '#{id}'.", data)
253 @time_series.push(new TimeSeries( 253 @time_series.push(new TimeSeries(
254 - id, title, target, data[id], @parameters[id].active, container 254 + id, title, target, data[id], @parameters[id].active, container, {
  255 + 'started_at': @started_at,
  256 + 'stopped_at': @stopped_at,
  257 + }
255 )) 258 ))
256 ) 259 )
257 @time_series.forEach((ts) ~> # returning true may be faster 260 @time_series.forEach((ts) ~> # returning true may be faster
@@ -347,24 +350,24 @@ export class TimeSeries @@ -347,24 +350,24 @@ export class TimeSeries
347 # Time in x-axis 350 # Time in x-axis
348 # Data in y-axis 351 # Data in y-axis
349 352
350 - (@parameter, @title, @target, data, @visible, @container, @options = {}) -> 353 + (@parameter, @title, @target, @data, @visible, @container, @options = {}) ->
351 # parameter : slug of the parameter to observe, like btan or pdyn 354 # parameter : slug of the parameter to observe, like btan or pdyn
352 # title : string, more descriptive, shown on the left of the Y axis 355 # title : string, more descriptive, shown on the left of the Y axis
353 # target : target object, like described in configuration 356 # target : target object, like described in configuration
354 # data : list of {x: <datetime>, y: <float>} 357 # data : list of {x: <datetime>, y: <float>}
355 - @setData(data)  
356 @init() 358 @init()
357 359
358 toString: -> "#{@title} of #{@target.name}" 360 toString: -> "#{@title} of #{@target.name}"
359 361
360 - setData: (data) ->  
361 - @data = data # and pre-compute extents for performance when zooming  
362 - @xDataExtent = d3.extent(@data, (d) -> d.x)  
363 - @yDataExtent = d3.extent(@data, (d) -> d.y)  
364 -  
365 init: -> 362 init: ->
366 console.info "Initializing plot of #{@}…" 363 console.info "Initializing plot of #{@}…"
367 364
  365 + # pre-compute extents for performance when zooming
  366 + @xDataExtent = d3.extent(@data, (d) -> d.x)
  367 + @yDataExtent = d3.extent(@data, (d) -> d.y)
  368 + if @options['started_at'] then @xDataExtent[0] = @options['started_at']
  369 + if @options['stopped_at'] then @xDataExtent[1] = @options['stopped_at']
  370 +
368 @margin = { 371 @margin = {
369 top: 30, 372 top: 30,
370 right: 20, 373 right: 20,