From b500e561e0f070d8674303e48add65935241b35b Mon Sep 17 00:00:00 2001 From: Goutte Date: Wed, 13 Sep 2017 19:11:28 +0200 Subject: [PATCH] Invert the orbits' axes. --- config.yml | 14 ++++++++++---- web/run.py | 12 ++++++++++++ web/static/js/swapp.js | 22 ++++++++++------------ web/static/js/swapp.ls | 27 ++++++++++++++------------- web/view/home.html.jinja2 | 4 ++++ 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/config.yml b/config.yml index 17c7605..a5fcb7e 100644 --- a/config.yml +++ b/config.yml @@ -72,15 +72,17 @@ targets: - type: 'planet' slug: 'mercury' name: 'Mercury' - title: 'Mercury (coming soon)' + title: 'Mercury' orbit: models: - slug: 'mercury_orb_all' + semimajor: 0 + semiminor: 0 models: - slug: 'tao_mercury_sw' started_at: "1990-01-01T01:30:00" stopped_at: "2017-02-19T00:00:00" - locked: true + locked: false default: true - type: 'planet' slug: 'venus' @@ -100,11 +102,14 @@ targets: - type: 'planet' slug: 'earth' name: 'Earth' - title: 'Earth (coming soon)' + title: 'Earth' orbit: models: - slug: 'earth_orb_all' - #model: 'tao_earth_sw' + semimajor: 0 + semiminor: 0 + models: + - slug: 'tao_earth_sw' locked: true default: true - type: 'planet' @@ -115,6 +120,7 @@ targets: - slug: 'tao_mars_sw' started_at: "1990-01-01T01:30:00" stopped_at: "2017-02-19T00:00:00" + - slug: 'tao_mars_swrt' orbit: models: - slug: 'mars_orb_all' diff --git a/web/run.py b/web/run.py index eaa7421..e9f8d67 100755 --- a/web/run.py +++ b/web/run.py @@ -767,6 +767,18 @@ def cache_clear(): return "Cache cleared! Removed %d old file(s)." % len(removed_files) +@app.route("/cache/warmup") +def cache_warmup(): + """ + Warms up the cache for the current day. + Linked to SpaceWeather#edit in swapp.ls + """ + from dateutil.relativedelta import relativedelta + # relativedelta(years=3) + # startted_at = datetime.datetime.now() - relativedelta(years=3) + return "To Do" + + # DEV TOOLS ################################################################### # @app.route("/inspect") diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 459fb66..6fb8728 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -708,7 +708,7 @@ this.orbitersElements = {}; this.extremum = 1; this.xScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); - this.yScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); + this.yScale = d3.scaleLinear().domain([this.extremum, -1 * this.extremum]); this.xAxis = d3.axisBottom().ticks(10); this.yAxis = d3.axisLeft().ticks(10); this.svg = d3.select(this.container).append('svg'); @@ -718,12 +718,12 @@ this.yAxisLine = this.plotWrapper.append('g').classed('y axis', true); this.xAxisTitle = this.xAxisLine.append('text').attr('fill', '#000'); this.xAxisTitle.style("text-anchor", "middle"); - this.xAxisTitle.append('tspan').text('X'); + this.xAxisTitle.append('tspan').text('Y'); this.xAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px'); this.xAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)'); this.yAxisTitle = this.yAxisLine.append('text').attr('fill', '#000'); this.yAxisTitle.style("text-anchor", "middle"); - this.yAxisTitle.append('tspan').text('Y'); + this.yAxisTitle.append('tspan').text('X'); this.yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px'); this.yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)'); this.yAxisTitle.attr('transform', 'rotate(-90)'); @@ -747,9 +747,9 @@ orbiter = this.plotWrapper.append("svg:image").attr('xlink:href', config['img']).attr('width', '32px').attr('height', '32px'); orbiter.append('svg:title').text(config.name); orbit_line = d3.line().x(function(d){ - return this$.xScale(d.x); + return this$.xScale(d.y); }).y(function(d){ - return this$.yScale(d.y); + return this$.yScale(d.x); }); orbit_section = this.plotWrapper.append('path').datum(data).classed('orbit orbit_section', true); this.orbiters[slug] = config; @@ -773,7 +773,7 @@ height = Math.ceil(1.0 * width); console.debug("Resizing orbits : " + width + " × " + height + "…"); this.xScale.range([0, width]); - this.yScale.range([height, 0]); + this.yScale.range([0, height]); this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom); this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16); for (slug in ref$ = this.orbiters) { @@ -798,12 +798,10 @@ c = Math.sqrt(a * a - b * b); cx = width / 2 - c; cy = height / 2; - this.yScale.range([0, height]); 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)); - this.yScale.range([height, 0]); data = this.data[slug]; - el['orbiter'].attr('x', this.xScale(data[data.length - 1].x) - 16); - el['orbiter'].attr('y', this.yScale(data[data.length - 1].y) - 16); + el['orbiter'].attr('x', this.xScale(data[data.length - 1].y) - 16); + el['orbiter'].attr('y', this.yScale(data[data.length - 1].x) - 16); return this; }; Orbits.prototype.repositionOrbiter = function(slug, datum){ @@ -811,8 +809,8 @@ data = this.data[slug]; datum == null && (datum = data[data.length - 1]); el = this.orbitersElements[slug]; - el['orbiter'].attr('x', this.xScale(datum.x) - 16); - el['orbiter'].attr('y', this.yScale(datum.y) - 16); + el['orbiter'].attr('x', this.xScale(datum.y) - 16); + el['orbiter'].attr('y', this.yScale(datum.x) - 16); return this; }; Orbits.prototype.bisectDate = d3.bisector(function(d){ diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index ed37071..668b8ce 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -644,6 +644,9 @@ export class Orbits init: -> console.log "Initializing plot of orbits…" + # In the variable names below, x and y are the usual ones. + # (on the plots we show Y on the x axis, and X reversed on the y axis) + @margin = { top: 30, right: 20, @@ -656,7 +659,7 @@ export class Orbits @orbitersElements = {} @extremum = 1 @xScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) - @yScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) + @yScale = d3.scaleLinear().domain([@extremum, -1 * @extremum]) @xAxis = d3.axisBottom().ticks(10) @yAxis = d3.axisLeft().ticks(10) @@ -671,7 +674,7 @@ export class Orbits @xAxisTitle = @xAxisLine.append('text').attr('fill', '#000') @xAxisTitle.style("text-anchor", "middle") - @xAxisTitle.append('tspan').text('X') + @xAxisTitle.append('tspan').text('Y') # No : https://bugzilla.mozilla.org/show_bug.cgi?id=308338 # @xAxisTitle.append('tspan').attr('baseline-shift', 'sub').text('HEE') # Also, don't use em as dy units @@ -680,7 +683,7 @@ export class Orbits @yAxisTitle = @yAxisLine.append('text').attr('fill', '#000') @yAxisTitle.style("text-anchor", "middle") - @yAxisTitle.append('tspan').text('Y') + @yAxisTitle.append('tspan').text('X') @yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px') @yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)') @yAxisTitle.attr('transform', 'rotate(-90)') @@ -712,8 +715,8 @@ export class Orbits orbiter.append('svg:title').text(config.name) orbit_line = d3.line() - .x((d) ~> @xScale(d.x)) - .y((d) ~> @yScale(d.y)) + .x((d) ~> @xScale(d.y)) + .y((d) ~> @yScale(d.x)) orbit_section = @plotWrapper.append('path') .datum(data) @@ -742,8 +745,8 @@ export class Orbits console.debug("Resizing orbits : #{width} × #{height}…") - @xScale.range([0, width]); - @yScale.range([height, 0]); + @xScale.range([0, width]) + @yScale.range([0, height]) @svg.attr('width', width + @margin.right + @margin.left) .attr('height', height + @margin.top + @margin.bottom) @@ -781,17 +784,15 @@ export class Orbits c = Math.sqrt(a*a - b*b) cx = (width / 2) - c cy = (height / 2) - @yScale.range([0, height]) el['orbit_ellipse'].attr('cx', cx).attr('cy', cy) .attr('rx', @xScale(a) - @xScale(0)) .attr('ry', @yScale(b) - @yScale(0)) # .attr('transform', 'rotate(66,'+(cx+c)+', '+cy+')') - @yScale.range([height, 0]) data = @data[slug] - el['orbiter'].attr('x', @xScale(data[data.length - 1].x) - 16) - el['orbiter'].attr('y', @yScale(data[data.length - 1].y) - 16) + el['orbiter'].attr('x', @xScale(data[data.length - 1].y) - 16) + el['orbiter'].attr('y', @yScale(data[data.length - 1].x) - 16) this @@ -799,8 +800,8 @@ export class Orbits data = @data[slug] datum ?= data[data.length - 1] el = @orbitersElements[slug] - el['orbiter'].attr('x', @xScale(datum.x) - 16) - el['orbiter'].attr('y', @yScale(datum.y) - 16) + el['orbiter'].attr('x', @xScale(datum.y) - 16) + el['orbiter'].attr('y', @yScale(datum.x) - 16) this bisectDate: d3.bisector((d) -> d.t).left diff --git a/web/view/home.html.jinja2 b/web/view/home.html.jinja2 index b45aed8..3da408e 100755 --- a/web/view/home.html.jinja2 +++ b/web/view/home.html.jinja2 @@ -151,6 +151,10 @@ } .mdl-layout__drawer > .mdl-layout-title { padding-left: 30px; + line-height: 42px; + } + .mdl-layout__drawer > .mdl-layout-title:first-of-type { + line-height: 60px; } #plots_wrapper { -- libgit2 0.21.2