Javascript must be enabled to use this page.
Area:  WestFlorida_AMSEAS DTG: 20261007 Model:  NCOM Graphics:  with current vector overlay

Displayed Image S42013 VENF1 S42023 BGCF1 FMRF1 NPSF1
Parameter:
Depth (ft):
Animate Frames
Loop Mode
Adjust
Speed:
Dwell First Frame: 
Dwell Last Frame: 
Time:
Tau:
Pixel Resolution:
Model Resolution:
Reference Point: S42013 VENF1 S42023 BGCF1 FMRF1 NPSF1
Speed(Knots):
Temperature(F):
Salinity(PSU):
Surface Elevation(ft):
Chlor a(mg/m^-3):
Depth(ft):
\n"); newWindow1.document.close(); } function writeTS(pt) { var hgt = (tauList.length + 12) * 18; var wid = 260; var np = document.control_form.elements["parameter_values[]"].length; var numParams =np + 3; wid += 75*(numParams-1); var winName = 'List Timeseries '+pt; var windowFeatures; windowFeatures = "width="+wid+",height="+hgt+",left=100,top=100,resizable=yes,scrollbars"; if (typeof(newWindow2) == 'object') { newWindow2.close(); } newWindow2 = window.open("","series_"+pt,windowFeatures); newWindow2.focus(); newWindow2.document.open(); newWindow2.document.write("\n\n\n"); newWindow2.document.write(""+winName+"\n"); newWindow2.document.write("\n"); newWindow2.document.write("\n\n"); depthIndex = parseInt(document.control_form.depth.selectedIndex); var depthVal = document.control_form.depth.options[depthIndex].text; for (var i = 0; i < refPts.length; i+=np) { if( String(refPts[i]).search('speed_'+pt) != -1 ) { var ptIndex = parseInt(i/np); break; } } newWindow2.document.write("
\n"); newWindow2.document.write("\n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n\n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); for (var i = 0; i < ref_speed[dtg][ptIndex][0].length; i++) { newWindow2.document.write(" \n"); newWindow2.document.write(" \n \n"); if( ref_speed[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); if( ref_water_temp[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); if( ref_water_sal[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); if( ref_surf_el[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); if( ref_chlor_a[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); if( ref_bathy[dtg][ptIndex].length == 1 ) { depthIndex = 0; } else { depthIndex = parseInt(document.control_form.depth.selectedIndex); } newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); } newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write(" \n"); newWindow2.document.write("
Location: "+pt+"
Depth: "+depthVal+" feet

Forecast
   Time   
 Tau Speed(Knots)
Direction
   (°T)   
Temperature(F)
Salinity(PSU)
Surface Elevation(ft)
Chlor a(mg/m^-3)
Depth(ft)
"+dateList[dtg][i]+""+tauList[i]+""+ref_speed[dtg][ptIndex][depthIndex][i]+""+ref_direc[dtg][ptIndex][depthIndex][i]+""+ref_water_temp[dtg][ptIndex][depthIndex][i]+""+ref_water_sal[dtg][ptIndex][depthIndex][i]+""+ref_surf_el[dtg][ptIndex][depthIndex][i]+""+ref_chlor_a[dtg][ptIndex][depthIndex][i]+""+ref_bathy[dtg][ptIndex][depthIndex][i]+"
\n"); newWindow2.document.write("
\n"); newWindow2.document.write("\n"); newWindow2.document.close(); } function drawPosProfile(lon,lat,pt) { var numParams =0; if (!(pt===undefined)){ var np = document.control_form.elements["parameter_values[]"].length; for (var i = 0; i < refPts.length; i+=np) { if( String(refPts[i]).search('speed_'+pt) != -1 ) { var ptIndex = parseInt(i/np); lon = ptIndex+1000; lat = ptIndex+1000; break; } } } var emptyslot =-1; var newWindow5=undefined; for (var i = 0; i < posPlot.length; i++) if(posPlot[i]==undefined){ if(emptyslot===-1) emptyslot=i; } else{ if(posPos[i][0]===lon && posPos[i][1]===lat){ newWindow5=posPlot[i]; if (newWindow5.closed){ posPlot[i]=undefined; return 1; } } } var tauindex=parseInt(tauList[current_image]); var d=[]; var dparams=[]; var first=true; var salindex=-1; var tempindex=-1; var paramValues=[]; var newLabel=[]; var PName=[]; for(var i=0;i0 && !isNaN(d[numParams][j])) if (first){ dparams[numParams]=i; first=false; } } if(!first){ numParams++; } } var SV=false; if(salindex>0 && tempindex>0){ var SV=true; d.push([]); first=true; var i=paramName.length; for(var j=0;j0 && !isNaN(d[numParams][j])) if (first){ dparams[numParams]=i; first=false; } } if(!first){ paramValues[numParams]="soundvelocity"; newLabel[numParams]="Sound Velocity(m/s)"; PName[numParams]="SOUND SPEED"; numParams++; } } if(newWindow5==undefined){ var hgt = (depthList.length + 12) * 35; wid = 180*(numParams+1); var windowFeatures = "width="+wid+",height="+hgt+",resizable=yes,scrollbars"; if (pt===undefined) newWindow5 = window.open("",'Profile_'+lon.toFixed(4)+'_'+lat.toFixed(4),windowFeatures); else newWindow5 = window.open("",'Profile_'+pt,windowFeatures); if(emptyslot>0) newslot=emptyslot; else{ newslot=posPlot.length posPos.push([]); } posPlot[newslot]=newWindow5; posPos[newslot][0]=lon; posPos[newslot][1]=lat; posId[newslot]=pt; newWindow5.focus(); } if (pt===undefined) var winName = 'Profile_'+lon.toFixed(4)+'_'+lat.toFixed(4); else var winName = 'Profile_'+pt; newWindow5.document.open(); newWindow5.document.write(""+winName+"\n"); i=current_image; if(i>last_image)i=last_image; var timeVal = dateList[0][i]; newWindow5.document.write("\n"); newWindow5.document.write(" \n"); if(pt===undefined) newWindow5.document.write(" \n"); else newWindow5.document.write(" \n"); newWindow5.document.write(" \n"); newWindow5.document.write(" \n"); newWindow5.document.write(" \n"); newWindow5.document.write(" \n"); newWindow5.document.write("
Lon:"+lon.toFixed(4)+" Lat:"+lat.toFixed(4)+"Location:"+pt+"
Time: "+timeVal+"

\n"); newWindow5.document.write("\n\n\n\n"); newWindow5.document.write(" \n"); newWindow5.document.write(" "); newWindow5.document.write("\n <\/td>\n <\/tr>\n<\/table>\n\n\n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" "); ctplotwindow.document.write("

"+winName+"

\n"); var salinity_flag=false; var temp_flag=false; for(j=0;j\n"); ctplotwindow.document.write("
\n"); for(var i=0;i
\n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write("
\n"); ctplotwindow.document.write(" Frequency  KHz  "); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); for(j=0;j\n"); } else if(paramValues[j]=="water_sal"){ ctplotwindow.document.write(" \n"); } else if(paramValues[j]=="water_temp") ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" Source Depth  m  \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write(" \n"); ctplotwindow.document.write("
\n"); ctplotwindow.document.write(" \n"); } for(j=0;j\n"); ctplotwindow.document.write(" \n") ctplotwindow.document.write(" \n") ctplotwindow.document.close(); } function extractData() { ctmode=0; inbox=ctwindow.document.getElementById('endlon'); endlon=parseFloat(inbox.value); inbox=ctwindow.document.getElementById('endlat'); endlat=parseFloat(inbox.value); inbox=ctwindow.document.getElementById('startlon'); startlon=parseFloat(inbox.value); inbox=ctwindow.document.getElementById('startlat'); startlat=parseFloat(inbox.value); inbox=ctwindow.document.getElementById('lonsample'); lonsample=parseInt(inbox.value); inbox=ctwindow.document.getElementById('latsample'); latsample=parseInt(inbox.value); if(startlat>endlat){ var temp=startlat; startlat=endlat; endlat=temp; } if(startlon>endlon){ var temp=startlon; startlon=endlon; endlon=temp; } ctwindow.close(); ctwindow = window.open('','Extracted Model Data','width=1200,height=1000'); ctwindow.focus(); var t=document.control_form.time.value; var winName = 'NCOM Data for Rectangle Bounded By West'+startlon.toFixed(2)+', South:'+startlat.toFixed(2)+', East:'+endlon.toFixed(2)+', and North:'+endlat.toFixed(2)+' at Time:'+t+'Z'; ctwindow.document.open(); ctwindow.document.write(""+winName+"\n"); ctwindow.document.write("\n"); ctwindow.document.write("

"+winName+"

\n"); var modelname = 'NCOM-'; var tauindex=parseInt(tauList[current_image]); var feet2meters=.3048; var meters2feet=3.28084; var knots2m_per_s=.514444444; var numParams =0; var d=[]; var dparams=[]; var salindex=-1; var tempindex=-1; var paramValues=[]; var newLabel=[]; var PName=[]; var latinc=(endlat-startlat+.000001)/latsample; var loninc=(endlon-startlon+.000001)/lonsample; for(var i=0;i0 && tempindex>0){ var SV=true; d.push([]); first=true; var i=paramName.length; var count=0; for (var lon=startlon;lon<=endlon;lon+=loninc){ for (var lat=startlat;lat<=endlat;lat+=latinc){ for(var j=0;j0 && !isNaN(d[numParams][j+count])) if (first){ dparams[numParams]=i; first=false; } } count+=depthList.length; } } if(!first){ paramValues[numParams]="soundvelocity"; newLabel[numParams]="Sound Velocity(m/s)"; PName[numParams]="SOUND SPEED"; numParams++; } } content="Longitude,Latitude,Depth(m)"; ctwindow.document.write("\n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); for(var i=0;i"+newLabel[i]+"
\n"); } ctwindow.document.write("
\n"); content=content+"!"; count=0; for (var lon=startlon;lon<=endlon;lon+=loninc){ for (var lat=startlat;lat<=endlat;lat+=latinc){ for (var depthIndex = 0; depthIndex < depthList.length; depthIndex++){ var line=""; var ecount=0; startline=parseFloat(lon.toFixed(4))+','+parseFloat(lat.toFixed(4))+','+parseInt(depthList[depthIndex]).toString(); for(var i=0;i0){ content=content+startline+line+"!"; ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); for(var i=0;i"+d[i][depthIndex+count].toFixed(4)+"\n"); ctwindow.document.write(" \n"); } } count+=depthList.length } } ctwindow.document.write("
Longitude
Latitude
Depth(m)
"+parseFloat(lon.toFixed(4))+""+parseFloat(lat.toFixed(4))+""+parseInt(depthList[depthIndex]).toString()+"
\n"); ctwindow.document.write("\n"); ctwindow.document.write(" \n"); downloadcall="window.opener.downloader('"+modelname+t.replace(' ','T')+".csv','"+content+"');window.close();"; downloadcall=downloadcall.replace(/\"/g,"'"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write("
\n"); } function downloader(filename, text) { var pom = document.createElement('a'); text=text.replace(/!/g,'\n'); pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); pom.setAttribute('download', filename); if (document.createEvent) { var event = document.createEvent('MouseEvents'); event.initEvent('click', true, true); pom.dispatchEvent(event); } else{ pom.click(); } } function getEndPoint(lon,lat,mode) { if(ctmode==0) if(ctwindow!=undefined)ctwindow.close(); ctmode=mode; var winName = 'Get Points'; if(ctmode==1){ var ctheader = 'Define Cross Track'; var cttitle = 'Cross Track Positions'; } if(ctmode==2){ var ctheader = 'Define Data Extraction Region'; var cttitle = 'Data Extraction Region'; } var tauindex=parseInt(document.control_form.tau.value); ctwindow = window.open('',winName,'width=500,height=250'); startlon=lon; startlat=lat; endlon=lon; endlat=lat; ctwindow.focus(); ctwindow.document.open(); ctwindow.document.write(""+ctheader+"\n"); ctwindow.document.write("

"+cttitle+"

\n"); ctwindow.document.write("\n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); if(ctmode==2){ ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); } ctwindow.document.write("
Start Lon: Start Lat:
End Lon: End Lat:
Y-Axis Samples
(Longitude)
X-Axis Samples
(Latitude)
\n"); ctwindow.document.write("\n"); ctwindow.document.write(" \n"); if(ctmode==1) ctwindow.document.write(" \n"); else ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write(" \n"); ctwindow.document.write("
\n"); ctwindow.document.write("\n"); ctwindow.document.write("\n"); ctwindow.document.close(); } function resetSliderBar() { var bar_cells = last_image - first_image + 1; var outer_wid = parseInt(document.animation.width); bar_wid = parseInt(outer_wid / bar_cells); outer_wid = String((bar_wid * bar_cells) + 1); modifyObject('sliderBox','','','','','',outer_wid,'','',''); modifyObject('sliderImg','','','','','',String(bar_wid),'','',''); modifyObject('tranImg','','','','','',String(bar_wid),'','',''); repositionBar(); } function repositionBar() { var bar_left = String(parseInt(((current_image-first_image) * bar_wid) + 0.5)); modifyObject('sliderImg','','','','','','','',bar_left,''); if (typeof (pointPlot[0]) != 'undefined') { drawPointProfile("S42013"); } if (typeof (pointPrint[0]) != 'undefined') { listPointProfile("S42013"); } if (typeof (pointPlot[1]) != 'undefined') { drawPointProfile("VENF1"); } if (typeof (pointPrint[1]) != 'undefined') { listPointProfile("VENF1"); } if (typeof (pointPlot[2]) != 'undefined') { drawPointProfile("S42023"); } if (typeof (pointPrint[2]) != 'undefined') { listPointProfile("S42023"); } if (typeof (pointPlot[3]) != 'undefined') { drawPointProfile("BGCF1"); } if (typeof (pointPrint[3]) != 'undefined') { listPointProfile("BGCF1"); } if (typeof (pointPlot[4]) != 'undefined') { drawPointProfile("FMRF1"); } if (typeof (pointPrint[4]) != 'undefined') { listPointProfile("FMRF1"); } if (typeof (pointPlot[5]) != 'undefined') { drawPointProfile("NPSF1"); } if (typeof (pointPrint[5]) != 'undefined') { listPointProfile("NPSF1"); } for(var i=0;i last_image) { if (play_mode == 0) { if (current_image == (last_image+1)) { status = 0; var node = ie ? document.all['stp_button'] : document.getElementById('stp_button'); setSelected(node,'animate'); current_image = last_image; return; } else { current_image = first_image; } } if (play_mode == 1) { current_image = first_image; } if (play_mode == 2) { current_image = last_image; animate_rev(); return; } } setImages(depthIndex); repositionBar(); updateRefPt(current_image); delay_time = delay; if (current_image == first_image) delay_time = start_dwell_multiplier*delay; if (current_image == last_image) delay_time = end_dwell_multiplier*delay; timeID = setTimeout("animate_fwd()",delay_time); } function animate_rev() { current_image--; if (current_image < first_image) { if (play_mode == 0) { if (current_image == (first_image-1)) { status = 0; var node = ie ? document.all['stp_button'] : document.getElementById('stp_button'); setSelected(node,'animate'); current_image = first_image; return; } else { current_image = last_image; } } if (play_mode == 1) { current_image = last_image; } if (play_mode == 2) { current_image = first_image; animate_fwd(); return; } } setImages(depthIndex); repositionBar(); updateRefPt(current_image); delay_time = delay; if (current_image == first_image) delay_time = start_dwell_multiplier*delay; if (current_image == last_image) delay_time = end_dwell_multiplier*delay; timeID = setTimeout("animate_rev()",delay_time); } function change_speed(dv) { delay+=dv; if(delay > delay_max) delay = delay_max; if(delay < delay_min) delay = delay_min; } function change_end_dwell(dv) { end_dwell_multiplier += dv; if(end_dwell_multiplier < 1) end_dwell_multiplier = 0; } function change_start_dwell(dv) { start_dwell_multiplier += dv; if(start_dwell_multiplier < 1) start_dwell_multiplier = 0; } function fwd() { stop(); status = 1; animate_fwd(); } function rev() { stop(); status = 1; animate_rev(); } function sweep() { stop(); status = 1; animate_fwd(); } function change_mode(mode) { play_mode = mode; } function launch() { stop(); resetListing(); change_mode(0); var cubeView = document.getElementById('wrapper'); var mainView = document.getElementById('main_wrapper'); cubeView.style.display = 'none'; mainView.style.display = 'block'; } function go2image(number) { stop(); if (number > last_image) number = first_image; if (number < first_image) number = last_image; current_image = number; setImages(depthIndex); repositionBar(); updateRefPt(current_image); var node = ie ? document.all['stp_button'] : document.getElementById('stp_button'); setSelected(node,'animate'); } function setSelected(thisNode,value) { var onSelect = 'selected'; var offSelect = 'unselected'; if(value == 'animate') { modifyObject(animate_id,'','',offSelect,'','','','','',''); animate_id = thisNode.id; } else if(value == 'mode') { if(thisNode.value == 'Sweep') { modifyObject(animate_id,'','',offSelect,'','','','','',''); } modifyObject(mode_id,'','',offSelect,'','','','','',''); mode_id = thisNode.id; } modifyObject(thisNode.id,'','',onSelect,'','','','','',''); } function setImages(selectedDepthIndex) { imageDepthIndex=0; if (setImage(document.depth0,0,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth1,1,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth2,2,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth3,3,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth4,4,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth5,5,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth6,6,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth7,7,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth8,8,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; if (setImage(document.depth9,9,imageDepthIndex,selectedDepthIndex))imageDepthIndex++; setImage(document.depth10,10,imageDepthIndex,selectedDepthIndex); try{ document.animation.src = depthImages[selectedDepthIndex][current_image].src; } catch(err){ document.animation.src = depthImages[0][current_image].src; } for (k=0;kmax) return "'Rainbow'"; if (logr==0) log=false; else log=true; var reverse=false; if (cs.startvalues.length >0){ var stepdist=cs.endvalues[0]-cs.startvalues[0]; } if (cs.startvalues.length >1){ if (cs.startvalues[0]-cs.endvalues[0] > 0){ reverse=true; } } var startcolors=[]; var endcolors=[]; var startv=[]; for (var k=0;k max)continue; if(log===true){ stepdist=Math.log(cs.endvalues[k])-Math.log(cs.startvalues[k]); } if (startcolors.length==0){ startv.push(max); if (cs.startvalues[k] == max){ startcolors.push(HSVtoRGB(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2])); } else{ startcolors.push(interpcolors(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2],cs.endcolors[k*3],cs.endcolors[k*3+1],cs.endcolors[k*3+2],cs.startvalues[k],max,stepdist,log)); } continue; } if (cs.startvalues[k] <= min){ if (k> 0){ startv.push(min); kk=k-1 startcolors.push(interpcolors(cs.startcolors[kk*3],cs.startcolors[kk*3+1],cs.startcolors[kk*3+2],cs.endcolors[kk*3],cs.endcolors[kk*3+1],cs.endcolors[kk*3+2],cs.startvalues[kk],min,stepdist,log)); break; } } else{ startv.push(cs.startvalues[k]); startcolors.push(HSVtoRGB(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2])); } } else{ if (cs.endvalues[k] < min)continue; if(log===true){ stepdist=Math.log(cs.endvalues[k])-Math.log(cs.startvalues[k]); } if (startcolors.length==0){ startv.push(min); if (cs.startvalues[k] == min){ startcolors.push(HSVtoRGB(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2])); } else{ startcolors.push(interpcolors(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2],cs.endcolors[k*3],cs.endcolors[k*3+1],cs.endcolors[k*3+2],cs.startvalues[k],min,stepdist,log)); } continue; } if (cs.startvalues[k] >= max){ if (k> 0){ startv.push(max); kk=k-1 startcolors.push(interpcolors(cs.startcolors[kk*3],cs.startcolors[kk*3+1],cs.startcolors[kk*3+2],cs.endcolors[kk*3],cs.endcolors[kk*3+1],cs.endcolors[kk*3+2],cs.startvalues[kk],max,stepdist,log)); break; } } else{ startv.push(cs.startvalues[k]); startcolors.push(HSVtoRGB(cs.startcolors[k*3],cs.startcolors[k*3+1],cs.startcolors[k*3+2])); } } } if (max==min){ s="[['0','rgb("+startcolors[0].r.toString()+","+startcolors[0].g.toString()+","+startcolors[0].b.toString()+")']," s=s+"['1','rgb("+startcolors[0].r.toString()+","+startcolors[0].g.toString()+","+startcolors[0].b.toString()+")']]" } else{ s="[" for (var k=0;k 1) return s.substr(0,s.length-1)+"]"; else return "'Rainbow'"; } function HSVtoRGB(h, s, v) { var rgb = { }; var h = Math.round(h); var s = Math.round(s * 255); var v = Math.round(v * 255); if (s == 0) { rgb.r = rgb.g = rgb.b = v; } else { var t1 = v; var t2 = (255 - s) * v / 255; var t3 = (t1 - t2) * (h % 60) / 60; if (h == 360) h = 0; if (h < 60) { rgb.r = t1; rgb.b = t2; rgb.g = t2 + t3 } else if (h < 120) { rgb.g = t1; rgb.b = t2; rgb.r = t1 - t3 } else if (h < 180) { rgb.g = t1; rgb.r = t2; rgb.b = t2 + t3 } else if (h < 240) { rgb.b = t1; rgb.r = t2; rgb.g = t1 - t3 } else if (h < 300) { rgb.b = t1; rgb.g = t2; rgb.r = t2 + t3 } else if (h < 360) { rgb.r = t1; rgb.g = t2; rgb.b = t1 - t3 } else { rgb.r = 0; rgb.g = 0; rgb.b = 0 } } return { r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b) }; } function getncbathy(filename,parameterString){ var reader; var oReq = new XMLHttpRequest(); oReq.open("GET", filename, true); oReq.responseType = "blob"; oReq.onload = function(oEvent) { var blob = oReq.response; reader_url = new FileReader(); reader_url.onload = function(e) { reader = new netcdfjs(this.result); var lats = reader.getDataVariable('lat'); var lons = reader.getDataVariable('lon'); var data = reader.getDataVariable(parameterString); bathy=new Interp (data,lons,lats); foreground=[0,0,1]; background=[0,0,0]; NaN=[0,0,0.5]; startvalues=[0,52,104,156,208,260]; endvalues=[52,104,156,208,260,312]; startcolors=[300,1,1,250,1,1,200,1,1,150,1,1,100,1,1,50,1,1]; endcolors=[250,1,1,200,1,1,150,1,1,100,1,1,50,1,1,0,1,1]; colorbathy={foreground,background,NaN,startvalues,endvalues,startcolors,endcolors} } reader_url.readAsArrayBuffer(blob); }; oReq.send(); //start process } function getncchloro(filename,parameterString){ var reader; var oReq = new XMLHttpRequest(); oReq.open("GET", filename, true); oReq.responseType = "blob"; oReq.onload = function(oEvent) { var blob = oReq.response; reader_url = new FileReader(); reader_url.onload = function(e) { reader = new netcdfjs(this.result); var lats = reader.getDataVariable('lat'); var lons = reader.getDataVariable('lon'); var data = reader.getDataVariable(parameterString); chl=new Interp (data,lons,lats); var foreground=[0,0,1]; var background=[0,0,0]; var NaN=[127.5,1,1]; var startvalues=[0.01,0.02,0.05,0.1,0.2,0.5,1,2,5,10]; var endvalues=[0.02,0.05,0.1,0.2,0.5,1,2,5,10,20]; var startcolors=[315.9183673469388,1.0,0.5764705882352941,266.4406779661017,1.0,0.6941176470588235,233.88235294117646,1.0,1.0,204.94117647058823,1.0,1.0,174.35294117647058,1.0,1.0,114.3529411764706,1.0,1.0,71.05882352941177,1.0,1.0,44.0,1.0,1.0,14.823529411764696,1.0,1.0,0.0,1.0,0.8627450980392157]; var endcolors=[266.4406779661017,1.0,0.6941176470588235,233.88235294117646,1.0,1.0,204.94117647058823,1.0,1.0,174.35294117647058,1.0,1.0,114.3529411764706,1.0,1.0,71.05882352941177,1.0,1.0,44.0,1.0,1.0,14.823529411764696,1.0,1.0,0.0,1.0,0.8627450980392157,0,0,0]; colorchl={foreground,background,NaN,startvalues,endvalues,startcolors,endcolors} } reader_url.readAsArrayBuffer(blob); }; oReq.send(); //start process } /* Global class for simulating the movement of particle through a 1km wind grid credit: All the credit for this work goes to: https://github.com/cambecc for creating the repo: https://github.com/cambecc/earth. The majority of this code is directly take nfrom there, since its awesome. This class takes a canvas element and an array of data (1km GFS from http://www.emc.ncep.noaa.gov/index.php?branch=GFS) and then uses a mercator (forward/reverse) projection to correctly map wind vectors in "map space". The "start" method takes the bounds of the map at its current extent and starts the whole gridding, interpolation and animation process. */ var Windy = function Windy(params) { var MIN_VELOCITY_INTENSITY = params.minVelocity || 0; // velocity at which particle intensity is minimum (m/s) var MAX_VELOCITY_INTENSITY = params.maxVelocity || 10; // velocity at which particle intensity is maximum (m/s) var VELOCITY_SCALE = (params.velocityScale || 0.005) * (Math.pow(window.devicePixelRatio, 1 / 3) || 1); // scale for wind velocity (completely arbitrary--this value looks nice) var MAX_PARTICLE_AGE = params.particleAge || 90; // max number of frames a particle is drawn before regeneration var PARTICLE_LINE_WIDTH = params.lineWidth || 1; // line width of a drawn particle var PARTICLE_MULTIPLIER = params.particleMultiplier || 1 / 300; // particle count scalar (completely arbitrary--this values looks nice) var PARTICLE_REDUCTION = Math.pow(window.devicePixelRatio, 1 / 3) || 1.6; // multiply particle count for mobiles by this amount var FRAME_RATE = params.frameRate || 15; var FRAME_TIME = 1000 / FRAME_RATE; // desired frames per second var OPACITY = 0.97; var defaulColorScale = ["rgb(36,104, 180)", "rgb(60,157, 194)", "rgb(128,205,193 )", "rgb(151,218,168 )", "rgb(198,231,181)", "rgb(238,247,217)", "rgb(255,238,159)", "rgb(252,217,125)", "rgb(255,182,100)", "rgb(252,150,75)", "rgb(250,112,52)", "rgb(245,64,32)", "rgb(237,45,28)", "rgb(220,24,32)", "rgb(180,0,35)"]; var colorScale = params.colorScale || defaulColorScale; var NULL_WIND_VECTOR = [NaN, NaN, null]; // singleton for no wind in the form: [u, v, magnitude] var builder; var grid; var gridData = params.data; var date; var A0, P0, DA, Dr, ni, nj; var setData = function setData(data) { gridData = data; }; var setOptions = function setOptions(options) { if (options.hasOwnProperty("minVelocity")) MIN_VELOCITY_INTENSITY = options.minVelocity; if (options.hasOwnProperty("maxVelocity")) MAX_VELOCITY_INTENSITY = options.maxVelocity; if (options.hasOwnProperty("velocityScale")) VELOCITY_SCALE = (options.velocityScale || 0.005) * (Math.pow(window.devicePixelRatio, 1 / 3) || 1); if (options.hasOwnProperty("particleAge")) MAX_PARTICLE_AGE = options.particleAge; if (options.hasOwnProperty("lineWidth")) PARTICLE_LINE_WIDTH = options.lineWidth; if (options.hasOwnProperty("particleMultiplier")) PARTICLE_MULTIPLIER = options.particleMultiplier; if (options.hasOwnProperty("opacity")) OPACITY = +options.opacity; if (options.hasOwnProperty("frameRate")) FRAME_RATE = options.frameRate; FRAME_TIME = 1000 / FRAME_RATE; }; // interpolation for vectors like wind (u,v,m) var bilinearInterpolateVector = function bilinearInterpolateVector(x, y, g00, g10, g01, g11) { var rx = 1 - x; var ry = 1 - y; var a = rx * ry, b = x * ry, c = rx * y, d = x * y; var u = g00[0] * a + g10[0] * b + g01[0] * c + g11[0] * d; var v = g00[1] * a + g10[1] * b + g01[1] * c + g11[1] * d; return [u, v, Math.sqrt(u * u + v * v)]; }; var createWindBuilder = function createWindBuilder(uComp, vComp) { var uData = uComp.data, vData = vComp.data; return { header: uComp.header, //recipe: recipeFor("wind-" + uComp.header.surface1Value), data: function data(i) { return [uData[i], vData[i]]; }, interpolate: bilinearInterpolateVector }; }; var createBuilder = function createBuilder(data) { var uComp = null, vComp = null, scalar = null; data.forEach(function (record) { switch (record.header.parameterCategory + "," + record.header.parameterNumber) { case "1,2": case "2,2": uComp = record; break; case "1,3": case "2,3": vComp = record; break; default: scalar = record; } }); return createWindBuilder(uComp, vComp); }; var buildGrid = function buildGrid(data, callback) { var supported = true; if (data.length < 2) supported = false; if (!supported) console.log("Windy Error: data must have at least two components (u,v)"); builder = createBuilder(data); var header = builder.header; if (header.hasOwnProperty("gridDefinitionTemplate") && header.gridDefinitionTemplate != 0) supported = false; if (!supported) { console.log("Windy Error: Only data with Latitude_Longitude coordinates is supported"); } supported = true; // reset for futher checks A0 = header.lo1; P0 = header.la1; // the grid's origin (e.g., 0.0E, 90.0N) DA = header.dx; Dr = header.dy; // distance between grid points (e.g., 2.5 deg lon, 2.5 deg lat) ni = header.nx; nj = header.ny; // number of grid points W-E and N-S (e.g., 144 x 73) if (header.hasOwnProperty("scanMode")) { var scanModeMask = header.scanMode.toString(2); scanModeMask = ('0' + scanModeMask).slice(-8); var scanModeMaskArray = scanModeMask.split('').map(Number).map(Boolean); if (scanModeMaskArray[0]) DA = -DA; if (scanModeMaskArray[1]) Dr = -Dr; if (scanModeMaskArray[2]) supported = false; if (scanModeMaskArray[3]) supported = false; if (scanModeMaskArray[4]) supported = false; if (scanModeMaskArray[5]) supported = false; if (scanModeMaskArray[6]) supported = false; if (scanModeMaskArray[7]) supported = false; if (!supported) console.log("Windy Error: Data with scanMode: " + header.scanMode + " is not supported."); } date = new Date(header.refTime); date.setHours(date.getHours() + header.forecastTime); // Scan modes 0, 64 allowed. // http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table3-4.shtml grid = []; var p = 0; var isContinuous = Math.floor(ni * DA) >= 360; for (var j = 0; j < nj; j++) { var row = []; for (var i = 0; i < ni; i++, p++) { row[i] = builder.data(p); } if (isContinuous) { // For wrapped grids, duplicate first column as last column to simplify interpolation logic row.push(row[0]); } grid[j] = row; } callback({ date: date, interpolate: interpolate }); }; /** * Get interpolated grid value from Lon/Lat position * @param A {Float} Longitude * @param P {Float} Latitude * @returns {Object} */ var interpolate = function interpolate(A, P) { if (!grid) return null; var i = floorMod(A - A0, 360) / DA; // calculate longitude index in wrapped range [0, 360) var j = (P0 - P) / Dr; // calculate latitude index in direction +90 to -90 var fi = Math.floor(i), ci = fi + 1; var fj = Math.floor(j), cj = fj + 1; var row; if (row = grid[fj]) { var g00 = row[fi]; var g10 = row[ci]; if (isValue(g00) && isValue(g10) && (row = grid[cj])) { var g01 = row[fi]; var g11 = row[ci]; if (isValue(g01) && isValue(g11)) { // All four points found, so interpolate the value. return builder.interpolate(i - fi, j - fj, g00, g10, g01, g11); } } } return null; }; /** * @returns {Boolean} true if the specified value is not null and not undefined. */ var isValue = function isValue(x) { return x !== null && x !== undefined; }; /** * @returns {Number} returns remainder of floored division, i.e., floor(a / n). Useful for consistent modulo * of negative numbers. See http://en.wikipedia.org/wiki/Modulo_operation. */ var floorMod = function floorMod(a, n) { return a - n * Math.floor(a / n); }; /** * @returns {Number} the value x clamped to the range [low, high]. */ var clamp = function clamp(x, range) { return Math.max(range[0], Math.min(x, range[1])); }; /** * @returns {Boolean} true if agent is probably a mobile device. Don't really care if this is accurate. */ var isMobile = function isMobile() { return /android|blackberry|iemobile|ipad|iphone|ipod|opera mini|webos/i.test(navigator.userAgent); }; /** * Calculate distortion of the wind vector caused by the shape of the projection at point (x, y). The wind * vector is modified in place and returned by this function. */ var distort = function distort(projection, A, P, x, y, scale, wind) { var u = wind[0] * scale; var v = wind[1] * scale; var d = distortion(projection, A, P, x, y); // Scale distortion vectors by u and v, then add. wind[0] = d[0] * u + d[2] * v; wind[1] = d[1] * u + d[3] * v; return wind; }; var distortion = function distortion(projection, A, P, x, y) { var t = 2 * Math.PI; // var H = Math.pow(10, -5.2); // 0.00000630957344480193 // var H = 0.0000360; // 0.0000360 degree P ~= 4m (from https://github.com/cambecc/earth/blob/master/public/libs/earth/1.0.0/micro.js#L13) var H = 5; // ToDo: Why does this work? var hA = A < 0 ? H : -H; var hP = P < 0 ? H : -H; var pA = project(P, A + hA, projection); var pP = project(P + hP, A, projection); // Meridian scale factor (see Snyder, equation 4-3), where R = 1. This handles issue where length of 1 degree A // changes depending on P. Without this, there is a pinching effect at the poles. var k = Math.cos(P / 360 * t); return [(pA[0] - x) / hA / k, (pA[1] - y) / hA / k, (pP[0] - x) / hP, (pP[1] - y) / hP]; }; var createField = function createField(columns, bounds, callback) { /** * @returns {Array} wind vector [u, v, magnitude] at the point (x, y), or [NaN, NaN, null] if wind * is undefined at that point. */ function field(x, y) { var column = columns[Math.round(x)]; return column && column[Math.round(y)] || NULL_WIND_VECTOR; } // Frees the massive "columns" array for GC. Without this, the array is leaked (in Chrome) each time a new // field is interpolated because the field closure's context is leaked, for reasons that defy explanation. field.release = function () { columns = []; }; field.randomize = function (o) { // UNDONE: this method is terrible var x, y; var safetyNet = 0; do { x = Math.round(Math.floor(Math.random() * bounds.width) + bounds.x); y = Math.round(Math.floor(Math.random() * bounds.height) + bounds.y); } while (field(x, y)[2] === null && safetyNet++ < 30); o.x = x; o.y = y; return o; }; callback(bounds, field); }; var buildBounds = function buildBounds(bounds, width, height) { var upperLeft = bounds[0]; var lowerRight = bounds[1]; var x = Math.round(upperLeft[0]); //Math.max(Math.floor(upperLeft[0], 0), 0); var y = Math.max(Math.floor(upperLeft[1], 0), 0); var xMax = Math.min(Math.ceil(lowerRight[0], width), width - 1); var yMax = Math.min(Math.ceil(lowerRight[1], height), height - 1); return { x: x, y: y, xMax: width, yMax: yMax, width: width, height: height }; }; var deg2rad = function deg2rad(deg) { return deg / 180 * Math.PI; }; var invert = function invert(x, y, extent) { var newlon=((x-extent.left)*extent.lonperpixel+extent.leftlon); var newlat=((extent.bottom-y)*extent.latperpixel+extent.bottomlat); return [newlon,newlat]; }; var project = function project(lat, lon, extent) { x=Math.floor((lon-extent.leftlon)/extent.lonperpixel+extent.left); y=Math.floor(extent.bottom-(lat-extent.bottomlat)/extent.latperpixel); return [x,y]; }; var interpolateField = function interpolateField(grid, bounds, extent, callback) { var projection = {}; // map.crs used instead var mapArea = (extent.south - extent.north) * (extent.west - extent.east); var velocityScale = VELOCITY_SCALE * Math.pow(mapArea, 0.4); var columns = []; var x = bounds.x; function interpolateColumn(x) { var column = []; for (var y = bounds.y; y <= bounds.yMax; y += 2) { var coord = invert(x, y, extent); if (coord) { var A = coord[0], P = coord[1]; if (isFinite(A)) { var wind = grid.interpolate(A, P); if (wind) { wind = distort(extent, A, P, x, y, velocityScale, wind); column[y + 1] = column[y] = wind; } } } } columns[x + 1] = columns[x] = column; } (function batchInterpolate() { var start = Date.now(); while (x < bounds.width) { interpolateColumn(x); x += 2; if (Date.now() - start > 1000) { //MAX_TASK_TIME) { setTimeout(batchInterpolate, 25); return; } } createField(columns, bounds, callback); })(); }; var animationLoop; var animate = function animate(bounds, field) { function windIntensityColorScale(min, max) { colorScale.indexFor = function (m) { // map velocity speed to a style return Math.max(0, Math.min(colorScale.length - 1, Math.round((m - min) / (max - min) * (colorScale.length - 1)))); }; return colorScale; } var colorStyles = windIntensityColorScale(MIN_VELOCITY_INTENSITY, MAX_VELOCITY_INTENSITY); var buckets = colorStyles.map(function () { return []; }); var particleCount = Math.round(bounds.width * bounds.height * PARTICLE_MULTIPLIER); if (isMobile()) { particleCount *= PARTICLE_REDUCTION; } var fadeFillStyle = "rgba(0, 0, 0, ".concat(OPACITY, ")"); var particles = []; for (var i = 0; i < particleCount; i++) { particles.push(field.randomize({ age: Math.floor(Math.random() * MAX_PARTICLE_AGE) + 0 })); } function evolve() { buckets.forEach(function (bucket) { bucket.length = 0; }); particles.forEach(function (particle) { if (particle.age > MAX_PARTICLE_AGE) { field.randomize(particle).age = 0; } var x = particle.x; var y = particle.y; var v = field(x, y); // vector at current position var m = v[2]; if (m === null) { particle.age = MAX_PARTICLE_AGE; // particle has escaped the grid, never to return... } else { var xt = x + v[0]; var yt = y + v[1]; if (field(xt, yt)[2] !== null) { // Path from (x,y) to (xt,yt) is visible, so add this particle to the appropriate draw bucket. particle.xt = xt; particle.yt = yt; buckets[colorStyles.indexFor(m)].push(particle); } else { // Particle isn't visible, but it still moves through the field. particle.x = xt; particle.y = yt; } } particle.age += 1; }); } var g = params.canvas.getContext("2d"); g.lineWidth = PARTICLE_LINE_WIDTH; g.fillStyle = fadeFillStyle; g.globalAlpha = 0.6; function draw() { // Fade existing particle trails. var prev = "lighter"; g.globalCompositeOperation = "destination-in"; g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.globalCompositeOperation = prev; g.globalAlpha = OPACITY === 0 ? 0 : OPACITY * 0.9; // Draw new particle trails. buckets.forEach(function (bucket, i) { if (bucket.length > 0) { g.beginPath(); g.strokeStyle = colorStyles[i]; bucket.forEach(function (particle) { g.moveTo(particle.x, particle.y); g.lineTo(particle.xt, particle.yt); particle.x = particle.xt; particle.y = particle.yt; }); g.stroke(); } }); } var then = Date.now(); (function frame() { animationLoop = requestAnimationFrame(frame); var now = Date.now(); var delta = now - then; if (delta > FRAME_TIME) { then = now - delta % FRAME_TIME; evolve(); draw(); } })(); }; var start = function start(bounds, extent) { var mapBounds = { south: deg2rad(extent[0][1]), north: deg2rad(extent[1][1]), east: deg2rad(extent[1][0]), west: deg2rad(extent[0][0]), leftlon: extent[0][0], bottomlat: extent[0][1], latperpixel: (extent[1][1]-extent[0][1])/(bounds[1][1]-bounds[0][1]), lonperpixel: (extent[1][0]-extent[0][0])/(bounds[1][0]-bounds[0][0]), left: bounds[0][0], bottom: bounds[1][1], width: bounds[1][0], height: bounds[1][1] }; stop(); // build grid buildGrid(gridData, function (grid) { // interpolateField interpolateField(grid, buildBounds(bounds, bounds[1][0], bounds[1][1]), mapBounds, function (bounds, field) { // animate the canvas with random points windy.field = field; animate(bounds, field); }); }); }; var stop = function stop() { if (windy.field) windy.field.release(); if (animationLoop) cancelAnimationFrame(animationLoop); }; var windy = { params: params, start: start, stop: stop, createField: createField, interpolatePoint: interpolate, setData: setData, setOptions: setOptions }; return windy; }; if (!window.cancelAnimationFrame) { window.cancelAnimationFrame = function (id) { clearTimeout(id); }; } function getvelocitydata(filename,velocitydata,n,tauindex,scale){ var reader; var j=filename.indexOf("_t"); var pname=filename.slice(0,j); var oReq = new XMLHttpRequest(); oReq.open("GET", filename, true); oReq.onload = function(oEvent) { myObj = JSON.parse(this.responseText); for(i=0;ithis.end[i]) return Number.NaN; if (this.start[i]==this.end[i]){ pos[i]=[this.start[i],this.start[i]]; weights[i]=0.; } else{ pos[i][0]=Math.trunc((arguments[i]-this.start[i])/this.inc[i]); while(arguments[i]this.array[i][pos[i][1]]){ pos[i][0]++; pos[i][1]++; } if (!Number.isNaN(this.array[i][pos[i][0]])) weights[i]=(arguments[i]-this.array[i][pos[i][0]])/(this.array[i][pos[i][1]]-this.array[i][pos[i][0]]); } } //z=[None]*(2<<(len(indexes)-1)) var z=[]; for( j=0;j<(1<<(arguments.length-1));j++){ ii=0; for (var i=arguments.length-1;i>0;i--) ii=ii*this.shape[i]+pos[i][j>>(i-1)&1]; z[j<<1]=this.v[ii*this.shape[0]+pos[0][0]]; z[(j<<1)+1]=this.v[ii*this.shape[0]+pos[0][1]]; if (Number.isNaN(z[j<<1])) if (Number.isNaN(z[(j<<1)+1])) z[j]=Number.NaN; else z[j]=z[(j<<1)+1]; else if (Number.isNaN(z[(j<<1)+1])) z[j]=z[(j<<1)]; else z[j]=z[j<<1]+(z[(j<<1)+1]-z[j<<1])*weights[0]; } for (var i=1;ithis.end[i]) return Number.NaN; if (this.start[i]==this.end[i]){ pos[i]=[this.start[i],this.start[i]]; weights[i]=0.; } else{ pos[i][0]=Math.trunc((arguments[m]-this.start[i])/this.inc[i]); while(arguments[m]this.array[i][pos[i][1]]){ pos[i][0]++; pos[i][1]++; } if (!Number.isNaN(this.array[i][pos[i][0]])) weights[i]=(arguments[m]-this.array[i][pos[i][0]])/(this.array[i][pos[i][1]]-this.array[i][pos[i][0]]); } i++; } //z=[None]*(2<<(len(indexes)-1)) var z=[]; for( j=0;j<(1<<(arguments.length-3));j++){ ii=0; for (var i=arguments.length-3;i>0;i--) ii=ii*this.shape[i]+pos[i][j>>(i-1)&1]; z[j<<1]=this.v[ii*this.shape[0]+pos[0][0]]; z[(j<<1)+1]=this.v[ii*this.shape[0]+pos[0][1]]; if (Number.isNaN(z[j<<1])) if (Number.isNaN(z[(j<<1)+1])) z[j]=Number.NaN; else z[j]=z[(j<<1)+1]; else if (Number.isNaN(z[(j<<1)+1])) z[j]=z[(j<<1)]; else{ var diff=z[(j<<1)+1]-z[j<<1]; //assume any gap > abs((high-low)/2) is a crossover if (diff>(high-low)>>1){ //crossover low to high diff-=(high-low); z[j]=z[j<<1]+(diff)*weights[0] ; if (z[j] >1){ //crossover high to low diff+=(high-low); z[j]=z[j<<1]+(diff)*weights[0] ; if (z[j] >high)z[j]-=(high-low); //correct for interpolated values > high } else //no crossover z[j]=z[j<<1]+diff*weights[0]; } } for (var i=1;i abs((high-low)/2) is a crossover if (diff>(high-low)>>1){ //crossover low to high diff-=(high-low); z[j]=z[j<<1]+(diff)*weights[i] ; if (z[j] >1){ //crossover high to low diff+=(high-low); z[j]=z[j<<1]+(diff)*weights[i] ; if (z[j] >high)z[j]-=(high-low); //correct for interpolated values > high } else //no crossover z[j]=z[j<<1]+diff*weights[i]; } } } return z[0]; } } function toggleView(viewButton) { var cubeView = document.getElementById("wrapper"); var mainView = document.getElementById("outsidewrapper"); if (cubeView.style.display === "none") { cubeView.style.display = "block"; mainView.style.display = "none"; viewButton.value = "Main View"; } else { cubeView.style.display = "none"; mainView.style.display = "block"; viewButton.value = "3-D View"; } } function setImage(imageBox, boxIndex, imageDepthIndex, selectedDepthIndex) { translationAmount = 0; interval = 50; distanceBetween = 800; indexDiff=imageDepthIndex-selectedDepthIndex if (indexDiff<0) translationAmount=distanceBetween-interval*imageDepthIndex; else translationAmount=-interval*imageDepthIndex; imageBox.parentElement.parentElement.style.transform="translateZ("+translationAmount+"px)"; if (selectedDepthIndex === boxIndex) { imageBox.src = null; imageBox.style.display = "none"; return false; } else { imageBox.src = depthImages[imageDepthIndex][current_image].src; imageBox.style.display = "block"; return true; } } function accessCube(e,dataType) { // Searches the server's filesystem (Archive directory) for the // archive data. //selectedDate = document.getElementById('datePicker').valueAsDate; selectedDate=e.target.valueAsDate; dateStr = selectedDate.getUTCFullYear() + padToTwoValues(selectedDate.getUTCMonth() + 1) + padToTwoValues(selectedDate.getUTCDate()); path = dataType + dateStr; // Clear the old results. resultsDiv = document.getElementById('results'); while (resultsDiv.firstChild) { resultsDiv.removeChild(resultsDiv.firstChild); } // Read the file on the server containing the list of archives allFileText = loadFile("/archive/archive.txt"); // Create a link for the necessary archives. var listing = parseDirectoryListing(allFileText); if (listing === undefined || listing === null || listing.length == 0) addNoDataLink(resultsDiv, '(' + dataType + ' - ' + dateStr + ')'); else //added a subdirectory to archive JB 07/18/24 listing.map((x) => addLink(resultsDiv, '/archive/' + dataType+ '/' + x + '/' + removeDate(x) + ".html", x)); function loadFile(filePath) { var result = null; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", filePath, false); xmlhttp.send(); if (xmlhttp.status == 200) { result = xmlhttp.responseText; } return result; } function parseDirectoryListing(text) { //var s1 = "([\\w]+)" + path + "([\\w]+)"; var s1 = path + "([\\w]+)"; var regex = new RegExp(s1, 'g'); let docs = text.match(regex); // pull out the ones for the date if (docs === undefined || docs === null || docs.length == 0) return new Array(); else { //docs = docs.map((x) => x.replace('href="', '')); // clean up //console.log(docs); return docs; } } function removeDate(text) { return text.slice(0, -10); // Change if date length is not 10 characters } } function padToTwoValues(number) { return ("0" + number).slice(-2) } function addLink(resultsDiv, link, linkTitle) { var aTag = document.createElement('a'); aTag.setAttribute('href', link); aTag.innerHTML = linkTitle; resultsDiv.appendChild(aTag); var brTag = document.createElement('br'); resultsDiv.appendChild(brTag); } function addNoDataLink(resultsDiv, searchTerm) { var aTag = document.createElement('a'); aTag.innerHTML = "No Archive Data Located " + searchTerm; resultsDiv.appendChild(aTag); var brTag = document.createElement('br'); resultsDiv.appendChild(brTag); } var events = new Events(); events.add = function(obj) { obj.events = { }; } events.implement = function(fn) { fn.prototype = Object.create(Events.prototype); } function Events() { this.events = { }; } Events.prototype.on = function(name, fn) { var events = this.events[name]; if (events == undefined) { this.events[name] = [ fn ]; this.emit('event:on', fn); } else { if (events.indexOf(fn) == -1) { events.push(fn); this.emit('event:on', fn); } } return this; } Events.prototype.once = function(name, fn) { var events = this.events[name]; fn.once = true; if (!events) { this.events[name] = [ fn ]; this.emit('event:once', fn); } else { if (events.indexOf(fn) == -1) { events.push(fn); this.emit('event:once', fn); } } return this; } Events.prototype.emit = function(name, args) { var events = this.events[name]; if (events) { var i = events.length; while(i--) { if (events[i]) { events[i].call(this, args); if (events[i].once) { delete events[i]; } } } } return this; } Events.prototype.unbind = function(name, fn) { if (name) { var events = this.events[name]; if (events) { if (fn) { var i = events.indexOf(fn); if (i != -1) { delete events[i]; } } else { delete this.events[name]; } } } else { delete this.events; this.events = { }; } return this; } var userPrefix; var prefix = (function () { var styles = window.getComputedStyle(document.documentElement, ''), pre = (Array.prototype.slice .call(styles) .join('') .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) )[1], dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1]; userPrefix = { dom: dom, lowercase: pre, css: '-' + pre + '-', js: pre[0].toUpperCase() + pre.substr(1) }; })(); function bindEvent(element, type, handler) { if(element.addEventListener) { element.addEventListener(type, handler, false); } else { element.attachEvent('on' + type, handler); } } function Viewport(data) { events.add(this); var self = this; this.element = data.element; this.fps = data.fps; this.sensivity = data.sensivity; this.sensivityFade = data.sensivityFade; this.touchSensivity = data.touchSensivity; this.speed = data.speed; this.lastX = 0; this.lastY = 0; this.mouseX = 0; this.mouseY = 0; this.distanceX = 0; this.distanceY = 0; this.positionX = 0; this.positionY = 60; this.torqueX = 0; this.torqueY = 0; this.down = false; this.upsideDown = false; this.previousPositionX = 0; this.previousPositionY = 0; this.currentSide = 0; this.calculatedSide = 0; bindEvent(document, 'mousedown', function() { self.down = true; }); bindEvent(document, 'mouseup', function() { self.down = false; }); bindEvent(document, 'keyup', function() { self.down = false; }); bindEvent(document, 'mousemove', function(e) { self.mouseX = e.pageX; self.mouseY = e.pageY; }); bindEvent(document, 'touchstart', function(e) { self.down = true; e.touches ? e = e.touches[0] : null; self.mouseX = e.pageX / self.touchSensivity; self.mouseY = e.pageY / self.touchSensivity; self.lastX = self.mouseX; self.lastY = self.mouseY; }); bindEvent(document, 'touchmove', function(e) { if(e.preventDefault) { e.preventDefault(); } if(e.touches.length == 1) { e.touches ? e = e.touches[0] : null; self.mouseX = e.pageX / self.touchSensivity; self.mouseY = e.pageY / self.touchSensivity; } }); bindEvent(document, 'touchend', function(e) { self.down = false; }); setInterval(this.animate.bind(this), this.fps); } events.implement(Viewport); Viewport.prototype.animate = function() { this.distanceX = (this.mouseX - this.lastX); this.distanceY = (this.mouseY - this.lastY); this.lastX = this.mouseX; this.lastY = this.mouseY; if(this.down) { this.torqueX = this.torqueX * this.sensivityFade + (this.distanceX * this.speed - this.torqueX) * this.sensivity; this.torqueY = this.torqueY * this.sensivityFade + (this.distanceY * this.speed - this.torqueY) * this.sensivity; } if(Math.abs(this.torqueX) > 1.0 || Math.abs(this.torqueY) > 1.0) { if(!this.down) { this.torqueX *= this.sensivityFade; this.torqueY *= this.sensivityFade; } this.positionY -= this.torqueY; if(this.positionY > 360) { this.positionY -= 360; } else if(this.positionY < 0) { this.positionY += 360; } if(this.positionY > 90 && this.positionY < 270) { this.positionX -= this.torqueX; if(!this.upsideDown) { this.upsideDown = true; this.emit('upsideDown', { upsideDown: this.upsideDown }); } } else { this.positionX += this.torqueX; if(this.upsideDown) { this.upsideDown = false; this.emit('upsideDown', { upsideDown: this.upsideDown }); } } if(this.positionX > 360) { this.positionX -= 360; } else if(this.positionX < 0) { this.positionX += 360; } if(!(this.positionY >= 46 && this.positionY <= 130) && !(this.positionY >= 220 && this.positionY <= 308)) { if(this.upsideDown) { if(this.positionX >= 42 && this.positionX <= 130) { this.calculatedSide = 3; } else if(this.positionX >= 131 && this.positionX <= 223) { this.calculatedSide = 2; } else if(this.positionX >= 224 && this.positionX <= 314) { this.calculatedSide = 5; } else { this.calculatedSide = 4; } } else { if(this.positionX >= 42 && this.positionX <= 130) { this.calculatedSide = 5; } else if(this.positionX >= 131 && this.positionX <= 223) { this.calculatedSide = 4; } else if(this.positionX >= 224 && this.positionX <= 314) { this.calculatedSide = 3; } else { this.calculatedSide = 2; } } } else { if(this.positionY >= 46 && this.positionY <= 130) { this.calculatedSide = 6; } if(this.positionY >= 220 && this.positionY <= 308) { this.calculatedSide = 1; } } if(this.calculatedSide !== this.currentSide) { this.currentSide = this.calculatedSide; this.emit('sideChange'); } } this.element.style[userPrefix.js + 'Transform'] = 'rotateX(' + this.positionY + 'deg) rotateY(' + this.positionX + 'deg)'; if(this.positionY != this.previousPositionY || this.positionX != this.previousPositionX) { this.previousPositionY = this.positionY; this.previousPositionX = this.positionX; this.emit('rotate'); } } var viewport = new Viewport({ element: document.getElementsByClassName('cube')[0], fps: 20, sensivity: .1, sensivityFade: .93, speed: 0.5, touchSensivity: 1.5 }); function Cube(data) { var self = this; this.element = data.element; this.sides = this.element.getElementsByClassName('side'); this.viewport = data.viewport; this.viewport.on('rotate', function() { self.rotateSides(); }); this.viewport.on('upsideDown', function(obj) { self.upsideDown(obj); }); this.viewport.on('sideChange', function() { self.sideChange(); }); } Cube.prototype.rotateSides = function() { var viewport = this.viewport; } Cube.prototype.upsideDown = function(obj) { var deg = (obj.upsideDown == true) ? '180deg' : '0deg'; var i = 5; } Cube.prototype.sideChange = function() { } new Cube({ viewport: viewport, element: document.getElementsByClassName('cube')[0] });
Page Last Updated: 2026-10-07 07:54:30.971534