Commit b500e561e0f070d8674303e48add65935241b35b

Authored by Goutte
1 parent c6e7153a

Invert the orbits' axes.

@@ -72,15 +72,17 @@ targets: @@ -72,15 +72,17 @@ targets:
72 - type: 'planet' 72 - type: 'planet'
73 slug: 'mercury' 73 slug: 'mercury'
74 name: 'Mercury' 74 name: 'Mercury'
75 - title: 'Mercury (coming soon)' 75 + title: 'Mercury'
76 orbit: 76 orbit:
77 models: 77 models:
78 - slug: 'mercury_orb_all' 78 - slug: 'mercury_orb_all'
  79 + semimajor: 0
  80 + semiminor: 0
79 models: 81 models:
80 - slug: 'tao_mercury_sw' 82 - slug: 'tao_mercury_sw'
81 started_at: "1990-01-01T01:30:00" 83 started_at: "1990-01-01T01:30:00"
82 stopped_at: "2017-02-19T00:00:00" 84 stopped_at: "2017-02-19T00:00:00"
83 - locked: true 85 + locked: false
84 default: true 86 default: true
85 - type: 'planet' 87 - type: 'planet'
86 slug: 'venus' 88 slug: 'venus'
@@ -100,11 +102,14 @@ targets: @@ -100,11 +102,14 @@ targets:
100 - type: 'planet' 102 - type: 'planet'
101 slug: 'earth' 103 slug: 'earth'
102 name: 'Earth' 104 name: 'Earth'
103 - title: 'Earth (coming soon)' 105 + title: 'Earth'
104 orbit: 106 orbit:
105 models: 107 models:
106 - slug: 'earth_orb_all' 108 - slug: 'earth_orb_all'
107 - #model: 'tao_earth_sw' 109 + semimajor: 0
  110 + semiminor: 0
  111 + models:
  112 + - slug: 'tao_earth_sw'
108 locked: true 113 locked: true
109 default: true 114 default: true
110 - type: 'planet' 115 - type: 'planet'
@@ -115,6 +120,7 @@ targets: @@ -115,6 +120,7 @@ targets:
115 - slug: 'tao_mars_sw' 120 - slug: 'tao_mars_sw'
116 started_at: "1990-01-01T01:30:00" 121 started_at: "1990-01-01T01:30:00"
117 stopped_at: "2017-02-19T00:00:00" 122 stopped_at: "2017-02-19T00:00:00"
  123 + - slug: 'tao_mars_swrt'
118 orbit: 124 orbit:
119 models: 125 models:
120 - slug: 'mars_orb_all' 126 - slug: 'mars_orb_all'
@@ -767,6 +767,18 @@ def cache_clear(): @@ -767,6 +767,18 @@ def cache_clear():
767 return "Cache cleared! Removed %d old file(s)." % len(removed_files) 767 return "Cache cleared! Removed %d old file(s)." % len(removed_files)
768 768
769 769
  770 +@app.route("/cache/warmup")
  771 +def cache_warmup():
  772 + """
  773 + Warms up the cache for the current day.
  774 + Linked to SpaceWeather#edit in swapp.ls
  775 + """
  776 + from dateutil.relativedelta import relativedelta
  777 + # relativedelta(years=3)
  778 + # startted_at = datetime.datetime.now() - relativedelta(years=3)
  779 + return "To Do"
  780 +
  781 +
770 # DEV TOOLS ################################################################### 782 # DEV TOOLS ###################################################################
771 783
772 # @app.route("/inspect") 784 # @app.route("/inspect")
web/static/js/swapp.js
@@ -708,7 +708,7 @@ @@ -708,7 +708,7 @@
708 this.orbitersElements = {}; 708 this.orbitersElements = {};
709 this.extremum = 1; 709 this.extremum = 1;
710 this.xScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); 710 this.xScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]);
711 - this.yScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); 711 + this.yScale = d3.scaleLinear().domain([this.extremum, -1 * this.extremum]);
712 this.xAxis = d3.axisBottom().ticks(10); 712 this.xAxis = d3.axisBottom().ticks(10);
713 this.yAxis = d3.axisLeft().ticks(10); 713 this.yAxis = d3.axisLeft().ticks(10);
714 this.svg = d3.select(this.container).append('svg'); 714 this.svg = d3.select(this.container).append('svg');
@@ -718,12 +718,12 @@ @@ -718,12 +718,12 @@
718 this.yAxisLine = this.plotWrapper.append('g').classed('y axis', true); 718 this.yAxisLine = this.plotWrapper.append('g').classed('y axis', true);
719 this.xAxisTitle = this.xAxisLine.append('text').attr('fill', '#000'); 719 this.xAxisTitle = this.xAxisLine.append('text').attr('fill', '#000');
720 this.xAxisTitle.style("text-anchor", "middle"); 720 this.xAxisTitle.style("text-anchor", "middle");
721 - this.xAxisTitle.append('tspan').text('X'); 721 + this.xAxisTitle.append('tspan').text('Y');
722 this.xAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px'); 722 this.xAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px');
723 this.xAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)'); 723 this.xAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)');
724 this.yAxisTitle = this.yAxisLine.append('text').attr('fill', '#000'); 724 this.yAxisTitle = this.yAxisLine.append('text').attr('fill', '#000');
725 this.yAxisTitle.style("text-anchor", "middle"); 725 this.yAxisTitle.style("text-anchor", "middle");
726 - this.yAxisTitle.append('tspan').text('Y'); 726 + this.yAxisTitle.append('tspan').text('X');
727 this.yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px'); 727 this.yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px');
728 this.yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)'); 728 this.yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)');
729 this.yAxisTitle.attr('transform', 'rotate(-90)'); 729 this.yAxisTitle.attr('transform', 'rotate(-90)');
@@ -747,9 +747,9 @@ @@ -747,9 +747,9 @@
747 orbiter = this.plotWrapper.append("svg:image").attr('xlink:href', config['img']).attr('width', '32px').attr('height', '32px'); 747 orbiter = this.plotWrapper.append("svg:image").attr('xlink:href', config['img']).attr('width', '32px').attr('height', '32px');
748 orbiter.append('svg:title').text(config.name); 748 orbiter.append('svg:title').text(config.name);
749 orbit_line = d3.line().x(function(d){ 749 orbit_line = d3.line().x(function(d){
750 - return this$.xScale(d.x); 750 + return this$.xScale(d.y);
751 }).y(function(d){ 751 }).y(function(d){
752 - return this$.yScale(d.y); 752 + return this$.yScale(d.x);
753 }); 753 });
754 orbit_section = this.plotWrapper.append('path').datum(data).classed('orbit orbit_section', true); 754 orbit_section = this.plotWrapper.append('path').datum(data).classed('orbit orbit_section', true);
755 this.orbiters[slug] = config; 755 this.orbiters[slug] = config;
@@ -773,7 +773,7 @@ @@ -773,7 +773,7 @@
773 height = Math.ceil(1.0 * width); 773 height = Math.ceil(1.0 * width);
774 console.debug("Resizing orbits : " + width + " × " + height + "…"); 774 console.debug("Resizing orbits : " + width + " × " + height + "…");
775 this.xScale.range([0, width]); 775 this.xScale.range([0, width]);
776 - this.yScale.range([height, 0]); 776 + this.yScale.range([0, height]);
777 this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom); 777 this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom);
778 this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16); 778 this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16);
779 for (slug in ref$ = this.orbiters) { 779 for (slug in ref$ = this.orbiters) {
@@ -798,12 +798,10 @@ @@ -798,12 +798,10 @@
798 c = Math.sqrt(a * a - b * b); 798 c = Math.sqrt(a * a - b * b);
799 cx = width / 2 - c; 799 cx = width / 2 - c;
800 cy = height / 2; 800 cy = height / 2;
801 - this.yScale.range([0, height]);  
802 el['orbit_ellipse'].attr('cx', cx).attr('cy', cy).attr('rx', this.xScale(a) - this.xScale(0)).attr('ry', this.yScale(b) - this.yScale(0)); 801 el['orbit_ellipse'].attr('cx', cx).attr('cy', cy).attr('rx', this.xScale(a) - this.xScale(0)).attr('ry', this.yScale(b) - this.yScale(0));
803 - this.yScale.range([height, 0]);  
804 data = this.data[slug]; 802 data = this.data[slug];
805 - el['orbiter'].attr('x', this.xScale(data[data.length - 1].x) - 16);  
806 - el['orbiter'].attr('y', this.yScale(data[data.length - 1].y) - 16); 803 + el['orbiter'].attr('x', this.xScale(data[data.length - 1].y) - 16);
  804 + el['orbiter'].attr('y', this.yScale(data[data.length - 1].x) - 16);
807 return this; 805 return this;
808 }; 806 };
809 Orbits.prototype.repositionOrbiter = function(slug, datum){ 807 Orbits.prototype.repositionOrbiter = function(slug, datum){
@@ -811,8 +809,8 @@ @@ -811,8 +809,8 @@
811 data = this.data[slug]; 809 data = this.data[slug];
812 datum == null && (datum = data[data.length - 1]); 810 datum == null && (datum = data[data.length - 1]);
813 el = this.orbitersElements[slug]; 811 el = this.orbitersElements[slug];
814 - el['orbiter'].attr('x', this.xScale(datum.x) - 16);  
815 - el['orbiter'].attr('y', this.yScale(datum.y) - 16); 812 + el['orbiter'].attr('x', this.xScale(datum.y) - 16);
  813 + el['orbiter'].attr('y', this.yScale(datum.x) - 16);
816 return this; 814 return this;
817 }; 815 };
818 Orbits.prototype.bisectDate = d3.bisector(function(d){ 816 Orbits.prototype.bisectDate = d3.bisector(function(d){
web/static/js/swapp.ls
@@ -644,6 +644,9 @@ export class Orbits @@ -644,6 +644,9 @@ export class Orbits
644 init: -> 644 init: ->
645 console.log "Initializing plot of orbits…" 645 console.log "Initializing plot of orbits…"
646 646
  647 + # In the variable names below, x and y are the usual ones.
  648 + # (on the plots we show Y on the x axis, and X reversed on the y axis)
  649 +
647 @margin = { 650 @margin = {
648 top: 30, 651 top: 30,
649 right: 20, 652 right: 20,
@@ -656,7 +659,7 @@ export class Orbits @@ -656,7 +659,7 @@ export class Orbits
656 @orbitersElements = {} 659 @orbitersElements = {}
657 @extremum = 1 660 @extremum = 1
658 @xScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) 661 @xScale = d3.scaleLinear().domain([-1 * @extremum, @extremum])
659 - @yScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) 662 + @yScale = d3.scaleLinear().domain([@extremum, -1 * @extremum])
660 663
661 @xAxis = d3.axisBottom().ticks(10) 664 @xAxis = d3.axisBottom().ticks(10)
662 @yAxis = d3.axisLeft().ticks(10) 665 @yAxis = d3.axisLeft().ticks(10)
@@ -671,7 +674,7 @@ export class Orbits @@ -671,7 +674,7 @@ export class Orbits
671 674
672 @xAxisTitle = @xAxisLine.append('text').attr('fill', '#000') 675 @xAxisTitle = @xAxisLine.append('text').attr('fill', '#000')
673 @xAxisTitle.style("text-anchor", "middle") 676 @xAxisTitle.style("text-anchor", "middle")
674 - @xAxisTitle.append('tspan').text('X') 677 + @xAxisTitle.append('tspan').text('Y')
675 # No : https://bugzilla.mozilla.org/show_bug.cgi?id=308338 678 # No : https://bugzilla.mozilla.org/show_bug.cgi?id=308338
676 # @xAxisTitle.append('tspan').attr('baseline-shift', 'sub').text('HEE') 679 # @xAxisTitle.append('tspan').attr('baseline-shift', 'sub').text('HEE')
677 # Also, don't use em as dy units 680 # Also, don't use em as dy units
@@ -680,7 +683,7 @@ export class Orbits @@ -680,7 +683,7 @@ export class Orbits
680 683
681 @yAxisTitle = @yAxisLine.append('text').attr('fill', '#000') 684 @yAxisTitle = @yAxisLine.append('text').attr('fill', '#000')
682 @yAxisTitle.style("text-anchor", "middle") 685 @yAxisTitle.style("text-anchor", "middle")
683 - @yAxisTitle.append('tspan').text('Y') 686 + @yAxisTitle.append('tspan').text('X')
684 @yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px') 687 @yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px')
685 @yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)') 688 @yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)')
686 @yAxisTitle.attr('transform', 'rotate(-90)') 689 @yAxisTitle.attr('transform', 'rotate(-90)')
@@ -712,8 +715,8 @@ export class Orbits @@ -712,8 +715,8 @@ export class Orbits
712 orbiter.append('svg:title').text(config.name) 715 orbiter.append('svg:title').text(config.name)
713 716
714 orbit_line = d3.line() 717 orbit_line = d3.line()
715 - .x((d) ~> @xScale(d.x))  
716 - .y((d) ~> @yScale(d.y)) 718 + .x((d) ~> @xScale(d.y))
  719 + .y((d) ~> @yScale(d.x))
717 720
718 orbit_section = @plotWrapper.append('path') 721 orbit_section = @plotWrapper.append('path')
719 .datum(data) 722 .datum(data)
@@ -742,8 +745,8 @@ export class Orbits @@ -742,8 +745,8 @@ export class Orbits
742 745
743 console.debug("Resizing orbits : #{width} × #{height}…") 746 console.debug("Resizing orbits : #{width} × #{height}…")
744 747
745 - @xScale.range([0, width]);  
746 - @yScale.range([height, 0]); 748 + @xScale.range([0, width])
  749 + @yScale.range([0, height])
747 750
748 @svg.attr('width', width + @margin.right + @margin.left) 751 @svg.attr('width', width + @margin.right + @margin.left)
749 .attr('height', height + @margin.top + @margin.bottom) 752 .attr('height', height + @margin.top + @margin.bottom)
@@ -781,17 +784,15 @@ export class Orbits @@ -781,17 +784,15 @@ export class Orbits
781 c = Math.sqrt(a*a - b*b) 784 c = Math.sqrt(a*a - b*b)
782 cx = (width / 2) - c 785 cx = (width / 2) - c
783 cy = (height / 2) 786 cy = (height / 2)
784 - @yScale.range([0, height])  
785 el['orbit_ellipse'].attr('cx', cx).attr('cy', cy) 787 el['orbit_ellipse'].attr('cx', cx).attr('cy', cy)
786 .attr('rx', @xScale(a) - @xScale(0)) 788 .attr('rx', @xScale(a) - @xScale(0))
787 .attr('ry', @yScale(b) - @yScale(0)) 789 .attr('ry', @yScale(b) - @yScale(0))
788 # .attr('transform', 'rotate(66,'+(cx+c)+', '+cy+')') 790 # .attr('transform', 'rotate(66,'+(cx+c)+', '+cy+')')
789 - @yScale.range([height, 0])  
790 791
791 data = @data[slug] 792 data = @data[slug]
792 793
793 - el['orbiter'].attr('x', @xScale(data[data.length - 1].x) - 16)  
794 - el['orbiter'].attr('y', @yScale(data[data.length - 1].y) - 16) 794 + el['orbiter'].attr('x', @xScale(data[data.length - 1].y) - 16)
  795 + el['orbiter'].attr('y', @yScale(data[data.length - 1].x) - 16)
795 796
796 this 797 this
797 798
@@ -799,8 +800,8 @@ export class Orbits @@ -799,8 +800,8 @@ export class Orbits
799 data = @data[slug] 800 data = @data[slug]
800 datum ?= data[data.length - 1] 801 datum ?= data[data.length - 1]
801 el = @orbitersElements[slug] 802 el = @orbitersElements[slug]
802 - el['orbiter'].attr('x', @xScale(datum.x) - 16)  
803 - el['orbiter'].attr('y', @yScale(datum.y) - 16) 803 + el['orbiter'].attr('x', @xScale(datum.y) - 16)
  804 + el['orbiter'].attr('y', @yScale(datum.x) - 16)
804 this 805 this
805 806
806 bisectDate: d3.bisector((d) -> d.t).left 807 bisectDate: d3.bisector((d) -> d.t).left
web/view/home.html.jinja2
@@ -151,6 +151,10 @@ @@ -151,6 +151,10 @@
151 } 151 }
152 .mdl-layout__drawer > .mdl-layout-title { 152 .mdl-layout__drawer > .mdl-layout-title {
153 padding-left: 30px; 153 padding-left: 30px;
  154 + line-height: 42px;
  155 + }
  156 + .mdl-layout__drawer > .mdl-layout-title:first-of-type {
  157 + line-height: 60px;
154 } 158 }
155 159
156 #plots_wrapper { 160 #plots_wrapper {