V
V.K.S.B.K
Guest
Dear Friends,
Here is a Function ( for calculating Sunrise time, given in "Swiss Ephemeris");
Public Declare Function swe_rise_trans_true_hor Lib "swedll32.dll" _
Alias "_swe_rise_trans_true_hor@60" (
ByVal tjd_ut As Double,
ByVal ipl As Integer,
ByVal starname As String,
ByVal epheflag As Integer,
ByVal rsmi As Integer,
ByRef geopos As Double,
ByVal atpress As Double,
ByVal attemp As Double,
ByVal horhgt As Double,
ByRef tret As Double,
ByVal serr As String
) As Integer
' serr must be able to hold 256 bytes.
The help document gives the following information;
Function definitions are as follows:
int32 swe_rise_trans(
double tjd_ut, /* search after this time (UT) */
int32 ipl, /* planet number, if planet or moon */
char *starname, /* star name, if star; must be NULL or empty, if ipl is used */
int32 epheflag, /* ephemeris flag */
int32 rsmi, /* integer specifying that rise, set, or one of the two meridian transits is wanted. see definition below */
double *geopos, /* array of three doubles containing geograph. long., lat., height of observer */
double atpress, /* atmospheric pressure in mbar/hPa */
double attemp, /* atmospheric temperature in deg. C */
double *tret, /* return address (double) for rise time etc. */
char *serr); /* return address for error message */
The rising times depend on the atmospheric pressure and temperature.
atpress expects the atmospheric pressure in millibar (hectopascal);
attemp the temperature in degrees Celsius.
If atpress is given the value 0, the function estimates the pressure from the geographical altitude given in geopos[2] and attemp. If geopos[2] is 0, atpress will be estimated for sea level.
For finding the Sunrise time, I declared the following variables;
Dim tjd_ut, SunRiseTret1 As Double
tjd_ut = SunRiseDay
ipl = SE_SUN 'SE_SUN = 0
epheflag = SEFL_SWIEPH
rsmi = SE_CALC_RISE + SE_BIT_CIVIL_TWILIGHT
Dim GeoPos(3) As Double
GeoPos(0) = 80.0 'Longitude
GeoPos(1) = 13 'Latitude
GeoPos(2) = 0 ' Altitude
Dim atpress As Double = 1013.25 ' atmospheric pressure
Dim attemp As Double = 15 'atmospheric temperature
Dim Serr As String
When I pass values for the Arguments in the Function I get Error as shown in the picture below;
Can you please let me know how to pass the 3 element Array (GeoPos) to this function?
The Help Document gives a Sample Program in C/C++ as given below.
In order to calculate the sunrise of a given date and geographic location, one can proceed as in the following program (tested code!):
int main()
{
char serr[AS_MAXCH];
double epheflag = SEFLG_SWIEPH;
int gregflag = SE_GREG_CAL;
int year = 2017;
int month = 4;
int day = 12;
int geo_longitude = 76.5; // positive for east, negative for west of Greenwich
int geo_latitude = 30.0;
int geo_altitude = 0.0;
double hour;
// array for atmospheric conditions
double datm[2];
datm[0] = 1013.25; // atmospheric pressure;
// irrelevant with Hindu method, can be set to 0
datm[1] = 15; // atmospheric temperature;
// irrelevant with Hindu method, can be set to 0
// array for geographic position
double geopos[3];
geopos[0] = geo_longitude;
geopos[1] = geo_latitude;
geopos[2] = geo_altitude; // height above see level in meters;
// irrelevant with Hindu method, can be set to 0
swe_set_topo(geopos[0], geopos[1], geopos[2]);
int ipl = SE_SUN; // object whose rising is wanted
char starname[255]; // name of star, if a star's rising is wanted
// is "" or NULL, if Sun, Moon, or planet is calculated
double trise; // for rising time
double tset; // for setting time
// calculate the julian day number of the date at 0:00 UT:
double tjd = swe_julday(year,month,day,0,gregflag);
// convert geographic longitude to time (day fraction) and subtract it from tjd
// this method should be good for all geographic latitudes except near in
// polar regions
double dt = geo_longitude / 360.0;
tjd = tjd - dt;
// calculation flag for Hindu risings/settings
int rsmi = SE_CALC_RISE | SE_BIT_HINDU_RISING;
// or SE_CALC_RISE + SE_BIT_HINDU_RISING;
// or SE_CALC_RISE | SE_BIT_DISC_CENTER | SE_BIT_NO_REFRACTION | SE_BIT_GEOCTR_NO_ECL_LAT;
int return_code = swe_rise_trans(tjd, ipl, starname, epheflag, rsmi, geopos, datm[0], datm[1], &trise, serr);
if (return_code == ERR) {
// error action
printf("%s\n", serr);
}
It seems that in the sample program, the 3-element Array is passed to the Function.
I don't know how to do that in VB.Net.
Can anybody help me, please?
Thanks
VKSBK
A Real Novice Programmer !
Continue reading...
Here is a Function ( for calculating Sunrise time, given in "Swiss Ephemeris");
Public Declare Function swe_rise_trans_true_hor Lib "swedll32.dll" _
Alias "_swe_rise_trans_true_hor@60" (
ByVal tjd_ut As Double,
ByVal ipl As Integer,
ByVal starname As String,
ByVal epheflag As Integer,
ByVal rsmi As Integer,
ByRef geopos As Double,
ByVal atpress As Double,
ByVal attemp As Double,
ByVal horhgt As Double,
ByRef tret As Double,
ByVal serr As String
) As Integer
' serr must be able to hold 256 bytes.
The help document gives the following information;
Function definitions are as follows:
int32 swe_rise_trans(
double tjd_ut, /* search after this time (UT) */
int32 ipl, /* planet number, if planet or moon */
char *starname, /* star name, if star; must be NULL or empty, if ipl is used */
int32 epheflag, /* ephemeris flag */
int32 rsmi, /* integer specifying that rise, set, or one of the two meridian transits is wanted. see definition below */
double *geopos, /* array of three doubles containing geograph. long., lat., height of observer */
double atpress, /* atmospheric pressure in mbar/hPa */
double attemp, /* atmospheric temperature in deg. C */
double *tret, /* return address (double) for rise time etc. */
char *serr); /* return address for error message */
The rising times depend on the atmospheric pressure and temperature.
atpress expects the atmospheric pressure in millibar (hectopascal);
attemp the temperature in degrees Celsius.
If atpress is given the value 0, the function estimates the pressure from the geographical altitude given in geopos[2] and attemp. If geopos[2] is 0, atpress will be estimated for sea level.
For finding the Sunrise time, I declared the following variables;
Dim tjd_ut, SunRiseTret1 As Double
tjd_ut = SunRiseDay
ipl = SE_SUN 'SE_SUN = 0
epheflag = SEFL_SWIEPH
rsmi = SE_CALC_RISE + SE_BIT_CIVIL_TWILIGHT
Dim GeoPos(3) As Double
GeoPos(0) = 80.0 'Longitude
GeoPos(1) = 13 'Latitude
GeoPos(2) = 0 ' Altitude
Dim atpress As Double = 1013.25 ' atmospheric pressure
Dim attemp As Double = 15 'atmospheric temperature
Dim Serr As String
When I pass values for the Arguments in the Function I get Error as shown in the picture below;
Can you please let me know how to pass the 3 element Array (GeoPos) to this function?
The Help Document gives a Sample Program in C/C++ as given below.
In order to calculate the sunrise of a given date and geographic location, one can proceed as in the following program (tested code!):
int main()
{
char serr[AS_MAXCH];
double epheflag = SEFLG_SWIEPH;
int gregflag = SE_GREG_CAL;
int year = 2017;
int month = 4;
int day = 12;
int geo_longitude = 76.5; // positive for east, negative for west of Greenwich
int geo_latitude = 30.0;
int geo_altitude = 0.0;
double hour;
// array for atmospheric conditions
double datm[2];
datm[0] = 1013.25; // atmospheric pressure;
// irrelevant with Hindu method, can be set to 0
datm[1] = 15; // atmospheric temperature;
// irrelevant with Hindu method, can be set to 0
// array for geographic position
double geopos[3];
geopos[0] = geo_longitude;
geopos[1] = geo_latitude;
geopos[2] = geo_altitude; // height above see level in meters;
// irrelevant with Hindu method, can be set to 0
swe_set_topo(geopos[0], geopos[1], geopos[2]);
int ipl = SE_SUN; // object whose rising is wanted
char starname[255]; // name of star, if a star's rising is wanted
// is "" or NULL, if Sun, Moon, or planet is calculated
double trise; // for rising time
double tset; // for setting time
// calculate the julian day number of the date at 0:00 UT:
double tjd = swe_julday(year,month,day,0,gregflag);
// convert geographic longitude to time (day fraction) and subtract it from tjd
// this method should be good for all geographic latitudes except near in
// polar regions
double dt = geo_longitude / 360.0;
tjd = tjd - dt;
// calculation flag for Hindu risings/settings
int rsmi = SE_CALC_RISE | SE_BIT_HINDU_RISING;
// or SE_CALC_RISE + SE_BIT_HINDU_RISING;
// or SE_CALC_RISE | SE_BIT_DISC_CENTER | SE_BIT_NO_REFRACTION | SE_BIT_GEOCTR_NO_ECL_LAT;
int return_code = swe_rise_trans(tjd, ipl, starname, epheflag, rsmi, geopos, datm[0], datm[1], &trise, serr);
if (return_code == ERR) {
// error action
printf("%s\n", serr);
}
It seems that in the sample program, the 3-element Array is passed to the Function.
I don't know how to do that in VB.Net.
Can anybody help me, please?
Thanks
VKSBK
A Real Novice Programmer !
Continue reading...