# How to calculate the position of the sun in long/lat?

We are searching data for your request:

Forums and discussions:
Manuals and reference books:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.

I have a world map, and I want to know, given a timestamp, where is the sun located right now, in terms of long/lat.

Here is a website that does that: https://www.timeanddate.com/worldclock/sunearth.html

But they do not share the calculations.

How can I calculate the sun's position in earth gps terms given a timestamp?

Edit: some context

I have a plane that is determined by 2 points on earth, and that plain is perpendicular to the earth in those points. I want to know where is the sun relative to that plane, so I can know if the sun is to the right of it, or to the left of it.

Instead of working in 3 dimensions, I decided to work in 2. I already have that plane in 2D (just a line on the map), now I need to know where the sun is

Edit2: Using the wiki page here, this is what I got so far

Note: The interesting part isgetCurrentPosition

class Sun { private julianTime(timestamp: number) { // Source: http://stackoverflow.com/questions/466321/convert-unix-timestamp-to-julian return timestamp / 86400 + 2440587.5; } private convertEclipticEquatorial(lambda: number, beta: number, R: number, n) { const epsilon = 23.439 - 0.0000004 * n; // Obliquity of the ecliptic console.log("epsilon", epsilon); const alpha = Math.atan2(Degrees.cos(epsilon) * Degrees.sin(lambda), Degrees.cos(lambda)); console.log("alpha", alpha); const delta = Math.asin(Degrees.sin(epsilon) * Degrees.sin(lambda)); // declination console.log("delta", delta); } getCurrentPosition(timestamp: number) { const JD = this.julianTime(timestamp); console.log("JD", JD); // Source: https://en.wikipedia.org/wiki/Position_of_the_Sun const n = JD - 2451545; console.log("n", n); const L = (280.460 + 0.9856474 * n) % 360; console.log("L", L); const g = (357.528 + 0.9856003 * n) % 360; console.log("g", g); const lambda = (L + 1.915 * Degrees.sin(g) + 0.020 * Degrees.sin(2 * g)) % 360; console.log("lambda", lambda); const R = 1.00014 - 0.01671 * Degrees.cos(g) - 0.00014 * Degrees.cos(2 * g); // Distance console.log("R", R); this.convertEclipticEquatorial(lambda, 0, R, n); } } class Degrees { static sin(angle: number) { return Math.sin(angle / 180 * Math.PI); } static cos(angle: number) { return Math.cos(angle / 180 * Math.PI); } } console.log(new Sun().getCurrentPosition(new Date().getTime() / 1000));

Running this now, gives:

JD2457844.130512928 (can confirm, this is correct)

n6299.1305129281245 (simple math)

L9.181612328272422 (simple math)

g85.95292328111373 (simple math)

lambda11.09465308568091

R0.9990992788207762

epsilon23.436480347794827 (can confirm, that is roughly correct)

alpha0.17801325468993906

delta0.0766106706512887

If you don't need this precisely, the easy way to figure this out would be the following:

You can assume that at noon UTC on one of the equinoxes, the Sun will be directly over (0N, 0E). The longitude of the sub-Solar point will then progress evenly over the course of a day: 4 hours later it's at 60W, 12 hours later at 180W, 18 hours later 90E, etc.

The latitude of the sub-Solar point will either increase or decrease (depending upon the starting equinox) as a sine curve with a period of year and an amplitude equal to the axial tilt of the Earth (23.43705 degrees).

That will be good to ~5 degrees over the course of the year.

To get a more precise answer, you'd need to calculate the Analemma over the course of the year, and position the sub-Solar point accordingly. Formally, this would mean calculating the Equation of Time and transforming the resulting time offset into a position offset for the sub-Solar point. E.g., what's happening in this image.

I'm not familiar with how to do that, so hopefully someone else can help - or the simple way above works.

By latitude and longitude of the sun, I think you mean latitude and longitude of a point on the earth's surface where the rays of the sun fall perpendicular to the surface.

In astronavigation, this point is called the Geographical Position (GP) of the sun and terminology to describe this point is slightly different:-

Latitude of the GP is called Declination, and it is numerically equal to what one might call "Latitude". It is measured in degrees North or South the equator.

Longitude of the GP is called Greenwich Hour Angle (GHA). Just like longitude, GHA is measured East or West of Greenwich Meridian.

Describing the sun's position in this way is called the Equatorial Coordinate System.

The Wikipedia page you have used gives the additional formulae below to convert from Ecliptic Coordinates (the steps you followed) to Equatorial Coordinates.

Follow these steps to determine Declination $$delta$$ (Equivalent to Latitude).

To get the sun's GHA, you need to first calculate $$RA$$ (Right Ascension) as shown above and then convert this to GHA by these= rules…

$$SHA° = 360 - 15 · RA[h]$$

$$GHA_{Aries}° = 15 · GST[h]$$

$$GHA = SHA + GHA_{Aries}$$

For the second step, you will need $$GST$$ (Greenwich Sidereal Time) which is you can calculate if you know UT (UT can be obtained from the time shown by a clock). Use this link to convert directly from UT to GST

If you want a simple, concise way to be able to calculate the positions of all manner of celestial bodies, the sun, moon, planets, stars, then I highly recommended the book Astronomical Formulae for Calculators by Jean Meeus. It is the simplest, most comprehensive collection of astronomical formulae you are likely find anywhere on earth.

I've implemented what Thomas suggested as an approximation. It seems to do its job for a small rendered globe toy in JavaScript.

function getSunEuler(date) { const now = date || new Date(); // The boilerplate: fiddling with dates const soy = (new Date(now.getFullYear(), 0, 0)).getTime(); const eoy = (new Date(now.getFullYear() + 1, 0, 0)).getTime(); const nows = now.getTime(); const poy = (nows - soy) / (eoy - soy); const secs = now.getUTCMilliseconds() / 1e3 + now.getUTCSeconds() + 60 * (now.getUTCMinutes() + 60 * now.getUTCHours()); const pod = secs / 86400; // leap secs? nah. // The actual magic const lat = (-pod + 0.5) * Math.PI * 2; const lon = Math.sin((poy - .22) * Math.PI * 2) * .41; return new THREE.Euler(0, lat, lon, 'YZX'); }

The returned Euler angle can be used to transform an X unit vector to find a point on a sphere where 0 N 0 E is at (1, 0, 0).

I got curious how accurate the solution is and fiddled with Skyfield a bit to get closer to the truth:

from skyfield.api import Topos, load ts = load.timescale() planets = load('de421.bsp') sun = planets['sun'] earth = planets['earth'] t = ts.utc(2019, 6, 21, 12, 0, 0) # A rather correct answer can probably be obtained from earth.at(t).observe(sun).apparent().position.au # but I ended up being too lazy to calculate the angles myself # This serves as a convenient workaround for manual verification np = earth + Topos('90 N', '180 W') np.at(t).observe(sun).apparent().altaz()

The approximation seems to be indeed accurate within a few degrees, but is in an different coordinate system. I'd love it if someone could provide a clean solution using skyfield.

## How to calculate the position of the sun in long/lat? - Astronomy

### Journal Information

International Journal of Energy Engineering

p-ISSN: 2163-1891 e-ISSN: 2163-1905

### Analytical Model for Determining the Sun’s Position at All Time Zones

Abhik Milan Pal , Subhra Das

Renewable Energy Department, Amity School of Applied Science, Amity University Haryana, Gurgaon, India

Correspondence to: Abhik Milan Pal , Renewable Energy Department, Amity School of Applied Science, Amity University Haryana, Gurgaon, India.

 Email:

Generation of electricity from solar energy using solar photo-voltaic (PV) cell is a promising and growing field. Energy conversion is maximum when the sun is directly overhead and sunrays fall perpendicularly on a solar PV module. Hence, exact position of the sun in sky throughout a day is an important factor to know while designing and installing a solar panel. In this paper, we present an algorithm to determine altitude and azimuth angles that specifies the sun’s position at any geographical location precisely. It takes latitude, longitude, date and deference of local time from Greenwich Mean Time as input and logically calculates the angles using Microsoft EXCEL. The location of Gurgaon, India is taken as an example for application of the model to display the sun’s path throughout a day in 4 characteristic days in a year and to determine lengths of days from sunrise and sunset times coming also as output. These results can be incorporated in design to orient a solar panel automatically without requiring any cumbersome tracking mechanism.

Keywords: Latitude, Longitude, Altitude, Azimuth angle, Hour angle, the Sun and Earth movement, Equation of Time

## How to calculate the position of the sun in long/lat? - Astronomy

This page is based on page C24 of the 1996 Astronomical Almanac which provides a method for finding the position of the Sun in the sky to an accuracy of 0.01 degree between the years 1950 and 2050. Positions are given in the equatorial coordinate system used by astronomers, and in the horizon coordinate system for a location with given latitude and longitude. You can use these formulas to work out the bearing and elevation of the Sun in your sky at a given time of day - horizon coordinates are accurate to about 1.5 arcmin (or 1/20th of the Sun's diameter). To put this level of accuracy in perspective, the Sun moves through about a quarter of a degree in the sky every minute. If you are not familiar with astronomical coordinate systems and the words used to describe them, then I would strongly recommend a visit to Nick Strobel's astronomy without a telescope page.

The formulas are based on an elliptical orbit for the Earth, using mean orbital elements and a two term approximation for the 'equation of centre'. There is also an approximate allowance made for the change in obliquity of the ecliptic with time, needed when converting to right ascension and declination. The positions are thus apparent positions, they are referred to the mean ecliptic and equinox of date.

I compared the positions found using this low precision formula with values referred to the mean ecliptic and equinox of date from a more accurate program. The results (for the whole 1950 to 2050 range) are summarised below. I found the series to be accurate within 3 seconds of RA and 15 arc seconds in declination.

Note added March 2001: I have had a number of e-mails from people who want to calculate the the azimuth (3 figure bearing from North) and altitude (elevation) of the Sun at a specific time and place. This is easily done by finding the local sidereal time for the place, finding the hour angle of the Sun and then converting to horizon coordinates. For convenience, I have added these formulas and examples of their use to this page. Altitude seems good to about 1.5 minutes of arc, and Azimuth seems good to about half an arcmin, but I have not tested this as fully as the RA and DEC. At the risk of being obvious, the altitude angle here is referred to a 'mathematical' horizon on a spherical Earth. This is a good approximation to the observerd horizon at sea, but poor in most land situations where buildings or hills will raise or lower the true horizon. If your application is critical, you need to take time to understand the coordinate systems in use, and check on the effects of refraction near the horizon.

Below, I give the formulas from page C24 of the Astronomical Almanac , with modified notation. I have given the formulas together with numerical values for a specific day. The calculations were done on a normal scientific calculator with 8 figure accuracy, except for the sidereal time calculation where I used an HP48 with 12 figures of precision.

• Single cell formula for finding the days since J2000.0
• Use the radians() function, degrees() function and mod(x, 360) functions to convert angular arguments into radian measure between 0 and 2pi

If the year, month day, UT hour and minute are in cells B6 to B10 , then the formula below will return the days since J2000.0 for any date since March 1900 until Dec 2099.

If the days since J2000.0 are in cell B24 , and the longitude in degrees (West negative) is in cell B11 , then the mean local sidereal time is given in degrees as

And you can convert that to radians as You could concatenate the formulas so that cells always gave degrees in the results, like (say) this

to give the sine of the local sidereal time, but I find it easier to keep column B for degrees, Column C for radians, D for sines, E for cosines and so on. Each row is a new step in the calculation.

Having said that, the Sun has ecliptic longitude of zero to an accuracy of arcseconds (the ecliptic plane being defined by the plane of the Sun-Earth orbit) so a one cell formula for the ecliptic longitude of the Sun in degrees might be useful. Where cell B24 must contain the days since J2000.0. This sort of thing can get inefficient, notice that the mean anomaly is being calculated twice for the same instant in the one cell formula above. With modern spreadsheets and computers, this minor duplication might matter less than the presentation advantage gained by using a more compact layout.

I modified the QBASIC program above to produce a file of positions for days from -20,000 to +20,000 - a 106 year period centred on J2000.0. The RA and DEC figures were rounded to 4 places of decimals in this file. I used Planeph to generate a similar file of positions for the Sun, referred to the mean ecliptic and equinox of date. I then loaded both files into a spreadsheet, and found the errors in seconds of time (RA) and arcseconds (DEC). The maximum and minimum errors are shown in the table below for various ranges of time about J2000.0

## My Astro-Page Raymond Kneip

The parallax of a star is the effect of seeing a nearby star from different positions in space compared to distant background stars. Usually, this shift in position is due to the rotation of the Earth around the Sun. With a baseline corresponding to the orbit of the Earth, the parallax of Wolf 359 is 0.413 arcsec. Therefore, we have to wait for several months or half a year to detect this annual parallax [1].

In case of New Horizons, the effect of parallax is 'instantaneous', as both, the Earth and the spacecraft observe the same star at a specific date (April 22/23, 2020). As both observers are separated by 7 billion km, much more than the earthly baseline, the New Horizons parallax should be clearly visible in the images [2].

Figure 1: Observations of Wolf 359 done from K26 on April 22 and the New Horizons spacecraft [3] on April 23, 2020. A shift in the position of Wolf 359 at the centre of both images is clearly visible. The image of New Horizons has been processed and resized to match the image taken from K26.

Figure 1 shows both images, taken from the observatory K26 and from the spacecraft New Horizons [3]. The images from New Horizons were taken with LORRI, the Long Range Reconnaissance Imager, a 20.8 cm RC telescope on April 23, 2020 [4]. Three images, with an exposure time of 5 seconds each, were processed (aligned, stacked, deleting hot pixels, histogram adaptation, convolution, sharpening and resizing) to match the image taken from K26 (April 22, 2020) using a CDK-14 telescope. Figure 2 shows the shift in position of Wolf 359 as an animation as seen from the two telescopes separated by a baseline of 7 billion km.

Some theory for calculating the absolute distance to Wolf 359

Let's do now some calculations to find the absolute distance D to Wolf 359 with the observed parallax &pi extracted from both images. Figure 3 shows the geometric configuration of the Sun (S), the Earth (E), New Horizons (NH) and of course Wolf 359 (W). The relative size of the different distances are not respected in this representation!

Figure 3: Geometric representation of the Earth, New Horizons and Wolf 359 for the calculation of the absolute distance to Wolf 359.

Data necessary for the calculation of the absolute distance D to Wolf 359 (April 23, 2020):

• Position of the Sun in equatorial (J2000) and ecliptic coordinates [5]:

$egin alpha_S & = 02:04:04 && delta_S = +12:35:18 ext & = 33^ 14' && ext = +0^ 0' end$

$egin alpha_W & = 10:56:28 && delta_W = +07:00:35 ext & = 162^ 40' && ext = +0^ 13' end$

• Position of Pluto (supposed to correspond to the position of New Horizons):

$egin alpha_P & = 19:47:12 && delta_P = -22:00:58 ext & = 294^ 43' && ext = -0^ 51' end$

As all objects are lying more or less in the plane of the ecliptic, the following angles are calculated in this plane.

• Angle &alpha (from ecliptic longitude) between Wolf 359 and New Horizons:

• Angle &beta between Wolf 359 and the Sun:

• Distance between the Earth and New Horizons:

• Distance Earth-Sun at the moment of observation:

$egin d_ = 1.006 cdot AU = 1.505 cdot 10^<8> km end$

Using the Law of Sines in the triangle (NH-E-W):

This is the expression that allows us to calculate the distance dW from Earth to Wolf 359. All we have to know is the distance from Earth to New Horizons dNH, the angle &alpha (between New Horizons and Wolf 359) and the parallax &pi . As the parallax (about 15'') is very small compared to the other angles, it can be neglected in the numerator of the forth line.

To be correct, the distance between the Sun and Wolf 359 has to be calculated. Therefore, we can use the Law of Cosines in the triangle (S-E-W):

$egin D^2 = d_^2 + d_^2 - 2 cdot d_ cdot d_ cdot cos eta end$

Now, we have to remember that the distance Sun-Earth (1 AU) is about 470 000 times smaller than the distance to Wolf 359 (7.9 lj). Every expression including dS can therefore be neglected. With this approximation, we can confirm that:

Absolute distance D to Wolf 359:

Combined observations from K26 and New Horizons

The image from New Horizons (April 23) has been aligned to the image taken at K26 (April 22) using several reference stars. A histogram transformation has been applied to this image in order that the brightness of the two images of Wolf 359 do not differ too much. Finally, Wolf 359 from the image of New Horizons has been added to the own image for the determination of the apparent positions of Wolf 359 using the astrometric software Astrometrica.

Figure 4: Wolf 359 from the image of New Horizons has been added to the own image to determine its apparent positions using Astrometrica.
Left: Position of Wolf 359 from the stack of 16 images (exp. time: each 120 s) from April 22 taken at K26
Right: Position of Wolf 359 from the stack of 3 images (exp. time: each 5 s) from April 23 taken from New Horizons.

• Measured positions of Wolf 359 from K26 and NH:

$egin alpha_ = 10:56:23.63 & qquad delta_ = +06:59:58.5 underline = 10:56:22.68> & qquad underline = +07:00:05.0> end$

Difference in Rectascension and Declination for both apparent positions of Wolf 359:

$egin Delta alpha = 0.95 / 24 cdot 360'' = 14.25'' qquad Delta delta = 6.5'' end$

• Parallax &pi of Wolf 359 using both images from K26 and New Horizons (April 22/23, 2020):

We can finally calculate the absolute distance D to Wolf 359 using the parallax &pi, the angle &alpha and the known distance to New Horizons dNH:

Thanks to the images of New Horizons, it is possible to measure and calculate the distance to one of our neighbour stars, Wolf 359, with the method of the interplanetary parallax. With a distance of 7.25 lj, there is a difference of about 8% to the current value of 7.89 lj [7]. Although the method does not give us the best precision, it was a funny and exciting exercise waiting for the images of New Horizons and finally finding a quite acceptable result for the distance to one of our stellar neighbours.

have a look at the questions below yours

1st the question and response to furtuna_6, then
2nd the question and discussion immediately below yours where this

Mistake! Swap ceiling and floor:

To get the CLOSEST value that is a multiple of 15 just use this.
The Floor and Ceiling skew the result to the next lower or higher integer.

How do I calculate LongituteTimeZone?

The LongituteTimeZone is the nearest longitude in multiple of 15 of the timezone of which you are calculating the sun rise or sun set.

It appears to be the same as Longitute, but somehow quantized to multiples of 15 degrees. Is that correct? If so, what are the rounding or truncation rules (for example do I use the nearest multiple of 15 degrees)?

Alternatively, maybe LongituteTimeZone isn't really base on longitude, maybe it is the local offset from UTC * 15. Is this the definition or .

The longitude is the longitude of your timezone in multiples of 15 degrees. I use the nearest multiple.

Very nice application but I am looking to extend it.
The maximum solar radiation calculated, is this for a flat surface?
I would like to calculate the radiation under a given corner, e.g. a solar pannel.

It is indeed for a flat surface.

I created a test case for Miami which calculates the sunrise and sunset times for Miami. It is calculated correctly, I checked with Sunrise and Sunset for U.S

I created the SunCalculator for the test case as follows.

This will return 07:26 for the sunrise. I also checked the sunset time and it returned 19:30. The website I mentioned returns 07:20 for the sunrise and 19:34 for the sunset which is pretty accurate.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!

I will update the article.

Timezone is GMT +4
UseSummerTime = false
Date 17.08.2011

I think you made mistake with using the api of the Suncalculator. Are you sure that you entered the correct value for the timezone. In you case this should be set to 45.

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

## How to calculate the position of the sun in long/lat? - Astronomy

It gave me 6: 15 AM where as Google value is 6:08 AM, so I doubt the accurazy of this code.

DateTime date = DateTime.Today
bool isSunrise = false
bool isSunset = false
DateTime sunrise = DateTime.Now
DateTime sunset = DateTime.Now

// Print out the Sunrise and Sunset times for the next 20 days
for (int i = 0 i < 20 i++)
<
// Coordinates of Tel-Aviv
SunTimes.Instance.CalculateSunRiseSetTimes(new SunTimes.LatitudeCoords
(6, 55, 0, SunTimes.LatitudeCoords.Direction.South),
new SunTimes.LongitudeCoords
(79, 50, 0, SunTimes.LongitudeCoords.Direction.East),
date, ref sunrise, ref sunset,
ref isSunrise, ref isSunset)

Console.WriteLine(date + ": Sunrise @" + sunrise.ToString("HH:mm") + "Sunset @" + sunset.ToString("HH:mm"))

date = date.AddDays(1) // Move to the next day
>

- A random opportunity is like a taller chair, those who sit hang on, those who hang on fall

L.W.C. Nirosh.
Colombo,
Sri Lanka.

I do not know what is the purpose for this, but as you will see it gets my computers time zone and reverts it sign (why?) and conditionally checks its sign with the longitude. I am on East. +2. Converted to -2 and check with West Lon, which is negative, condition met and then it says it is not compatible, returns false, code exits. What is the purpose?

I removed it and it is now working.

Did you consider taking elevation into consideration in your calculations? How would that change the code?

Also, I saw a question earlier about twilight. How could I change the calculations to allow for different degrees below the horizon (twilight and dawn)?

The following 'error check’ actually introduces an error and needs to be removed: -
-----------------
if ((Sign(zone) == Sign(lon)) && (zone != 0))
<
Debug.Print("WARNING: time zone and longitude are incompatible!")
return false
>
-----------------
This error check is inappropriate because in reality countries have adopted pragmatic "time zone(s)" based on country / state / county borders, regardless of whether those borders happen to stray across actual time zones.

If the code above is removed, and the TimeZone.CurrentTimeZone and the coordinates are correct, the result will be correct.

The town of Penzance in England uses TimeZone.CurrentTimeZone = "GMT Standard Time" GMT(0), as the rest of England does. It is however in GMT(-1). GMT(0) starts East of Penzance in Greenwich, London (where time zones were 'invented' - hence "Greenwich Mean Time" (GMT)) - http://en.wikipedia.org/wiki/Greenwich_Mean_Time[^].

Use these coordinates (for Penzance, England, UK) to see the bad result.
(50, 7, 6, SunTimes.LatitudeCoords.Direction.North),
(5, 32, 12, SunTimes.LongitudeCoords.Direction.West)

NB: You will find this problem in virtually every country, so remove the offending code.

BOTTOM LINE: -
Remove these 2 pieces of code and it'll work properly: -
-----------------
using System.Linq
-----------------

-----------------
if ((Sign(zone) == Sign(lon)) && (zone != 0))
<
Debug.Print("WARNING: time zone and longitude are incompatible!")
return false
>
-----------------

Did you happen to test the (fixed) code at locations across the globe, and can tell if basically the code is correct worldwide?

some claim it does not work well in all locations (e.g. Rafone's post below)

Will appreciate any more inputs,

original
double zone = -(int)Math.Round(TimeZone.CurrentTimeZone.GetUtcOffset(date).TotalSeconds / 3600)

changed
double zone = (int)Math.Round(TimeZone.CurrentTimeZone.GetUtcOffset(date).TotalSeconds / 3600)

at the current moment the class is calulating
sunrise 5:42
sunset 17:41

the local weather page says.
sunrise 6:36
sunset 18:37

is this because we don't do the dst shuffle??

thanks a bunch. this is neat

Thanks for the input, I now know the code might not work worldwide and potentially needs some fixing.

I don't think the (just) an issue of DST. Essentially the code should give the exact sunrise and sunset times down to the minute level, and there is a discrepancy of 6 minutes between the calculated time and your local weather pages (which I assume are accurate).

DST might cause the 1 hour diff, but I'm more alarmed with the 6 minutes diff.

I wish I could give you a better solution, but unfortunately I know zilch about astronomy as opposed to my coding knowledge. I merely adapter/adjusted the code from JavaScript.

Whereabouts in Arizona? I'm in Gold Canyon (near Apache Junction).

I'm in Tempe.
I ended up using a class from the NOAA to get sunrise sunset working. It did take into account the astronomical calc's.

Please can you share the class you've found with all of us? or provide a link to it?

using System
using System.Collections.Generic
using System.Text

// NAA - NOAA's Astronomical Algorithms
// (JavaScript web page http://www.srrb.noaa.gov/highlights/sunrise/sunrise.html by
// Chris Cornwall, Aaron Horiuchi and Chris Lehman)
// Ported to C# by Pete Gray ([email protected]), June 2006
// Released as Open Source and can be used in any way, as long as the above description
// remains in place.

// Convert radian angle to degrees

<
return (180.0 * angleRad / Math.PI)
>

// Convert degree angle to radians

<
return (Math.PI * angleDeg / 180.0)
>

//***********************************************************************/
//* Name: calcJD
//* Type: Function
//* Purpose: Julian day from calendar day
//* Arguments:
//* year : 4 digit year
//* month: January = 1
//* day : 1 - 31
//* Return value:
//* The Julian day corresponding to the date
//* Note:
//* Number is returned for start of day. Fractional days should be
//***********************************************************************/

static public double calcJD(int year, int month, int day)
<
if (month <= 2) <
year -= 1
month += 12
>
double A = Math.Floor(year/100.0)
double B = 2 - A + Math.Floor(A/4)

double JD = Math.Floor(365.25*(year + 4716)) + Math.Floor(30.6001*(month+1)) + day + B - 1524.5
return JD
>

//***********************************************************************/
//* Name: calcTimeJulianCent
//* Type: Function
//* Purpose: convert Julian Day to centuries since J2000.0.
//* Arguments:
//* jd : the Julian Day to convert
//* Return value:
//* the T value corresponding to the Julian Day
//***********************************************************************/

static public double calcTimeJulianCent(double jd)
<
double T = (jd - 2451545.0)/36525.0
return T
>

//***********************************************************************/
//* Name: calcJDFromJulianCent
//* Type: Function
//* Purpose: convert centuries since J2000.0 to Julian Day.
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* the Julian Day corresponding to the t value
//***********************************************************************/

static public double calcJDFromJulianCent(double t)
<
double JD = t * 36525.0 + 2451545.0
return JD
>

//***********************************************************************/
//* Name: calGeomMeanLongSun
//* Type: Function
//* Purpose: calculate the Geometric Mean Longitude of the Sun
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* the Geometric Mean Longitude of the Sun in degrees
//***********************************************************************/

static public double calcGeomMeanLongSun(double t)
<
double L0 = 280.46646 + t * (36000.76983 + 0.0003032 * t)
while(L0 > 360.0)
<
L0 -= 360.0
>
while(L0 < 0.0)
<
L0 += 360.0
>
return L0 // in degrees
>

//***********************************************************************/
//* Name: calGeomAnomalySun
//* Type: Function
//* Purpose: calculate the Geometric Mean Anomaly of the Sun
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* the Geometric Mean Anomaly of the Sun in degrees
//***********************************************************************/

static public double calcGeomMeanAnomalySun(double t)
<
double M = 357.52911 + t * (35999.05029 - 0.0001537 * t)
return M // in degrees
>

//***********************************************************************/
//* Name: calcEccentricityEarthOrbit
//* Type: Function
//* Purpose: calculate the eccentricity of earth's orbit
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* the unitless eccentricity
//***********************************************************************/

static public double calcEccentricityEarthOrbit(double t)
<
double e = 0.016708634 - t * (0.000042037 + 0.0000001267 * t)
return e // unitless
>

static public double calcSunEqOfCenter(double t)
<
double m = calcGeomMeanAnomalySun(t)

double C = sinm * (1.914602 - t * (0.004817 + 0.000014 * t)) + sin2m * (0.019993 - 0.000101 * t) + sin3m * 0.000289
return C // in degrees
>

static public double calcSunTrueLong(double t)
<
double l0 = calcGeomMeanLongSun(t)
double c = calcSunEqOfCenter(t)

double O = l0 + c
return O // in degrees
>

static public double calcSunTrueAnomaly(double t)
<
double m = calcGeomMeanAnomalySun(t)
double c = calcSunEqOfCenter(t)

double v = m + c
return v // in degrees
>

<
double v = calcSunTrueAnomaly(t)
double e = calcEccentricityEarthOrbit(t)

double R = (1.000001018 * (1 - e * e)) / (1 + e * Math.Cos(degToRad(v)))
return R // in AUs
>

//***********************************************************************/
//* Name: calcSunApparentLong
//* Type: Function
//* Purpose: calculate the apparent longitude of the sun
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* sun's apparent longitude in degrees
//***********************************************************************/

static public double calcSunApparentLong(double t)
<
double o = calcSunTrueLong(t)

double omega = 125.04 - 1934.136 * t
double lambda = o - 0.00569 - 0.00478 * Math.Sin(degToRad(omega))
return lambda // in degrees
>

//***********************************************************************/
//* Name: calcMeanObliquityOfEcliptic
//* Type: Function
//* Purpose: calculate the mean obliquity of the ecliptic
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* mean obliquity in degrees
//***********************************************************************/

static public double calcMeanObliquityOfEcliptic(double t)
<
double seconds = 21.448 - t*(46.8150 + t*(0.00059 - t*(0.001813)))
double e0 = 23.0 + (26.0 + (seconds/60.0))/60.0
return e0 // in degrees
>

//***********************************************************************/
//* Name: calcObliquityCorrection
//* Type: Function
//* Purpose: calculate the corrected obliquity of the ecliptic
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* corrected obliquity in degrees
//***********************************************************************/

static public double calcObliquityCorrection(double t)
<
double e0 = calcMeanObliquityOfEcliptic(t)

double omega = 125.04 - 1934.136 * t
double e = e0 + 0.00256 * Math.Cos(degToRad(omega))
return e // in degrees
>

static public double calcSunRtAscension(double t)
<
double e = calcObliquityCorrection(t)
double lambda = calcSunApparentLong(t)

return alpha // in degrees
>

static public double calcSunDeclination(double t)
<
double e = calcObliquityCorrection(t)
double lambda = calcSunApparentLong(t)

return theta // in degrees
>

//***********************************************************************/
//* Name: calcEquationOfTime
//* Type: Function
//* Purpose: calculate the difference between true solar time and mean
//* solar time
//* Arguments:
//* t : number of Julian centuries since J2000.0
//* Return value:
//* equation of time in minutes of time
//***********************************************************************/

static public double calcEquationOfTime(double t)
<
double epsilon = calcObliquityCorrection(t)
double l0 = calcGeomMeanLongSun(t)
double e = calcEccentricityEarthOrbit(t)
double m = calcGeomMeanAnomalySun(t)

y *= y

double sin2l0 = Math.Sin(2.0 * degToRad(l0))
double cos2l0 = Math.Cos(2.0 * degToRad(l0))
double sin4l0 = Math.Sin(4.0 * degToRad(l0))
double sin2m = Math.Sin(2.0 * degToRad(m))

double Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0
- 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m

return radToDeg(Etime)*4.0 // in minutes of time
>

//***********************************************************************/
//* Name: calcHourAngleSunrise
//* Type: Function
//* Purpose: calculate the hour angle of the sun at sunrise for the
//* latitude
//* Arguments:
//* lat : latitude of observer in degrees
//* solarDec : declination angle of sun in degrees
//* Return value:
//* hour angle of sunrise in radians
//***********************************************************************/

static public double calcHourAngleSunrise(double lat, double solarDec)
<

//***********************************************************************/
//* Name: calcHourAngleSunset
//* Type: Function
//* Purpose: calculate the hour angle of the sun at sunset for the
//* latitude
//* Arguments:
//* lat : latitude of observer in degrees
//* solarDec : declination angle of sun in degrees
//* Return value:
//* hour angle of sunset in radians
//***********************************************************************/

static public double calcHourAngleSunset(double lat, double solarDec)
<

//***********************************************************************/
//* Name: calcSunriseUTC
//* Type: Function
//* Purpose: calculate the Universal Coordinated Time (UTC) of sunrise
//* for the given day at the given location on earth
//* Arguments:
//* JD : julian day
//* latitude : latitude of observer in degrees
//* longitude : longitude of observer in degrees
//* Return value:
//* time in minutes from zero Z
//***********************************************************************/

static public double calcSunriseUTC(double JD, double latitude, double longitude)
<
double t = calcTimeJulianCent(JD)

// *** Find the time of solar noon at the location, and use
// that declination. This is better than start of the
// Julian day

double noonmin = calcSolNoonUTC(t, longitude)
double tnoon = calcTimeJulianCent (JD+noonmin/1440.0)

// *** First pass to approximate sunrise (using solar noon)

double eqTime = calcEquationOfTime(tnoon)
double solarDec = calcSunDeclination(tnoon)
double hourAngle = calcHourAngleSunrise(latitude, solarDec)

double delta = longitude - radToDeg(hourAngle)
double timeDiff = 4 * delta // in minutes of time
double timeUTC = 720 + timeDiff - eqTime // in minutes

// alert("eqTime = " + eqTime + " solarDec = " + solarDec + " timeUTC eqTime = " + eqTime + " solarDec = " + solarDec + " timeUTC ForumSig">Statistics are like bikini's.
What they reveal is astonishing .
But what they hide is vital .

Do you find this code to be working better than my code? if so - how? is it more accurate?

Hey as I stated above yours mostly worked but it was not taking into account my No DST and the civil twlight etc.
This class does take all this into account.

I don´t know what to think.

That is just a matter of an implementation decision.
There are several ways to implement design patterns.

I don't have an answer for that, but surely someone more acquainted with VB will have an answer.

Perhaps you need to tweak my package/classes definitions and make them available to "outsiders".

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

## Sun in zodiac constellations, 2019

Ophiuchus the Serpent Bearer isn’t an astrological sign, but it is one of the constellations of the zodiac. In other words, many people are born when the sun appears in front of this constellation. In 2019, the sun will cross into Ophiuchus on November 30. Image via IanRidpath.com.

You might know that the real sun in the real sky does not appear in front of a constellation of the zodiac within the same range of dates you’ll see listed in astrological horoscopes. That’s because astrology and astronomy are different systems. Astrologers typically indicate the sun’s position with signs while astronomers use constellations. We were asked for:

… a list of the constellations that fall on the ecliptic with the exact degrees.

And we’ve located this information in Guy Ottewell’s Astronomical Calendar 2019. Below, you’ll find the dates for the sun’s entry into each zodiacal constellation during the year 2019, plus the sun’s ecliptic longitude – its position east of the March equinox point on the ecliptic – for each given date.

We are using the boundaries for the zodiacal constellations established by the International Astronomical Union in the 1930s.

The sun resides at a longitude of 0 o on the ecliptic at the March equinox. The sun is at 90 o ecliptic longitude at the June solstice, 180 o ecliptic longitude at the September equinox and 270 o ecliptic longitude on the December solstice. Image via Wikipedia

Date of sun’s entry into each zodiacal constellation (and corresponding ecliptic longitude):

Dec 18, 2018: Sun enters constellation Sagittarius (266.60 o )

Jan 20, 2019: Sun enters constellation Capricornus (299.71 o )

Feb 16, 2019: Sun enters constellation Aquarius (327.89 o )

Mar 12, 2019: Sun enters constellation Pisces (351.57 o )

Apr 19, 2019: Sun enters constellation Aries (29.09 o )

May 14, 2018: Sun enters constellation Taurus (53.47 o )

Jun 22, 2019: Sun enters constellation Gemini (90.43 o )

Jul 21, 2019: Sun enters constellation Cancer (118.26 o )

Aug 11, 2019: Sun enters constellation Leo (138.18 o )

Sep 17, 2019: Sun enters constellation Virgo (174.16 o )

Oct 31, 2019: Sun enters constellation Libra (217.80 o )

Nov 23, 2019: Sun enters constellation Scorpius (241.14 o )

Nov 30, 2019: Sun enters constellation Ophiuchus (248.04 o )

Dec 18, 2019: Sun enters constellation Sagittarius (266.61 o )

Earth-centered ecliptic coordinates as seen from outside the celestial sphere. Ecliptic longitude (red) is measured along the ecliptic from the vernal equinox at 0 o longitude. Ecliptic latitude (yellow) is measured perpendicular to the ecliptic. Image via Wikimedia Commons.

Constellations of the zodiac:

Dates of sun’s entry into astrological signs versus astronomical constellations. Chart and more explanation at Guy’s Ottewell’s blog. Used with permission.

Bottom line: Sun-entry dates to zodiac constellations in 2019, using boundaries for constellations set by the International Astronomical Union in the 1930s.

### Sunlight times

Returns an object with the following properties (each is a Date object):

PropertyDescription
sunrise sunrise (top edge of the sun appears on the horizon)
sunriseEnd sunrise ends (bottom edge of the sun touches the horizon)
goldenHourEnd morning golden hour (soft light, best time for photography) ends
solarNoon solar noon (sun is in the highest position)
goldenHour evening golden hour starts
sunsetStart sunset starts (bottom edge of the sun touches the horizon)
sunset sunset (sun disappears below the horizon, evening civil twilight starts)
dusk dusk (evening nautical twilight starts)
nauticalDusk nautical dusk (evening astronomical twilight starts)
night night starts (dark enough for astronomical observations)
nadir nadir (darkest moment of the night, sun is in the lowest position)
nightEnd night ends (morning astronomical twilight starts)
nauticalDawn nautical dawn (morning nautical twilight starts)
dawn dawn (morning nautical twilight ends, morning civil twilight starts)

### Sun position

Returns an object with the following properties:

e.g. 0 at the horizon and PI/2 at the zenith (straight over your head)

e.g. 0 is south and Math.PI * 3/4 is northwest

### Moon position

Returns an object with the following properties:

• altitude : moon altitude above the horizon in radians
• azimuth : moon azimuth in radians
• distance : distance to moon in kilometers
• parallacticAngle : parallactic angle of the moon in radians

### Moon illumination

Returns an object with the following properties:

• fraction : illuminated fraction of the moon varies from 0.0 (new moon) to 1.0 (full moon)
• phase : moon phase varies from 0.0 to 1.0 , described below
• angle : midpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk

the moon is waxing if the angle is negative, and waning if positive

Moon phase value should be interpreted like this:

PhaseName
0New Moon
Waxing Crescent
0.25First Quarter
Waxing Gibbous
0.5Full Moon
Waning Gibbous
0.75Last Quarter
Waning Crescent

By subtracting the parallacticAngle from the angle one can get the zenith angle of the moons bright limb (anticlockwise). The zenith angle can be used do draw the moon shape from the observers perspective (e.g. moon lying on its back).

### Moon rise and set times

Returns an object with the following properties:

• rise : moonrise time as Date
• set : moonset time as Date
• alwaysUp : true if the moon never rises/sets and is always above the horizon during the day
• alwaysDown : true if the moon is always below the horizon

By default, it will search for moon rise and set during local user's day (frou 0 to 24 hours). If inUTC is set to true, it will instead search the specified date from 0 to 24 UTC hours.

Astronomy is the branch of natural science that studies the celestial bodies. The word is a combination of astron, Greek for “star,” and nomos, Greek for “law.” Astrology was formerly part of astronomy, with astrological determinations being viewed as a “practical application” of astronomical knowledge. Prior to the modern period, all of the great astronomers were also astrologers, including such luminaries as Tycho Brahe and Johannes Kepler.

Several hundred years ago, however, the two fields began to diverge, and today there are two distinct communities: astrologers, who are largely ignorant of astronomy, and astronomers, who know almost nothing about astrology. For the most part, contemporary astronomers despise astrology as a medieval superstition. This is not, however, because astrology fails to pass empirical tests of validity, but because astronomers reject astrology out of hand. When skeptics have actually subjected astrology to empirical tests, they have found—sometimes to their dismay𠅌orrelations between celestial and terrestrial phenomena.

For their part, astrologers are more often than not woefully ignorant of astronomy. This ignorance is sometimes compounded by an attitude that condemns all science as narrow-minded and spiritually dead. There are, however, a handful of contemporary astrologers who have explored current astronomy for potential astrological insights, including Michael and Margaret Erlewine, whose Astrophysical Directions offers a starting point for astrologers interested in pursuing this line of research, and Philip Sedgwick, whose Astrology of Deep Space is a creative follow-up on the Erlewines’ work.

## Contents

The invention of a geographic coordinate system is generally credited to Eratosthenes of Cyrene, who composed his now-lost Geography at the Library of Alexandria in the 3rd century BC. [3] A century later, Hipparchus of Nicaea improved on this system by determining latitude from stellar measurements rather than solar altitude and determining longitude by timings of lunar eclipses, rather than dead reckoning. In the 1st or 2nd century, Marinus of Tyre compiled an extensive gazetteer and mathematically-plotted world map using coordinates measured east from a prime meridian at the westernmost known land, designated the Fortunate Isles, off the coast of western Africa around the Canary or Cape Verde Islands, and measured north or south of the island of Rhodes off Asia Minor. Ptolemy credited him with the full adoption of longitude and latitude, rather than measuring latitude in terms of the length of the midsummer day. [4]

Ptolemy's 2nd-century Geography used the same prime meridian but measured latitude from the Equator instead. After their work was translated into Arabic in the 9th century, Al-Khwārizmī's Book of the Description of the Earth corrected Marinus' and Ptolemy's errors regarding the length of the Mediterranean Sea, [note 1] causing medieval Arabic cartography to use a prime meridian around 10° east of Ptolemy's line. Mathematical cartography resumed in Europe following Maximus Planudes' recovery of Ptolemy's text a little before 1300 the text was translated into Latin at Florence by Jacobus Angelus around 1407.

In 1884, the United States hosted the International Meridian Conference, attended by representatives from twenty-five nations. Twenty-two of them agreed to adopt the longitude of the Royal Observatory in Greenwich, England as the zero-reference line. The Dominican Republic voted against the motion, while France and Brazil abstained. [5] France adopted Greenwich Mean Time in place of local determinations by the Paris Observatory in 1911.

In order to be unambiguous about the direction of "vertical" and the "horizontal" surface above which they are measuring, map-makers choose a reference ellipsoid with a given origin and orientation that best fits their need for the area to be mapped. They then choose the most appropriate mapping of the spherical coordinate system onto that ellipsoid, called a terrestrial reference system or geodetic datum.

Datums may be global, meaning that they represent the whole Earth, or they may be local, meaning that they represent an ellipsoid best-fit to only a portion of the Earth. Points on the Earth's surface move relative to each other due to continental plate motion, subsidence, and diurnal Earth tidal movement caused by the Moon and the Sun. This daily movement can be as much as a meter. Continental movement can be up to 10 cm a year, or 10 m in a century. A weather system high-pressure area can cause a sinking of 5 mm . Scandinavia is rising by 1 cm a year as a result of the melting of the ice sheets of the last ice age, but neighboring Scotland is rising by only 0.2 cm . These changes are insignificant if a local datum is used, but are statistically significant if a global datum is used. [1]

Examples of global datums include World Geodetic System (WGS 84, also known as EPSG:4326 [6] ), the default datum used for the Global Positioning System, [note 2] and the International Terrestrial Reference System and Frame (ITRF), used for estimating continental drift and crustal deformation. [7] The distance to Earth's center can be used both for very deep positions and for positions in space. [1]

Local datums chosen by a national cartographical organization include the North American Datum, the European ED50, and the British OSGB36. Given a location, the datum provides the latitude ϕ and longitude λ . In the United Kingdom there are three common latitude, longitude, and height systems in use. WGS 84 differs at Greenwich from the one used on published maps OSGB36 by approximately 112 m. The military system ED50, used by NATO, differs from about 120 m to 180 m. [1]

The latitude and longitude on a map made against a local datum may not be the same as one obtained from a GPS receiver. Converting coordinates from one datum to another requires a datum transformation such as a Helmert transformation, although in certain situations a simple translation may be sufficient. [8]

In popular GIS software, data projected in latitude/longitude is often represented as a Geographic Coordinate System. For example, data in latitude/longitude if the datum is the North American Datum of 1983 is denoted by 'GCS North American 1983'.