batoulapps / adhan-js

High precision Islamic prayer time library for JavaScript
MIT License
385 stars 86 forks source link

Altitude #16

Closed kafiln closed 4 years ago

kafiln commented 4 years ago

Does the variation of the altitude from a city to another change the results ?

z3bi commented 4 years ago

It does but it’s extremely minor. It takes about 5,000 ft of elevation to add 1 minute to sunset time.

That could be something to add to the library though.

kafiln commented 4 years ago

What are the other parameters that can change the results that are not taken into consideration by this library ?

z3bi commented 4 years ago

Elevation is the only thing that I am aware of.

ench0 commented 4 years ago

Here's another vote for elevation. This app claims to have 'high precision', so it would be great to stay true to its word :-). One minute difference can mean a lot when using rounding.

kafiln commented 4 years ago

@ench0 maybe you could help with a PR :)

ench0 commented 4 years ago

@ench0 maybe you could help with a PR :)

I will try, still reading Meeus' book and trying to get to understand some of the concepts. Altitude seems to be mentioned mostly in terms of celestial bodies. There are also other variables, like pressure, humidity and Sun's refraction, not sure if that is considered in this app.

z3bi commented 4 years ago

Altitude is tricky as it only has an effect when the altitude of the observer differs from the altitude of the horizon, for example being on mountain peak. But if the city you live in has a high altitude in all locations it has no effect.

Here is a good explanation of the apparent effects of altitude on sunrise https://astronomy.stackexchange.com/questions/24632/how-do-i-adjust-the-sunrise-equation-to-account-for-elevation

One thing I did want to look at adding is light refraction. As you mentioned @ench0 atmospheric pressure and temperature can effect refraction but in the book it mentions that the level of precision at that point is mostly unnecessary. I think adding in the calculation for light refraction at an average pressure and temperature might be a good first attempt.

ench0 commented 4 years ago

I hope you don't mind, I ported your library to Dart programming language. I use it in several projects that I work on. I will be doing some testing and hopefully could contribute back. There are a lot of calculation methods out there and I think we really need scientifically proven one to stand out.

z3bi commented 4 years ago

@ench0 that sounds great! If you have an exact port of all the equations let me know and we can add it to the list of ports here https://github.com/batoulapps/adhan

Contributions are always appreciated!

ench0 commented 4 years ago

@ench0 that sounds great! If you have an exact port of all the equations let me know and we can add it to the list of ports here https://github.com/batoulapps/adhan

Contributions are always appreciated!

Currently it uses different approach in class naming, but I can create a fork that follows Adhan exactly. I will update it in next few days.

ench0 commented 4 years ago

Available now, pending testing. If everything checks, I will upload to Dart's package repository.

https://github.com/prayer-timetable/adhan_dart

z3bi commented 4 years ago

@smartazanclock if you look at the praytimes description of altitude they say "If the observer's location is higher than the surrounding terrain".

As I mentioned above, altitude should only be taken into account IF the horizon is at a different altitude than the observer. What makes an effect on the observed sunrise/sunset times is the difference in elevation between the observer and the horizon.

This is a difficult thing to know and requires a more in-depth topological understanding of the area.

z3bi commented 4 years ago

Available now, pending testing. If everything checks, I will upload to Dart's package repository.

https://github.com/prayer-timetable/adhan_dart

Excellent job mashAllah. I would recommend adding the same unit tests that adhan has. They are very comprehensive and help to double check none of the equation values are off.

ench0 commented 4 years ago

Available now, pending testing. If everything checks, I will upload to Dart's package repository. https://github.com/prayer-timetable/adhan_dart

Excellent job mashAllah. I would recommend adding the same unit tests that adhan has. They are very comprehensive and help to double check none of the equation values are off.

Thanks, currently caught in between few deadlines, but I plan to do publish it by the end of the month. I also plan to publish another library that will have multiple ways of producing full timetable: fixed, relative and calculated; where first one takes fixed json of prayer times (single city), second one uses one base input and multiple 'differences' (multiple cities) and third one calculating times, based on Adhan. All three methods produce 5 daily prayers plus durations from/to prayers. All will be open source and inshaAllah sadaqah jariyah that we all participate in :-)

github-actions[bot] commented 4 years ago

Stale issue message

Noitidart commented 3 years ago

It does but it’s extremely minor. It takes about 5,000 ft of elevation to add 1 minute to sunset time.

That could be something to add to the library though.

This is a great quesiton, and great answer on why it's not important, it was on my mind too.

iBasit commented 2 years ago

There is lots of information here, just to keep it relevant to the topic and follow up information in the same place.

I have a simple question. If I have sea level, pressure, and temperature data. How can I add it to the calculation?

"sealevel": "14",
"today_weather": {
     "pressure": 1018,
      "temperature": "13"
},

sandbox for london times

z3bi commented 2 years ago

@iBasit the library does not support temperature or pressure. It could potentially since those values can effect the atmospheric refraction, however it would only be in extreme temperatures that we would see the difference of maybe a minute. The harder problem with these values is providing prayer times for times in the future only to have them change due to atmospheric conditions.

In terms of sea level, that actually is technically what we would need to adjust an apparent sunrise. We would technically need the altitude of the horizon from the observer. This is a much harder value to correctly have.

iBasit commented 2 years ago

however it would only be in extreme temperatures that we would see the difference of maybe a minute.

I can get today's data based on the location and add it to the timing if such functionality is added to the library.

We would technically need the altitude of the horizon from the observer.

If you don't mind me asking, can you give a code example of how I can add Sealevel to the calculation for the CalculationMethod?