Jump to content
Sign in to follow this  
Guest

Sun elevation

Recommended Posts

Guest bartels

The sun elevation angle is the angle of the sun over the local horizon at a certain time.Assumed is spring begin at the 80th day of year (21 March) and an average yearlength of 365.25 days. Individual year lengths and spring shifts are neglected. In first order approximation the earth orbit is circular.To get the local "sun" time, GMT and the longitude is needed:localsuntime=zulutime+longitude*24/360=zulutime+longitude/15The "real" local time can't be used, because of the timezones that attach the same time for a whole stretch of longitudes (ideal 15

Share this post


Link to post
Share on other sites
Guest bartels

In principle it is:%( (* zulutime+longitude/15 *)(P:ZULU TIME,hours) (A:PLANE LONGITUDE, degrees) 15 / + (* (7.3*sin((dayofyear-3)/365.25*360) *)(P:ZULU DAY OF YEAR,number) 3 - 365.25 / 2.0 pi * * sin 7.3 * (* -9.8*sin((dayofyear-80)/365.25*720)) *)(P:ZULU DAY OF YEAR,number) 80 - 365.25 / 4.0 pi * * sin -9.8 * + 60 / - (>L:local_sun_time,number) (* 23.5*sin((dayofyear-80)/365.25*360) *)(P:ZULU DAY OF YEAR,number) 80 - 365.25 / 2.0 pi * * sin 23.5 *(* (abs(lat)-90)*cos(localsuntime/24*360) *)(L:local_sun_time,number) 24.0 / 2.0 pi * * cos90 (A:PLANE LATITUDE, degrees) abs - *(A:PLANE LATITUDE, degrees) 0 > if{ - } els{ + }(>L:local_sun_angle,number)(L:local_sun_angle,number))%!.4f!but I have my doubts, if FS does handle it this way. There are differences at about +- 3

Share this post


Link to post
Share on other sites
Guest

Sheesh! :)Thanks Arne... I'll have to digest this awhile before moving forward. Hopefully FS2k2 will be able to 'calculate' this quicker that it took to type it it!I'll have to try this in a gauge and then see if the calculated L:local_sun_angle,number will be useful as a trigger for a boolean operation.BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites
Guest Fabio Miguez

Makes good sense, Arne. Thanks for taking the time.

Share this post


Link to post
Share on other sites

Arne,Question:What does ** mean?, cuadratic equation? (like x2)Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest bartels

No it doesn't. You can use sqr for this. The two * * are two seperate multiplication, one after the other.BTW. my results are not really good. I have to think about it again, maybe it's wrong to apply the eccentric approximation, which is astronomically correct for the shift of the midday line, to the dusk/dawn time. Or I'm totally wrong. Or MS's astronomy differs from real world, I don't know.Arne Bartels

Share this post


Link to post
Share on other sites
Guest

I guess Microsoft atronomy differs from real world in that the earth is a cylinder instead of a sphere :) Not sure though, but it seems to be this way due to the massive rendering errors close to the poles, although the starmap doesn't seem to suffer this problem; the north star is where it is supposed to be :DEarth orbit eccentricity and earth radius variation I think is not significant in this calculation.Thanks for the formulas, I now know in which direction to look, my earlier attempts where, err, somewhat different :)

Share this post


Link to post
Share on other sites

Hi,Tested it at several places and times, it looks good.Using:(L:local_sun_angle,number).> if{ (>K:.) }works of course.(I put the big formulas elsewhere)Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest

>Tested it at several places and times, it looks good.>Using:>>(L:local_sun_angle,number).> if{ (>K:.) }>>works of course.>>(I put the big formulas elsewhere)Jan, could you post the .xml as an attachment, or send it to me at n4gix@attbi.com?I simply don't have enough time to figure out why I cannot get anthing other than 51.0502 to display... :)I just need something that will toggle a K_Event on/off approximately at sunrise and sunset...TIABillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites

Frather,Here it is, but all credits to Arne.The first one i have put in a "store-file" with other difficult formulas. (P:ZULU TIME,hours) (A:PLANE LONGITUDE, degrees) 15 / + (P:ZULU DAY OF YEAR,number) 3 - 365.25 / 2.0 pi * * sin 7.3 *(P:ZULU DAY OF YEAR,number) 80 - 365.25 / 4.0 pi * * sin -9.8 * + 60 / - (>L:local_sun_time,number) (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 2.0 pi * * sin 23.5 *(L:local_sun_time,number) 24.0 / 2.0 pi * * cos90 (A:PLANE LATITUDE, degrees) abs - *(A:PLANE LATITUDE, degrees) 0 > if{ - } els{ + }(>L:local_sun_angle,number)The last one you can use anywhere as an invisible gauge.(L:local_sun_angle,number) 10 < (A:Anything etc.) && if{ (>K:Anything etc.) }I think _ON, _OFF ans _SET commands works best.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest

Thank you Jan and Arne!Part of the problem I had was splicing the formula back together to eliminate the "carriage returns" and eliminate thepesky 'spaces' that seem to creep into the formula at unexpected places... :)Now I have a nice little 'counter' displaying on a test gauge that is busy reporting the results of the calculation in 'real time.' When I get back from $job this afternoon I'll set up the 'autoswitch' I need to control the 'daytime' 3d panel lighting. It will be so nice to have a brightly illuminated 3d panel that won't be so drastically affected by the sun's relative position to the a/c's position.MS seems to have grossly "overmodeled" the shading effects of the sun's position in the 3d cockpit, and fx lighting will overcome this fault. This 'autoswitch' will eliminate the need for the pilot to turn the fx OFF manually. It is really TOO bright at night and destroys the carefully crafted panel lighting already developed. :)It didn't have to be "perfect;" simply consistent and approximate is good enough!BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites
Guest

Perhaps I'm just too slow to figure this out (or else too tired!), but I cannot seem to get this to work as I need it to... The problem is with the last statement. If I set the conditional to = 10, the K_Event will not be triggered because the calculated value is never EXACTLY equal to 10.If I set the conditional to < 10, then the K_Event will be continuously triggered on/off!!!How can I specify that I only want the K_Event to trigger ONCE each time the L:local_sun_angle is less than X degrees?Do I need to set G:Var1 and check for both conditions?In other words, if L:local_sun_angle,number < 10 AND G:Var1,bool == 1, THEN (>K:TOGGLE_XXX) (>G:Var1) ??? (P:ZULU TIME,hours) (A:PLANE LONGITUDE,degrees) 15 / + (P:ZULU DAY OF YEAR,number) 3 - 365.25 / 2.0 pi * * sin 7.3 * (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 4.0 pi * * sin -9.8 * + 60 / - (>L:local_sun_time,number) (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 2.0 pi * * sin 23.5 * (L:local_sun_time,number) 24.0 / 2.0 pi * * cos 90 (A:PLANE LATITUDE, degrees) abs - * (A:PLANE LATITUDE, degrees) 0 > if{ - }els{ + }(>L:local_sun_angle,number) %(L:local_sun_angle,number)%!.4f!(L:local_sun_angle,number) 10 == if{ (>K:PANEL_LIGHTS_TOGGLE) 0 (>K:TOGGLE_AFTERBURNER1) }BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites

Frather Bill,Hope you had a good night sleep, i didn't because of my job.I use this one and i shall explain, what happens.(L:panellights,bool) 0 == (L:local_sun_angle,number) 10 < && if{ (L:panellights,bool) ! (>L:panellights,bool) }(L:panellights,bool) 1 == (L:local_sun_angle,number) 10 > && if{ (L:panellights,bool) ! (>L:panellights,bool) }There is a switch in the panel (L:panellights,bool).When (L:local_sun_angle,number) is > 10 (other numbers as well) the switch automaticaly goes off.When (L:local_sun_angle,number) is < 10 the switch automaticaly comes on, independant of her position (on/off), but it is not possible to switch it manually. I think i have to work on that.Adding another variable (L:auto,bool) works ok, but i don't need that one.May be you can do something with this.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest

>Frather Bill,>>Hope you had a good night sleep, i didn't because of my job.>I use this one and i shall explain, what happens.Jan, I fully understand how it is *supposed* to work, yet the fact remains that it will not work here for some strange and inexplicable reason! :( (P:ZULU TIME,hours) (A:PLANE LONGITUDE,degrees) 15 / + (P:ZULU DAY OF YEAR,number) 3 - 365.25 / 2.0 pi * * sin 7.3 * (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 4.0 pi * * sin -9.8 * + 60 / - (>L:local_sun_time,number) (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 2.0 pi * * sin 23.5 * (L:local_sun_time,number) 24.0 / 2.0 pi * * cos 90 (A:PLANE LATITUDE, degrees) abs - * (A:PLANE LATITUDE, degrees) 0 > if{ - }els{ + }(>L:local_sun_angle) %(L:local_sun_angle, number)%!.4f!(A:Light Nav, bool) 1 == (L:local_sun_angle, number) 10 < && if{ (K:TOGGLE_NAV_LIGHTS) ! (>K:TOGGLE_NAV_LIGHTS) } (A:Light Nav, bool) 0 == (L:local_sun_angle, number) 10 > && if{ (K:TOGGLE_NAV_LIGHTS) ! (>K:TOGGLE_NAV_LIGHTS) }I can SEE the bloody variable L:local_sun_angle, number) counting downwards, yet when it passes 10, nothing happens!What DOES HAPPEN is that the Nav lights are locked ON, and do not toggle OFF whenever L:local_sun_angle, number is less than 10, which simply tells me that for some reason the computed value is NOT changing in the statement, even though it IS clearly changing in the function's display... BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites
Guest

OK, another test has proven that there is still something terribly wrong with my formula.I created another small display gauge that does nothing more than display the L:local_sun_angle, number variable, and it is reporting all ZEROS... Clearly then, there is a syntax error in this formula, but I'll be darned if I can spot it! :( (P:ZULU TIME,hours) (A:PLANE LONGITUDE,degrees) 15 / + (P:ZULU DAY OF YEAR,number) 3 - 365.25 / 2.0 pi * * sin 7.3 * (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 4.0 pi * * sin -9.8 * + 60 / - (>L:local_sun_time,number) (P:ZULU DAY OF YEAR,number) 80 - 365.25 / 2.0 pi * * sin 23.5 * (L:local_sun_time,number) 24.0 / 2.0 pi * * cos 90 (A:PLANE LATITUDE, degrees) abs - * (A:PLANE LATITUDE, degrees) 0 > if{ - }els{ + }(>L:local_sun_angle) As I've said, I have the display in the 'main gauge' working and it *does* display a countdown/up of angles from 0 to 90 degrees, but for some reason that I cannot find is not actually assigning the value to the L: variable.BTW, it makes no difference whatever if I use (>L:local_sun_angle,number) or simply (>L:local_sun_angle) in the formula.BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...