var lookangles_updated,SetLocation,credittext,CreditShown,LookanglesTest,pulsecounterpoffset_lookang_satlist lookangles_updated="Calculator script updated 27-02-2012
"; updated="Updated 27 February 2012
"; /* 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+="\n" credittext+="\n" credittext+="\nLast Changes" credittext=credittext+"\n1201-2009: Corrected bug in Satellite Elevation" credittext=credittext+"\n2101-2009: Added 'simple elevation' , elevation with no refraction or earth flattening" credittext=credittext+"\n2101-2009: Solved bug - height over ocean was not and has never been working" credittext+="\n" credittext+="\n" credittext+="\nHistory:" credittext=credittext+"\n28702-2012: Satellite latitude calculated from two line elements is now \n used in calculations(refresh to get new updated azimuth/elevation)" credittext=credittext+"\n2702-2012: Added view of current calculated latitude from two line elements" credittext=credittext+"\n2101-2009: Solved bug - height over ocean was not and has never been working" credittext=credittext+"\n2101-2009: Added 'simple elevation' , elevation with no refraction or earth flattening" credittext=credittext+"\n1201-2009: Corrected bug in Satellite Elevation" credittext=credittext+"\n0105-2008: Corrected local time error for southern hemisphere (still not working well in Mozilla Firefox)" credittext=credittext+"\n1302-2008: Changed the history message" credittext=credittext+"\n0710-2007: Corrected bug in time calculation caused by the 2309 fix" credittext=credittext+"\n2309-2007: Corrected bug in time calculation when satellite longitude equals site longitude" credittext=credittext+"\n1103-2007: Accounted for atmospheric refrection when calculating theoretical satellite arc limits" credittext=credittext+"\n1103-2007: Calculates eastmost and westmost satellite longitude from geometric elevation (atmospheric refrection not accounted for)" credittext=credittext+"\n0101-2007: Does not show the time when Sun azimuth equals satellite azimiuth if the sun is below horizon" credittext=credittext+"\n2509-2006: Added table generation for time when Sun azimuth equals satellite azimiuth" credittext=credittext+"\n2506-2006: Added Azimuth/Elevation table generation" credittext=credittext+"\n0503-2006: Added difference between between sun and satellite elevation in one year timetable" credittext=credittext+"\n0503-2006: Added Sun elevation when satellite azimuth equals sun azimuth" credittext=credittext+"\n1202-2006: Small fixes in timetable printout" credittext=credittext+"\n0402-2006: Possible to print one year timetable for sun az.=sat az. time" credittext=credittext+"\n0202-2006: Added input date for sun az.=sat az. calculation" credittext=credittext+"\n0901-2006: Added display of geometric elevation and atmospheric refraction for elevation angles below 10.2 degrees" credittext=credittext+"\n2105-2005: Added calculation of time delay one direction and roundtrip delay (up downlink same site)" credittext=credittext+"\n0708-2004: Added calculation of pulse counter for H-H polarmounts" credittext=credittext+"\n3008-2003: Added degrees, minute, seconds format for site coordinates" credittext=credittext+"\n1608-2003: Changed the offset 'elevation' to offset antenna 'tilt'" credittext=credittext+"\n1007-2003: More satellites and coordinates added" credittext=credittext+"\n0807-2003: Corrected azimuth bug when site latitude is on equator" credittext=credittext+"\n0707-2003: Updated satellite list" credittext=credittext+"\n2104-2003: Added more coordinates" 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+"\n0712-2002: Changed layout" credittext=credittext+"\n0808-2002: Added calculation of pulsecountervalues for horizon-horizon polarmounts" credittext=credittext+"\n1001-2002: Updated satellite list" 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+"\n0505-2001: Added higher accuracy using Intelsat IESS-412 formulas. Atmospheric refraction is included" credittext=credittext+"\n0105-2001: Corrected bug in Azimuth & Hourangle for southern hemisphere" credittext=credittext+"\n0105-2001: Rewritten to javascript. Time calculation not finished yet" credittext=credittext+"\n0802-2001: Removed time calculation - replaced with a N/A for latitudes near equator" credittext=credittext+"\n0602-2001: Sun az.=sat az. time calculation is more inacurrate the nearer equator the receiving site is" credittext=credittext+"\n0602-2001: Disabled sun az.=sat az. time calculation for latitudes<4deg. (near equator)" credittext=credittext+"\n0302-2001: Updated satellite list" credittext=credittext+"\n0302-2001: Added world site locations" credittext=credittext+"\n1307-2000: Site locations in alfabetic order" credittext=credittext+"\n1207-2000: Corrected a small bug in default listbox settings" credittext=credittext+"\n1107-2000: If errors should occur just 'OK them' and choose site&satellite again (Cookie problems....)" credittext=credittext+"\n1107-2000: Added more European sites..." credittext=credittext+"\n1007-2000: Added predefined site locations" credittext=credittext+"\n1007-2000: User default site position works now" credittext=credittext+"\n0907-2000: Added site position storded in a cookie ( just a test yet...) " credittext=credittext+"\n0507-2000: Corrected bug in Azimuth calculation for West longitudes." credittext=credittext+"\n2606-2000: Test of UTC time calculations for more earthpositions" credittext=credittext+"\n2006-2000: Corrected bugs in calculating the time when the sun has the same azimuth as the satellite" credittext=credittext+"\n1806-2000: Added time when the sun has the same azimuth as the satellite" credittext=credittext+"\n1903-2000: Updated satellite list." credittext=credittext+"\n0801-2000: Added position as x degrees west(not for edit). Some minor fixes" credittext=credittext+"\n0701-2000: Updated satellite list. Added all known satellites in Clarke belt" credittext=credittext+"\n0601-2000: More corrections for southern hemisphere and polarmount angles" credittext=credittext+"\n0501-2000: More corrections for southern hemisphere" credittext=credittext+"\n2812-1999: Corrected polarmountangle calculations for southern hemisphere" credittext=credittext+"\n1612-1999: Added more angle calculations for Polarmounts" credittext=credittext+"\n2410-1999: First version, VB script" /* credittext+=""; credittext+="" */ function date_and_time(){ date_and_time=Date(); //alert(Date()); } function ShowCredit() { alert(credittext); //PrintWindow=window.open("","Print_window") //PrintWindow.oldWindow = top //PrintWindow.document.write(credittext) //PrintWindow.document.close() } var HA_for_calibrated_position,SetLocation function SelectSatellite() { var tmpstring; var satposarray=new Array(); tmpstring=document.Satellite.Name.value; satposarray=tmpstring.split(":"); //' Reads 6 cookie values in to the array //satposarray[0];= lon // lat 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"; document.OrbitPosition.Latitude.value=satposarray[1]; } function ShowCookie() { // var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal,HightAboveOcean,SatNameCurrentIndex var ValArray=new Array(); var SubArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,cookie_decoded_content 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 cookie_decoded_content='COOKIE CONTENT:'; cookie_decoded_content=cookie_decoded_content+'\nSite Latitude:'+ValArray[0]+' '+ValArray[1]; cookie_decoded_content=cookie_decoded_content+'\r\nSite Latitude:'+ValArray[2]+' '+ValArray[3]; cookie_decoded_content=cookie_decoded_content+'\r\nSite Position List Index:'+ValArray[4]; cookie_decoded_content=cookie_decoded_content+'\r\nSat Position List Index:'+ValArray[5]; cookie_decoded_content=cookie_decoded_content+'\r\nSet Location:'+ValArray[6]; cookie_decoded_content=cookie_decoded_content+'\r\nCalibrate pulsevalue:'+ValArray[7]; cookie_decoded_content=cookie_decoded_content+'\r\nCalibrate puls per HA degree:'+ValArray[8]; cookie_decoded_content=cookie_decoded_content+'\r\nPulse counter increasing in direction:'+ValArray[9]; cookie_decoded_content=cookie_decoded_content+'\r\nHourangle for calibrated position:'+ValArray[10]; cookie_decoded_content=cookie_decoded_content+'\r\nHight above ocean:'+ValArray[11]; cookie_decoded_content=cookie_decoded_content+'\r\nAntenna Size:'+1*ValArray[12]; cookie_decoded_content=cookie_decoded_content+'\r\nRx Frequency:'+1*ValArray[13]; cookie_decoded_content=cookie_decoded_content+'\r\nCookie14:'+ValArray[14]; cookie_decoded_content=cookie_decoded_content+'\r\nSite name:'+ValArray[15]; cookie_decoded_content=cookie_decoded_content+'\r\nGoogle Map Zoom:'+ValArray[16]; cookie_decoded_content=cookie_decoded_content+'\r\nAntenna hight above ground:'+1*ValArray[17]; cookie_decoded_content=cookie_decoded_content+'\r\nCookie18:'+ValArray[18]; cookie_decoded_content=cookie_decoded_content+'\r\nCookie19:'+ValArray[19]; cookie_decoded_content=cookie_decoded_content+'\r\nPolarmount pulse counter offset:'+ValArray[20]; alert(cookie_decoded_content); } else alert('Cookie is empty'); //alert('Site Latitude:'+ValArray[0]+' '+ValArray[1]+'\r\nSite Latitude:'+ValArray[2]+' '+ValArray[3]); //61.10301827211036:North:7.51039981842041:East:0:231:undefined:NaN:NaN:0:undefined:0:undefined:undefined:undefined:Hanseskogen 31B, 6887 Lærdal, Norway:16:undefined:undefined:undefined //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 //60.14367412766545:North:10.806244800000059:East:0:230:undefined:NaN:NaN:0:undefined:265:undefined:undefined:undefined:User defined location:15:5:undefined:undefined //CookieValue=Lat+":"+LatDir+":"+Lon+":"+LonDir+":"+SitePosCurrentIndex+":"+SatNameCurrentIndex+":"+SetLocation+":"+Calibrate_pulsevalue+":"+Calibrate_pulse_per_ha_degree+":"+calibrate_inc_direction+":"+HA_for_calibrated_position+":"+HightAboveOcean+":"+cookie12+":"+cookie13+":"+cookie14+":"+cookie15+":"+cookie16+":"+cookie17+":"+cookie19+":"+cookie20+";expires=Tue, 10 Jul 2040 23:59:59 UTC;"; } 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=1*(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 PrintSunAtSatAzimuth(Azimuth,LonSat,Lati,r_sat) // må ha med SatLon,SatLat og R { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele,UTCTimeSunAtSatAzimuth 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } // alert(Lat+" "+Lon); Azi=Azimuth2(LonSat,Lat,Lon,0,Lati,r_sat); if (Math.abs(Lat)<4) UTCTimeSunAtSatAzimuth="Too close to equator" else UTCTimeSunAtSatAzimuth=get_the_time(Azi,Lon,Lat); //alert(Azi); // alert(Lat+" "+Lon+" "+LookanglesArray[0]); // Azimuth // LookanglesArray[1]= Elevation2(359,Lat,Lon,0,-10,42164); // Elevation //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; return(UTCTimeSunAtSatAzimuth); //alert(Azi.toString()); } function PrintSunAtSatAzimuthForMoreDays(Azimuth,LonSat,Lati,r_sat) // må ha med SatLon,SatLat og R { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele,UTCTimeSunAtSatAzimuth 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; // alert(Lat+" "+Lon); } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Azi=Azimuth2(LonSat,Lat,Lon,0,Lati,r_sat); if (Math.abs(Lat)<4) UTCTimeSunAtSatAzimuth="Too close to equator" else UTCTimeSunAtSatAzimuth=get_the_time(Azi,Lon,Lat); //alert(Azi); // alert(Lat+" "+Lon+" "+LookanglesArray[0]); // Azimuth // LookanglesArray[1]= Elevation2(359,Lat,Lon,0,-10,42164); // Elevation //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; return(UTCTimeSunAtSatAzimuth); //alert(Azi.toString()); } 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,SatLat,r) { 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,SatLat,TLE_r_sat var tmpstring var satpos_array=new Array(); //tmpstring=document.Satellite.Name.value; //alert(tmpstring+" Azimuth"); //satpos_array=tmpstring.split(":"); //TLE_r_sat=1*satpos_array[2];//sat r //SatLat=1*satpos_array[1];// sat lat f=(1/298.257) ; // Earth flattning factor r_sat=42164.57; // Distance from earth centre to satellite r_eq=6378.14 ; // Earth radius r_sat=r; //alert("r_sat "+r_sat+" SatLat "+SatLat+" Azimuth"); 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(SatLat))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // // **** TRY TO CALCULATE geosenric z for satellitte (lat) and compensate azimuth/Elevation for latitude 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,SatLat,r) { 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,TLE_r_sat var El_observed,Elevation,SatLat var x,a0,a1,a2,a3,a4 var tmpstring; var satposarray=new Array(); a0=0.58804392; a1=-0.17941557 a2=0.29906946E-1; a3=-0.25187400E-2; a4=0.82622101E-4; //tmpstring=document.Satellite.Name.value; //satposarray=tmpstring.split(":"); //TLE_r_sat=1*satposarray[2];//sat r //SatLat=1*satposarray[1];// sat lat // TEST WITH NO FLATTENING f=0;// (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 r_sat=r; //alert("r_sat "+r_sat+" SatLat "+SatLat+" Elevation"); 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)+Height_over_ocean)*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_rx=r_sat*Math.cos(Radians(SatLat))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // //alfa_rx=r_sat*Math.cos(Radians(SatLon))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; //alfa_ry=r_sat*Math.cos(Radians(SatLon))*Math.sin(Radians(SatLon-SiteLon)) ; //alfa_rz=r_sat*Math.sin(Radians(SatLon)) -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))); //document.Simple.Elevation.value=formatvalue(El_geometric,5); // no earth flattening //alert("El_geometric "+El_geometric+" Elevation"); // END TEST NO FLATTENING 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 r_sat=r; // 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)+Height_over_ocean)*Math.sin(Radians(SiteLat)); alfa_r=r_sat-Rstation ; //alert(Height_over_ocean); /* alfa_rx=r_sat*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=-Rz; */ alfa_rx=r_sat*Math.cos(Radians(SatLat))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // //alfa_rx=r_sat*Math.cos(Radians(SatLon))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; //alfa_ry=r_sat*Math.cos(Radians(SatLon))*Math.sin(Radians(SatLon-SiteLon)) ; //alfa_rz=r_sat*Math.sin(Radians(SatLon)) -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))); //alert("El_geometric "+El_geometric+" Elevation"); 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))) ); // refraction for high elevation //document.Atmospheric.Refraction.value=formatvalue(0.01617*(Math.cos(Radians(Math.abs(El_geometric)))/Math.sin(Radians(Math.abs(El_geometric))) ),5); } else { El_observed=El_geometric+refraction ; //document.Atmospheric.Refraction.value=formatvalue(refraction,5); } //document.Geometric.Elevation.value=formatvalue(El_geometric,5); // compensated for earth flattening // compensated for b if (alfa_r_zenith<-3000) El_observed=-99; //alert("El_observed "+El_observed+" Elevation"+" refraction " +refraction); //alert(El_observed); if (El_observed<0) return("Below horizon") else return(El_observed); //return(El_observed); // includes flattening and refraction } function ElevationGeometric(SatLon,SiteLat,SiteLon,Height_over_ocean,SatLat,r) { 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,TLE_r_sat var El_observed,Elevation,SatLat var x,a0,a1,a2,a3,a4 var tmpstring; var satposarray=new Array(); a0=0.58804392; a1=-0.17941557 a2=0.29906946E-1; a3=-0.25187400E-2; a4=0.82622101E-4; //tmpstring=document.Satellite.Name.value; //satposarray=tmpstring.split(":"); //TLE_r_sat=1*satposarray[2];//sat r //SatLat=1*satposarray[1];// sat lat // TEST WITH NO FLATTENING f=0;// (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 r_sat=r; //alert("r_sat "+r_sat+" SatLat "+SatLat+" Elevation"); 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)+Height_over_ocean)*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_rx=r_sat*Math.cos(Radians(SatLat))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // //alfa_rx=r_sat*Math.cos(Radians(SatLon))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; //alfa_ry=r_sat*Math.cos(Radians(SatLon))*Math.sin(Radians(SatLon-SiteLon)) ; //alfa_rz=r_sat*Math.sin(Radians(SatLon)) -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))); //document.Simple.Elevation.value=formatvalue(El_geometric,5); // no earth flattening //alert("El_geometric "+El_geometric+" Elevation"); // END TEST NO FLATTENING 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 r_sat=r; // 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)+Height_over_ocean)*Math.sin(Radians(SiteLat)); alfa_r=r_sat-Rstation ; //alert(Height_over_ocean); /* alfa_rx=r_sat*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=-Rz; */ alfa_rx=r_sat*Math.cos(Radians(SatLat))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-SiteLon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // //alfa_rx=r_sat*Math.cos(Radians(SatLon))*Math.cos(Radians(SatLon-SiteLon)) -Ra ; //alfa_ry=r_sat*Math.cos(Radians(SatLon))*Math.sin(Radians(SatLon-SiteLon)) ; //alfa_rz=r_sat*Math.sin(Radians(SatLon)) -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))); //alert("El_geometric "+El_geometric+" Elevation"); //document.Geometric.Elevation.value=formatvalue(El_geometric,5); // compensated for earth flattening // compensated for b if (alfa_r_zenith<-3000) El_observed=-99; //alert("El_observed "+El_observed+" Elevation"+" refraction " +refraction); //alert(El_observed); El_observed=El_geometric; if (El_observed<0) return("Below horizon") else return(El_observed); //return(El_observed); // includes flattening and refraction } 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. // must use TLE based r 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 TLESlantRange(SiteLat,fi,r_sat) { var Slantrange var Re,Rg,H Re=6378.14; // earth radius in km. Rg=r_sat; // geosyncronus radius in km. // must use TLE based r 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]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } 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; if ((ValArray[20]!="undefined") && (!isNaN(ValArray[20])) ) pulsecounterpoffset_lookang_satlist=1*ValArray[20] else pulsecounterpoffset_lookang_satlist=1000; } // end function function PrintAzimuth(LonSat,Lati,r_sat) // må ha med SatLon,SatLat og R { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; // alert(Lat+" "+Lon); } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Azi=Azimuth2(LonSat,Lat,Lon,0,Lati,r_sat); Ele= Elevation2(LonSat,Lat,Lon,0,Lati,r_sat); // Elevation, ok works //alert(Azi); // alert(Lat+" "+Lon+" "+LookanglesArray[0]); // Azimuth // LookanglesArray[1]= Elevation2(359,Lat,Lon,0,-10,42164); // Elevation //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; if (Ele=="Below horizon") return("N/A") return(formatvalue(Azi,8)); //alert(Azi.toString()); //LookanglesArray } // end function function GetPolarmountAngles(SatLon,SatLat,r_sat,headline) { var polarmount_angles_text,MyCookieVal,Lat,Lon,LatDir,LonDir,Declination,Hourangle,PolarAxisCorrection,PolaraxisAngle,DeclinationHorPlane var CalculatedPulseCounter,Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,HA_for_calibrated_position var Elevation,Azimuth,MainAxisAngle 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Elevation=PrintElevation(SatLon,SatLat,r_sat); Azimuth=PrintAzimuth(SatLon,SatLat,r_sat) ; //alert("Azimuth: "+Azimuth+"\r\nElevation: "+Elevation+"\r\nSatLon:"+SatLon+"\r\nSatLat:"+SatLat+"\r\nr_sat "+r_sat+"\r\n"+Lat+"\r\n"+Lon); Declination=formatvalue(CalculateDeclination2(Lat,Azimuth,Elevation),6); Hourangle=formatvalue(CalculateSatHourangle(Azimuth,Elevation,Declination,Lat),6); PolarAxisCorrection=formatvalue(PolarAxisCorrectionAngle(Lat),5); //=formatvalue(PolarAxisCorrection,5); PolaraxisAngle=formatvalue((90-Lat-PolarAxisCorrection),5); MainAxisAngle=180-PolaraxisAngle-90; DeclinationHorPlane=formatvalue((180-1*PolaraxisAngle-90+1*Declination),5); //360-polaraxisangle-90+declination if ((ValArray[20]!="undefined") && (!isNaN(ValArray[20])) ) pulsecounterpoffset_lookang_satlist=1*ValArray[20] else pulsecounterpoffset_lookang_satlist=1000; if (calibrate_inc_direction==1) { CalculatedPulseCounter=Math.floor(Calibrate_pulsevalue+(HA_for_calibrated_position-Hourangle)*Calibrate_pulse_per_ha_degree); } else if (calibrate_inc_direction==0) CalculatedPulseCounter=Math.floor(Calibrate_pulsevalue-(HA_for_calibrated_position-Hourangle)*Calibrate_pulse_per_ha_degree); if (CalculatedPulseCounter<0) CalculatedPulseCounter=CalculatedPulseCounter+pulsecounterpoffset_lookang_satlist else if (CalculatedPulseCounter>=1000) CalculatedPulseCounter=CalculatedPulseCounter-pulsecounterpoffset_lookang_satlist; // 3 digits pulse counter polarmount_angles_text=""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+""; polarmount_angles_text=polarmount_angles_text+"
"+headline+"
Hourangle:"+Hourangle+"°
Declination:"+Declination+"°
Polaraxis Angle:"+PolaraxisAngle+"°
Polaraxis Correction Angle:"+PolarAxisCorrection+"°
Main Polarmount Axis Angle:"+formatvalue(MainAxisAngle,5)+"°
Declination from horisontal plane:"+DeclinationHorPlane+"°
H-H pulse counter:"+CalculatedPulseCounter+" pulses
"; return(polarmount_angles_text); } function GetHourAngle(SatLon,SatLat,r_sat) { var polarmount_angles_text,MyCookieVal,Lat,Lon,LatDir,LonDir,Declination,Hourangle,PolarAxisCorrection,PolaraxisAngle,DeclinationHorPlane var CalculatedPulseCounter,Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,HA_for_calibrated_position var Elevation,Azimuth,MainAxisAngle 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Elevation=PrintElevation(SatLon,SatLat,r_sat); Azimuth=PrintAzimuth(SatLon,SatLat,r_sat) ; //alert("Azimuth: "+Azimuth+"\r\nElevation: "+Elevation+"\r\nSatLon:"+SatLon+"\r\nSatLat:"+SatLat+"\r\nr_sat "+r_sat+"\r\n"+Lat+"\r\n"+Lon); Declination=formatvalue(CalculateDeclination2(Lat,Azimuth,Elevation),6); Hourangle=formatvalue(CalculateSatHourangle(Azimuth,Elevation,Declination,Lat),6); PolarAxisCorrection=formatvalue(PolarAxisCorrectionAngle(Lat),5); //=formatvalue(PolarAxisCorrection,5); PolaraxisAngle=formatvalue((90-Lat-PolarAxisCorrection),5); MainAxisAngle=180-PolaraxisAngle-90; DeclinationHorPlane=formatvalue((180-1*PolaraxisAngle-90+1*Declination),5); //360-polaraxisangle-90+declination if ((ValArray[20]!="undefined") && (!isNaN(ValArray[20])) ) pulsecounterpoffset_lookang_satlist=1*ValArray[20] else pulsecounterpoffset_lookang_satlist=1000; if (calibrate_inc_direction==1) { CalculatedPulseCounter=Math.floor(Calibrate_pulsevalue+(HA_for_calibrated_position-Hourangle)*Calibrate_pulse_per_ha_degree); } else if (calibrate_inc_direction==0) CalculatedPulseCounter=Math.floor(Calibrate_pulsevalue-(HA_for_calibrated_position-Hourangle)*Calibrate_pulse_per_ha_degree); if (CalculatedPulseCounter<0) CalculatedPulseCounter=CalculatedPulseCounter+pulsecounterpoffset_lookang_satlist else if (CalculatedPulseCounter>=1000) CalculatedPulseCounter=CalculatedPulseCounter-pulsecounterpoffset_lookang_satlist; // 3 digits pulse counter return(Hourangle); } function PrintDeclination(SatLon,SatLat,r_sat) { var polarmount_angles_text,MyCookieVal,Lat,Lon,LatDir,LonDir,Declination,Hourangle,PolarAxisCorrection,PolaraxisAngle,DeclinationHorPlane var CalculatedPulseCounter,Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,HA_for_calibrated_position var Elevation,Azimuth,MainAxisAngle 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Elevation=PrintElevationGeometric(SatLon,SatLat,r_sat); // Azimuth=PrintAzimuth(SatLon,SatLat,r_sat) ; Declination=formatvalue(((CalculateDeclination2(1*Lat,1*Azimuth,1*Elevation))),6); //alert("Printdecl "+Declination+"\r\nAzimuth: "+Azimuth+"\r\nElevation: "+Elevation+"\r\nSatLon:"+SatLon+"\r\nSatLat:"+SatLat+"\r\nr_sat "+r_sat+"\r\nSiteLat"+Lat+"\r\nSiteLon"+Lon); //Declination=formatvalue(CalculateDeclination2(1*Lat,1*Azimuth,1*Elevation),6); //alert(Declination+" "+SatLat); if (SatLat>0) return(1*Declination+SatLat) else return(1*Declination+SatLat); } function PrintTransitDeclination() { var polarmount_angles_text,MyCookieVal,Lat,Lon,LatDir,LonDir,Declination,Hourangle,PolarAxisCorrection,PolaraxisAngle,DeclinationHorPlane var CalculatedPulseCounter,Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction,HA_for_calibrated_position var Elevation,Azimuth,MainAxisAngle 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; Calibrate_pulsevalue=ValArray[7]; Calibrate_pulse_per_ha_degree=ValArray[8]; calibrate_inc_direction=ValArray[9]; HA_for_calibrated_position=ValArray[10]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Elevation=PrintElevationGeometric(Lon,0,42164); // Azimuth=PrintAzimuth(Lon,0,42164); // Declination=formatvalue(((CalculateDeclination2(1*Lat,1*Azimuth,1*Elevation))),6); //alert("Printdecl "+Declination+"\r\nAzimuth: "+Azimuth+"\r\nElevation: "+Elevation+"\r\nSatLon:"+SatLon+"\r\nSatLat:"+SatLat+"\r\nr_sat "+r_sat+"\r\nSiteLat"+Lat+"\r\nSiteLon"+Lon); //Declination=formatvalue(CalculateDeclination2(1*Lat,1*Azimuth,1*Elevation),6); //alert(Declination+" "+SatLat); if (Lat>0) return(1*Declination) else return(1*Declination); } function PrintDeclinationError() { var error,MyCookieVal,Lat,Lon,LatDir,LonDir 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } if (Lat<0) error=PrintTransitDeclination()-PrintDeclination() else error=PrintTransitDeclination()-PrintDeclination(); return(error); } function GetMaxEast() { // calculate eastern and western limit of the satellite arc from geometric elevation =0 var max_east_west_text,MyCookieVal,Lat,Lon,LatDir,LonDir,max_west_in_west_format var G,E,loops,teller,nevner var max_west_in_east_format,max_east_in_west_format,max_east_in_east_format //0.1512/COS(Radians(SiteLat)) 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } G =Deg(Math.acos(0.1512/Math.cos(Radians(Lat)) ) ); //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 //max_east_in_east_format=formatvalue(Rev((Lon+G) % 360),5)+"°East"; //max_east_in_west_format=formatvalue(Rev((360-(G+Lon)) % 360) ,5)+"°West"; //max_west_in_east_format=formatvalue(Rev((Lon-G) % 360),5)+"°East"; //max_west_in_west_format=formatvalue(Rev((360-(Lon-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(Lat))- 0.1512; nevner= Math.sqrt(1-Math.cos(Radians(G))*Math.cos(Radians(G))*Math.cos(Radians(Lat))*Math.cos(Radians(Lat)) ) ; E = Deg(Math.atan(teller/nevner)); loops=loops+1; } max_east_in_east_format=formatvalue(Rev( (1*Lon+G) % 360),5)+"°East"; //alert(max_east_in_east_format); max_east_in_west_format=formatvalue(Rev((360-(G+1*Lon)) % 360),5) +"°West"; max_west_in_east_format=formatvalue(Rev((1*Lon-G) % 360),5)+"°East"; max_west_in_west_format=formatvalue(Rev((360-(1*Lon-G)) % 360),5)+"°West"; var temparray=new Array(); max_east_west_text=max_east_in_east_format+"("+max_east_in_west_format+")"; //temparray[0]=max_east_in_east_format+"("+max_east_in_west_format+")"; //max_east_west_text=max_east_west_text+"
Theoretical west limit:"+max_west_in_west_format+"("+max_west_in_east_format+")"; //temparray[1]=max_west_in_west_format+"("+max_west_in_east_format+")"; return(max_east_west_text); } function GetMaxWest() { // calculate eastern and western limit of the satellite arc from geometric elevation =0 var max_east_west_text,MyCookieVal,Lat,Lon,LatDir,LonDir,max_west_in_west_format var G,E,loops,teller,nevner var max_west_in_east_format,max_east_in_west_format,max_east_in_east_format //0.1512/COS(Radians(SiteLat)) 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } G =Deg(Math.acos(0.1512/Math.cos(Radians(Lat)) ) ); //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 //max_east_in_east_format=formatvalue(Rev((Lon+G) % 360),5)+"°East"; //max_east_in_west_format=formatvalue(Rev((360-(G+Lon)) % 360) ,5)+"°West"; //max_west_in_east_format=formatvalue(Rev((Lon-G) % 360),5)+"°East"; //max_west_in_west_format=formatvalue(Rev((360-(Lon-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(Lat))- 0.1512; nevner= Math.sqrt(1-Math.cos(Radians(G))*Math.cos(Radians(G))*Math.cos(Radians(Lat))*Math.cos(Radians(Lat)) ) ; E = Deg(Math.atan(teller/nevner)); loops=loops+1; } max_east_in_east_format=formatvalue(Rev( (1*Lon+G) % 360),5)+"°East"; //alert(max_east_in_east_format); max_east_in_west_format=formatvalue(Rev((360-(G+1*Lon)) % 360),5) +"°West"; max_west_in_east_format=formatvalue(Rev((1*Lon-G) % 360),5)+"°East"; max_west_in_west_format=formatvalue(Rev((360-(1*Lon-G)) % 360),5)+"°West"; var temparray=new Array(); //max_east_west_text="
Theoretical east limit:"+max_east_in_east_format+"("+max_east_in_west_format+")"; //temparray[0]=max_east_in_east_format+"("+max_east_in_west_format+")"; max_east_west_text=max_west_in_west_format+"("+max_west_in_east_format+")"; //temparray[1]=max_west_in_west_format+"("+max_west_in_east_format+")"; return(max_east_west_text); } function GetAtmosphericRefraction(Sat__Lon,Sat__Lat,r_sat) { var El_observed,CalculatedRefraction,El_geometric,refraction_temp 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; CalculatedRefraction=""; El_geometric=1*PrintElevation(Sat__Lon,Sat__Lat,r_sat); El_observed=1*El_geometric; x=Math.abs(El_geometric+0.589); refraction_temp=1*Math.abs(1*a0+a1*x+a2*x*x+a3*x*x*x +a4*x*x*x*x) ; //alert(1*refraction_temp); 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))) ); CalculatedRefraction=0.01617*( Math.cos(Radians(Math.abs(El_geometric))) / Math.sin(Radians(Math.abs(El_geometric))) ) ; CalculatedRefraction=formatvalue(CalculatedRefraction,5) ; // alert(El_observed); } else { El_observed=El_geometric+refraction_temp ; CalculatedRefraction=formatvalue(refraction_temp,5) ; } return(CalculatedRefraction); } function GetSlantRange(SatLon,r_sat) { var slant_range,MyCookieVal,Lat,Lon,LatDir,LonDir 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } slant_range=formatvalue(TLESlantRange(Lat,fi(SatLon,Lon),r_sat),8); return(slant_range); } function GetSlantRangeDelay(SatLon) { var slant_range_delay,MyCookieVal,Lat,Lon,LatDir,LonDir 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } slant_range_delay=formatvalue((SlantRange(Lat,fi(SatLon,Lon))/300),7); return(slant_range_delay); } function GetSlantRangeDelay2(SatLon) { var slant_range_delay,MyCookieVal,Lat,Lon,LatDir,LonDir 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } slant_range_delay=formatvalue((2*SlantRange(Lat,fi(SatLon,Lon))/300),7); return(slant_range_delay); } function GetSkew(SatLon) { var skew,MyCookieVal,Lat,Lon,LatDir,LonDir 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } skew=formatvalue(CalculatedPolTilt(SatLon,Lat,Lon),6); return(skew); } function GetSkewInclined(SatLon,SatLat,r_sat) { var skew,MyCookieVal,Lat,Lon,LatDir,LonDir var Rstation,f,r_eq,r_sat,Ra,Rz,alfa_r,alfa_rx,alfa_ry,alfa_rz,alfa_r_north,alfa_r_zenith,Azimuth,SatLat,TLE_r_sat var tmpstring var satpos_array=new Array(); 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } var Height_over_ocean=0; f=(1/298.257) ; // Earth flattning factor //r_sat=42164.57; // Distance from earth centre to satellite r_eq=6378.14 ; // Earth radius //r_sat=r; //alert("r_sat "+r_sat+" SatLat "+SatLat+" Azimuth"); Rstation= r_eq/( Math.sqrt( 1 - f*(2-f)*Math.sin(Radians(Lat))*Math.sin(Radians(Lat)) ) ) ; Ra= (Rstation+Height_over_ocean)*Math.cos(Radians(Lat)) ; Rz= Rstation*(1-f)*(1-f)*Math.sin(Radians(Lat)); alfa_r=r_sat-Rstation ; alfa_rx=r_sat*Math.cos(Radians(SatLat))*Math.cos(Radians(SatLon-Lon)) -Ra ; alfa_ry=r_sat*Math.cos(Radians(SatLat))*Math.sin(Radians(SatLon-Lon)) ; alfa_rz=r_sat*Math.sin(Radians(SatLat))-Rz; // // **** TRY TO CALCULATE geosenric z for satellitte (lat) and compensate azimuth/Elevation for latitude alfa_r_north=-alfa_rx*Math.sin(Radians(Lat)) + alfa_rz*Math.cos(Radians(Lat)) ; alfa_r_zenith=alfa_rx*Math.cos(Radians(Lat)) +alfa_rz*Math.sin(Radians(Lat)) ; //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 ))); /* */ //skew=formatvalue(CalculatedPolTilt(SatLon,Lat,Lon),6); skew = -Deg(Math.atan( Math.sin(Radians(Lon - SatLon)) / Math.tan(Radians(-Lat+SatLat)) ) ); //skew = Deg(Math.atan( Math.sin(Radians(Lon - SatLon)) / Math.tan(Radians(Lat)) ) ); //skew = Deg(Math.atan( alfa_ry / alfa_rx ) ); //skew=Deg(Math.atan(alfa_ry/alfa_r_north )); //Acos(Cos(LatES-LatSat)*Cos(Lon)) skew= formatvalue(skew,7); return(skew); } function PrintNewDeclination(x,y,z) { var newdecl newdecl=Deg(Math.atan2(z,Math.sqrt(x*x + y*y ) )); //alert(newdecl); return(formatvalue(newdecl,6)); //alert(Azi.toString()); //LookanglesArray } // end function function PrintElevationGeometric(LonSat,Lati,r_sat) { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } // alert(Lat+" "+Lon); // Azi=Azimuth2(LonSat,Lat,Lon,0); //alert(Azi); // alert(Lat+" "+Lon+" "+LookanglesArray[0]); // Azimuth Ele= ElevationGeometric(LonSat,Lat,Lon,0,Lati,r_sat); // Elevation, ok works //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; return(formatvalue(Ele,6)); //alert(Azi.toString()); //LookanglesArray } // end function function PrintElevation(LonSat,Lati,r_sat) { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } // alert(Lat+" "+Lon); // Azi=Azimuth2(LonSat,Lat,Lon,0); //alert(Azi); // alert(Lat+" "+Lon+" "+LookanglesArray[0]); // Azimuth Ele= Elevation2(LonSat,Lat,Lon,0,Lati,r_sat); // Elevation, ok works //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; return(formatvalue(Ele,6)); //alert(Azi.toString()); //LookanglesArray } // end function function BelowHorison(LonSat,Lati,r_sat) { var Lat,Lon,LatDir,LonDir,CookieValue,MyCookieVal,ReturnText var ValArray=new Array(); var SubArray=new Array(); var LookanglesArray=new Array(); var Calibrate_pulsevalue,Calibrate_pulse_per_ha_degree,calibrate_inc_direction var Azi,Ele ReturnText=""; 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]; if (LatDir=="South") Lat=-Lat; Lon=ValArray[2]; LonDir=ValArray[3]; if (LonDir=="West") Lon=360-Lon; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=360-122.42; } Ele= Elevation2(LonSat,Lat,Lon,0,Lati,r_sat); // Elevation, ok works //LookanglesTest=" "+LookanglesArray[0];//+" "+LookanglesArray[1]; if ((1*Ele)>0) ReturnText="" else ReturnText="Satellite below horizon !"; return(ReturnText); } // end function function ReadPositionOld() // Store the selected position in the cookie { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal,Coordinates 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]; Coordinates=formatvalue(Lat,6)+LatDir+formatvalue(Lon,6)+LonDir; //Coordinates="test"; return(Coordinates); } } function ReadPosition() { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Sitename var CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); 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]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=122.42; LonDir="West"; LatDir="North"; } // End function Sitename=ValArray[15]; Coordinates="Selected site: "+Sitename+"
Site coordinates: "+formatvalue(Lat,6)+"°"+LatDir+" "+formatvalue(Lon,6)+"°"+LonDir; //Coordinates="test"; return(Coordinates); } function ReadSiteCoordinates() { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Sitename var CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); 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]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=122.42; LonDir="West"; LatDir="North"; } // End function Sitename=ValArray[15]; Coordinates=formatvalue(Lat,6)+"°"+LatDir+" "+formatvalue(Lon,6)+"°"+LonDir; //Coordinates="test"; return(Coordinates); } function ReadHemisphere() { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Sitename var CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); 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]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=122.42; LonDir="West"; LatDir="North"; } // End function Sitename=ValArray[15]; Coordinates=formatvalue(Lat,6)+"°"+LatDir+" "+formatvalue(Lon,6)+"°"+LonDir; //Coordinates="test"; return(LatDir); } function ReadSiteLocation() { var Lat,Lon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Sitename var CookieValue,MyCookieVal var ValArray=new Array(); var SubArray=new Array(); 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]; } else { // set any Lon,Lat 37.77,-122.42 Lat=37.77; Lon=122.42; LonDir="West"; LatDir="North"; } // End function Sitename=ValArray[15]; Coordinates=Sitename; //Coordinates="test"; return(Coordinates); } 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,timenow var SunData=new Array(3); //**** today = new Date(); Hour= today.getUTCHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); timenow=Hour+(Minute/60) +(Second/(60*60)); Day=today.getUTCDate(); Month=today.getUTCMonth()+1; Year=today.getUTCFullYear(); 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...) // if UT allready passed then calculate for next day //alert(timenow+" "+time); //alert("time="+time+">timenow="+timenow); if (timenow>time) { d=daynumber((Day+1),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+1,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...) Day=Day+1; } 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(d_to_date_and_time(d)+" "+StrHour+":"+StrMinute+":"+StrSecond+" UTC"+"
"); //return(Day+"/"+Month+"/"+Year+" "+StrHour+":"+StrMinute+":"+StrSecond+" UTC"); // date } function get_the_time_for_one_week(Azimuth,SiteLon,SiteLat) { var k,Day,Month,Year,Hour,Minute,Second,today,d_midnight,time,SunData,RA2,Decl,GMST0,StrHour,StrMinute,StrSecond,timenow,NextDay var SunData=new Array(3); var Returverdi Returverdi=""; Returverdi=""; //**** today = new Date(); Hour= today.getUTCHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); timenow=Hour+(Minute/60) +(Second/(60*60)); Day=today.getUTCDate(); Month=today.getUTCMonth()+1; Year=today.getUTCFullYear(); 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...) // if UT allready passed then calculate for next day //alert(timenow+" "+time); //alert("time="+time+">timenow="+timenow); if (timenow>time) NextDay="True"; 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; //Returverdi=Returverdi+d_to_date_and_time(d)+" "+StrHour+":"+StrMinute+":"+StrSecond+" UTC"+"
"; for (i = 0; i <= 14; i++) { if (NextDay=="True") k=i+1 else k=i; d=daynumber((Day+k),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+k,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); 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; if (k%2==0) Returverdi=Returverdi+"" else Returverdi=Returverdi+""; // alert(Returverdi); } Returverdi=Returverdi+"
Sun azimuth equals sat azimuth at:
"+convert_date_time_to_UTC_offet(d_to_date_and_time(d))+""+StrHour+":"+StrMinute+":"+StrSecond+" UTC"+"
"+convert_date_time_to_UTC_offet(d_to_date_and_time(d))+""+StrHour+":"+StrMinute+":"+StrSecond+" UTC"+"
"; return(Returverdi); //return(Day+"/"+Month+"/"+Year+" "+StrHour+":"+StrMinute+":"+StrSecond+" UTC"); // date } function GetSunAtSatAzForMoreDates(SatLon,SatLat,r_sat) { var SiteLat,SiteLon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Az var CookieValue,MyCookieVal,Returverdi var ValArray=new Array(); var SubArray=new Array(); 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 SiteLat=ValArray[0]; LatDir=ValArray[1]; SiteLon=ValArray[2]; LonDir=ValArray[3]; if (LatDir=="South") SiteLat=-SiteLat; LonDir=ValArray[3]; if (LonDir=="West") SiteLon=360-SiteLon; } else { // set any Lon,Lat 37.77,-122.42 SiteLat=37.77; SiteLon=360-122.42; } // End function //sun_at_sat_az_get_more_days(SatLon,SatLat,SiteLon,SiteLat,Height_above_ocean) //Returverdi=sun_at_sat_az_get_more_days(SatLon,SatLat,SiteLon,SiteLat,0,r_sat) ; Az=Azimuth2(SatLon,SiteLat,SiteLon,0,SatLat,r_sat); //Azimuth2(SatLon,SiteLat,SiteLon,Height_over_ocean,SatLat,r) //Returverdi=get_the_time_for_selected_day(,SiteLon,SiteLat) if (Math.abs(SiteLat)<4) Returverdi="Disabled +/-4 degrees close to equator" else Returverdi=get_the_time_for_one_week(Az,SiteLon,SiteLat); return(Returverdi); } function doublefigure(number) { if (number<10) number="0"+number; return(number) } function convert_date_time_to_UTC_offet(dateandtimeinput) { var Hour,Minute,Second,Month,Day,Year,formatteddate,timeoffset today = new Date(); today=dateandtimeinput; Hour= today.getHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; Month= today.getMonth()+1; Day= today.getDate() ; Year= today.getFullYear(); timeoffset=today.getTimezoneOffset()/60; if (timeoffset>0) formatteddate=doublefigure(Day)+"."+doublefigure(Month)+"."+Year+" "+doublefigure(Hour)+":"+doublefigure(Minute)+":"+doublefigure(Second)+" UTC"+(-1*timeoffset) else formatteddate=doublefigure(Day)+"."+doublefigure(Month)+"."+Year+" "+doublefigure(Hour)+":"+doublefigure(Minute)+":"+doublefigure(Second)+" UTC+"+(-1*timeoffset); return(formatteddate); } function testcookie(){ var SiteLat,SiteLon,LatDir,LonDir,CookieValue,MyVal,Coordinates,Az var CookieValue,MyCookieVal,Returverdi var ValArray=new Array(); var SubArray=new Array(); MyCookieVal=document.cookie; alert(MyCookieVal); if (MyCookieVal == "") alert("Empty Cookie"); //alert(isNaN(MyCookieVal)); if (MyCookieVal !== "") // If cookie has value then set users defaults { ValArray=MyCookieVal.split(":"); //' Reads 6 cookie values in to the array SiteLat=ValArray[0]; LatDir=ValArray[1]; SiteLon=ValArray[2]; LonDir=ValArray[3]; if (LatDir=="South") SiteLat=-SiteLat; LonDir=ValArray[3]; if (LonDir=="West") SiteLon=360-SiteLon; } else { // set any Lon,Lat 37.77,-122.42 SiteLat=37.77; SiteLon=360-122.42; alert("Lat"+SiteLat+" SiteLon"+SiteLon); } //isNaN(value) } function sun_at_sat_az_get_more_days(SatLon,SatLat,SiteLon,SiteLat,Height_above_ocean,r_sat) { var i,k,Azimuth,Day,Month,Year,Hour,Minute,Second,today,d_midnight,time,SunData,RA2,Decl,GMST0,StrHour,StrMinute,StrSecond var SunData=new Array(3); var timetoprint var numberofdays,SatDir var listing,SatLonWest,RealDate,RealYear,SunOffset,SatElevation,SunElevation k=0; RealDate = new Date(); RealYear=RealDate.getYear(); // error in SiteLon when SiteLon is West SatLonWest=360-SatLon; alert("TEST"); numberofdays=10; Azimuth=Azimuth2(SatLon,SiteLat,SiteLon,0,SatLat,r_sat); // Azi=Azimuth2(LonSat,Lat,Lon,0,Lati,r_sat); listing=""; today = new Date(); Day=today.getUTCDate(); Month=today.getUTCMonth()+1; Year=today.getUTCFullYear(); Hour= today.getHours() ; Minute=today.getMinutes() ; Second=today.getSeconds() ; //Month= today.getMonth()+1; //Day= today.getDate() ; //Year= today.getYear(); for (i = 0; i <= 7; 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); 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; } // for return(listing); } 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 */