我为测试我的javascript做了一个小提琴。我最初无法获取csv数据,因为没有为我的Google云端桶设置交叉源请求标头。在修改json标头并将数据拉入我的小提琴后,我得到了一些工作。在MTurk Worker沙箱中实施以测试我的数据后,不再拉入我的handson表,而且控制台中不存在任何错误。我真的不确定问题是什么,所以我在这里发帖,因为我没有什么可以解决的。任何有关搜索的建议都将非常感激。
其他信息:Chrome停止为我的链接工作此页面无效
workersandbox.mturk.com重定向了你太多次了。 尝试清除您的cookie。 ERR_TOO_MANY_REDIRECTS
然而HIT在firefox中显示正常。
的Javascript
var csvLink = 'https://storage.googleapis.com/directionalsurvey/testDScsv.csv';
var data = [];
//var trueTVD = X6J374YZ;
var trueTVD = 700;
d3.csv(csvLink, function(dat) {
for (i = 0; i < dat.length; i++) {
var inner = [];
inner.push(dat[i]['Measured Depth']);
inner.push(dat[i]['Inclination']);
inner.push(dat[i]['Azimuth']);
data.push(inner);
}
var container1 = document.getElementById('Table'),
hot1;
var hot1 = new Handsontable(container1, {
data: data,
colHeaders: ['Measured Depth', "Inclination", "Azimuth"],
rowHeaders: true,
minSpareRows: 0,
contextMenu: ['row_above', 'row_below', 'remove_row']
});
function countRows() {
var ht = hot1
var rowcount = ht.countRows() - ht.countEmptyRows();
return rowcount;
}
$("#get_data").click(submitForm);
/////////////////////////////////////////Begin Functions for Minimum Curvature Algorithm////////////////////////////
function Beta(I1, I2, Az1, Az2) {
var dI = Deg2Rad(I2) - Deg2Rad(I1);
var dA = Deg2Rad(Az2) - Deg2Rad(Az1);
var X = math.sin(Deg2Rad(I1)) * math.sin(Deg2Rad(I2));
var Y = math.cos(dI);
var Z = math.cos(dA);
var beta = math.acos(Y - (X * (1 - Z)));
return beta;
}
function RF(beta) {
var b = beta;
var rf = (2 / b) * math.tan(b / 2);
return rf;
}
function TVD(dmd, I1, I2, RF) {
var A = math.cos(Deg2Rad(I1)) + math.cos(Deg2Rad(I2));
var tvd = (dmd / 2) * A * RF;
return tvd;
}
function Deg2Rad(deg) {
return deg * math.pi / 180;
}
function Rad2Deg(rad) {
return rad * 180 / math.pi
}
// function to calculate the TVD
function TVDcalc(MD, INC, AZI, Depth) {
var md = MD;
var inc = INC;
var azi = AZI;
var i;
for (i = 0; i < md.length - 1; i++) {
var beta = Beta(inc[i], inc[i + 1], azi[i], azi[i + 1]);
if (inc[i] == inc[i + 1]) {
var rf = 1;
} else {
var rf = RF(beta);
}
var dMD = md[i + 1] - md[i];
Depth.push(TVD(dMD, inc[i], inc[i + 1], rf) + Depth[i]);
}
return Depth
}
/////////////////////////////////////////End Functions for Minimum Curvature Algorithm////////////////////////////
function enable(TVD) {
if (TVD[TVD.length - 1] >= trueTVD - 5 && TVD[TVD.length - 1] <= trueTVD + 5) {
//console.log(TVD[TVD.length - 1]);
$('#submitButton').prop("disabled", false);
} else {
$('#submitButton').prop("disabled", true);
}
}
function submitForm() {
var htContents = hot1.getSourceData() //getSourceData(1,1,countRows(),3)
//console.log(htContents);
var md = [];
var inc = [];
var azi = [];
var Depth = [];
var fd = Number($('#TVD1').val())
Depth.push(fd);
//transform the HOT into individual arrays for ingestion in TVD calc
for (i = 0; i < countRows(); i++) {
md.push(htContents[i][0]);
inc.push(htContents[i][1]);
azi.push(htContents[i][2]);
}
var TVD = TVDcalc(md, inc, azi, Depth)
enable(TVD);
console.log("".concat("Calculated TVD: ", Math.round(Depth[Depth.length - 1])));
console.log("".concat("Expected TVD: ", trueTVD))
}
});