Commit b500e561e0f070d8674303e48add65935241b35b

Authored by Goutte
1 parent c6e7153a

Invert the orbits' axes.

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