mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-04-05 07:15:38 -04:00
Added C# demo for lunar eclipse.
Alphebetized demo readme pages.
This commit is contained in:
@@ -2,19 +2,6 @@
|
||||
|
||||
---
|
||||
|
||||
### [Moon Phase Calculator](moonphase.c)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Body Positions](positions.c)
|
||||
An example of how to calculate equatorial and horizontal coordinates for all of the major solar system bodies.
|
||||
|
||||
### [Rise/Set](riseset.c)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.c)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
### [Culmination](culminate.c)
|
||||
Finds when the Sun, Moon, and planets reach their highest position in the sky on a given date,
|
||||
as seen by an observer at a specified location on the Earth.
|
||||
@@ -27,6 +14,23 @@ This is a more advanced example. It shows how to use coordinate
|
||||
transforms to find where the ecliptic intersects with an observer's
|
||||
horizon at a given date and time.
|
||||
|
||||
### [Lunar Eclipse](lunar_eclipse.c)
|
||||
Calculates details about the first 10 partial/total lunar eclipses
|
||||
after the given date and time.
|
||||
|
||||
### [Moon Phase Calculator](moonphase.c)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Positions](positions.c)
|
||||
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
|
||||
|
||||
### [Rise/Set](riseset.c)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.c)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
---
|
||||
|
||||
# [API Reference](../../source/c/)
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
|
||||
---
|
||||
|
||||
### [Moon Phase Calculator](moonphase/moonphase.cs)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Body Positions](positions/positions.cs)
|
||||
An example of how to calculate equatorial and horizontal coordinates for all of the major solar system bodies.
|
||||
|
||||
### [Rise/Set](riseset/riseset.cs)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons/seasons.cs)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
### [Culmination](culminate/culminate.cs)
|
||||
Finds when the Sun, Moon, and planets reach their highest position in the sky on a given date,
|
||||
as seen by an observer at a specified location on the Earth.
|
||||
@@ -27,6 +14,23 @@ This is a more advanced example. It shows how to use coordinate
|
||||
transforms to find where the ecliptic intersects with an observer's
|
||||
horizon at a given date and time.
|
||||
|
||||
### [Lunar Eclipse](lunar_eclipse/lunar_eclipse.js)
|
||||
Calculates details about the first 10 partial/total lunar eclipses
|
||||
after the given date and time.
|
||||
|
||||
### [Moon Phase Calculator](moonphase/moonphase.cs)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Positions](positions/positions.cs)
|
||||
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
|
||||
|
||||
### [Rise/Set](riseset/riseset.cs)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons/seasons.cs)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
---
|
||||
|
||||
# [API Reference](../../source/csharp/)
|
||||
|
||||
@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo_helper", "demo_helper\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "astronomy", "..\..\source\csharp\astronomy.csproj", "{B5681C91-3FEF-4455-AAA9-15070BDDB9C9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lunar_eclipse", "lunar_eclipse\lunar_eclipse.csproj", "{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -128,5 +130,17 @@ Global
|
||||
{B5681C91-3FEF-4455-AAA9-15070BDDB9C9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B5681C91-3FEF-4455-AAA9-15070BDDB9C9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B5681C91-3FEF-4455-AAA9-15070BDDB9C9}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F65EC67F-7BC8-48D8-8D74-B58747B6BA7A}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
73
demo/csharp/lunar_eclipse/lunar_eclipse.cs
Normal file
73
demo/csharp/lunar_eclipse/lunar_eclipse.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using demo_helper;
|
||||
using CosineKitty;
|
||||
|
||||
namespace lunar_eclipse
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
AstroTime time;
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
time = new AstroTime(DateTime.Now);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
time = DemoHelper.ParseTime("lunar_eclipse", args[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.WriteLine("USAGE: lunar_eclipse [date]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
LunarEclipseInfo eclipse = Astronomy.SearchLunarEclipse(time);
|
||||
for(;;)
|
||||
{
|
||||
if (eclipse.kind != EclipseKind.Penumbral)
|
||||
{
|
||||
PrintEclipse(eclipse);
|
||||
if (++count == 10)
|
||||
break;
|
||||
}
|
||||
eclipse = Astronomy.NextLunarEclipse(eclipse.center);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void PrintEclipse(LunarEclipseInfo eclipse)
|
||||
{
|
||||
// Calculate beginning/ending of different phases
|
||||
// of an eclipse by subtracting/adding the center time
|
||||
// with the number of minutes indicated by the "semi-duration"
|
||||
// fields sd_partial and sd_total.
|
||||
const double MINUTES_PER_DAY = 24 * 60;
|
||||
|
||||
AstroTime p1 = eclipse.center.AddDays(-eclipse.sd_partial / MINUTES_PER_DAY);
|
||||
Console.WriteLine("{0} Partial eclipse begins.", p1);
|
||||
|
||||
if (eclipse.sd_total > 0.0)
|
||||
{
|
||||
AstroTime t1 = eclipse.center.AddDays(-eclipse.sd_total / MINUTES_PER_DAY);
|
||||
Console.WriteLine("{0} Total eclipse begins.", t1);
|
||||
}
|
||||
|
||||
Console.WriteLine("{0} Peak of {1} eclipse.", eclipse.center, eclipse.kind.ToString().ToLowerInvariant());
|
||||
|
||||
if (eclipse.sd_total > 0.0)
|
||||
{
|
||||
AstroTime t2 = eclipse.center.AddDays(+eclipse.sd_total / MINUTES_PER_DAY);
|
||||
Console.WriteLine("{0} Total eclipse ends.", t2);
|
||||
}
|
||||
|
||||
AstroTime p2 = eclipse.center.AddDays(+eclipse.sd_partial / MINUTES_PER_DAY);
|
||||
Console.WriteLine("{0} Partial eclipse ends.", p2);
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
demo/csharp/lunar_eclipse/lunar_eclipse.csproj
Normal file
14
demo/csharp/lunar_eclipse/lunar_eclipse.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\source\csharp\astronomy.csproj" />
|
||||
<ProjectReference Include="..\demo_helper\demo_helper.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
1
demo/csharp/test/.gitignore
vendored
1
demo/csharp/test/.gitignore
vendored
@@ -4,3 +4,4 @@ riseset.txt
|
||||
seasons.txt
|
||||
culminate.txt
|
||||
horizon.txt
|
||||
lunar_eclipse.txt
|
||||
|
||||
50
demo/csharp/test/lunar_eclipse_correct.txt
Normal file
50
demo/csharp/test/lunar_eclipse_correct.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
1988-03-03T16:04:42.484Z Partial eclipse begins.
|
||||
1988-03-03T16:13:29.227Z Peak of partial eclipse.
|
||||
1988-03-03T16:22:15.970Z Partial eclipse ends.
|
||||
|
||||
1988-08-27T10:07:57.338Z Partial eclipse begins.
|
||||
1988-08-27T11:05:04.753Z Peak of partial eclipse.
|
||||
1988-08-27T12:02:12.168Z Partial eclipse ends.
|
||||
|
||||
1989-02-20T13:44:07.827Z Partial eclipse begins.
|
||||
1989-02-20T14:56:15.430Z Total eclipse begins.
|
||||
1989-02-20T15:36:04.478Z Peak of total eclipse.
|
||||
1989-02-20T16:15:53.526Z Total eclipse ends.
|
||||
1989-02-20T17:28:01.129Z Partial eclipse ends.
|
||||
|
||||
1989-08-17T01:21:19.201Z Partial eclipse begins.
|
||||
1989-08-17T02:20:31.653Z Total eclipse begins.
|
||||
1989-08-17T03:08:46.679Z Peak of total eclipse.
|
||||
1989-08-17T03:57:01.705Z Total eclipse ends.
|
||||
1989-08-17T04:56:14.157Z Partial eclipse ends.
|
||||
|
||||
1990-02-09T17:29:19.371Z Partial eclipse begins.
|
||||
1990-02-09T18:50:02.143Z Total eclipse begins.
|
||||
1990-02-09T19:11:46.639Z Peak of total eclipse.
|
||||
1990-02-09T19:33:31.135Z Total eclipse ends.
|
||||
1990-02-09T20:54:13.906Z Partial eclipse ends.
|
||||
|
||||
1990-08-06T12:44:54.290Z Partial eclipse begins.
|
||||
1990-08-06T14:13:00.287Z Peak of partial eclipse.
|
||||
1990-08-06T15:41:06.284Z Partial eclipse ends.
|
||||
|
||||
1991-12-21T10:00:27.419Z Partial eclipse begins.
|
||||
1991-12-21T10:33:39.370Z Peak of partial eclipse.
|
||||
1991-12-21T11:06:51.320Z Partial eclipse ends.
|
||||
|
||||
1992-06-15T03:27:15.071Z Partial eclipse begins.
|
||||
1992-06-15T04:57:38.272Z Peak of partial eclipse.
|
||||
1992-06-15T06:28:01.474Z Partial eclipse ends.
|
||||
|
||||
1992-12-09T21:59:59.280Z Partial eclipse begins.
|
||||
1992-12-09T23:07:16.402Z Total eclipse begins.
|
||||
1992-12-09T23:44:42.637Z Peak of total eclipse.
|
||||
1992-12-10T00:22:08.873Z Total eclipse ends.
|
||||
1992-12-10T01:29:25.994Z Partial eclipse ends.
|
||||
|
||||
1993-06-04T11:11:48.333Z Partial eclipse begins.
|
||||
1993-06-04T12:12:49.449Z Total eclipse begins.
|
||||
1993-06-04T13:01:01.725Z Peak of total eclipse.
|
||||
1993-06-04T13:49:14.001Z Total eclipse ends.
|
||||
1993-06-04T14:50:15.117Z Partial eclipse ends.
|
||||
|
||||
@@ -5,7 +5,7 @@ Fail()
|
||||
exit 1
|
||||
}
|
||||
rm -rf exe
|
||||
rm -f test/{moonphase,positions,riseset,seasons,culminate,horizon}.txt
|
||||
rm -f test/{moonphase,positions,riseset,seasons,culminate,horizon,lunar_eclipse}.txt
|
||||
dotnet build --output ${PWD}/exe || Fail "Error building ${PWD}/demo.sln"
|
||||
|
||||
echo "Testing example: moonphase.cs"
|
||||
@@ -32,5 +32,9 @@ echo "Testing example: horizon.cs"
|
||||
dotnet exe/horizon.dll +25.5 -85.3 2016-12-25T12:30:45Z > test/horizon.txt || Fail "Error testing horizon.cs"
|
||||
diff test/horizon.txt test/horizon_correct.txt || Fail "Error comparing horizon.cs output."
|
||||
|
||||
echo "Testing example: lunar_eclipse.cs"
|
||||
dotnet exe/lunar_eclipse.dll 1988-01-01T00:00:00Z > test/lunar_eclipse.txt || Fail "Error running lunar_eclipse.cs."
|
||||
diff test/lunar_eclipse.txt test/lunar_eclipse_correct.txt || Fail "Error comparing lunar_eclipse.cs output."
|
||||
|
||||
echo "PASS: C# examples"
|
||||
exit 0
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
The source file
|
||||
[`astronomy.js`](../../source/js/astronomy.js)
|
||||
works as a Node.js module. Download the file into your project directory.
|
||||
works as a Node.js module. Download the file into your project directory.
|
||||
Then in your own source file, do this:
|
||||
|
||||
```javascript
|
||||
const Astronomy = require('astronomy.js');
|
||||
```
|
||||
|
||||
 There are no external dependencies!
|
||||
 There are no external dependencies!
|
||||
Astronomy Engine is completely self-contained, and it always will be.
|
||||
|
||||
(By the way, you can use the same file `astronomy.js` for
|
||||
@@ -17,19 +17,6 @@ Astronomy Engine is completely self-contained, and it always will be.
|
||||
|
||||
---
|
||||
|
||||
### [Moon Phase Calculator](moonphase.js)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Planet Positions](positions.js)
|
||||
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
|
||||
|
||||
### [Rise/Set](riseset.js)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.js)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
### [Culmination](culminate.js)
|
||||
Finds when the Sun, Moon, and planets reach their highest position in the sky on a given date,
|
||||
as seen by an observer at a specified location on the Earth.
|
||||
@@ -42,6 +29,23 @@ This is a more advanced example. It shows how to use coordinate
|
||||
transforms to find where the ecliptic intersects with an observer's
|
||||
horizon at a given date and time.
|
||||
|
||||
### [Lunar Eclipse](lunar_eclipse.js)
|
||||
Calculates details about the first 10 partial/total lunar eclipses
|
||||
after the given date and time.
|
||||
|
||||
### [Moon Phase Calculator](moonphase.js)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Positions](positions.js)
|
||||
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
|
||||
|
||||
### [Rise/Set](riseset.js)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.js)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
---
|
||||
|
||||
# [API Reference](../../source/js/)
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
each body's "hour angle" is 0.
|
||||
|
||||
Having an hour angle of 0 is another way of saying that the body is
|
||||
crossing the meridian, the imaginary semicircle in the sky that passes
|
||||
from due north on the horizon, through the zenith (straight up),
|
||||
toward due south on the horizon. At this moment the body appears to
|
||||
crossing the meridian, the imaginary semicircle in the sky that passes
|
||||
from due north on the horizon, through the zenith (straight up),
|
||||
toward due south on the horizon. At this moment the body appears to
|
||||
have an azimuth of either 180 degrees (due south) or 0 (due north).
|
||||
|
||||
To execute, run the command:
|
||||
|
||||
79
demo/nodejs/lunar_eclipse.js
Normal file
79
demo/nodejs/lunar_eclipse.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
lunar_eclipse.js - by Don Cross - 2020-05-17
|
||||
|
||||
Example Node.js program for Astronomy Engine:
|
||||
https://github.com/cosinekitty/astronomy
|
||||
|
||||
Searches for the next 10 partial/total lunar eclipses after
|
||||
the current date, or a date specified on the command line.
|
||||
|
||||
To execute, run the command:
|
||||
node lunar_eclipse [date]
|
||||
*/
|
||||
|
||||
const Astronomy = require('../../source/js/astronomy.js');
|
||||
|
||||
function Pad(s, w) {
|
||||
s = s.toFixed(0);
|
||||
while (s.length < w) {
|
||||
s = '0' + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function FormatDate(t) {
|
||||
const date = t.date;
|
||||
var year = Pad(date.getUTCFullYear(), 4);
|
||||
var month = Pad(1 + date.getUTCMonth(), 2);
|
||||
var day = Pad(date.getUTCDate(), 2);
|
||||
var hour = Pad(date.getUTCHours(), 2);
|
||||
var minute = Pad(date.getUTCMinutes(), 2);
|
||||
var svalue = date.getUTCSeconds() + (date.getUTCMilliseconds() / 1000);
|
||||
var second = Pad(Math.round(svalue), 2);
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second} UTC`;
|
||||
}
|
||||
|
||||
function PrintEclipse(e) {
|
||||
// Calculate beginning/ending of different phases
|
||||
// of an eclipse by subtracting/adding the center time
|
||||
// with the number of minutes indicated by the "semi-duration"
|
||||
// fields sd_partial and sd_total.
|
||||
const MINUTES_PER_DAY = 24 * 60;
|
||||
|
||||
const p1 = e.center.AddDays(-e.sd_partial / MINUTES_PER_DAY);
|
||||
console.log(`${FormatDate(p1)} - Partial eclipse begins.`);
|
||||
|
||||
if (e.sd_total > 0) {
|
||||
const t1 = e.center.AddDays(-e.sd_total / MINUTES_PER_DAY);
|
||||
console.log(`${FormatDate(t1)} - Total eclipse begins.`);
|
||||
}
|
||||
|
||||
console.log(`${FormatDate(e.center)} - Peak of ${e.kind} eclipse.`);
|
||||
|
||||
if (e.sd_total > 0) {
|
||||
const t2 = e.center.AddDays(+e.sd_total / MINUTES_PER_DAY);
|
||||
console.log(`${FormatDate(t2)} - Total eclipse ends.`);
|
||||
}
|
||||
|
||||
const p2 = e.center.AddDays(+e.sd_partial / MINUTES_PER_DAY);
|
||||
console.log(`${FormatDate(p2)} - Partial eclipse ends.`);
|
||||
console.log('');
|
||||
}
|
||||
|
||||
function Demo() {
|
||||
const date = (process.argv.length === 3) ? new Date(process.argv[2]) : new Date();
|
||||
let count = 0;
|
||||
let eclipse = Astronomy.SearchLunarEclipse(date);
|
||||
for(;;) {
|
||||
if (eclipse.kind !== 'penumbral') {
|
||||
PrintEclipse(eclipse);
|
||||
if (++count === 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
eclipse = Astronomy.NextLunarEclipse(eclipse.center);
|
||||
}
|
||||
}
|
||||
|
||||
Demo();
|
||||
process.exit(0);
|
||||
@@ -36,14 +36,14 @@ function FormatDate(date) {
|
||||
function Demo() {
|
||||
const date = (process.argv.length === 3) ? new Date(process.argv[2]) : new Date();
|
||||
|
||||
// Calculate the Moon's current phase angle,
|
||||
// Calculate the Moon's current phase angle,
|
||||
// which ranges from 0 to 360 degrees.
|
||||
// 0 degrees = new moon,
|
||||
// 90 degrees = first quarter,
|
||||
// 180 degrees = full moon,
|
||||
// 270 degrees = third quarter.
|
||||
const phase = Astronomy.MoonPhase(date);
|
||||
console.log(`${FormatDate(date)} : Moon's phase angle = ${phase.toFixed(6)} degrees.`);
|
||||
console.log(`${FormatDate(date)} : Moon's phase angle = ${phase.toFixed(6)} degrees.`);
|
||||
console.log('');
|
||||
|
||||
// Now we predict when the next 10 lunar quarter phases will happen.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
location on the Earth.
|
||||
|
||||
To execute, run the command:
|
||||
|
||||
|
||||
node positions.js latitude longitude [date]
|
||||
|
||||
where
|
||||
|
||||
@@ -32,7 +32,7 @@ function Demo() {
|
||||
DisplayEvent('sunrise', sunrise);
|
||||
DisplayEvent('sunset', sunset);
|
||||
DisplayEvent('moonrise', moonrise);
|
||||
DisplayEvent('moonset', moonset);
|
||||
DisplayEvent('moonset', moonset);
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.log('USAGE: node riseset.js latitude longitude [date]');
|
||||
|
||||
1
demo/nodejs/test/.gitignore
vendored
1
demo/nodejs/test/.gitignore
vendored
@@ -4,3 +4,4 @@ riseset.txt
|
||||
seasons.txt
|
||||
culminate.txt
|
||||
horizon.txt
|
||||
lunar_eclipse.txt
|
||||
|
||||
50
demo/nodejs/test/lunar_eclipse_correct.txt
Normal file
50
demo/nodejs/test/lunar_eclipse_correct.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
1988-03-03 16:04:42 UTC - Partial eclipse begins.
|
||||
1988-03-03 16:13:29 UTC - Peak of partial eclipse.
|
||||
1988-03-03 16:22:16 UTC - Partial eclipse ends.
|
||||
|
||||
1988-08-27 10:07:57 UTC - Partial eclipse begins.
|
||||
1988-08-27 11:05:05 UTC - Peak of partial eclipse.
|
||||
1988-08-27 12:02:12 UTC - Partial eclipse ends.
|
||||
|
||||
1989-02-20 13:44:08 UTC - Partial eclipse begins.
|
||||
1989-02-20 14:56:15 UTC - Total eclipse begins.
|
||||
1989-02-20 15:36:04 UTC - Peak of total eclipse.
|
||||
1989-02-20 16:15:54 UTC - Total eclipse ends.
|
||||
1989-02-20 17:28:01 UTC - Partial eclipse ends.
|
||||
|
||||
1989-08-17 01:21:19 UTC - Partial eclipse begins.
|
||||
1989-08-17 02:20:32 UTC - Total eclipse begins.
|
||||
1989-08-17 03:08:47 UTC - Peak of total eclipse.
|
||||
1989-08-17 03:57:02 UTC - Total eclipse ends.
|
||||
1989-08-17 04:56:14 UTC - Partial eclipse ends.
|
||||
|
||||
1990-02-09 17:29:19 UTC - Partial eclipse begins.
|
||||
1990-02-09 18:50:02 UTC - Total eclipse begins.
|
||||
1990-02-09 19:11:47 UTC - Peak of total eclipse.
|
||||
1990-02-09 19:33:31 UTC - Total eclipse ends.
|
||||
1990-02-09 20:54:14 UTC - Partial eclipse ends.
|
||||
|
||||
1990-08-06 12:44:54 UTC - Partial eclipse begins.
|
||||
1990-08-06 14:13:00 UTC - Peak of partial eclipse.
|
||||
1990-08-06 15:41:06 UTC - Partial eclipse ends.
|
||||
|
||||
1991-12-21 10:00:27 UTC - Partial eclipse begins.
|
||||
1991-12-21 10:33:39 UTC - Peak of partial eclipse.
|
||||
1991-12-21 11:06:51 UTC - Partial eclipse ends.
|
||||
|
||||
1992-06-15 03:27:15 UTC - Partial eclipse begins.
|
||||
1992-06-15 04:57:38 UTC - Peak of partial eclipse.
|
||||
1992-06-15 06:28:01 UTC - Partial eclipse ends.
|
||||
|
||||
1992-12-09 21:59:59 UTC - Partial eclipse begins.
|
||||
1992-12-09 23:07:16 UTC - Total eclipse begins.
|
||||
1992-12-09 23:44:43 UTC - Peak of total eclipse.
|
||||
1992-12-10 00:22:09 UTC - Total eclipse ends.
|
||||
1992-12-10 01:29:26 UTC - Partial eclipse ends.
|
||||
|
||||
1993-06-04 11:11:48 UTC - Partial eclipse begins.
|
||||
1993-06-04 12:12:49 UTC - Total eclipse begins.
|
||||
1993-06-04 13:01:02 UTC - Peak of total eclipse.
|
||||
1993-06-04 13:49:14 UTC - Total eclipse ends.
|
||||
1993-06-04 14:50:15 UTC - Partial eclipse ends.
|
||||
|
||||
@@ -29,5 +29,9 @@ echo "Testing example: horizon.js"
|
||||
node horizon +25.5 -85.3 2016-12-25T12:30:45Z > test/horizon.txt || Fail "Error running horizon.js."
|
||||
diff test/horizon.txt test/horizon_correct.txt || Fail "Error comparing horizon.js output."
|
||||
|
||||
echo "Testing example: lunar_eclipse.js"
|
||||
node lunar_eclipse.js 1988-01-01 > test/lunar_eclipse.txt || Fail "Error running lunar_eclipse.js."
|
||||
diff test/lunar_eclipse.txt test/lunar_eclipse_correct.txt || Fail "Error comparing lunar_eclipse.js output."
|
||||
|
||||
echo "PASS: nodejs examples"
|
||||
exit 0
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
|
||||
---
|
||||
|
||||
### [Moon Phase Calculator](moonphase.py)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Body Positions](positions.py)
|
||||
An example of how to calculate equatorial and horizontal coordinates for all of the major solar system bodies.
|
||||
|
||||
### [Rise/Set](riseset.py)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.py)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
### [Culmination](culminate.py)
|
||||
Finds when the Sun, Moon, and planets reach their highest position in the sky on a given date,
|
||||
as seen by an observer at a specified location on the Earth.
|
||||
@@ -27,6 +14,23 @@ This is a more advanced example. It shows how to use coordinate
|
||||
transforms to find where the ecliptic intersects with an observer's
|
||||
horizon at a given date and time.
|
||||
|
||||
### [Lunar Eclipse](lunar_eclipse.py)
|
||||
Calculates details about the first 10 partial/total lunar eclipses
|
||||
after the given date and time.
|
||||
|
||||
### [Moon Phase Calculator](moonphase.py)
|
||||
This example shows how to determine the Moon's current phase,
|
||||
and how to predict when the next few quarter phases will occur.
|
||||
|
||||
### [Positions](positions.py)
|
||||
Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.
|
||||
|
||||
### [Rise/Set](riseset.py)
|
||||
Shows how to calculate sunrise, sunset, moonrise, and moonset times.
|
||||
|
||||
### [Seasons](seasons.py)
|
||||
Calculates the equinoxes and solstices for a given calendar year.
|
||||
|
||||
---
|
||||
|
||||
# [API Reference](../../source/python/)
|
||||
|
||||
Reference in New Issue
Block a user