GithubHelp home page GithubHelp logo

fabiz / meeusjs Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 16.0 83 KB

MeeusJs is an implementation of some algorithms of the Book 'Astronomical Algorithms of Jean Meeus' in Javascript.

License: MIT License

HTML 3.45% JavaScript 95.98% Shell 0.57%

meeusjs's People

Contributors

fabiz avatar jumpjack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meeusjs's Issues

Error in example

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);	

Is this true or false?

Hello @Fabiz
In the function: A.Solar.apparentEquatorial()
Why did you write :
var T = jdo.jdJ2000Century();
And not:
var T = jdo.jdeJ2000Century();

Solstice/Solistice

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.

Confusion with degrees and radians

* @return {number} degrees in radians

"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°).

A.Moon.times bug?

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

Eastern European Winter Time gives wrong sun times

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!

A.JulianDay.dateToJD forces UTC, giving wrong times if dates differ

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?

altitude

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

Azimuth errato

Math.atan2(sH, cH * slat - (sdec / cdec) * clat), // Azimuth - (13.5) p. 93

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
		);
	}

Calculating when the sun is at a specific angle?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.