-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the prayer times calculations #2
Comments
I think the only calculation that differs from that document is Asr, and I have fixed that in my pull request #3 all of the others seem to be fine. |
I live in the Netherlands and I see that the times reported by ITL differ from the calendar used by the local mosques for all prayers by 2+ minutes. I think that the source of error is the method used to compute the Sun coordinates. The current astro.h/.c use the method from Jean Meeus book in 1998. That method uses huge tables. The US Naval Observatory (USNO) released an approximate algorithm for calculating the Sun coordinates (see http://aa.usno.navy.mil/faq/docs/SunApprox.php). I would propose that we replace astro.c/.h with simple and easy-to-maintain method to determine the Sun coordinates. |
Go ahead and try it Mohamed. If the USNO algorithm implementation gives more accurate timings than the old method, then we'll use it in lieu of the old one. |
Hi arabeyes, |
No idea. I am not the original project owner and this isn't really my field of expertise. Is this program developed by NASA itself, or someone else did it based on NASA's almanac? If it is the latter, we should perhaps double-check it to make sure it contains no mistakes. |
Salam, |
Wa alikom alsalam haqman, I agree that local mosques are not a proper reference point. However, we can use the official calendars used in Islamic countries as the reference point. |
Hi Mr. @mohamed, |
Salam abdelhak, |
Hi, @mohamed After I saw the code of the current pray times implementation of ITL, I think that in your case it require more inputs to perform the exact results, because as you can see at the "Location" structure, it had three extras fields "temperature", "pressure" and "seaLevel", try to change the default values, if you get wrong results for your location, the new implementation will be the best one 👍 |
Was this implementation finished or is any work needed to help test? |
If the sun coordinates could be calculated would there be a need at all for the different calculation methods (ISNA, MWL, etc.) since those only differ in the sun angle for Fajr and Isha? If the angle could be dynamically calculated based on lat/lng to some accuracy than wouldn't that be better than these methods and provide the ability to make a "one formula" that would be "most accurate"? If this can be implemented it is an exciting proposition and I would like to port to JavaScript to stop using praytimes.org inshaa' Allah |
Assalam 3alaykom my brother @alisalaah, of course, the sun coordinates (sun declination) can be calculated, but for the lat/long depended zenith angle I don't know! |
I already have a Javascript library that works but with the 6 methods "trying" to get the times.. I would port this library if it had a sun angle algorithm that offered a one calculation for all locations and better accuracy. Otherwise I'll hold off inshaa' Allah |
Yes of course, in my pyIslam library, all calculations depend on: |
I'm not sure we have determined if calculating things like the declination of the sun is better than the current table of values. I don't think we should make this change unless we can say for certain that calculating these values is more accurate. Honestly, I feel like the table is less error prone as the calculation will lose precision due to floating point math. |
Is there an endorsed global table/map of when to use which calculation for On Fri, Jul 11, 2014 at 11:30 PM, Ameir Al-Zoubi notifications@github.com
|
@alisalaah I don't think there is any official table of which method to use for a particular country. As with any Fiqh issue there will always be multiple opinions. My suggestion is to start an open source listing of the most common method for different countries. This could potentially be a component of this project or perhaps a separate repo. We could then compile this list and verify each addition with a valid source, eventually we would be able to have a comprehensive list inshAllah. |
Is the only difference per each method the Fajr and Isha angles? Could we I haven't studied the different methods in detail but could we do something
|
http://moonsighting.com/how-we.html On Tue, Jul 15, 2014 at 9:53 PM, Ali Camarata alisalaah@gmail.com wrote:
|
Alsalam alikom all, |
Thank you for the work on this. I will try to help in creating some test cases so we can verify the new calculations against the existing ones. |
@mohamed I left a few comments on your pull request based on a quick glance, I will try to do a more thorough review soon inshAllah. |
Thanks a lot Ameir! I will look into them and update the code accordingly. |
@mohamed I've been using the new_method code with actual prayer time applications and I have a few comments/suggestions. The idea of "config" files are good for testing, but for practically using this as a library, it also needs a good programmatic interface. This will most likely be how most people interact with this code. Specifically, the way you set a date is not ideal. The previous code had a struct with year, month, day which was very easy to use. I recommend doing something similar. It also doesn't make sense to use round DOWN or round UP. Turning 5:29:01 into 5:30 or 5:29:59 into 5:29 is a big difference. It would be safer to use normal rounding, that way at most the difference is 29 seconds. For the dhuhr safety margin you are currently adding, it is based on the third definition of this page http://praytimes.org/wiki/A_note_on_Dhuhr but if you look at the first two fiqh definitions, a safety margin is not needed. Perhaps the dhuhr safety margin can be something set, a boolean to decide whether or not to include it. Based on my earlier comment about the programmatic interface I would suggest making the location struct contain location information only (latitude, longitude, altitude, timezone) and then having another struct with all the configuration info (method, madhab, extreme, etc) and then similar to the current library there should be a method to populate the config struct with the default values. My last comment right now is that it does not build on Mac OS X as it errors out on the redefining of the "round" function. |
@ameiralzoubi I am glad that someone is taking a careful look to the code! 👍 |
I will work on that inshAllah and add in the ability for custom angles. |
I implemented the USNO for a globally accurate single dynamic formula at http://praycalc.com which is also on my github (written in JavaScript for Meteor, based on the SunCalc (USNO formula) which does most the work). |
Alsalam alikom Ali, Thanks a lot for the link. Did you implement the extreme latitude methods? That's the only missing thing now from my USNO implementation. I didn't have time to go and study the equations and methods used in the extreme latitude calculations so an existing clean implementation is highly valuable. |
No, I haven't done that yet due to time but it should be easy. The current methods return times due to the inaccuracy of static angles and the USNO would return null because the twilights never actual happen, which we know. According to fiqh you should go by the time of the nearest place that has these times in reality. All that needs to be done is, if Fajr is null, then loop calculating Fajr again but subtract .1 from the latitude until you get a result. Then display the result (maybe with a * to show it's derived this way). Same for Isha or Maghrib. |
If anyone on this thread is interested, I created a new prayer time library https://github.com/batoulapps/Adhan All astronomical equations have been implemented from scratch directly from the book "Astronomical Algorithms", it has an official implementation in Swift and JavaScript with Python and Java in progress. It also features an extensive set of unit tests as well as worldwide location testing.x |
How does it compare with libITL? I need to remove C++ dependency from munadi.org and have one app for both web and native!
|
@haqman the main differences is that in Adhan we re-implemented all the astronomical equations from scratch using a widely recognized book on astronomical calculations. Every equation is cited back to the book and has unit tests using values from the book. In addition we will be adding suggested methods for a location very soon. Right now we are collecting data to use for automated testing and to help determine the best method for a particular location. |
If using the NOAA, etc. algorithms there should be no need for "calculation On Mon, Apr 11, 2016 at 8:12 PM, زعبي notifications@github.com wrote:
|
@alisalaah the astronomical equations can give you precise values for sunrise, sunset, transit and whatever hour angle you ask it for. However, the challenge is still finding the visual appearance and disappearance of twilight (the basis for fajr and isha) which have a lot of variation based on light refraction. In addition, safeguards are put in place not just for null values, but to account for "hardship". An isha time of 11:45 PM and a fajr time of 1:30 AM are not reasonable, in these situations a comprise is used (such as using the more favorable time of 1/7 of the night). |
@z3bi Are you planning to have an implementation in C? |
@mohamed right now we don't have a plan to write a version in C but we would gladly accept a pull request if someone was interested in doing it. The large number of unit tests should make it easier to stay consistent when porting to a new language. |
The methods used in prayertime are a bit old and do not reflect the prayer times reported by most modern prayer times tools. I am working on a "clean-room" implementation of prayertime which is based on the theory given in http://praytimes.org/calculation/
The text was updated successfully, but these errors were encountered: