function showcredit() { var credit credit= "Script programmed by Jens T.Saetre 04022001" credit+="\n04022001 Calculates max. LNB gain vs saturation" credit+="\n04022001 Corrected bug in slant range calculation" credit+="\n18122001 Corrected bug in slant range calculation" credit+="\n03012002 Corrected bug in slant range calculation" credit+="\n10012002 Updated Satellitelist" credit+="\n08122002 Changed layout" credit+="\n04012003 Corrected bug in LNB Input dBm power" credit+="\n21042003 Added more coordinates" credit+="\n07072003 Updated Satellitelist" credit+="\n10072003 Added more satellites and coordinates" credit+="\n25062006 Corrected slantrange/free space path loss for southern hemispheare" credit+="\n25062006 Added satellite position input fields" credit+="\n25062006 Added Azimut,Elevation,Slant Range and Free Space Path Loss output" window.alert(credit); //var theResponse = window.prompt("Welcome?","Enter your name here."); } function ReadCookie() { var CookieValue CookieValue= document.cookie; if (CookieValue == null) { document.Power.Location.selectedIndex=1074 // Set default groundstation } else { var tabell=new Array(); tabell = CookieValue.split(":") ; document.Power.Location.selectedIndex=tabell[4] ;// Set default groundstation document.Power.SatelliteName.selectedIndex=tabell[5] ; // Set default satellitelist //window.alert(tabell[4]+" Readcookie"); } } // end readcookie - works !!! function deleteAllCookies() { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; } } function SetCookie() { var CookieValue var expires=";expires=Tue, 10 Jul 2040 23:59:59 UTC;" CookieValue=document.cookie; if (CookieValue == null) { var alrt="Error in CookieValue" alrt+="\nUse Antenna Look Angles calculator to cure the problem"; window.alert(alrt); } else { var tabell=new Array(); tabell = CookieValue.split(":") ; tabell[4]=document.Power.Location.selectedIndex ;// Set default groundstation tabell[5]=document.Power.SatelliteName.selectedIndex; CookieValue=""; document.cookie=""; SubArray=document.Power.Location.value.split(","); //alert(SubArray[2]); tabell[15]=SubArray[2]; CookieValue=tabell[0]+":"+tabell[1]+":"+tabell[2]+":"+tabell[3]+":"+tabell[4]+":"+tabell[5]+":"+tabell[6]+":"+tabell[7]+":"+tabell[8]+":"+tabell[9]+":"+tabell[10]+":"+tabell[11]+":"+tabell[12]+":"+tabell[13]+":"+tabell[14]+":"+tabell[15]+":"+tabell[16]+":"+tabell[17]+":"+tabell[18]+":"+tabell[19]+":"+tabell[20]+expires; //window.alert(tabell[4]+" Setcookie"); //window.alert(CookieValue); deleteAllCookies(); document.cookie=CookieValue ; } } // end SetCookie - works !!! function log10(X) { return( Math.log(X)/Math.log(10) ); // works OK ! } function open_single_satellite_view() { var catalog; var tmpstring; var satarray=new Array(); tmpstring=document.Power.SatelliteName.value; satarray=tmpstring.split(":"); //' Reads value array which is separated by ":", satcatid at index 3 satcatid=satarray[3]; //SingleSatPath,satcatid //alert("http://www.online.no"); //catalog="Catalog\"; //open2("http://www.online.no",1); //ondblclick= window.open("Catalog/"+satcatid+".htm",satcatid,''); //ondblclick="open2(window.location.href+'#38095',1)" } function CalculatePower() { var eirp,FSPL,ATMLOSS,AntennaPower,LNBPower,IF_Frequency,LNBGain,DownlinkFrequency,Suggestion,MinPower,MaxPower,Elevation var sa_correctionfactor=2; var Number_of_transponders,Compressionpoint,lowgain,crosspoleirp; eirp=1*document.Power.EIRP.value; ATMLOSS=1*document.Power.AtmosphericLoss.value; Number_of_transponders=1*1*document.Power.Numbertxp.value; eirp=eirp+10*log10(Number_of_transponders); crosspoleirp=eirp- 20 // with a crosspol rejection of 20dB. document.Power.TotalEIRP.value=formatvalue(eirp,4); var neweirp neweirp=Math.pow(10,(eirp/10)) +Math.pow(10,(crosspoleirp/10)); eirp=10*log10(neweirp ); //window.alert(eirp); document.Power.FreeSpacePathLoss.value=formatvalue(FreeSpacePathLoss() ,6); AntennaPower=eirp-FreeSpacePathLoss()-ATMLOSS; document.Power.AntennaPower.value =formatvalue(AntennaPower,7); document.Power.FluxDensity.value= formatvalue((eirp + SphericalLoss() -ATMLOSS),7); VSWR=Loss_dB(); LNBInputPower=AntennaPower+ AntennaGain() - 1*document.Power.FeedLoss.value - VSWR; document.Power.LNBInputPower.value =formatvalue(LNBInputPower+30,7); LNBGain=1*document.Power.LNBGain.value ; LNBOutputPower=LNBInputPower+LNBGain; Compressionpoint=1*document.Power.compressionpoint.value ; lowgain=LNBGain -( (LNBOutputPower+30)-(Compressionpoint-7)); if (LNBOutputPower+30>Compressionpoint-7) window.alert("LNB is saturated !\nChange to a LNB with lower gain \nLNB Gain should not exceed "+formatvalue(lowgain,4)+" dB"); document.Power.LNBOutputPower.value =formatvalue(LNBOutputPower+30,7); //Elevation=CalculateElevation(SatLon,SiteLon,SiteLat); //if (Elevation<0) alert("Satellite below horizon"); check_elevation(); } function Cable_loss(IF_Frequency) { } function Loss_dB() { return(-10*log10(1-(Loss_Percent()/100))); } function Loss_Percent() { var vswr,loss vswr=1*document.Power.VSWR.value; loss=100* Math.pow( ( (vswr-1)/(vswr+1) ),2 ); return(loss); } function UpdateCoordinates() { var LatDeg,LatMin,LatSec,LonDeg,LonMin,LonSec LatDeg=1*document.Power.LatHour.value; LatMin=1*document.Power.LatMin.value; LatSec=1*document.Power.LatSec.value; LonDeg=1*document.Power.LonHour.value; LonMin=1*document.Power.LonMin.value; LonSec=1*document.Power.LonSec.value; document.Power.Latitude.value=formatvalue((LatDeg + (LatMin/60) + (LatSec/3600)),5) ; // Latitude document.Power.Longitude.value=formatvalue( (LonDeg+ (LonMin/60) + (LonSec/3600)),5); // Longitude } function Convert_to_deg_min_sec(){ var Latitude,Longitude,LatDeg,LatMin,LatSec,LonDeg,LonMin,LonSec Latitude=document.Power.Latitude.value // Latitude Longitude=document.Power.Longitude.value // Longitude document.Power.LatHour.value=formatvalue( Math.floor(Latitude),2); LatMin=Math.floor((Latitude- Math.floor(Latitude))*60); LatSec=Math.floor( ((Latitude- Math.floor(Latitude))*60 - LatMin)*60 ); document.Power.LatMin.value=formatvalue(LatMin ,2); document.Power.LatSec.value=formatvalue(LatSec ,2); document.Power.LonHour.value=formatvalue( Math.floor(Longitude),2); LonMin=Math.floor((Longitude- Math.floor(Longitude))*60); LonSec=Math.floor( ((Longitude- Math.floor(Longitude))*60 - LonMin)*60 ); document.Power.LonMin.value=formatvalue(LonMin ,2); document.Power.LonSec.value=formatvalue(LonSec ,2); } function SetLocation(){ var Location=Array(); var Longitude=Array(); var Latitude= Array(); var LatDeg,LatMin,LatSec,LonDeg,LonMin,LonSec var s = document.Power.Location.value ; // Split at each space character. Location= s.split(","); // split into two Latitude=Location[0].split(":");// split into degrees and North/South Longitude=Location[1].split(":");// split into degrees and East/West // window.prompt(Longitude[1],"Enter your name here."); document.Power.Latitude.value= Latitude[0]; // Latitude document.Power.Longitude.value= Longitude[0]; // Longitude document.Power.LatDir.value = Latitude[1]; // Latitude direction document.Power.LonDir.value =Longitude[1]; //Longitude direction document.Power.LatHour.value=formatvalue( Math.floor(Latitude[0]),2); LatMin=Math.floor((Latitude[0]- Math.floor(Latitude[0]))*60); LatSec=Math.floor( ((Latitude[0]- Math.floor(Latitude[0]))*60 - LatMin)*60 ); document.Power.LatMin.value=formatvalue(LatMin ,2); document.Power.LatSec.value=formatvalue(LatSec ,2); document.Power.LonHour.value=formatvalue( Math.floor(Longitude[0]),2); LonMin=Math.floor((Longitude[0]- Math.floor(Longitude[0]))*60); LonSec=Math.floor( ((Longitude[0]- Math.floor(Longitude[0]))*60 - LonMin)*60 ); document.Power.LonMin.value=formatvalue(LonMin ,2); document.Power.LonSec.value=formatvalue(LonSec ,2); } function AntennaGain() { var AntennaEfficiency,RxFrequency,Gain,AntennaDiameter RxFrequency=1*document.Power.DownlinkFrequency.value; AntennaEfficiency=1*document.Power.AntennaEfficiency.value; AntennaDiameter=1*document.Power.AntennaDiameter.value ; Gain=10*log10(AntennaEfficiency/100) +20*log10(RxFrequency/1000) +20*log10(AntennaDiameter)+20.4 ; //window.prompt(Gain,"Test verdi"); document.Power.AntennaGain.value =formatvalue(Gain,5); return(Gain); } function SetSatellitePosition(){ document.Power.Degrees.value=1*formatvalue(document.Power.SatelliteName.value,6); document.Power.Direction.selectedIndex=0; document.Power.West_angle.value=360-1*formatvalue(document.Power.SatelliteName.value,6); } function change_satellite_position() { if (document.Power.Direction.selectedIndex==0) { document.Power.West_angle.value=360-1*document.Power.Degrees.value; } else { document.Power.West_angle.value=1*document.Power.Degrees.value; } } function check_elevation(){ var SatLon,Latitude,Longitude,SiteLat,LatDir,SiteLon,LonDir,Elevation if (document.Power.Direction.selectedIndex==0) //==0 East, ==1 West { SatLon=1*document.Power.Degrees.value; } else { SatLon=360-1*document.Power.Degrees.value; } SiteLat=1*document.Power.Latitude.value; // Latitude LatDir=document.Power.LatDir.value; // Latitude direction SiteLon=1*document.Power.Longitude.value; // Longitude LonDir=document.Power.LonDir.value ; //Longitude direction if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; Elevation=CalculateElevation(SatLon,SiteLon,SiteLat); if (Elevation<0) alert("Satellite "+formatvalue(Math.abs(Elevation),5)+" degrees below horizon"); document.Power.Elevation.value=formatvalue(Elevation,5); document.Power.Azimuth.value=formatvalue(CalculateAzimuth(SatLon,SiteLat,SiteLon,0),6); } function CalculateElevation(SatLon,SiteLon,SiteLat) { var x,y,Re,Rg,El Re=6378.14 // earth radius in km. Rg=42164.57 // geosyncronus radius in km. y=Math.cos(Radians(SiteLon-SatLon))*Math.cos(Radians(SiteLat)) - Re/Rg ; x=Math.sqrt( Math.sin(Radians( SiteLon-SatLon))*Math.sin(Radians( SiteLon-SatLon)) + Math.cos(Radians(SiteLon-SatLon))*Math.cos(Radians(SiteLon-SatLon))*Math.sin(Radians(SiteLat))*Math.sin(Radians(SiteLat)) ); El=Deg(Math.atan2(y,x)); // Works correct ! return(El) } function CalculateAzimuth(SatLon,SiteLat,SiteLon,Height_over_ocean) { var Rstation,Hemisphere,f,r_eq,r_sat,Ra,Rz,alfa_r,alfa_rx,alfa_ry,alfa_rz,alfa_r_north,alfa_r_zenith,Azimuth f=(1/298.257) ; // Earth flattning factor r_sat=42164.57; // Distance from earth centre to satellite r_eq=6378.14 ; // Earth radius Rstation= r_eq/( Math.sqrt( 1 - f*(2-f)*Math.sin(Radians(SiteLat))*Math.sin(Radians(SiteLat)) ) ) ; Ra= (Rstation+Height_over_ocean)*Math.cos(Radians(SiteLat)) ; Rz= Rstation*(1-f)*(1-f)*Math.sin(Radians(SiteLat)); alfa_r=r_sat-Rstation ; alfa_rx=r_sat*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=-Rz; alfa_r_north=-alfa_rx*Math.sin(Radians(SiteLat)) + alfa_rz*Math.cos(Radians(SiteLat)) ; alfa_r_zenith=alfa_rx*Math.cos(Radians(SiteLat)) +alfa_rz*Math.sin(Radians(SiteLat)) ; if (alfa_r_north<=0) Azimuth=180+Deg(Math.atan(alfa_ry/alfa_r_north )) else Azimuth=Rev(360+Deg(Math.atan(alfa_ry/alfa_r_north ))); return(Azimuth); } function Rev(number) { var x x= number -Math.floor(number/360.0)*360 ; return(x) } function slantrange(){ var S,SatLon,Latitude,Longitude,SiteLat,LatDir,SiteLon,LonDir,Elevation if (document.Power.Direction.selectedIndex==0) //==0 East, ==1 West { SatLon=1*document.Power.Degrees.value; } else { SatLon=360-1*document.Power.Degrees.value; } SiteLat=1*document.Power.Latitude.value; // Latitude LatDir=document.Power.LatDir.value; // Latitude direction SiteLon=1*document.Power.Longitude.value; // Longitude LonDir=document.Power.LonDir.value ; //Longitude direction if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; Elevation=CalculateElevation(SatLon,SiteLon,SiteLat); if (Elevation>0) S=Slant_Range(SiteLat,fi(SatLon,SiteLon));// else document.Power.SlantRange.value=formatvalue(S,8); return(S); } function Slant_Range(SiteLat,fi) { var Slant_range_computed,SiteLat,LatDir,SiteLon,LonDir,SatLon,toRad,toDeg var Re,Rg,H Re=6378.14; // earth radius in km. Rg=42164.57; // geosyncronus radius in km. H=Rg-Re; toRad=Math.PI/180; toDeg=180/Math.PI; SiteLat=1*document.Power.Latitude.value; // Latitude LatDir=document.Power.LatDir.value; // Latitude direction SiteLon=1*document.Power.Longitude.value; // Longitude LonDir=document.Power.LonDir.value ; //Longitude direction if (document.Power.Direction.selectedIndex==0) //==0 East, ==1 West { SatLon=1*document.Power.Degrees.value; } else { SatLon=360-1*document.Power.Degrees.value; } if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; //alert("SiteLat="+SiteLat+" fi="+fi); Slant_range_computed=Math.sqrt( Re*Re+(Re+H)*(Re+H)-2*Re*(Re+H)*Math.cos(Radians(SiteLat))*Math.cos(Radians(fi)) ); return(Slant_range_computed); } function Radians(number) { var rad rad=number*Math.PI/180; return(rad) } function Deg(number) { var rad rad=number*180/Math.PI; return(rad) } function fi(SatLon,SiteLon) { // ok. Is working var Fi,SiteLat,LatDir,SiteLon,LonDir,SatLon SiteLat=1*document.Power.Latitude.value; // Latitude LatDir=document.Power.LatDir.value; // Latitude direction SiteLon=1*document.Power.Longitude.value; // Longitude LonDir=document.Power.LonDir.value ; //Longitude direction if (document.Power.Direction.selectedIndex==0) //==0 East, ==1 West { SatLon=1*document.Power.Degrees.value; } else { SatLon=360-1*document.Power.Degrees.value; } if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; Fi= Math.min(Math.abs(SatLon-SiteLon-360),Math.abs(SiteLon-SatLon),Math.abs(SiteLon-SatLon-360)) return(Fi); } function FreeSpacePathLoss() { var FSPL,Rx_Frequency Rx_Frequency=1*document.Power.DownlinkFrequency.value; //FSPL=20*log10(4*Math.PI*slantrange()*Rx_Frequency); FSPL=20*log10(4*Math.PI*slantrange()*1000*Rx_Frequency*1000000/300000000); return (FSPL) ;// *1000000 MHz... } function SphericalLoss() { // Works ! var FSPL,Rx_Frequency Rx_Frequency=1*document.Power.DownlinkFrequency.value; //FSPL=20*log10(4*Math.PI*slantrange()*Rx_Frequency); FSPL=10*log10(1/4/Math.PI/Math.pow((slantrange()*1000),2)); //=10*LOG(1/4/pi/(E28*1000)^2) return (FSPL) ;// *1000000 MHz... } function OLD_slantrange() { var Latitude,Longitude,LonDir,LatDir,SatLon,Fi,S,R,h,toRad,toDeg var satellitedata R=6378; // Earth Radius in km Hs=42164; //Satellite radius h=Hs-R; // hight above equator toRad=Math.PI/180; toDeg=180/Math.PI; Latitude=1*document.Power.Latitude.value; // Latitude Longitude=1*document.Power.Longitude.value; // Longitude LatDir=document.Power.LatDir.value; // Latitude direction LonDir=document.Power.LonDir.value ; //Longitude direction SatLon=1*document.Power.Degrees.value; // 0-360 deg. //Convert longitude to 0-360 deg. format if (LonDir=="West") { Longitude = 360- Longitude ; // converted to deg. eastwards format //window.prompt(Longitude,"Longitude lnd"); } if ( (SatLon>Longitude)&&(SatLon>180)&&(Longitude<270) ) { Fi= SatLon-Longitude; // Bugfix for SatLon=286E Longitude = 241.75E (L.A.) } if ( (SatLon>Longitude)&&(SatLon>180)&&(Longitude>270)&&(Longitude<=360) ) { Fi= SatLon-Longitude; // //window.prompt(Fi,"If 1"); } if ( (SatLon180)&&(Longitude>270)&&(Longitude<=360) ) { Fi= Longitude-SatLon; // //window.prompt(Fi,"If 1"); } // 13 258.83 13 358.83 358.83 if ( (SatLon270)&&(Longitude<=360) ) { Fi= SatLon -Longitude+360; // //window.prompt(Fi,"If 1"); } //window.prompt("Fi"+Fi+"Longitude="+Longitude,"=Fi "); if ((SatLon>Longitude)&&(SatLon>270)&&(Longitude<90)) { Fi=Longitude+(360-SatLon); // 10.9 Øst - 359 øst //window.prompt(Fi,"If 2"); // OK } if ((SatLon>Longitude)&&(SatLon<90)&&(Longitude<90)) { Fi=SatLon-Longitude; // 10.9 Øst - 359 øst //window.prompt(Fi,"If 2"); // OK } if ((SatLon parseFloat(nines.substring(0,rsize)+".4")) return invalid.substring(0, rsize); var rounded = "" + (fltin + (fltin - parseFloat(strin.substring(0, rsize)))); return rounded.substring(0, rsize); }