@@ -4,137 +4,93 @@ import 'package:astro_calculations/src/solar_calc.dart';
44import 'data/solar_test_data.dart' ;
55
66void main () {
7+ group ('Julian Day Tests' , () {
8+ test ('Get Julian Day from Gregorian Day' , () {
9+ for (var dateTime in TestData ['julianDayTestData' ].keys) {
10+ expect (getJulianDay (dateTime), equals (TestData ['julianDayTestData' ][dateTime]));
11+ }
12+ });
13+
14+ test ('Get Gregorian Day from Julian Day' , () {
15+ final _reversedMap = TestData ['julianDayTestData' ].map ((key, value) => MapEntry (value, key));
16+ for (var julianDay in TestData ['julianDayTestData' ].values) {
17+ expect (getGregorianDay (julianDay), equals (_reversedMap[julianDay]));
18+ }
19+ });
20+ });
21+
722 group ('Heliocentric Calculations' , () {
823 test ('Get Heliocentric Latitude' , () {
9- expect (getHeliocentricLatitude (TestData ['julianMillenium' ]),
10- closeTo (TestData ['heliocentricLatitude' ], 0.001 ));
24+ expect (getHeliocentricLatitude (TestData ['julianMillenium' ]), closeTo (TestData ['heliocentricLatitude' ], 0.001 ));
1125 });
1226
1327 test ('Get Heliocentric longitude' , () {
14- expect (getHeliocentricLongitude (TestData ['julianMillenium' ]),
15- closeTo (TestData ['heliocentricLongitude' ], 0.001 ));
28+ expect (getHeliocentricLongitude (TestData ['julianMillenium' ]), closeTo (TestData ['heliocentricLongitude' ], 0.001 ));
1629 });
1730
1831 test ('Get Earth Radius Vector' , () {
19- expect (getEarthRadiusVector (TestData ['julianMillenium' ]),
20- closeTo (TestData ['earthSunDistance' ], 0.001 ));
32+ expect (getEarthRadiusVector (TestData ['julianMillenium' ]), closeTo (TestData ['earthSunDistance' ], 0.001 ));
2133 });
2234 });
2335
2436 group ('Get Nutation Values' , () {
2537 final nutationValue = getNutation (TestData ['julianEphemerisCentury' ]);
2638 test ('Get Nutation longitude' , () {
27- expect (nutationValue.longitude,
28- closeTo (TestData ['nutation' ].longitude, 0.0000001 ));
39+ expect (nutationValue.longitude, closeTo (TestData ['nutation' ].longitude, 0.0000001 ));
2940 });
3041 test ('Get Nutation Obliquity' , () {
31- expect (nutationValue.obliquity,
32- closeTo (TestData ['nutation' ].obliquity, 0.0000001 ));
42+ expect (nutationValue.obliquity, closeTo (TestData ['nutation' ].obliquity, 0.0000001 ));
3343 });
3444 });
3545
3646 test ('Get true obliquity of ecliptic' , () {
37- expect (
38- getTrueObliquityOfEcliptic (
39- TestData ['julianMillenium' ], TestData ['nutation' ]),
40- closeTo (TestData ['trueObliquityOfEcliptic' ], 0.00001 ));
47+ expect (getTrueObliquityOfEcliptic (TestData ['julianMillenium' ], TestData ['nutation' ]), closeTo (TestData ['trueObliquityOfEcliptic' ], 0.00001 ));
4148 });
4249
4350 test ('Get Aberration Correction' , () {
44- expect (getAberrationCorrection (TestData ['earthSunDistance' ]),
45- closeTo (TestData ['aberrationCorrection' ], 0.00001 ));
51+ expect (getAberrationCorrection (TestData ['earthSunDistance' ]), closeTo (TestData ['aberrationCorrection' ], 0.00001 ));
4652 });
4753
4854 test ('Get Apparent Sun Longitude' , () {
49- expect (
50- getApparentSunLongitude (TestData ['geocentricLongitude' ],
51- TestData ['nutation' ], TestData ['aberrationCorrection' ]),
52- closeTo (TestData ['apparentSunLongitude' ], 0.001 ));
55+ expect (getApparentSunLongitude (TestData ['geocentricLongitude' ], TestData ['nutation' ], TestData ['aberrationCorrection' ]), closeTo (TestData ['apparentSunLongitude' ], 0.001 ));
5356 });
5457
5558 test ('Get Apparent Sidereal Time' , () {
56- expect (
57- getApparentSiderealTime (TestData ['julianDay' ],
58- TestData ['julianMillenium' ], TestData ['nutation' ]),
59- closeTo (TestData ['apparentSiderealTime' ], 0.01 ));
59+ expect (getApparentSiderealTime (TestData ['julianDay' ], TestData ['julianMillenium' ], TestData ['nutation' ]), closeTo (TestData ['apparentSiderealTime' ], 0.01 ));
6060 });
6161 test ('Get Geocentric Sun Right Ascension' , () {
62- expect (
63- getGeocentricSunRightAscension (
64- TestData ['apparentSunLongitude' ],
65- TestData ['trueObliquityOfEcliptic' ],
66- TestData ['geocentricLatitude' ]),
67- closeTo (TestData ['geocentricRightAscension' ], 0.001 ));
62+ expect (getGeocentricSunRightAscension (TestData ['apparentSunLongitude' ], TestData ['trueObliquityOfEcliptic' ], TestData ['geocentricLatitude' ]), closeTo (TestData ['geocentricRightAscension' ], 0.001 ));
6863 });
6964 test ('Get Geocentric Sun Declination' , () {
70- expect (
71- getGeocentricSunDeclination (
72- TestData ['apparentSunLongitude' ],
73- TestData ['trueObliquityOfEcliptic' ],
74- TestData ['geocentricLatitude' ]),
75- closeTo (TestData ['geocentricSunDeclination' ], 0.001 ));
65+ expect (getGeocentricSunDeclination (TestData ['apparentSunLongitude' ], TestData ['trueObliquityOfEcliptic' ], TestData ['geocentricLatitude' ]), closeTo (TestData ['geocentricSunDeclination' ], 0.001 ));
7666 });
7767 test ('get Observer local hour angle' , () {
78- expect (
79- getLocalHourAngle (TestData ['apparentSiderealTime' ],
80- TestData ['longitude' ], TestData ['geocentricRightAscension' ]),
81- closeTo (TestData ['localHourAngle' ], 0.01 ));
68+ expect (getLocalHourAngle (TestData ['apparentSiderealTime' ], TestData ['longitude' ], TestData ['geocentricRightAscension' ]), closeTo (TestData ['localHourAngle' ], 0.01 ));
8269 });
8370
8471 group ('Position of sun with respect to observer on earth' , () {
8572 test ('get Topocentric Right Ascension' , () {
86- expect (
87- getTopocentricSunRightAscension (
88- TestData ['projectedRadialDistance' ],
89- TestData ['equatorialHorizontalParallaxOfSun' ],
90- TestData ['localHourAngle' ],
91- TestData ['apparentSunLongitude' ],
92- TestData ['trueObliquityOfEcliptic' ],
93- TestData ['geocentricLatitude' ]),
94- closeTo (TestData ['topocentricSunRightAscension' ], 0.001 ));
73+ expect (getTopocentricSunRightAscension (TestData ['projectedRadialDistance' ], TestData ['equatorialHorizontalParallaxOfSun' ], TestData ['localHourAngle' ], TestData ['apparentSunLongitude' ], TestData ['trueObliquityOfEcliptic' ], TestData ['geocentricLatitude' ]), closeTo (TestData ['topocentricSunRightAscension' ], 0.001 ));
9574 });
9675 test ('get Topocentric Sun Declination ' , () {
97- expect (
98- getTopocentricSunDeclination (
99- TestData ['projectedAxialDistance' ],
100- TestData ['equatorialHorizontalParallaxOfSun' ],
101- TestData ['localHourAngle' ],
102- TestData ['projectedRadialDistance' ],
103- TestData ['geocentricSunDeclination' ]),
104- closeTo (TestData ['topocentricSunDeclination' ], 0.0001 ));
76+ expect (getTopocentricSunDeclination (TestData ['projectedAxialDistance' ], TestData ['equatorialHorizontalParallaxOfSun' ], TestData ['localHourAngle' ], TestData ['projectedRadialDistance' ], TestData ['geocentricSunDeclination' ]), closeTo (TestData ['topocentricSunDeclination' ], 0.0001 ));
10577 });
10678 });
10779
10880 test ('get Topocentric Local Hour Angle' , () {
10981 //Value of parallaxInSunRightAscension is calculated from this program itself since I couldn't find any data for it
110- expect (
111- getTopocentricLocalHourAngle (TestData ['localHourAngle' ],
112- TestData ['parallaxInSunRightAscension' ]),
113- closeTo (TestData ['topocentricLocalHourAngle' ], 0.0001 ));
82+ expect (getTopocentricLocalHourAngle (TestData ['localHourAngle' ], TestData ['parallaxInSunRightAscension' ]), closeTo (TestData ['topocentricLocalHourAngle' ], 0.0001 ));
11483 });
11584
11685 test ('get Topocentric Zenith Angle' , () {
117- expect (
118- getTopocentricZenithAngle (
119- TestData ['latitude' ],
120- TestData ['topocentricSunDeclination' ],
121- TestData ['topocentricLocalHourAngle' ],
122- TestData ['pressure' ],
123- TestData ['temperatureInCelsius' ]),
124- closeTo (TestData ['topocentricZenithAngle' ], 0.0001 ));
86+ expect (getTopocentricZenithAngle (TestData ['latitude' ], TestData ['topocentricSunDeclination' ], TestData ['topocentricLocalHourAngle' ], TestData ['pressure' ], TestData ['temperatureInCelsius' ]), closeTo (TestData ['topocentricZenithAngle' ], 0.0001 ));
12587 });
12688
12789 test ('get Topocentric Azimuth Angle' , () {
128- expect (
129- getTopocentricAzimuthAngle (TestData ['topocentricLocalHourAngle' ],
130- TestData ['latitude' ], TestData ['topocentricSunDeclination' ]),
131- closeTo (TestData ['topocentricAzimuthAngle' ], 0.0001 ));
90+ expect (getTopocentricAzimuthAngle (TestData ['topocentricLocalHourAngle' ], TestData ['latitude' ], TestData ['topocentricSunDeclination' ]), closeTo (TestData ['topocentricAzimuthAngle' ], 0.0001 ));
13291 });
13392
13493 test ('get Topocentric Incidence Angle' , () {
135- expect (
136- getIncidenceAngle (TestData ['topocentricZenithAngle' ], TestData ['slope' ],
137- TestData ['slopeOrientation' ], TestData ['topocentricAzimuthAngle' ]),
138- closeTo (TestData ['incidenceAngle' ], 0.001 ));
94+ expect (getIncidenceAngle (TestData ['topocentricZenithAngle' ], TestData ['slope' ], TestData ['slopeOrientation' ], TestData ['topocentricAzimuthAngle' ]), closeTo (TestData ['incidenceAngle' ], 0.001 ));
13995 });
14096}
0 commit comments