fabiz / meeusjs Goto Github PK
View Code? Open in Web Editor NEWMeeusJs is an implementation of some algorithms of the Book 'Astronomical Algorithms of Jean Meeus' in Javascript.
License: MIT License
MeeusJs is an implementation of some algorithms of the Book 'Astronomical Algorithms of Jean Meeus' in Javascript.
License: MIT License
Error highlighted below (in example on home page):
// gets the moon position and times for zurich
var jdo = new A.JulianDay(new Date()); // now
var coord = A.EclCoord.fromWgs84(47.3957, 8.4867, 440); // zurich
// gets the position of the moon
var tp = A.Moon.topocentricPosition(jdo, coord, true);
// print azi and alt
console.log(tp.hz.toString() + ", dist:" + tp.delta);
// gets the rise, transit and set time of the moon for today
var times = A.Moon.times(jdo, coord);
// print rise, transit and set in universal time
console.log("rise:" + A.Coord.secondsToHMSStr(times.rise) +
", transit:" + A.Coord.secondsToHMSStr(times.transit) +
", set:" + A.Coord.secondsToHMSStr(times.set));
// print moon phase and illuminated
var suneq = A.Solar.apparentTopocentric(jdo, coord);
var i = A.MoonIllum.phaseAngleEq2(tp.eq, suneq);
var k = A.MoonIllum.illuminated(i);
var chi = A.MoonIllum.positionAngle(moontp.eq, suneq); //////////////////// ERROR! "moontp" is not defined, it should be just "tp"
console.log("phase:" + i + ", illuminated:" + k + ", angle:" + chi);
Can this be used for android project?
Hello @Fabiz
In the function: A.Solar.apparentEquatorial()
Why did you write :
var T = jdo.jdJ2000Century();
And not:
var T = jdo.jdeJ2000Century();
Is there a good reason to use both "solstice" and "solistice" - with an i - unregularly as code variables, package listing and library file name? I think the correct word is without an i.
In Astro.Solistice.js source code all the function comments refer to "JDE of the March equinox for the given year." This is peanuts but by flyover reading one could accidentally pick a wrong function to use.
Cannot figure out why equinoxes and solstices here give about 1 - 1,5 minutes later times than the ones listed by Wikipedia.
Line 136 in 3f412c6
"Degrees" and "radians" are units of measure, hence "degrees in radians" is a nonsense, just like saying "centimeters in meters"; it should be instead "angle in radians" or "angle in degrees".
Also the function name is misleading: "dmsToDeg" should apparently return a valule in degrees, instead it returns radians; a proper name should be "dmsToDecimal" (x° x' x"" becomes x.xxxxx°).
Thank you @Fabiz for this script ..
I think PHP is more important than javascript in this case, so is there a PHP version of this script?
The README mentions A.MoonPhase but the code isn't here.
hi Fabiz. Amazing adaptation of the Meeus algorithms!
but i noticed an oddity with the moonrise times function for Berlin (Lat: 52.49, Lon. 13.43) for this month...
if the rise times are returned in seconds since 00:00 of the given day, then i get the following moonrise times (in readable format and UTC):
2017-07-18T23:15:10
2017-07-19T23:47:49
2017-07-20T00:27:31 <--------- the moon rises again 40 min later?
2017-07-21T00:26:57
Hello!
I just tried this library, i got some wrong times (two hours difference) and i don't know how to solve them, can you help?
result from examples.html
MeeusJs
Observer: Athens, lat: 37.9788, lng:23.7414
Mon Oct 31 2022 10:22:24 GMT+0200 (Eastern European Winter Time), jd:2459883.848888889
Sun position
azi:-30.8402, alt:32.2552
Moon position
azi:-79.394, alt:-30.807, dist:369384.0473902419
Moon illumination
phase:1.7724708628872738, illuminated:0.3998448958278997
Sun times
rise:04:49:26, transit:10:08:39, set:15:27:23 <---- two hours difference
Moon times
rise:11:14:40, transit:15:54:52, set:20:42:59
And couple of questions
some variables not used like earthsunDelta, BesselianYear, JMod etc,
does those exist for a reason?
In DeltaT,estimate, do they need calculations from 2005 add bellow?
Thank you!
I could be missing something, but:
I am currently in UTC+2. Dates and times are all returned fine except between midnight and 2AM. In this period UTC date is one day behind the actual date; the times and other data provided are then actually for yesterday. I can't convert them after they're returned because they're given as seconds from midnight and there's no way for me to know if that is today or tomorrow (talking about the Moon now).
I think it's because A.JulianDay.dateToJD forces UTC and ignores any timezone offset, which I suppose there's a good reason for. However, this causes incorrect times when local date and UTC date are different.
This actually forces me to do two separate calculations every time. One with date with added timezone offset and one with actual date. If I send date with forced added offset to A.JulianDay times will be correct, but topographic positions will be off. So I do one calculation for rise/set times (with forced UTC offset sent to A.JulianDay) and another with actual date (for topographic position).
Maybe I misunderstand something. How to get around this?
..
// no error
..
I found the calculation doesn't take into account the altitude, although the parameter h is included in coordinates. It doesn't modify anything for the results, and it should. Can you confirm that ?
Thx
Hello @Fabiz !
http://maia.usno.navy.mil/ser7/deltat.data
This link show that delta T in 2018-1-1 is 68.9677
Test this function
A.DeltaT.estimate(new A.JulianDay(new Date(2018,1-1,1)).jd)
delta T is 70.5081
Is this a bug ?
How would I get the different solistice and equinox dates?
Line 315 in 069bbe2
Come da commento presente nel codice stesso, il valore di azimuth restituito è errato, in quanto calcolato rispetto al sud, mentre la convenzione lo vuole calcolato rispetto al nord; forse conviene aggiungere un'opzione per specificare quale convenzione usare.
io ho fatto così:
eqToHz: function(eqcoord, eclCoord, strad, typeOfAzimuth) { // ADDED OPTION FO FIX AZIMUTH
var H = strad - eclCoord.lng - eqcoord.ra; // ra = Right Ascension (alpha)
var sH = Math.sin(H); // H = hour angle
var cH = Math.cos(H);
var slat = Math.sin(eclCoord.lat); // lat = latitude (phi)
var clat = Math.cos(eclCoord.lat);
var sdec = Math.sin(eqcoord.dec); // dec = declination (delta)
var cdec = Math.cos(eqcoord.dec);
//// FIX AZIMUTH:
var addAz = 0;
if (typeof typeOfAzimuth !== 'undefined') {
if((typeOfAzimuth==="N")||(typeOfAzimuth==="n")) {
addAz=Math.PI;
} else {
addAz=0;
}
}
////
return new A.HzCoord(
// Meeus citation:
// "If one wishes to reckon the azimuth from the North instead of the South,
// add 180 degrees to the first value"
Math.atan2(sH, cH * slat - (sdec / cdec) * clat) + addAz, // Azimuth - (13.5) p. 93
Math.asin(slat * sdec + clat * cdec * cH) // Altitude - (13.6) p. 93
);
}
Need this to calculate certain times even before sunrise. When is the sun X degrees below/above the horizon?
Suncalc has a function called addtimes() that takes an angle as a parameter and returns a time, but suncalc is returning very inaccurate times, and I want to use MeeusJs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.