示例#1
0
void MainWindow::setSunVectors(ln_zonedate* date, ln_lnlat_posn* observer, Vector* vector)
{
    struct ln_equ_posn equ;
    struct ln_hrz_posn hpos;

    double JD;

    ln_date lnDate;
    lnDate.years = date->years;
    lnDate.months = date->months;
    lnDate.days = date->days;
    lnDate.hours = date->hours;
    lnDate.minutes = date->minutes;
    lnDate.seconds = date->seconds;

    JD = ln_get_julian_day(&lnDate);

    /* ra, dec */
    ln_get_solar_equ_coords (JD, &equ);


    ln_get_hrz_from_equ(&equ, observer, JD, &hpos);

    double a = ln_range_degrees(hpos.az - 180);
    vector->setHeading(a);
}
示例#2
0
bool LX200SS2000PC::updateTime(ln_date * utc, double utc_offset) {
  bool result = true;
  // This method is largely identical to the one in the LX200Generic class.
  // The difference is that it ensures that updates that require planetary
  // data to be recomputed by the SkySensor2000PC are only done when really
  // necessary because this takes quite some time.
  if (!isSimulation()) {
    result = false;
    struct ln_zonedate ltm;
    ln_date_to_zonedate(utc, &ltm, static_cast<long>(utc_offset*3600.0+0.5));
    DEBUGF(INDI::Logger::DBG_DEBUG, "New zonetime is %04d-%02d-%02d %02d:%02d:%06.3f (offset=%ld)", ltm.years, ltm.months, ltm.days, ltm.hours, ltm.minutes, ltm.seconds, ltm.gmtoff);
    JD = ln_get_julian_day(utc);
    DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %f", JD);
    if (setLocalTime(PortFD, ltm.hours, ltm.minutes, static_cast<int>(ltm.seconds+0.5)) < 0) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time.");
    }
    else if (!setCalenderDate(ltm.years, ltm.months, ltm.days)) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date.");
    }
    // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which
    // is the opposite of the standard definition of UTC offset!
    else if (!setUTCOffset(-static_cast<int>(utc_offset))) {
      DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
    }
    else {
      DEBUG(INDI::Logger::DBG_SESSION, "Time updated.");
      result = true;
    }
  }
  return result;
}
示例#3
0
bool ioptronHC8406::updateTime(ln_date *utc, double utc_offset)
{
    struct ln_zonedate ltm;

    if (isSimulation())
        return true;

    ln_date_to_zonedate(utc, &ltm, utc_offset * 3600.0);

    JD = ln_get_julian_day(utc);

    DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %.2f", JD);

    // Set Local Time
    if (setLocalTime(PortFD, ltm.hours, ltm.minutes, ltm.seconds) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time.");
        return false;
    }

    if (setCalenderDate(PortFD, ltm.days, ltm.months, ltm.years) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting local date.");
        return false;
    }

    if (setioptronHC8406UTCOffset(utc_offset) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
        return false;
    }

    return true;
}
示例#4
0
void MainWindow::setSunCurrentHeading(const QDateTime &dateTime)
{
    struct ln_equ_posn equ;
    struct ln_lnlat_posn observer;

    struct ln_hrz_posn hpos;

    double JD;

    observer.lat = ui->latEdit->text().toFloat();
    observer.lng = ui->lngEdit->text().toFloat();

    ln_date novaDate;
    novaDate.years = dateTime.date().year();
    novaDate.months = dateTime.date().month();
    novaDate.days = dateTime.date().day();
    novaDate.hours = dateTime.time().hour();
    novaDate.minutes = dateTime.time().minute();
    novaDate.seconds = dateTime.time().second();

    JD = ln_get_julian_day(&novaDate);

    /* ra, dec */
    ln_get_solar_equ_coords (JD, &equ);


    ln_get_hrz_from_equ(&equ, &observer, JD, &hpos);

    double a = ln_range_degrees(hpos.az - 180);

    sunHeading->setHeading(a);

    mc->updateRequestNew();
}
示例#5
0
void MainWindow::on_pushButton_clicked()
{
    QString fileName = QFileDialog::getSaveFileName(this,
         tr("Open Image"), "*.csv", tr("Data Files (*.txt *.csv)"));

    if(fileName.isEmpty())
        return;

    if(QFile::exists(fileName))
        QFile::remove(fileName);

    QFile file(fileName);

    if(!file.open(QFile::WriteOnly | QFile::Truncate))
        return;

    struct ln_lnlat_posn observer;
    struct ln_equ_posn equ;
    struct ln_hrz_posn hpos;

    double JD;

    observer.lat = ui->latEdit->text().toFloat();
    observer.lng = ui->lngEdit->text().toFloat();

    QDateTime dateTime = ui->dateTimeEdit_2->dateTime();
    QTextStream ts(&file);

    for (int i = 0; i < 1000; ++i) {
        ln_date lnDate;
        lnDate.years = dateTime.date().year();
        lnDate.months = dateTime.date().month();
        lnDate.days = dateTime.date().day();
        lnDate.hours = dateTime.time().hour();
        lnDate.minutes = dateTime.time().minute();
        lnDate.seconds = dateTime.time().second();

        JD = ln_get_julian_day(&lnDate);

        /* ra, dec */
        ln_get_solar_equ_coords (JD, &equ);
        ln_get_hrz_from_equ(&equ, &observer, JD, &hpos);

        ui->tableWidget->insertRow(i);
        ui->tableWidget->setItem(i,0, new QTableWidgetItem(dateTime.toString("yyyy-MM-dd hh:mm")));
        ui->tableWidget->setItem(i,1, new QTableWidgetItem(QString::number(hpos.az, 'f', 3)));
        ui->tableWidget->setItem(i,2, new QTableWidgetItem(QString::number(hpos.alt, 'f', 3)));

        //QStringList sl;

        ts << dateTime.toString() << ";" << QString::number(hpos.az, 'f', 3) << ";" << QString::number(hpos.alt, 'f', 3) << "\r\n";

        dateTime = dateTime.addSecs(600);
    }

    file.close();


}
示例#6
0
/*! \fn double ln_get_julian_local_date(struct ln_zonedate* zonedate)
* \param zonedate Local date
* \return Julian day (UT)
*
* Calculate Julian day (UT) from zone date
*/
double ln_get_julian_local_date(struct ln_zonedate* zonedate)
{
	struct ln_date date;
	
	ln_zonedate_to_date (zonedate, &date);

	return ln_get_julian_day (&date);
}
示例#7
0
int parseDate (const char *in_date, time_t *out_time, bool forceUT, bool *only_date)
{
	int ret;
	struct ln_date l_date;
	ret = parseDate (in_date, &l_date, forceUT, only_date);
	if (ret)
		return ret;
	ln_get_timet_from_julian (ln_get_julian_day (&l_date), out_time);
	return 0;
}
示例#8
0
int parseDate (const char *in_date, double &JD, bool forceUT, bool *only_date)
{
	struct ln_date l_date;
	int ret;
	ret = parseDate (in_date, &l_date, forceUT, only_date);
	if (ret)
		return ret;
	JD = ln_get_julian_day (&l_date);
	return 0;
}
示例#9
0
/*! \fn double ln_get_julian_from_mpc (char* mpc_date)
* \param mpc_date Pointer to string MPC date
* \return Julian day.
*
* Calculate the julian day from the a MPC packed date.
* See http://cfa-www.harvard.edu/iau/info/PackedDates.html for info.
*/
double ln_get_julian_from_mpc (char* mpc_date)
{
	struct ln_date date;
	double JD;
	
	ln_get_date_from_mpc(&date, mpc_date);	
	JD = ln_get_julian_day(&date);
	
	return JD;
}
示例#10
0
/*! \fn double ln_get_julian_from_sys()
* \return Julian day (UT)
*
* Calculate the julian day (UT) from the local system time
*/
double ln_get_julian_from_sys()
{
	double JD;
	struct ln_date date;
		
	/* get sys date */
	ln_get_date_from_sys (&date);
	JD = ln_get_julian_day (&date);

	return JD;
}
示例#11
0
/*! \fn unsigned int ln_get_day_of_week (struct ln_date *date)
* \param date Date required
* \return Day of the week
*
* Calculate the day of the week. 
* Returns 0 = Sunday .. 6 = Saturday
*/
unsigned int ln_get_day_of_week (struct ln_date *date)
{
    unsigned int day;
    double JD;
    
    /* get julian day */
    JD = ln_get_julian_day (date);
    JD += 1.5;
    day = (int)JD % 7; 
    
    return day;
}	
示例#12
0
/*! \fn void ln_zonedate_to_date (struct ln_zonedate * zonedate, struct ln_date * date)
* \param zonedate Ptr to zonedate
* \param date Ptr to date
*
* Converts a ln_zonedate (local time) to a ln_date (UT). 
*/
void ln_zonedate_to_date (struct ln_zonedate * zonedate, struct ln_date * date)
{
	double jd;
	struct ln_date dat;

	dat.years   = zonedate->years;
	dat.months  = zonedate->months;
	dat.days    = zonedate->days;
	dat.hours   = zonedate->hours;
	dat.minutes = zonedate->minutes;
	dat.seconds = zonedate->seconds;

	jd = ln_get_julian_day (&dat);
	jd -= zonedate->gmtoff / 86400.0;
	ln_get_date (jd, date);
}
示例#13
0
int parseDate (const char *in_date, struct ln_date *out_time, bool forceUT, bool *only_date)
{
	bool islocal;
	int ret = parseLocalDate (in_date, out_time, islocal, only_date);
	if (forceUT == false && islocal)
	{
		double JD = ln_get_julian_day (out_time);
		struct timeval tv;
		struct timezone tz;
		gettimeofday (&tv, &tz);
		JD += tz.tz_minuteswest / 1440.0;
		ln_get_date (JD, out_time);
		if (out_time->seconds < 0.001)
			out_time->seconds = 0;
	}
	return ret;
}
示例#14
0
/*! \fn void ln_date_to_zonedate (struct ln_date * date, struct ln_zonedate * zonedate, long gmtoff)
* \param zonedate Ptr to zonedate
* \param gmtoff Offset in seconds from UT
* \param date Ptr to date
*
* Converts a ln_date (UT) to a ln_zonedate (local time). 
*/
void ln_date_to_zonedate (struct ln_date * date, struct ln_zonedate * zonedate, long gmtoff)
{
	double jd;
	struct ln_date dat;

	jd = ln_get_julian_day (date);
	jd += gmtoff / 86400.0;
	ln_get_date (jd, &dat);

	zonedate->years   = dat.years;
	zonedate->months  = dat.months;
	zonedate->days    = dat.days;
	zonedate->hours   = dat.hours;
	zonedate->minutes = dat.minutes;
	zonedate->seconds = dat.seconds;

	zonedate->gmtoff  = gmtoff;
}
示例#15
0
END_TEST

START_TEST(test_altaz_2)
{
	// test 2, 2016-04-12T19:20:47 HST = 2016-4-13U20:23:47
	struct ln_date test_t;
	test_t.years = 2016;
	test_t.months = 4;
	test_t.days = 13;
	test_t.hours = 20;
	test_t.minutes = 23;
	test_t.seconds = 47;

	double JD = ln_get_julian_day (&test_t);
	ck_assert_dbl_eq (JD, 2457492.34985, 10e-5);

	ck_assert_dbl_eq (ln_get_mean_sidereal_time (JD), ln_get_apparent_sidereal_time (JD) + 6.842610000035165e-05, 10e-10);
}
示例#16
0
文件: lx200gps.cpp 项目: rumengb/indi
bool LX200GPS::updateTime(ln_date *utc, double utc_offset)
{
    ln_zonedate ltm;

    if (isSimulation())
        return true;

    JD = ln_get_julian_day(utc);

    DEBUGF(INDI::Logger::DBG_DEBUG, "New JD is %f", (float)JD);

    ln_date_to_zonedate(utc, &ltm, utc_offset * 3600);

    DEBUGF(INDI::Logger::DBG_DEBUG, "Local time is %02d:%02d:%02g", ltm.hours, ltm.minutes, ltm.seconds);

    // Set Local Time
    if (setLocalTime(PortFD, ltm.hours, ltm.minutes, ltm.seconds) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting local time time.");
        return false;
    }

    if (setCalenderDate(PortFD, utc->days, utc->months, utc->years) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC date.");
        return false;
    }

    // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which
    // is the opposite of the standard definition of UTC offset!
    if (setUTCOffset(PortFD, (utc_offset * -1.0)) < 0)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Error setting UTC Offset.");
        return false;
    }

    DEBUG(INDI::Logger::DBG_SESSION, "Time updated, updating planetary data...");
    return true;
}
示例#17
0
END_TEST

START_TEST(test_altaz_1)
{
	// test 1, 2016-01-12T19:20:47 HST = 2016-01-13U05:20:47
	struct ln_date test_t;
	test_t.years = 2016;
	test_t.months = 1;
	test_t.days = 13;
	test_t.hours = 5;
	test_t.minutes = 20;
	test_t.seconds = 47;

	double JD = ln_get_julian_day (&test_t);
	ck_assert_dbl_eq (JD, 2457400.7227662038, 10e-10);

	struct ln_hrz_posn hrz, res_hrz;
	hrz.alt = 80;
	hrz.az = 20;

	struct ln_equ_posn pos;
	pos.ra = 20;
	pos.dec = 80;

	int32_t azc = -20000000;
	int32_t altc = 1000;

	int ret = altAzTest->test_hrz2counts (&hrz, azc, altc);
	ck_assert_int_eq (ret, 0);
	ck_assert_int_eq (azc, -13048946);
	ck_assert_int_eq (altc, 3169029);

	altAzTest->test_counts2hrz (azc, altc, &res_hrz);
	ck_assert_dbl_eq (res_hrz.az, hrz.az, 10e-5);
	ck_assert_dbl_eq (res_hrz.alt, hrz.alt, 10e-5);

	ck_assert_dbl_eq (ln_get_mean_sidereal_time (JD), ln_get_apparent_sidereal_time (JD) + 7.914799999397815e-06, 10e-10);

	altAzTest->modelOff ();

	ret = altAzTest->test_sky2counts (JD, 0, &pos, azc, altc);
	ck_assert_int_eq (ret, 0);
#ifdef RTS2_LIBERFA
	ck_assert_int_eq (azc, 16135692);
	ck_assert_int_eq (altc, 27318632);
#else
	ck_assert_int_eq (azc, 16147941);
	ck_assert_int_eq (altc, 27349158);
#endif

	altAzTest->test_counts2sky (JD, azc, altc, pos.ra, pos.dec);

#ifdef RTS2_LIBERFA
	ck_assert_dbl_eq (pos.ra, 20, 10e-1);
	ck_assert_dbl_eq (pos.dec, 80, 10e-1);
#else
	ck_assert_dbl_eq (pos.ra, 20, 10e-4);
	ck_assert_dbl_eq (pos.dec, 80, 10e-4);
#endif

	altAzTest->modelOn ();

	// origin
	pos.ra = 344.16613;
	pos.dec = -80.3703305;

	ret = altAzTest->test_sky2counts (JD, 0, &pos, azc, altc);
	ck_assert_int_eq (ret, 0);
#ifdef RTS2_LIBERFA
	ck_assert_int_eq (azc, 49514704);
	ck_assert_int_eq (altc, 12305112);
#else
	ck_assert_int_eq (azc, 49510278);
	ck_assert_int_eq (altc, 12292286);
#endif

	// target
	pos.ra = 62.95859;
	pos.dec = -80.51601;

	float e = altAzTest->test_move (JD, &pos, azc, altc, 2.0, 200);
	ck_assert_msg (!std::isnan (e), "position %f %f not reached", pos.ra, pos.dec);

	struct ln_equ_posn curr;
	curr.ra = curr.dec = 0;

	altAzTest->test_counts2sky (JD, azc, altc, curr.ra, curr.dec);

#ifdef RTS2_LIBERFA
	ck_assert_dbl_eq (pos.ra, curr.ra, 10e-1);
	ck_assert_dbl_eq (pos.dec, curr.dec, 10e-1);
#else
	ck_assert_dbl_eq (pos.ra, curr.ra, 10e-3);
	ck_assert_dbl_eq (pos.dec, curr.dec, 10e-3);
#endif

	altAzTest->test_counts2hrz (-70194687, -48165219, &hrz);
	ck_assert_dbl_eq (hrz.alt, -4.621631, 10e-3);
	ck_assert_dbl_eq (hrz.az, 73.446355, 10e-3);

	ret = altAzTest->test_hrz2counts (&hrz, azc, altc);
	ck_assert_int_eq (ret, 0);
	ck_assert_int_eq (azc, 64023041);
	ck_assert_int_eq (altc, 18943644);

	altAzTest->test_counts2hrz (-68591258, -68591258, &hrz);
	ck_assert_dbl_eq (hrz.alt, 75.047819, 10e-2);
	ck_assert_dbl_eq (hrz.az, 262.047819, 10e-2);

	ret = altAzTest->test_hrz2counts (&hrz, azc, altc);
	ck_assert_int_eq (ret, 0);
	ck_assert_int_eq (azc, 32072038);
	ck_assert_int_eq (altc, 4092184);
}
示例#18
0
void MainWindow::setSunRiseAndSetVectors(const QDateTime &dateTime)
{
    struct ln_equ_posn equ;
    struct ln_rst_time rst;
    struct ln_zonedate rise, set, transit;
    struct ln_lnlat_posn observer;

    struct ln_hrz_posn hpos;

    double JD;

    observer.lat = ui->latEdit->text().toFloat();
    observer.lng = ui->lngEdit->text().toFloat();

    ln_date date;
    date.years = dateTime.date().year();
    date.months = dateTime.date().month();
    date.days = dateTime.date().day();
    date.hours = dateTime.time().hour();
    date.minutes = dateTime.time().minute();
    date.seconds = dateTime.time().second();

    JD = ln_get_julian_day(&date);

    /* ra, dec */
    ln_get_solar_equ_coords (JD, &equ);


    ln_get_hrz_from_equ(&equ, &observer, JD, &hpos);

    double a = ln_range_degrees(hpos.az - 180);

    QString s;
    s.sprintf("Azimut: %0.3f", a);
    ui->listWidget->addItem(s);
    s.sprintf("Evaluation: %0.3f", hpos.alt);
    ui->listWidget->addItem(s);

    /* rise, set and transit */
    if (ln_get_solar_rst (JD, &observer, &rst) == 1) {
        ui->listWidget->addItem(QString("Zirkumpolar"));
    } else {
        ln_get_local_date (rst.rise, &rise);
        ln_get_local_date (rst.transit, &transit);
        ln_get_local_date (rst.set, &set);
        s.sprintf("Aufgang: %02d:%02d:%02d", rise.hours, rise.minutes, (int)rise.seconds);
        ui->listWidget->addItem(s);
        s.sprintf("Transit: %02d:%02d:%02d", transit.hours, transit.minutes, (int)transit.seconds);
        ui->listWidget->addItem(s);
        s.sprintf("Untergang: %02d:%02d:%02d", set.hours, set.minutes, (int)set.seconds);
        ui->listWidget->addItem(s);

    }

    //sunHeading->setVisible(false);

    setSunVectors(&rise, &observer, sunRise);
    setSunVectors(&set, &observer, sunSet);

    mc->setView(QPointF(observer.lng, observer.lat));

    //overlay->addGeometry();
}
示例#19
0
void cmd_libnova_test (BaseSequentialStream *chp, int argc, char *argv) {
       (void) argv;
 	 if (argc > 0) {
 	   chprintf(chp, "Usage: novatest\r\n");
 	   return;
 	 }
	struct lnh_equ_posn hobject, hequ;
	struct lnh_lnlat_posn hobserver;
	struct ln_equ_posn object, equ;
	struct ln_hrz_posn hrz;
	struct lnh_hrz_posn hhrz;
	struct ln_lnlat_posn observer;

	double JD;
	struct ln_date date;

	
	/* 
	 * observers position
	 * longitude is measured positively eastwards
	 * Madrid
	 */
	hobserver.lng.degrees = -3;
	hobserver.lng.minutes = 42;
	hobserver.lng.seconds = 36;
	hobserver.lat.degrees = 40;
	hobserver.lat.minutes = 25;
	hobserver.lat.seconds = 11.99;

	/* Alnilam */
	hobject.ra.hours = 5;
	hobject.ra.minutes = 36;
	hobject.ra.seconds = 12.8;
	hobject.dec.neg = 1;
	hobject.dec.degrees = 1;
	hobject.dec.minutes = 12;
	hobject.dec.seconds = 7;

	chprintf(chp,"ANILAM: RA %d:%d:%f  DEC %d:%d:%f\n", hobject.ra.hours, hobject.ra.minutes,
		hobject.ra.seconds, hobject.dec.degrees, hobject.dec.minutes, hobject.dec.seconds);


        ln_now(&date);
        
	JD = ln_get_julian_day (&date);
	ln_hequ_to_equ (&hobject, &object);
	ln_hlnlat_to_lnlat (&hobserver, &observer);



	ln_get_hrz_from_equ (&object, &observer, JD, &hrz);
	chprintf(chp,"(Alnilam) Equ to Horiz ALT %f\n", hrz.alt);
	chprintf(chp,"(Alnilam) Equ to Horiz AZ %f\n", hrz.az);
	ln_hrz_to_hhrz(&hrz, &hhrz);
	chprintf(chp,"ALT %d:%d:%f  AZ %d:%d:%f\n", hhrz.alt.degrees, hhrz.alt.minutes,
		hhrz.alt.seconds, hhrz.az.degrees, hhrz.az.minutes, hhrz.az.seconds);

	ln_get_equ_from_hrz (&hrz, &observer, JD, &equ);
	chprintf(chp,"(Alnilam) Horiz to Equ RA %f\n", equ.ra);
	chprintf(chp,"(Alnilam) Horiz to Equ DEC %f\n", equ.dec);
	ln_equ_to_hequ(&equ, &hequ);
	chprintf(chp,"RA %d:%d:%f  DEC %d:%d:%f\n", hequ.ra.hours, hequ.ra.minutes,
		hequ.ra.seconds, hequ.dec.degrees, hequ.dec.minutes, hequ.dec.seconds);


}