var lookangles_updated,SetLocation,credittext lookangles_updated="Calculator script updated 01-05-2008
"; updated="Updated 01 May 2008
"; credittext="" credittext+="" credittext+="" credittext+="" credittext+="Lookangle calculator history" credittext+="" credittext+="" credittext+="" //credittext+="" credittext+="" credittext+="First uploaded 24101999 " credittext+="
\nProgrammed by Jens T. Satre" credittext+="
\nScript for antenna look angles calculations" credittext=credittext+"
\n2410-1999: First version, VB script" credittext=credittext+"
\n1612-1999: Added more angle calculations for Polarmounts" credittext=credittext+"
\n2812-1999: Corrected polarmountangle calculations for southern hemisphere" credittext=credittext+"
\n0501-2000: More corrections for southern hemisphere" credittext=credittext+"
\n0601-2000: More corrections for southern hemisphere and polarmount angles" credittext=credittext+"
\n0701-2000: Updated satellite list. Added all known satellites in Clarke belt" credittext=credittext+"
\n0801-2000: Added position as x degrees west(not for edit). Some minor fixes" credittext=credittext+"
\n1903-2000: Updated satellite list." credittext=credittext+"
\n1806-2000: Added time when the sun has the same azimuth as the satellite" credittext=credittext+"
\n2006-2000: Corrected bugs in calculating the time when the sun has the same azimuth as the satellite" credittext=credittext+"
\n2606-2000: Test of UTC time calculations for more earthpositions" credittext=credittext+"
\n0507-2000: Corrected bug in Azimuth calculation for West longitudes." credittext=credittext+"
\n0907-2000: Added site position storded in a cookie ( just a test yet...) " credittext=credittext+"
\n1007-2000: User default site position works now" credittext=credittext+"
\n1007-2000: Added predefined site locations" credittext=credittext+"
\n1107-2000: Added more European sites..." credittext=credittext+"
\n1107-2000: If errors should occur just 'OK them' and choose site&satellite again (Cookie problems....)" credittext=credittext+"
\n1207-2000: Corrected a small bug in default listbox settings" credittext=credittext+"
\n1307-2000: Site locations in alfabetic order" credittext=credittext+"
\n0302-2001: Added world site locations" credittext=credittext+"
\n0302-2001: Updated satellite list" credittext=credittext+"
\n0602-2001: Disabled sun az.=sat az. time calculation for latitudes<4deg. (near equator)" credittext=credittext+"
\n0602-2001: Sun az.=sat az. time calculation is more inacurrate the nearer equator the receiving site is" credittext=credittext+"
\n0802-2001: Removed time calculation - replaced with a N/A for latitudes near equator" credittext=credittext+"
\n0105-2001: Rewritten to javascript. Time calculation not finished yet" credittext=credittext+"
\n0105-2001: Corrected bug in Azimuth & Hourangle for southern hemisphere" credittext=credittext+"
\n0505-2001: Added higher accuracy using Intelsat IESS-412 formulas. Atmospheric refraction is included" credittext=credittext+"
\n0605-2001: Added the time when the Sun Azimuth equals the Satellite Azimuth.
\n Can be used to find the direction when installing a dish." credittext=credittext+"
\n1001-2002: Updated satellite list" credittext=credittext+"
\n0808-2002: Added calculation of pulsecountervalues for horizon-horizon polarmounts" credittext=credittext+"
\n0712-2002: Changed layout" credittext=credittext+"
\n0812-2002: Added the localtime when the Sun Azimuth equals the Satellite Azimuth
\n (based on the computers time zone setting)" credittext=credittext+"
\n2104-2003: Added more coordinates" credittext=credittext+"
\n0707-2003: Updated satellite list" credittext=credittext+"
\n0807-2003: Corrected azimuth bug when site latitude is on equator" credittext=credittext+"
\n1007-2003: More satellites and coordinates added" credittext=credittext+"
\n1608-2003: Changed the offset 'elevation' to offset antenna 'tilt'" credittext=credittext+"
\n3008-2003: Added degrees, minute, seconds format for site coordinates" credittext=credittext+"
\n0708-2004: Added calculation of pulse counter for H-H polarmounts" credittext=credittext+"
\n2105-2005: Added calculation of time delay one direction and roundtrip delay (up downlink same site)" credittext=credittext+"
\n0901-2006: Added display of geometric elevation and atmospheric refraction for elevation angles below 10.2 degrees" credittext=credittext+"
\n0202-2006: Added input date for sun az.=sat az. calculation" credittext=credittext+"
\n0402-2006: Possible to print one year timetable for sun az.=sat az. time" credittext=credittext+"
\n1202-2006: Small fixes in timetable printout" credittext=credittext+"
\n0503-2006: Added Sun elevation when satellite azimuth equals sun azimuth" credittext=credittext+"
\n0503-2006: Added difference between between sun and satellite elevation in one year timetable" credittext=credittext+"
\n2506-2006: Added Azimuth/Elevation table generation" credittext=credittext+"
\n2509-2006: Added table generation for time when Sun azimuth equals satellite azimiuth" credittext=credittext+"
\n0101-2007: Does not show the time when Sun azimuth equals satellite azimiuth if the sun is below horizon" credittext=credittext+"
\n1103-2007: Calculates eastmost and westmost satellite longitude from geometric elevation (atmospheric refrection not accounted for)" credittext=credittext+"
\n1103-2007: Accounted for atmospheric refrection when calculating theoretical satellite arc limits" credittext=credittext+"
\n2309-2007: Corrected bug in time calculation when satellite longitude equals site longitude" credittext=credittext+"
\n0710-2007: Corrected bug in time calculation caused by the 2309 fix" credittext=credittext+"
\n1302-2008: Changed the history message" credittext=credittext+"
\n0105-2008: Corrected local time error for southern hemisphere (still not working well in Mozilla Firefox)" credittext+="
"; credittext+="" function date_and_time(){ date_and_time=Date(); //alert(Date()); } function ShowCredit() { //alert(credittext); PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=no,status=no,toolbar=no,scrollbars=yes"); //height=800,width=1000 PrintWindow.oldWindow = top PrintWindow.document.write(credittext) PrintWindow.document.close() } var HA_for_calibrated_position,SetLocation function SelectSatellite() { document.OrbitPosition.Degrees.value=formatvalue(document.Satellite.Name.value,6); document.OrbitPosition.West_angle.value=formatvalue((360-document.OrbitPosition.Degrees.value),5); document.OrbitPosition.Direction.value="East"; } function CalculateCoordinate() { var degrees,minute,seconds,SiteLon,SiteLat SiteLat=1*document.Latitude.Degrees.value; SiteLon=1*document.Longitude.Degrees.value; degrees=Math.floor(SiteLat); minutes=Math.floor((SiteLat-degrees)*60); seconds= Math.floor(((SiteLat-degrees)*60- minutes)*60); document.Latitude.LatDegrees.value=degrees; document.Latitude.LatMinutes.value=minutes; document.Latitude.LatSeconds.value=seconds; degrees=Math.floor(SiteLon); minutes=Math.floor((SiteLon-degrees)*60); seconds= Math.floor(((SiteLon-degrees)*60- minutes)*60); document.Longitude.LonDegrees.value=degrees; document.Longitude.LonMinutes.value=minutes; document.Longitude.LonSeconds.value=seconds; } function CalculateLat() { var degrees,minutes,seconds,decimaldegrees degrees=1*document.Latitude.LatDegrees.value; minutes=1*document.Latitude.LatMinutes.value; seconds=1*document.Latitude.LatSeconds.value; decimaldegrees= degrees + (minutes/60) + (seconds/(60*60)); document.Latitude.Degrees.value=formatvalue(decimaldegrees,6); } function CalculateLon() { var degrees,minutes,seconds,decimaldegrees degrees=1*document.Longitude.LonDegrees.value; minutes=1*document.Longitude.LonMinutes.value; seconds=1*document.Longitude.LonSeconds.value; decimaldegrees= degrees + (minutes/60) + (seconds/(60*60)); document.Longitude.Degrees.value=formatvalue(decimaldegrees,6); } function CalculateAngles() { var Lat,Lon,LatDir,LonDir,SatLon,SatDir,Elevation,Azimuth,Declination,Hourangle,Slantrange,PolaraxisAngle,PolarAxisCorrection,DeclinationHorPlane var OffsetAngle,OffsetElevation,Height_above_ocean var Pulse_pr_deg,HA,Reference_pulse,Pulse_inc_direction,CalculatedPulseCounter,d,Day,Month,Year,timestring,SunElevation var G,SatLonLimit,E,teller,nevner,loops SiteLat=1*document.Latitude.Degrees.value; LatDir=document.Latitude.Direction.value; SiteLon=1*document.Longitude.Degrees.value; LonDir=document.Longitude.Direction.value; SatDir=document.OrbitPosition.Direction.value; SatLon=document.OrbitPosition.Degrees.value; Height_above_ocean=1*document.Height.Above_ocean.value; if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; if (SatDir=="West") SatLon=360-SatLon; document.OrbitPosition.West_angle.value=formatvalue((360-SatLon),5); Elevation=Elevation2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000));//CalculateElevation(SatLon,SiteLon,SiteLat); if (Elevation<=0) alert("Satellite below horizon !"); Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000));//CalculateAzimuth(SatLon,SiteLon,SiteLat,fi(SatLon,SiteLon)); Declination=CalculateDeclination2(SiteLat,Azimuth,Elevation); Hourangle=CalculateSatHourangle(Azimuth,Elevation,Declination,SiteLat); document.Elevation.Degrees.value=formatvalue(Elevation, 6); document.Azimuth.Degrees.value=formatvalue(Azimuth, 6); document.Declination.Degrees.value=formatvalue(Declination,5); document.Polarmount.Hourangle.value=formatvalue(Hourangle,5); Slantrange=SlantRange(SiteLat,fi(SatLon,SiteLon)); document.Sat.Distance.value=formatvalue(Slantrange,9); document.Sat_delay.Delay.value=formatvalue((Slantrange/300),7); document.Sat_roundtripdelay.Delay.value=formatvalue((Slantrange*2/300),7); OffsetAngle=1*document.Offset.Degrees.value; OffsetElevation=90-(-Elevation+OffsetAngle); document.OffsetElevation.Degrees.value=formatvalue(OffsetElevation,5); document.Old.CompassAngle.value=formatvalue(Azimuth, 6); document.New.CompassAngle.value=formatvalue(Azimuth*400/360, 6); document.Pol.HTilt.value=formatvalue(CalculatedPolTilt(SatLon,SiteLat,SiteLon),6); if (document.Pol.HTilt.value>0) document.Pol.vpoldir.value="Clockwise" ; else document.Pol.vpoldir.value="Counter Clockwise"; document.Pol.VTilt.value=formatvalue(CalculatedPolTilt(SatLon,SiteLat,SiteLon)+90,6); if (document.Pol.VTilt.value>0) document.Pol.hpoldir.value="Clockwise" ; else document.Pol.hpoldir.value="Counter Clockwise"; document.Pol.v2tilt.value=formatvalue(CalculatedPolTilt(SatLon,SiteLat,SiteLon)-90,6); if (document.Pol.v2tilt.value>0) document.Pol.v2poldir.value="Clockwise" ; else document.Pol.v2poldir.value="Counter Clockwise"; document.Pol.h2tilt.value=formatvalue(CalculatedPolTilt(SatLon,SiteLat,SiteLon)-180,6); if (document.Pol.h2tilt.value>0) document.Pol.h2poldir.value="Clockwise" ; else document.Pol.h2poldir.value="Counter Clockwise"; PolarAxisCorrection=PolarAxisCorrectionAngle(SiteLat); document.Polaraxsis.Correction.value=formatvalue(PolarAxisCorrection,5); PolaraxisAngle=90-SiteLat-PolarAxisCorrection; document.Polar_axsis.Angle.value=formatvalue(PolaraxisAngle,5); DeclinationHorPlane=Declination+PolaraxisAngle; document.Corrected.Declination.value=formatvalue(DeclinationHorPlane,5); if (Math.abs(SiteLat)<4) document.SunSatAz.Time.value="N/A" else { document.SunSatAz.Time.value=get_the_time(Azimuth,SiteLon,SiteLat); document.SunSatAzLocal.Time.value=get_the_local_time(Azimuth,SiteLon,SiteLat) } Day=1*document.Selected.Day.value; Month=1*document.Selected.Month.value; Year=1*document.Selected.Year.value; // BRUK SPLIT STRING var timearray=new Array(); timestring=document.SunSatAz.Time.value; timearray=timestring.split(":"); //' Reads 6 cookie values in to the array d=daynumber(Day,Month,Year,timearray[0],timearray[1],timearray[2]); SunElevation=sun_angles(d,SiteLon,SiteLat); // document.Sun_Elevation.Degrees.value=formatvalue(SunElevation,5); // Calculate pulse counters.... if ((SunElevation<-0.833)||(Elevation<0)) { document.SunSatAz.Time.value='N/A'; document.SunSatAzLocal.Time.value='N/A'; } //HA_for_calibrated_position skal være ok //,HA,Reference_pulse HA=1*document.Polarmount.Hourangle.value; Reference_pulse=1*document.Counter.calibrate_pulse_counter.value; Pulse_pr_deg=1*document.Pulse.pulse_per_degree.value; Pulse_inc_direction=1*document.HHPulse.Increase_direction.selectedIndex; // West=0 East=1 //alert(Math.abs(HA_for_calibrated_position-HA)*Pulse_pr_deg); if (Pulse_inc_direction==1) { CalculatedPulseCounter=Reference_pulse+(HA_for_calibrated_position-HA)*Pulse_pr_deg } else if (Pulse_inc_direction==0) CalculatedPulseCounter=Reference_pulse-(HA_for_calibrated_position-HA)*Pulse_pr_deg; document.OutPulseCounter.PulseCounterValue.value=Math.floor(CalculatedPulseCounter); // calculate eastern and western limit of the satellite arc from geometric elevation =0 //0.1512/COS(Radians(SiteLat)) G =Deg(Math.acos(0.1512/Math.cos(Radians(SiteLat)) ) ); //alert(SiteLon+" "+G); // must convert satlon and sitelon to 0-360E system // sitelon is already 0-360 // G+SiteLon mod 360 //'271 E // refraction 0.58804392 deg ved 0 grader elevasjon, dvs. elevasjonsgrense er -0.58804392 document.Easternlimit.Degrees.value=formatvalue(Rev((SiteLon+G) % 360),5)+" East"; document.Easternlimit.WestDegrees.value=formatvalue(Rev((360-(G+SiteLon)) % 360) ,5)+" West"; document.Westernlimit.Degrees.value=formatvalue(Rev((SiteLon-G) % 360),5)+" East"; document.Westernlimit.WestDegrees.value=formatvalue(Rev((360-(SiteLon-G)) % 360),5)+" West"; //E = ATAN[ COS(G)COS(L)- 0.1512 / SQRT(1-COS(G)*COS(G)*COS(L)*COS(L))] //Now we adjust the result for atmospheric refraction E=0; loops=0; // while ((E>-0.58804392)&&(loops<40)) { G=G+0.05; // increase by 0.05 and recalculate E, elevation until elevation is -0.58804392 teller= Math.cos(Radians(G))*Math.cos(Radians(SiteLat))- 0.1512; nevner= Math.sqrt(1-Math.cos(Radians(G))*Math.cos(Radians(G))*Math.cos(Radians(SiteLat))*Math.cos(Radians(SiteLat)) ) ; E = Deg(Math.atan(teller/nevner)); loops=loops+1; } document.Easternlimit.Degrees.value=formatvalue(Rev((SiteLon+G) % 360),5)+" East"; document.Easternlimit.WestDegrees.value=formatvalue(Rev((360-(G+SiteLon)) % 360) ,5)+" West"; document.Westernlimit.Degrees.value=formatvalue(Rev((SiteLon-G) % 360),5)+" East"; document.Westernlimit.WestDegrees.value=formatvalue(Rev((360-(SiteLon-G)) % 360),5)+" West"; } function set_todays_date(){ var today,Day,Month,Year today = new Date(); Month= today.getMonth()+1; Day= today.getDate() ; Year= today.getUTCFullYear(); document.Selected.Day.value=Day; document.Selected.Month.value=Month; document.Selected.Year.value=Year; } function printresult(){ var listing listing="" listing+="" listing+="" listing+="" listing+="Sun azimuth ~ Satellite Longitude" listing+="" listing+="" listing+="" listing+="
"+UTCDateString+"
" listing+="
"+LTDateString+"
" listing+="
" listing+="
" listing+="
Satellite Position:"+document.Output.Satpos.value+"
" listing+="
" listing+="
Sun Azimuth:"+document.Output.SunAzimuth.value+"
" listing+="
Satellite Elevation:"+document.Output.Satel.value+"
" listing+="
" listing+="
Sun Elevation:"+document.Output.SunAltitude.value+"
" //listing+="
|Satellite Elevation-Sun Elevation|:"+document.Output.Satel.value+"
" } function d_to_date_and_time(d) { var today,t var MinMilli = 1000 * 60; var HrMilli = MinMilli * 60; var DyMilli = HrMilli * 24; today = new Date(); // d+10956= Date() format //window.alert('d= '+d ); d=d+10956; d*DyMilli; today.setTime(d*DyMilli); //t=((today.getTime()/DyMilli)-10956); //window.alert('t= '+t ); time_offset=today.getTimezoneOffset() ; Hour= today.getUTCHours() ; Minute=today.getUTCMinutes() ; Second=today.getUTCSeconds() ; Month= today.getUTCMonth()+1; Day= today.getUTCDate() ; Year= today.getUTCFullYear(); return(today) } // get the time for more days, function calculate_time_azimuth_table() { var i,SiteLat,LatDir,SiteLon,LonDir,SatDir,SatLon,Height_above_ocean,SatLonWest,RealYear,RealDate var listing,Azimuth,Elevation,HA,Reference_pulse,Pulse_pr_degree,Pulse_inc_direction,Declination var Day,Month,year,Height_above_ocean,d,time,SunElevation SiteLat=1*document.Latitude.Degrees.value; LatDir=document.Latitude.Direction.value; SiteLon=1*document.Longitude.Degrees.value; LonDir=document.Longitude.Direction.value; SatDir=document.OrbitPosition.Direction.value; SatLon=document.OrbitPosition.Degrees.value; Height_above_ocean=1*document.Height.Above_ocean.value; RealDate = new Date(); RealYear=RealDate.getYear(); Height_above_ocean=1*document.Height.Above_ocean.value; Reference_pulse=1*document.Counter.calibrate_pulse_counter.value; Pulse_pr_deg=1*document.Pulse.pulse_per_degree.value; Pulse_inc_direction=1*document.HHPulse.Increase_direction.selectedIndex; // West=0 East=1 //alert(Math.abs(HA_for_calibrated_position-HA)*Pulse_pr_deg); Day=1*document.Selected.Day.value; Month=1*document.Selected.Month.value; Year=1*document.Selected.Year.value; if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; if (SatDir=="West") SatLon=360-SatLon; listing="" listing+="" listing+="" listing+="" listing+="Azimuth/Elevation Table" listing+="" listing+="" listing+="" listing+="
-----------------------------------------------------------
"; listing+="
Time when Sun Azimuth = Satellite Azimuth
"; listing+="
Site coordinates "+SiteLat+"°"+LatDir+" "+SiteLon+"°"+LonDir+"
"; listing+="
-----------------------------------------------------------
"; listing+="
"; listing+="
www.satellite-calculations.com
"; listing+="
"; listing+="
(C) "+RealYear+" Jens T. Satre
"; listing+="
"; listing+="
-----------------------------------------------------------
"; listing+="
-----------------------------------------------------------
"; listing+="
"; //listing+="
SatPosition-------------------Az-----El-------------Time-------------------
"; // Satposition: 360.000000° East ( 0.000000° West ) 192.18° 21.11° for (i = 1800; i <= 5400; i++) { SatLon=Rev((360-i)/10); SatLonWest=360-SatLon; Elevation=Elevation2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Declination=CalculateDeclination2(SiteLat,Azimuth,Elevation); HA=CalculateSatHourangle(Azimuth,Elevation,Declination,SiteLat); d=daynumber(Day,Month,Year,12,0,0); // Use 12:00:00 to get sun data as near as possible of first try time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); d=daynumber(Day,Month,Year,Hour,Minute,Second); //Recalculate with the time found. time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); //Get's the excact time. // No need to recalculate more times (tested...) timetoprint=d_to_date_and_time(d); // must check if the Sun is above horizon here SunElevation=sun_angles(d,SiteLon,SiteLat); // if ((Elevation>=0 )&&(SunElevation>-0.833)) { if (SatLon>180) { listing+="
"+formatnumber(SatLonWest,2)+"° West "+timetoprint+"
"; } else { listing+="
"+formatnumber(SatLon,2)+"° East "+timetoprint+"
"; } } /* if (SatLon>180) { SatLon=Rev(360-i)-0.5; } else { SatLon=Rev(360-i)+0.5; } SatLonWest=360-SatLon; Elevation=Elevation2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Declination=CalculateDeclination2(SiteLat,Azimuth,Elevation); HA=CalculateSatHourangle(Azimuth,Elevation,Declination,SiteLat); d=daynumber(Day,Month,Year,12,0,0); // Use 12:00:00 to get sun data as near as possible of first try time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); d=daynumber(Day,Month,Year,Hour,Minute,Second); //Recalculate with the time found. time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); //Get's the excact time. // No need to recalculate more times (tested...) timetoprint=d_to_date_and_time(d); if (Elevation>=0) { if (SatLon>180) { listing+="
"+formatnumber(SatLonWest,2)+"° West "+timetoprint+"
"; } else { listing+="
"+formatnumber(SatLon,2)+"° East "+timetoprint+"
"; } } */ } listing+=""; PrintWindow=window.open("","Print_window") PrintWindow.oldWindow = top PrintWindow.document.write(listing) PrintWindow.document.close() } function calculate_azimuth_table() { var i,SiteLat,LatDir,SiteLon,LonDir,SatDir,SatLon,Height_above_ocean,SatLonWest,RealYear,RealDate var listing,Azimuth,Elevation,HA,Reference_pulse,Pulse_pr_degree,Pulse_inc_direction,Declination,AzString,NewAzString SiteLat=1*document.Latitude.Degrees.value; LatDir=document.Latitude.Direction.value; SiteLon=1*document.Longitude.Degrees.value; LonDir=document.Longitude.Direction.value; SatDir=document.OrbitPosition.Direction.value; SatLon=document.OrbitPosition.Degrees.value; Height_above_ocean=1*document.Height.Above_ocean.value; RealDate = new Date(); RealYear=RealDate.getYear(); Reference_pulse=1*document.Counter.calibrate_pulse_counter.value; Pulse_pr_deg=1*document.Pulse.pulse_per_degree.value; Pulse_inc_direction=1*document.HHPulse.Increase_direction.selectedIndex; // West=0 East=1 //alert(Math.abs(HA_for_calibrated_position-HA)*Pulse_pr_deg); if (LatDir=="South") SiteLat=-SiteLat; if (LonDir=="West") SiteLon=360-SiteLon; if (SatDir=="West") SatLon=360-SatLon; listing="" listing+="" listing+="" listing+="" listing+="Azimuth/Elevation Table" listing+="" listing+="" listing+="" listing+="
-----------------------------------------------------------
"; listing+="
Azimuth / Elevation Table
"; listing+="
Site coordinates "+SiteLat+"°"+LatDir+" "+SiteLon+"°"+LonDir+"
"; listing+="
-----------------------------------------------------------
"; listing+="
"; listing+="
www.satellite-calculations.com
"; listing+="
"; listing+="
(C) "+RealYear+" Jens T. Satre
"; listing+="
"; listing+="
-----------------------------------------------------------
"; listing+="
-----------------------------------------------------------
"; listing+="
"; listing+="
SatPosition-------------------Az-------El---Counter
"; // Satposition: 360.000000° East ( 0.000000° West ) 192.18° 21.11° /* AzString=formatvalue(1*Math.Round(Azimuth),7); alert(AzString.length); for (i=0;i<=AzString.length;i++) NewAzString=NewAzString+AzString[i]; alert(NewAzString); */ for (i = 1800; i <= 5400; i++) { // sat pos = i/10 SatLon=Rev((3600-i)/10); SatLonWest=360-SatLon; Elevation=Elevation2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Declination=CalculateDeclination2(SiteLat,Azimuth,Elevation); HA=CalculateSatHourangle(Azimuth,Elevation,Declination,SiteLat); if (Pulse_inc_direction==1) { CalculatedPulseCounter=Reference_pulse+(HA_for_calibrated_position-HA)*Pulse_pr_deg } else if (Pulse_inc_direction==0) CalculatedPulseCounter=Reference_pulse-(HA_for_calibrated_position-HA)*Pulse_pr_deg; if (Elevation>=0) { if (SatLon>180) { listing+="
"+formatnumber(SatLonWest,2)+"° West ("+formatnumber(SatLon,2)+"° East )"+Azimuth.toFixed(2)+"° "+formatvalue(Elevation,6)+"° "+formatvalue(Math.floor(CalculatedPulseCounter),4)+"
"; } else { listing+="
"+formatnumber(SatLon,2)+"° East ("+formatnumber(SatLonWest,2)+"° West )"+Azimuth.toFixed(2)+"° "+formatvalue(Elevation,6)+"° "+formatvalue(Math.floor(CalculatedPulseCounter),4)+"
"; } } } listing+=""; PrintWindow=window.open("","Print_window") PrintWindow.oldWindow = top PrintWindow.document.write(listing) PrintWindow.document.close() } function get_more_days() { var i,k,Azimuth,Day,Month,Year,Hour,Minute,Second,today,d_midnight,time,SunData,RA2,Decl,GMST0,StrHour,StrMinute,StrSecond,SiteLat,LatDir,SiteLon,LonDir var SunData=new Array(3); var timetoprint,Height_above_ocean var numberofdays,SatLon,SatDir var listing,SatLonWest,RealDate,RealYear,SunOffset,SatElevation,SunElevation k=0; SiteLat=1*document.Latitude.Degrees.value; LatDir=document.Latitude.Direction.value; SiteLon=1*document.Longitude.Degrees.value; LonDir=document.Longitude.Direction.value; SatDir=document.OrbitPosition.Direction.value; SatLon=document.OrbitPosition.Degrees.value; RealDate = new Date(); RealYear=RealDate.getYear(); // error in SiteLon when SiteLon is West if (SatDir=="East") SatLonWest=360-SatLon else SatLonWest=SatLon; if (LatDir=="South") SiteLat=-SiteLat; //if (LonDir=="West") SiteLon=SiteLon; if (SatDir=="West") SatLon=360-SatLon; numberofdays=10; Height_above_ocean=1*document.Height.Above_ocean.value; Azimuth=Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,(Height_above_ocean/1000)); Day=1*document.Selected.Day.value; Month=1*document.Selected.Month.value; Year=1*document.Selected.Year.value; listing="" listing+="" listing+="" listing+="" listing+="One Year Time table for Sun azimuth = Satellite Azimuth for satellite position "+SatLon+" East ("+SatLonWest+" West )" listing+="" listing+="" listing+="" listing+="
-----------------------------------------------------------
"; listing+="
One Year Time table for Sun azimuth = Satellite Azimuth
"; listing+="
for satellite position "+SatLon+"° East ("+SatLonWest+"° West )
"; listing+="
Site coordinates "+SiteLat+"°"+LatDir+" "+SiteLon+"°"+LonDir+"
"; listing+="
-----------------------------------------------------------
"; listing+="
"; listing+="
All times is local time as configured on your local computer
"; listing+="
"; listing+="
www.satellite-calculations.com
"; listing+="
"; listing+="
(C) "+RealYear+" Jens T. Satre
"; listing+="
"; listing+="
-----------------------------------------------------------
"; listing+="
"; today = new Date(); Hour= today.getHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); for (i = 0; i <= 365; i++) { d=k+daynumber(Day,Month,Year,12,0,0); // Use 12:00:00 to get sun data as near as possible of first try time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); d=k+daynumber(Day,Month,Year,Hour,Minute,Second); //Recalculate with the time found. time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); //Get's the excact time. // No need to recalculate more times (tested...) timetoprint=d_to_date_and_time(d); SatElevation=1*document.Elevation.Degrees.value; SunElevation=sun_angles(d,SiteLon,SiteLat); // SunOffset=SunElevation-SatElevation; SunOffset=formatvalue(SunOffset,5); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); if (Hour<10) StrHour="0"+Hour else StrHour=Hour; if (Minute<10) StrMinute="0"+Minute else StrMinute=Minute; if (Second<10) StrSecond="0"+Second else StrSecond=Second; SunElevation=sun_angles(d,SiteLon,SiteLat); // if (SunElevation>-0.833){ if (SunOffset<0) { SunOffset=Math.abs(SunOffset); listing+="
"+timetoprint+" Sun "+SunOffset+"° below satellite
"; } else { SunOffset=Math.abs(SunOffset); listing+="
"+timetoprint+" Sun "+SunOffset+"° above satellite
"; } } k=k+1; } listing+="" PrintWindow=window.open("","Print_window") //PrintWindow =window.open("","Print_window","menubar=yes,status=yes,toolbar=yes,scrollbars=yes"); //height=800,width=1000 PrintWindow.oldWindow = top //PrintWindow.document.write(document.Output.Satpos.value) PrintWindow.document.write(listing) PrintWindow.document.close() } function sun_angles(d,SiteLon,SiteLat){ var SunSouth,HourAngle,SIDEREALTIME,SatAz,SunSat,Tst,SatelliteAzimuth,pi,NewRA var w,a,e,M,L,oblecl,E,x,y,r,v,sunlon,z,xequat,yequat,zequat,RA,Decl,GMST0,UT,SIDTIME,HA var SunElevation,xhor,yhor,zhor,SunSatElevationDifference,SatElevation pi=Math.PI; //*********CALCULATE SUN DATA ********************* w=282.9404 + 4.70935E-5 * d ; //OK a=1; e= 0.016709 - 1.151E-9 *d ; M= 356.0470 + 0.9856002585 * d; oblecl=23.4393 -3.563E-7 * d ; L=w+Rev(M); L=Rev(L); E=M+ (180/pi)*e*Math.sin(Radians(M))*( 1+e * Math.cos(Radians(M)) ); E=Rev(E); // OK x= Math.cos(Radians(E)) -e ; y= Math.sin(Radians(Rev(E)))*Math.sqrt(1-e*e); r=Math.sqrt(x*x+y*y); v=Deg(Math.atan2(y,x)); sunlon=Rev(v+w); // trolig ok x=r*Math.cos(Radians(sunlon)); y=r*Math.sin(Radians(sunlon)); z=0; xequat=x; yequat=y*Math.cos(Radians(oblecl)) +z*Math.sin(Radians(oblecl)); zequat=y*Math.sin(Radians(oblecl)) +z*Math.cos(Radians(oblecl)); RA=Rev(Deg(Math.atan2(yequat,xequat))); // OK Decl=Deg(Math.atan2(zequat,Math.sqrt(xequat*xequat + yequat*yequat ) )); // trolig OK GMST0=(L+180); //*********CALCULATE TIME ********************* UT=d-Math.floor(d); //alert("UT="+UT); SIDEREALTIME=GMST0+UT*360+SiteLon; // ok HourAngle=SIDEREALTIME-RA; // trolig ok x=Math.cos(HourAngle*pi/180) * Math.cos(Decl*pi/180); y=Math.sin(HourAngle*pi/180) * Math.cos(Decl*pi/180); z=Math.sin(Decl*pi/180); xhor=x*Math.sin(SiteLat*pi/180) - z*Math.cos(SiteLat*pi/180); yhor=y; zhor=x*Math.cos(SiteLat*pi/180) + z*Math.sin(SiteLat*pi/180); SunElevation=Deg( Math.asin(zhor)); // ok SunElevation=ElevationRefraction(SunElevation); // atmospheric refraction //SunSouth=(360+RA2-GMST0*15-SITELON)/15 ; //return(SunElevation); return(SunElevation); } function get_the_time(Azimuth,SiteLon,SiteLat) { var Day,Month,Year,Hour,Minute,Second,today,d_midnight,time,SunData,RA2,Decl,GMST0,StrHour,StrMinute,StrSecond var SunData=new Array(3); //**** today = new Date(); Hour= today.getHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); Day=1*document.Selected.Day.value; Month=1*document.Selected.Month.value; Year=1*document.Selected.Year.value; d=daynumber(Day,Month,Year,12,0,0); // Use 12:00:00 to get sun data as near as possible of first try time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); d=daynumber(Day,Month,Year,Hour,Minute,Second); //Recalculate with the time found. time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); //Get's the excact time. // No need to recalculate more times (tested...) Hour=Math.floor(time); //alert(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); if (Hour<10) StrHour="0"+Hour else StrHour=Hour; if (Minute<10) StrMinute="0"+Minute else StrMinute=Minute; if (Second<10) StrSecond="0"+Second else StrSecond=Second; return(StrHour+":"+StrMinute+":"+StrSecond); } function get_the_local_time(Azimuth,SiteLon,SiteLat) { var Day,Month,Year,Hour,Minute,Second,today,d_midnight,time,SunData,RA2,Decl,GMST0,StrHour,StrMinute,StrSecond var SunData=new Array(3); var d = new Date(); var tz= d.getTimezoneOffset(); // gir feil for Mozilla today = new Date(); Hour= today.getHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); Day=1*document.Selected.Day.value; Month=1*document.Selected.Month.value; Year=1*document.Selected.Year.value; d=daynumber(Day,Month,Year,12,0,0); // Use 12:00:00 to get sun data as near as possible of first try time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); d=daynumber(Day,Month,Year,Hour,Minute,Second); //Recalculate with the time found. time=SunAtSatAzimuth(d,Azimuth,SiteLon,SiteLat); //Get's the excact time. // No need to recalculate more times (tested...) time=(time-(tz/60) ) % 24; //alert("tz="+tz); Hour=Math.floor(time); Minute= Math.floor((time-Hour)*60); Second= Math.floor( ((time-Hour)*60-Minute)*60); if (Hour<10) StrHour="0"+Hour else StrHour=Hour; if (Minute<10) StrMinute="0"+Minute else StrMinute=Minute; if (Second<10) StrSecond="0"+Second else StrSecond=Second; return(StrHour+":"+StrMinute+":"+StrSecond); } function SunAtSatAzimuth(d,GlobalAzimuth,SITELON,SITELAT) { var SunSouth,HourAngle,SIDEREALTIME,SatAz,SunSat,Tst,SatelliteAzimuth,pi,NewRA var w,a,e,M,L,oblecl,E,x,y,r,v,sunlon,z,xequat,yequat,zequat,RA,Decl,GMST0,UT,SIDTIME,HA pi=Math.PI; //*********CALCULATE SUN DATA ********************* w=282.9404 + 4.70935E-5 * d ; //OK a=1; e= 0.016709 - 1.151E-9 *d ; M= 356.0470 + 0.9856002585 * d; oblecl=23.4393 -3.563E-7 * d ; L=w+Rev(M); L=Rev(L); E=M+ (180/pi)*e*Math.sin(Radians(M))*( 1+e * Math.cos(Radians(M)) ); E=Rev(E); // OK x= Math.cos(Radians(E)) -e ; y= Math.sin(Radians(Rev(E)))*Math.sqrt(1-e*e); r=Math.sqrt(x*x+y*y); v=Deg(Math.atan2(y,x)); sunlon=Rev(v+w); x=r*Math.cos(Radians(sunlon)); y=r*Math.sin(Radians(sunlon)); z=0; xequat=x; yequat=y*Math.cos(Radians(oblecl)) +z*Math.sin(Radians(oblecl)); zequat=y*Math.sin(Radians(oblecl)) +z*Math.cos(Radians(oblecl)); RA=Rev(Deg(Math.atan2(yequat,xequat))); // OK Decl=Deg(Math.atan2(zequat,Math.sqrt(xequat*xequat + yequat*yequat ) )); // OK GMST0=Rev(L+180); //alert(GlobalAzimuth); if (GlobalAzimuth==180) GlobalAzimuth=180.000000001; //*********CALCULATE TIME ********************* RA2=RA; SunSouth=(360+RA2-GMST0*15-SITELON)/15 ; // error when satlon=sitelon if (SITELAT<0) GlobalAzimuth=Rev(180-(360-GlobalAzimuth)); SatelliteAzimuth=GlobalAzimuth; if (Decl>0) { if ((SatelliteAzimuth<=270)&&(SatelliteAzimuth>180)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) - Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+360; // Alert('180'); } if ((SatelliteAzimuth<180)&&(SatelliteAzimuth>=90)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) + Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+360; } if ((SatelliteAzimuth<90)&&(SatelliteAzimuth>0)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) + Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); if (HourAngle<0) HourAngle=HourAngle+180 else HourAngle=HourAngle+540; } if ((SatelliteAzimuth<360)&&(SatelliteAzimuth>270)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) - Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+540; } } //end if Decl>0 .... else { if ((SatelliteAzimuth<=270)&&(SatelliteAzimuth>180)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) - Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+720; } if ((SatelliteAzimuth<180)&&(SatelliteAzimuth>=90)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) + Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+720; } if ((SatelliteAzimuth<90)&&(SatelliteAzimuth>0)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) + Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+900; } if ((SatelliteAzimuth<360)&&(SatelliteAzimuth>270)) { HourAngle=180/pi*( Math.atan((Math.sin(SITELAT*pi/180)*Math.tan(GlobalAzimuth*pi/180))) - Math.asin(Math.cos(SITELAT*pi/180)*Math.tan(Decl*pi/180)/Math.sqrt(((1/(Math.tan(GlobalAzimuth*pi/180)*Math.tan(GlobalAzimuth*pi/180)) +Math.sin(SITELAT*pi/180)*Math.sin(SITELAT*pi/180)))))); HourAngle=HourAngle+900; } } // end else if ((RA)<-180) NewRA=Rev(RA) else NewRA=RA; SIDEREALTIME=(HourAngle+NewRA)/15; // pass på grader og timer UT=Rev(SIDEREALTIME*15-GMST0-SITELON)/15 ; //alert(SatelliteAzimuth); if (SatelliteAzimuth==180) UT=SunSouth; return(UT) // what if SatLon=SiteLon? } // end function function Azimuth2(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 ))); /* if (SiteLat>0) { Hemisphere=180; Azimuth=(Hemisphere+ Deg(Math.atan2(Math.tan(Radians(SiteLon-SatLon)) , Math.sin(Radians(SiteLat)) )) )%360; } else { Hemisphere=0; Azimuth=(Deg(Math.atan2(Math.tan(Radians(SiteLon-SatLon)) , Math.sin(Radians(SiteLat)) )) )%360; //alert("Raw Azimuth="+(360-Azimuth)); Azimuth=Math.abs(Rev(180+Azimuth)); } */ return(Azimuth); } function Elevation2(SatLon,SiteLat,SiteLon,Height_over_ocean) { var Rstation,f,r_eq,r_sat,Ra,Rz,alfa_r,alfa_rx,alfa_ry,refraction,alfa_rz,alfa_r_north,alfa_r_zenith,El_geometric var El_observed,Elevation var x,a0,a1,a2,a3,a4 a0=0.58804392; a1=-0.17941557 a2=0.29906946E-1; a3=-0.25187400E-2; a4=0.82622101E-4; f=(1/298.257) ; // Earth flattning factor r_sat=42164.57; // Distance from earth centre to satellite in km r_eq=6378.14 ; // Earth radius in km 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)) ; El_geometric=Deg(Math.atan2( alfa_r_zenith , Math.sqrt(alfa_r_north*alfa_r_north+alfa_ry*alfa_ry))); x=Math.abs(El_geometric+0.589); refraction=Math.abs(a0+a1*x+a2*x*x+a3*x*x*x +a4*x*x*x*x) ; if (El_geometric>10.2) { El_observed=El_geometric+0.01617*(Math.cos(Radians(Math.abs(El_geometric)))/Math.sin(Radians(Math.abs(El_geometric))) ); document.Atmospheric.Refraction.value="Not available"; } else { El_observed=El_geometric+refraction ; document.Atmospheric.Refraction.value=formatvalue(refraction,5); } document.Geometric.Elevation.value=formatvalue(El_geometric,5); if (alfa_r_zenith<-3000) El_observed=-99; return(El_observed); } function ElevationRefraction(El_geometric) { var El_observed var x,a0,a1,a2,a3,a4 a0=0.58804392; a1=-0.17941557 a2=0.29906946E-1; a3=-0.25187400E-2; a4=0.82622101E-4; El_observed=El_geometric; x=Math.abs(El_geometric+0.589); refraction=Math.abs(a0+a1*x+a2*x*x+a3*x*x*x +a4*x*x*x*x) ; if (El_geometric>10.2) { El_observed=El_geometric+0.01617*(Math.cos(Radians(Math.abs(El_geometric)))/Math.sin(Radians(Math.abs(El_geometric))) ); } else { El_observed=El_geometric+refraction ; } return(El_observed); } function PolarAxisCorrectionAngle(SiteLat) { var correction,Re,Rg, a,b Re=6378.14; // earth radius in km. Rg=42164.57; // geosyncronus radius in km. K=Rg/Re; a=Deg( Math.atan( Math.sin(Radians(SiteLat))/ (K-Math.cos(Radians(SiteLat))) ) ); b=Deg( Math.atan( Math.sin(Radians(SiteLat)) / Math.sqrt( K*K-Math.cos(Radians(SiteLat))*Math.cos(Radians(SiteLat)) )) ); correction= a-b; return(correction); } function CalculatedPolTilt(SatLon,SiteLat,SiteLon) { var pi = Math.PI; var CalculatedPolTilt CalculatedPolTilt = Deg(Math.atan( Math.sin(Radians(SiteLon - SatLon)) / Math.tan(Radians(SiteLat)) ) ); //CalculatedPolTilt = - CalculatedPolTilt ; return(CalculatedPolTilt); } function SlantRange(SiteLat,fi) { var Slantrange var Re,Rg,H Re=6378.14; // earth radius in km. Rg=42164.57; // geosyncronus radius in km. H=Rg-Re; Slantrange=Math.sqrt( Re*Re+(Re+H)*(Re+H)-2*Re*(Re+H)*Math.cos(Radians(SiteLat))*Math.cos(Radians(fi)) ); return(Slantrange); } function fi(SatLon,SiteLon) { var Fi Fi= Math.min(Math.abs(SatLon-SiteLon-360),Math.abs(SiteLon-SatLon),Math.abs(SiteLon-SatLon-360)) return(Fi); } 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,SiteLon,SiteLat,fi) { var Azimuth,Hemisphere if (SiteLat>0) { Hemisphere=180; Azimuth=(Hemisphere+ Deg(Math.atan2(Math.tan(Radians(SiteLon-SatLon)) , Math.sin(Radians(SiteLat)) )) )%360; } else { Hemisphere=0; Azimuth=(Deg(Math.atan2(Math.tan(Radians(SiteLon-SatLon)) , Math.sin(Radians(SiteLat)) )) )%360; //alert("Raw Azimuth="+(360-Azimuth)); Azimuth=Math.abs(Rev(180+Azimuth)); } return(Azimuth) // Works correct } function CalculateSatHourangle(Azimuth,Elevation,Declination,Lat) { var returnvalue,a,b a= -Math.cos(Radians(Elevation))*Math.sin(Radians(Azimuth)); b= Math.sin(Radians(Elevation))*Math.cos(Radians(Lat)) - Math.cos(Radians(Elevation))*Math.sin(Radians(Lat))*Math.cos(Radians(Azimuth)) returnvalue=180+Deg(Math.atan2(a,b)) // Works for all azimuths (northern & sourhern hemisphere) //alert(returnvalue); if (Azimuth>270) { returnvalue=((returnvalue-180)+360); if (returnvalue>360) returnvalue = 360-(returnvalue-360); } if (Azimuth<90) returnvalue=(180-returnvalue) ; return(returnvalue) } function CalculateDeclination(Lat_es,Lon_es,Lon_sat) { var Az,SatDecl,El,HAsat,HAsun,SunDecl,Hemisphere,Re,G,Sign,Separation Rg=6378.14 //Earthradius G=42164.57 // GSO Sign=1; Hemisphere=180; Az= Deg(Math.atan( Math.tan(Radians(Lon_es-Lon_sat))/Math.sin(Radians(Lat_es) ) )); if (Az<0) Sign=-1 Az=Az+Hemisphere; //Az=Rev(Az); // Az ok El=Deg( Math.atan( (Math.cos(Radians(Lon_es-Lon_sat))*Math.cos(Radians(Lat_es)) -Rg/G) / Math.sqrt( Math.sin(Radians(Lon_es-Lon_sat))* Math.sin(Radians(Lon_es-Lon_sat)) +Math.cos(Radians(Lon_es-Lon_sat)) *Math.cos(Radians(Lon_es-Lon_sat))*Math.sin(Radians(Lat_es))*Math.sin(Radians(Lat_es)) )) ); //El ok SatDecl=Deg(Math.asin( Math.sin(Radians(Lat_es))*Math.sin(Radians(El)) +Math.cos(Radians(Lat_es))*Math.cos(Radians(El))*Math.cos(Radians(Az)) ) ); // OK return(SatDecl); } function CalculateDeclination2(SiteLat,Azimuth,Elevation) { var SatDecl SatDecl= Deg( Math.asin( Math.sin(Radians(Elevation))*Math.sin(Radians(SiteLat)) +Math.cos(Radians(Elevation))*Math.cos(Radians(SiteLat))*Math.cos(Radians(Azimuth)) ) ); return(SatDecl); } //********WORKS OK function SetCookie() { var Lat,Lon,LatDir,LonDir,CookieValue var SitePosCurrentIndex,SatNameCurrentIndex var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction SitePosCurrentIndex=document.Site.Position.selectedIndex; SatNameCurrentIndex=document.Satellite.Name.selectedIndex; Lat=1*document.Latitude.Degrees.value; LatDir=document.Latitude.Direction.value; Lon=1*document.Longitude.Degrees.value; LonDir=document.Longitude.Direction.value; Calibrate_pulsevalue=1*document.Counter.calibrate_pulse_counter.value; Calibrate_pulse_per_ha_degree=1*document.Pulse.pulse_per_degree.value; calibrate_inc_direction=1*document.HHPulse.Increase_direction.selectedIndex; CookieValue=Lat+":"+LatDir+":"+Lon+":"+LonDir+":"+SitePosCurrentIndex+":"+SatNameCurrentIndex+":"+SetLocation+":"+Calibrate_pulsevalue+":"+Calibrate_pulse_per_ha_degree+":"+calibrate_inc_direction+":"+HA_for_calibrated_position+";expires=Tue, 10 Jul 2040 23:59:59 UTC;"; document.cookie =CookieValue ; // Store cookie } function ReadCookie() { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction SitePosCurrentIndex =1073 ; // Used only if there are not any cookie stored SatNameCurrentIndex =40 ; MyCookieVal=document.cookie; //alert(MyCookieVal); if (MyCookieVal !== "") // If cookie has value then set users defaults { ValArray=MyCookieVal.split(":"); //' Reads 6 cookie values in to the array Lat=ValArray[0]; LatDir=ValArray[1]; Lon=ValArray[2]; LonDir=ValArray[3]; SitePosCurrentIndex=ValArray[4] ; SatNameCurrentIndex=ValArray[5]; SetLocation= ValArray[6]; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } document.Satellite.Name.selectedIndex=SatNameCurrentIndex; //' Set default Satellite document.Site.Position.selectedIndex=SitePosCurrentIndex; document.Latitude.Degrees.value=Lat ; // Set user defaults if cookie already stored on the system document.Latitude.Direction.value=LatDir; // ' Set user defaults if cookie already stored on the system document.Longitude.Degrees.value=Lon ; //' Set user defaults if cookie already stored on the system document.Longitude.Direction.value=LonDir; // ' Set user defaults if cookie already stored on the system document.Counter.calibrate_pulse_counter.value=1*Calibrate_pulsevalue; document.Pulse.pulse_per_degree.value=Calibrate_pulse_per_ha_degree; document.HHPulse.Increase_direction.selectedIndex=calibrate_inc_direction; } // end function function ReadPosition() // Store the selected position in the cookie { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal var ValArray=new Array(); var SubArray=new Array(); MyVal=document.Site.Position.value; if (MyVal == null) alert("Cookie damaged - plese run the cookie repair script !"); if (MyVal !== null) { // Check position ValArray=MyVal.split(","); SubArray = ValArray[0].split(":") ; // The first subarray containing Lat:LatDir Lat=SubArray[0]; LatDir=SubArray[1]; SubArray = ValArray[1].split(":"); // The second subarray containing Lon:LonDir Lon=SubArray[0]; LonDir=SubArray[1]; document.Latitude.Degrees.value=Lat ; // Set user defaults if cookie already stored on the system document.Latitude.Direction.value=LatDir ; // Set user defaults if cookie already stored on the system document.Longitude.Degrees.value=Lon ; // Set user defaults if cookie already stored on the system document.Longitude.Direction.value=LonDir ; // Set user defaults if cookie already stored on the system } } // End function function Rev(number) { var x x= number -Math.floor(number/360.0)*360 ; return(x) } 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 daynumber(Day,Month,Year,Hour,Minute,Second) { //window.alert(Day+" "+Month+" "+Year+" "+Hour+" "+Minute+" "+Second); d=367*Year - Div( (7*(Year+(Div((Month+9),12)))),4 ) + Div((275*Month),9) + Day - 730530 // d is correct //window.alert(d); d=d+ Hour/24 + Minute/(60*24) + Second/(24*60*60) // OK return(d) } function Div(a,b) { return((a-a%b)/b) //OK } function formatnumber(num,places) { var strOP,i,decimals,newdecimals,integer,newstring,numcopy var ss=new Array() numcopy=num; var a = Math.pow(10,Math.abs(places) == places ? places : 2); strOP=String(Math.round(num * a) / a).replace(/^(\d)/," $1"); if (num<0) strOP=" "+strOP; // put " " on negative numbers //num=parseFloat(strOP); ss = strOP.split(".");// split string by . what about zero..? if ((num!==0)&&(ss.length>1)) { decimals=ss[1]; integer=ss[0]; if (decimals.length=0) strOP=" "+strOP; return(strOP) } function formatvalue(input, rsize) // Desimal avrunding { var invalid = "**************************"; var temp,temp2 var nines = "999999999999999999999999"; var strin = "" + input; var fltin = parseFloat(strin); if (strin.length <= rsize) return strin; if (strin.indexOf("e") != -1 || fltin > parseFloat(nines.substring(0,rsize)+".4")) return invalid.substring(0, rsize); var rounded = "" + (fltin + (fltin - parseFloat(strin.substring(0, rsize)))); temp=rounded.substring(0, rsize); return(temp); } /* var num = 10; var result = num.toFixed(2); // result will equal 10.00 num = 930.9805; result = num.toFixed(3); // result will equal 930.981 num = 500.2349; result = num.toPrecision(4); // result will equal 500.2 num = 5000.2349; result = num.toPrecision(4); // result will equal 5000 num = 555.55; result = num.toPrecision(2); // result will equal 5.6e+2 */