Commit 780828a8f84541a50d539e1cd71059bf9bcf7f81

Authored by Goutte
1 parent 3c2b15fc

Prepare horizontal lines in the time series and change the default time interval.

CHANGELOG.md
... ... @@ -5,7 +5,6 @@
5 5 - [ ] rajouter MAVEN, New Horizons, Cassini, Galileo, ExoMars comme spacecraft cible
6 6 - [ ] prévoir la possibilité à l'utilisateur d'afficher le temps en Day Of Year
7 7 - [ ] modifier le bandeau vertical d'affichage des choix utilisateurs pour qu'il soit plus petit (en particulier les champs paramètres)
8   -- [ ] ajouter dans le bandeau vertical un onglet LAYERS avec 3 choix possibles: Jupiter Thermosphere Model, HST Jupiter Observations, HST Saturn Observations
9 8 - [ ] ajouter un bouton ALERT qui permet d'ouvrir une nouvelle page de formulaire ou l'utilisateur entrerait les données suivantes:
10 9 * email
11 10 * target (= planète, spacecraft, comet)
... ... @@ -14,6 +13,7 @@
14 13 - [ ] juno/rosetta doivent aussi bouger le long de leur orbite lorsque l'on parcourt à la souris les données de la série temporelle; pour les intervalles de temps où rosetta n'existe plus (crash à la surface de la comète) il faut qu'elle disparaisse; pour les intervalles de temps où juno est en orbite autour de jupiter il faut que juno suive jupiter
15 14 -> tout ceci est configurable dans le fichier de configuration, je n'ai pas les ids !
16 15  
  16 +- [ ] ajouter dans le bandeau vertical un onglet LAYERS avec 3 choix possibles: Jupiter Thermosphere Model, HST Jupiter Observations, HST Saturn Observations
17 17  
18 18 ## Future ?
19 19  
... ... @@ -33,6 +33,8 @@
33 33 ## 1.0.0-rc7
34 34  
35 35 - [ ] Give the future data another color
  36 +- [x] Change the default interval (from 2 months in the past to one in the future)
  37 +- [x] Prepare horizontal lines in the time series
36 38 - [x] Add buttons to the orbits plot zoom to inner or outer heliosphere
37 39 - [x] Make the Y-Axis of time series dynamic (at the expense of animations)
38 40  
... ...
web/run.py
... ... @@ -1148,8 +1148,8 @@ def cache_warmup():
1148 1148 Linked to SpaceWeather#edit in swapp.ls to get the default time interval.
1149 1149 If you edit this code you'll need to edit the other as well and vice versa.
1150 1150 """
1151   - before = relativedelta(years=1)
1152   - after = relativedelta(weeks=3)
  1151 + before = relativedelta(months=2)
  1152 + after = relativedelta(months=1)
1153 1153 today = datetime.datetime.now().replace(hour=0, minute=0, second=0)
1154 1154 started_at = today - before
1155 1155 stopped_at = today + after
... ...
web/static/js/swapp.js
... ... @@ -14,7 +14,7 @@
14 14 return Target;
15 15 }());
16 16 out$.SpaceWeather = SpaceWeather = (function(){
17   - "The main app, instanciated from an inline script.\nIt defaults to an interval starting a year ago, and ending in seven days.\n(both at midnight)";
  17 + "The main app, instanciated from an inline script.\nIt defaults to an interval starting a month ago, and ending in a month.\n(both at midnight)";
18 18 SpaceWeather.displayName = 'SpaceWeather';
19 19 var API_TIME_FORMAT, INPUT_TIME_FORMAT, prototype = SpaceWeather.prototype, constructor = SpaceWeather;
20 20 API_TIME_FORMAT = "YYYY-MM-DDTHH:mm:ss";
... ... @@ -42,8 +42,8 @@
42 42 SpaceWeather.prototype.init = function(){
43 43 "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)";
44 44 var started_at, stopped_at, this$ = this;
45   - started_at = moment().subtract(1, 'year').hours(0).minutes(0).seconds(0);
46   - stopped_at = moment().add(3, 'week').hours(0).minutes(0).seconds(0);
  45 + started_at = moment().subtract(2, 'month').hours(0).minutes(0).seconds(0);
  46 + stopped_at = moment().add(1, 'month').hours(0).minutes(0).seconds(0);
47 47 this.setStartAndStop(started_at, stopped_at);
48 48 this.loadAndCreatePlots(started_at, stopped_at);
49 49 window.addEventListener('resize', function(){
... ... @@ -472,7 +472,7 @@
472 472 return this.title + " of " + this.target.name;
473 473 };
474 474 TimeSeries.prototype.init = function(){
475   - var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, dx, this$ = this;
  475 + var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, i$, ref$, len$, line, lineElement, dx, this$ = this;
476 476 console.info("Initializing plot of " + this + "…");
477 477 this.xDataExtent = d3.extent(this.data, function(d){
478 478 return d.x;
... ... @@ -543,6 +543,17 @@
543 543 this.pathWrapper = this.plotWrapper.append('g');
544 544 this.pathWrapper.attr("clip-path", "url(#" + clipId + ")");
545 545 this.path = this.pathWrapper.append('path').datum(this.data).classed('line', true);
  546 + this.horizontalLines = [];
  547 + if (this.options['horizontalLines']) {
  548 + for (i$ = 0, len$ = (ref$ = this.options['horizontalLines']).length; i$ < len$; ++i$) {
  549 + line = ref$[i$];
  550 + lineElement = this.svg.append("line").attr("class", "line horitonal-line").style("stroke", "orange").style("stroke-dasharray", "3, 2");
  551 + this.horizontalLines.push({
  552 + 'element': lineElement,
  553 + 'config': line
  554 + });
  555 + }
  556 + }
546 557 this.brush = this.plotWrapper.append("g").attr("class", "brush");
547 558 this.mouseCanvas = this.plotWrapper.append("rect").style("fill", "none");
548 559 this.plotWrapper.append('g').classed('x axis', true);
... ... @@ -560,7 +571,7 @@
560 571 };
561 572 RATIO = GOLDEN_RATIO * GOLDEN_RATIO * GOLDEN_RATIO * GOLDEN_RATIO;
562 573 TimeSeries.prototype.resize = function(){
563   - var width, height;
  574 + var width, height, i$, ref$, len$, line, lineValue;
564 575 width = Math.ceil($(this.container).width() - this.margin.left - this.margin.right);
565 576 height = Math.ceil(RATIO * width);
566 577 this.plotWidth = width;
... ... @@ -571,6 +582,11 @@
571 582 this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom);
572 583 this.clip.attr("width", width).attr("height", height);
573 584 this.path.attr('d', this.line);
  585 + for (i$ = 0, len$ = (ref$ = this.horizontalLines).length; i$ < len$; ++i$) {
  586 + line = ref$[i$];
  587 + lineValue = this.yScale(line['config']['value']) + this.margin.top;
  588 + line['element'].attr("x1", this.margin.left).attr("y1", lineValue).attr("x2", this.margin.left + width).attr("y2", lineValue);
  589 + }
574 590 this.xAxis.scale(this.xScale);
575 591 this.yAxis.scale(this.yScale);
576 592 this.xAxis.ticks(Math.floor(width / 80.0));
... ...
web/static/js/swapp.ls
... ... @@ -31,7 +31,7 @@ class Target
31 31 export class SpaceWeather
32 32 """
33 33 The main app, instanciated from an inline script.
34   - It defaults to an interval starting a year ago, and ending in seven days.
  34 + It defaults to an interval starting two months ago, and ending in a month.
35 35 (both at midnight)
36 36 """
37 37  
... ... @@ -75,8 +75,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE
75 75 # Default time interval is from one year ago to three weeks ahead.
76 76 # We set the h/m/s to zero to benefit from a daily cache.
77 77 # If you edit these values you need to change the cache warmup too (run.py)
78   - started_at = moment().subtract(1, 'year').hours(0).minutes(0).seconds(0)
79   - stopped_at = moment().add(3, 'week').hours(0).minutes(0).seconds(0)
  78 + started_at = moment().subtract(2, 'month').hours(0).minutes(0).seconds(0)
  79 + stopped_at = moment().add(1, 'month').hours(0).minutes(0).seconds(0)
80 80 @setStartAndStop(started_at, stopped_at)
81 81 @loadAndCreatePlots(started_at, stopped_at)
82 82 window.addEventListener 'resize', ~> @resize()
... ... @@ -434,6 +434,15 @@ export class TimeSeries
434 434 .datum(@data)
435 435 .classed('line', true)
436 436  
  437 + @horizontalLines = []
  438 + if @options['horizontalLines']
  439 + for line in @options['horizontalLines']
  440 + lineElement = @svg.append("line")
  441 + .attr("class", "line horitonal-line")
  442 + .style("stroke", "orange") # move to CSS
  443 + .style("stroke-dasharray", ("3, 2")) # idem
  444 + @horizontalLines.push({'element': lineElement, 'config': line})
  445 +
437 446 @brush = @plotWrapper.append("g")
438 447 .attr("class", "brush")
439 448  
... ... @@ -505,6 +514,13 @@ export class TimeSeries
505 514  
506 515 @path.attr('d', @line)
507 516  
  517 + for line in @horizontalLines
  518 + lineValue = @yScale(line['config']['value']) + @margin.top
  519 + line['element'].attr("x1", @margin.left)
  520 + .attr("y1", lineValue)
  521 + .attr("x2", @margin.left + width)
  522 + .attr("y2", lineValue)
  523 +
508 524 @xAxis.scale(@xScale)
509 525 @yAxis.scale(@yScale)
510 526  
... ...