Created
July 1, 2018 21:42
-
-
Save f1729/51784ca005836dc2a952329b8a4d1197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A x B | |
const matrix = [["25027M67","25023M67","25021M67","27015M67","29012M66","32012M67"], | |
["26035M68","26033M67","26031M67","27031M68","28027M67","29027M66"], | |
["26052M67","25058M67","26056M67","27060M67","28056M66","29048M66"], | |
["26083M68","26079M67","26068M65","27060M63","29068M62","29071M62"], | |
["27068M66","26066M65","26056M64","27048M62","29054M62","28064M61"]] | |
const topMax = ["0600W", "0550W", "0500W", "0450W", "0400W", "0350W"] | |
const leftMax = ["050S", "100S", "150S", "200S", "250S"] | |
let values = []; | |
matrix.forEach((rows, i) => { | |
rows.forEach((element, j) => { | |
if (i !== 0 && j !== 0 && i !== matrix.length - 1 && j !== rows.length - 1) { | |
values.push([transformData(getCross(element, i, j)), i, j]); | |
} | |
}) | |
}); | |
/* | |
En el eje x: | |
(ui,vj) = 26033M67 | |
(ui−1,vj)= 26035M68 | |
(ui+1 , vj )=26031M67 | |
En el eje y: | |
(ui, vj+1) = 25058M67 (ui, vj−1) = 25023M67 | |
*/ | |
function getCross(element, i, j) { | |
// return a matrix with X, Y axes | |
return [[matrix[i][j-1], matrix[i][j+1]], [matrix[i+1][j], matrix[i-1][j]]] | |
} | |
//Donde cada valor para 25058M67 significa 250 grados (direcci ́on del viento), 58 kt nudos de intensidad , M representa el signo menos y 67 representa la temperatura como se muestra en la siguiente data. | |
function transformData(matrix, i, j) { | |
var x = matrix[0]; // ["25027M67", "25027M67"] | |
var y = matrix[1]; // the same | |
return [ | |
// [ | |
2 * Number(x[0].substring(3, 5)) * Math.cos(Number(x[0].substring(0, 3)) * Math.PI / 180), | |
2 * Number(x[0].substring(3, 5)) * Math.sin(Number(x[0].substring(0, 3)) * Math.PI / 180) | |
/* | |
], | |
[ | |
2 * Number(x[1].substring(3, 5)) * Math.cos(Number(x[1].substring(1, 3)) * Math.PI / 181), | |
2 * Number(x[1].substring(3, 5)) * Math.sin(Number(x[1].substring(0, 3)) * Math.PI / 180) | |
] | |
*/ | |
]; | |
} | |
function getVorticityPerPoint(matrix, w) { | |
// We use just a X axes, then: | |
// console.log(matrix); | |
if (w === 12) return; | |
var x = matrix[0]; | |
var i = matrix[1]; | |
var j = matrix[2]; | |
var diffTop = Math.abs(Number(topMax[j+1].substring(0,3)) - Number(topMax[j-1].substring(0,3))) * 110; | |
var diffLef = Math.abs(Number(leftMax[i+1].substring(0,2)) - Number(leftMax[i-1].substring(0,2))) * 110; | |
var diffU = values[w][0][0] - x[0]; | |
var diffV = values[w][0][1] - x[1]; | |
// console.log(w, (diffV/(2*diffLef)) - (diffU/(2*diffTop))); | |
return (diffV/(2*diffLef)) - (diffU/(2*diffTop)); | |
} | |
values.forEach((info, w) => { | |
console.log(getVorticityPerPoint(info, w+1)); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment