Open Raviu56 opened 1 year ago
I should add my personal experience here: I've monitored the Sunrise many times from my house of 450m elevation above sea level, and it's almost always 4 to 5 minutes before Sunrise calculated by most applications and online sites for my location.
Thats an interesting observation. Generally speaking if you're at a high elevation you can expect to see sunrise/sunset times change by about 1 minute for every 1600 meters.
There has been a lot of requests to do this, I will look into how we will do it correctly. I believe what may be needed to implement this is both the elevation of the user and the elevation of the horizon. It would be wrong if developers simply supplied the user's elevation and assumed that was enough to change sunrise/sunset. (see https://public.nrao.edu/ask/altitude-correction-for-time-of-sunrise-and-sunset/)
Just because another library gives the option for elevation with no explanation does not mean that is more accurate. If we implement this we will need to do it in a way that makes it very clear to the developer that both elevations are needed (user and horizon) - which is very hard to know unless you have topographical data not just GPS coordinates.
The developer would essentially need to use an API like https://developers.google.com/maps/documentation/elevation/start to get the elevation of the horizon. This could be further complicated by needing to know the horizon elevation for both sunrise and sunset, if we look at the use case of Morocco it has sea level to the West but a mountain range to the East.
If we look at the wikipedia page on the sunrise equation (https://en.wikipedia.org/wiki/Sunrise_equation#Hour_angle) they state the same thing, that elevation correction assumes that the horizon is sea level which is not true outside of airplanes, towers, etc.
@z3bi Thanks brother , I've done my some further research for the horizon issue and I came to a conclusion that the horizon elevation could (or better) or in some cases (like in narrow valleys) should be neglected.
Please see this fatwa https://islamqa.info/ar/answers/365222/ And also the attached pdf - which I've just read for the 1st time-
You can see in the pdf that Sunrise time at 500m altitude 3 minutes after sea level at South KSA where he mentioned should be 1 plus minutes at North KSA and would always increase with latitude and differ between different seasons. Which made me assured that my personal observation was correct. مشكلة دخول وقت صلاة المغرب في المواقع الجبلية المرتفعة.pdf
Thank you for this information but this fatawa is for the opposite problem. People who are at a lower elevation than the horizon and the fatwa is to ignore the hills on the horizon. For adjusting sunrise and sunset based on a user having a higher elevation we HAVE to have the horizon elevation otherwise we are just making up an incorrect number. What the adjustment is accounting for is that we are able to see the rays of sun sooner for sunrise and longer for sunset and that 100% depends on understanding the horizon.
Also based on physics it’s not possible for sunrise/sunset to change more than 1 minute per every 1600 meters. If you have astronomical calculations to suggest otherwise please share them.
Earth is not a perfect sphere, I think the 1 minute difference for every 1600m is assumed at equator only and not from 0 to 1600m, but for higher altitudes like if you go up from 3000 to 4600m - however not sure as I did not get a good resource about this specific info.
However I've found a good resource from astronomy center where I find also that they have a calculation program, I did not test it yet, but they state in the program page that:
Elevation: Times of sunrise and sunset at a site that is 1000 meters above sea-level for example, will be different than those at sea-level. The Sun rises at a site which is 1000 meter above sea-level, well before it does so at a site located at sea-level. While it sets at the elevated site after it does so at sea-level. At 1000 meters above sea-level, the average difference is somewhere between 5-13 minutes (Depending on the location's latitude).
Could be found on archive as website is currently down:
https://web.archive.org/web/20221129145023/https://www.astronomycenter.net/accut.html?l=en
So I investigated the github repo you posted above and saw they are using the Time4J library. Looking at the source code I see that when the altitude of the user is given, it's applied to sunrise and sunset to adjust the "apparent solar altitude".
The sunrise and sunset equations actually compute when the center of the sun is at the horizon, however we want to know when the tip of the sun first becomes visible (sunrise) or fully disappears (sunset). The solar altitude normally used is 50'. We get this value by adding the radius of the sun 16' with the atmospheric refraction of 34' (how the light bends over the horizon). This value for atmospheric refraction assumes average atmospheric conditions and temperatures.
Time4J adjusts the apparent solar altitude angle in two different ways:
They adjust the atmospheric refraction value to account for the different pressure and average temperature at a higher altitude (code). This adjustment (while minor) should increase accuracy and can be applied without knowing any information about the horizon.
Using the radius of the Earth, they calculate how far below the horizon you are able to see due to your current elevation (code). This adjustment absolutely assumes that either the horizon is at sea level or that the elevation supplied is the difference between the elevation of the horizon and the user's elevation. Otherwise we can see with simple geometry that this adjustment would be wrong if we don't take into account the elevation of the horizon.
Consider the use case of the city of Denver, Colorado. This city has an altitude of 5,000 ft above sea level. But the entire city is at that elevation, not just a single point. So when you look to the horizon, that horizon is also at 5,000 ft above sea level. This means you are not gaining any ability to see below the horizon.
We can add in the same kinds of adjustment to the adhan library, but we will absolutely need the developer to supply the altitude at the horizon to ensure accuracy.
Jazaku Allahu khayran for clarification.
But What if the horizon altitude is higher than the user's location altitude? What if it's much higher that a significant time difference can occur?
Should we account for horizon altitude as long as it's of same or less than elevation of the user's elevation? So a horizon_alt = min(user_alt,horizon_alt)
?
We can assume that horizon altitude is at sea level by default. As "Accurate Times" of astronomycenter assumes.
Also, you can embed any suitable atmospheric model to compensate for different air properties temprature/pressure/density for a give location and altitude for standard case. Some models allow to correct for latitude and day-of-year (or season) for better accuracy. Some are shown in this python project https://github.com/lcx366/ATMOS
Finally astronomycenter website is back online, they have a very good page on calculating prayer times with equations but it was missing on archive , - now it's saved there -
https://www.astronomycenter.net/article/2001_salat.html
Archived version https://web.archive.org/web/20230301091546/https://www.astronomycenter.net/article/2001_salat.html
They have different notes and equations in the page for elevations and horizon issue. Better to read them there.
@Raviu56 alhamdulillah it seems they confirm what I have been saying
2- أن يكون أفق المنطقة الواقعة فوق مستوى سطح البحر يقع على نفس ارتفاع المنطقة، ومثل هذا ينطبق على الهضاب الواسعة، فقد يكون ارتفاع المنطقة 500 م فوق مستوى سطح البحر مثلا، إلا أن جميع المنطقة المحيطة بها تقع على نفس هذا الارتفاع، فالمنظر بالنسبة للراصد مستوي، وفي هذه الحالة فإن الارتفاع عن مستوى سطح البحر لا يؤثر على وقت الشروق أو الغروب، أي أنه يجب اعتبار المنطقة واقعة على مستوى سطح البحر.
2- That the horizon of the area located above sea level is located at the same height as the area, and the same applies to wide plateaus. The observer has a level, and in this case, the height above sea level does not affect the time of sunrise or sunset, meaning that the area must be considered as being at sea level.
Based on this I think the plan of adding a parameter for the horizon altitude makes sense
@z3bi Yes, I've read the whole article and I did not quote anything specific because I think all useful and relevant. Like the paragraph you mentioned, atmospheric conditions and issue number 7-2 too. I think you can you can try to contact them, maybe they can share their experience here too. Better you do so as I've no experience with prayer times equations.
What I understand from the whole article is that:
@Raviu56 I agree with points 1-3 but I'm not sure I agree that assuming a sea level horizon is correct (also Asr prayer doesn't change at all based on altitude)
For AlAsr I mean the end/final/maximum time which is just before AlMaghrib. You know every Prayer time has Begin and End time, Why would we care for Sunrise time? Because it's the end time for AlFajr prayer. Also Sunset is the end time for AlAsr prayer, think of some one on a travel or cannot find water so he planned delaying AlAsr prayer just before Sunset. If Sunset time is extended further than it should, he would get praying AlAsr after its time. (Same issue for AlFajr with Sunrise)
For AlAsr I mean the end/final/maximum time which is just before AlMaghrib. You know every Prayer time has Begin and End time, Why would we care for Sunrise time? Because it's the end time for AlFajr prayer. Also Sunset is the end time for AlAsr prayer, think of some one on a travel or cannot find water so he planned delaying AlAsr prayer just before Sunset. If Sunset time is extended further than it should, he would get praying AlAsr after its time. (Same issue for AlFajr with Sunrise)
ok that makes sense
Ok, let me explain why I think assuming sea level horizon would be a failsafe option (a horizon altitude option should be added but in case it's unknown/undetermined) If you go back to fatwa I've mentioned before - archived version let me pick these quotes from it:
من كان يسكن في الأودية المنخفضة أو خلف الجبال فإنه يستدل على طلوع الشمس بوجود أشعتها التي تنعكس على الأجسام في الجهة الغربية.
قال في "حاشية الطحطاوي الحنفي"، ص328: " قوله: "وطلوع الشمس في الفجر" : ليس المراد أن ينظر إلى القرص، بل إذا رأى الشعاع الذي لو لم يكن ثمة جبل يمنعه، لرأى القرص" انتهى.
قال ابن دقيق العيد: " وَالْأَمَاكِنُ تَخْتَلِفُ ، فَمَا كَانَ مِنْهَا فِيهِ حَائِلٌ بَيْنَ الرَّائِي وَبَيْنَ قُرْصِ الشَّمْسِ : لَمْ يَكْتَفِ بِغَيْبُوبَةِ الْقُرْصِ عَنْ الْأَعْيُنِ ، وَيُسْتَدَلُّ عَلَى غُرُوبِهَا بِطُلُوعِ اللَّيْلِ مِنْ الْمَشْرِقِ" انتهى من "إحكام الأحكام"(1/166).
وقال النفراوي في "الفواكه الدواني" (1/168): " مَا ذَكَرَهُ الْمُصَنِّفُ مِنْ أَنَّ وَقْتَ الْمَغْرِبِ: غُرُوبُ الشَّمْسِ، إنَّمَا هُوَ بِالنِّسْبَةِ لِمَنْ يَكُونُ فِي رُءُوسِ الْجِبَالِ، أَوْ فِي فَلَاةٍ مِنْ الْأَرْضِ.
وَأَمَّا مَنْ يَكُونُ خَلْفَ الْجِبَالِ: فَلَا يُعَوِّلُ عَلَى غُرُوبِ الشَّمْسِ، وَإِنَّمَا يُعَوِّلُ عَلَى إقْبَالِ الظُّلْمَةِ مِنْ جِهَةِ الْمَشْرِقِ، فَإِذَا ظَهَرَتْ، كَانَ دَلِيلًا عَلَى مَغِيبِهَا، فَيُصَلِّي وَيُفْطِرُ" انتهى.
وقال الرملي في "نهاية المحتاج" (1/366): " ويعرف الغروب في العمران بزوال الشعاع عن أعلى الحيطان، وفي الجبال عن أعلاها، وإقبال الظلام من المشرق" انتهى.
So suppose that someone who would try to apply those sentences is monitoring Sunset with a some mountains both to the east and the west with different random altitudes, he would be looking the mountains' top tips on the East side until all Sun rays disappear, this would in many cases mean it would be like monitoring from the top of the eastern mountain with steeper angle.
Also look for this sentence which is about Sunset إقبال الظلام من المشرق
, suppose low or no mountains to the East, only to the West , so he has to look on the opposite side - the East horizon - and make sure darkness is there, .. I'm sure this means Sun would have set below sea level horizon on most cases.
I've carefully read your comment before about this fatwa, just please re-read it carefully as I'm sure the quotes mentioned in it are still relevant and it says when in doubt one should be in safe side , which in our case to consider sea level horizon so safer for Fajr and Maghrib - and iftar in Ramadan, which I think is valid for most cases except for the case you mentioned where a city is located on a high plateau that extends to the horizon.
Please also read those fatwas carefully. I think unless it's an extended plateau, horizon level should be considered to be at sea level. As in many cases there are multiple valleys and mountains of different altitudes to either sides.
https://islamqa.info/ar/answers/232822 - archived
It mentions this hadith and many quotes explaining the cases of mountains underneath
وقال النبي صلى الله عليه وسلم : ( إِذَا أَقْبَلَ اللَّيْلُ مِنْ هَا هُنَا [يعني : جهة المشرق] ، وَأَدْبَرَ النَّهَارُ مِنْ هَا هُنَا [يعني : جهة المغرب]، وَغَرَبَتْ الشَّمْسُ : فَقَدْ أَفْطَرَ الصَّائِمُ ) رواه البخاري (1954) ، ومسلم (1100) .
And this fatwa too https://islamqa.info/ar/answers/93148 - archived
@Raviu56 I have read through these and I still don't see a justification for pretending the horizon is at sea level. Mountains are an obstruction of the horizon and are special cases. A plateau has a true horizon and shouldn't be ignored. Ultimately the app developer can choose to supply a horizon altitude of 0 if they believe that is the right choice. But as a library we will not be defaulting any values since that will only serve to hide how this actually works.
Cannot wait to see this implemented :)
May Allah be with you
I haven't read these carefully, but does it mean there's 2 horizon altitudes to consider ? one for west and one for east ? (does mountain change altitude of horizon?)
this website https://www.muwaqqit.com/ takes elevation into consideration and some other factors, there is some technical documentation available.
Assalamo alaykom, Jazakum Allahu khayran for your library. I see this is not a duplicate of previous altitude closed issues. As one has been discussing Aeroplane altitudes. And for the other it was very old and I'm introducing more info.
There is one problem that most Prayer times app does not take into account which is Altitude/elevation above sea level of the location point. This is really a big problem and can make difference of minutes of prayer time. The app assumes everything is at sea level which is not the case usually. Consider those 2 locations:
36.34444/30.12013/~35m 36.33877/30.05053/~1650m
Distance between them is around 6300m while elevation difference is over 1600m which diffidently should have much effect on prayer time.
You can watch this video in Arabic language
https://www.youtube.com/watch?v=yIaVmmRXLcI
I think you should seek help from https://www.astronomycenter.net/ on how to take elevations into account
I've seen your comments here https://github.com/batoulapps/adhan-js/issues/126#issuecomment-1213634448 and here https://github.com/batoulapps/adhan-js/issues/16#issuecomment-640287803
The solution for your comment is simply a simply option to enable/disable elevation correction.
Check this application, please, it's for Sunrise and Sunset time calculations. Its default calculation method called time4a-time4j takes elevation into account and you can with simple click turn on/off elevation and see how much it affects Sunrise/Sunset times . You can make use of its code and calculations used too.
https://github.com/forrestguice/SuntimesWidget
You know for AlFajr prayer time, it's limited by Sunrise, and many people could wake-up few minutes before Sunrise and actually there can miss it if they depend on a calculation method that does not consider elevation/altitude
I should add my personal experience here: I've monitored the Sunrise many times from my house of 450m elevation above sea level, and it's almost always 4 to 5 minutes before Sunrise calculated by most applications and online sites for my location.
This is actually too much. When I used the mention Suntimes app it has shown very accurate results compared to most prayer times apps and compensated for those 4 minutes.