void SkServer::getExtFrame() { QByteArray data; double ra,dec, angle; if (g_cDrawing.getExtFrame(ra, dec, angle)) { CMapView *view = m_mainWin->getView(); precess(&ra, &dec, JD2000, view->m_mapView.jd); if (view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC) { precess(&ra, &dec, view->m_mapView.jd, JD2000); } qDebug() << "frame" << R2D(ra) << R2D(dec) << angle; data.append(dblToString(angle, 4)); data.append(","); data.append(dblToString(R2D(ra), 6)); data.append(","); data.append(dblToString(R2D(dec), 6)); sendData(data); return; } sendData(SKS_NOT_FOUND); }
// ICRS to TEME conversion void icrs_to_teme(double mjd,double a[3][3]) { int i,j; double dpsi,deps,eps,z,theta,zeta,h; double p[3][3],n[3][3],q[3][3],b[3][3]; // Precession precess(51544.5,mjd,&zeta,&z,&theta); identity_matrix(p); rotate_z(-zeta,p); rotate_y(theta,p); rotate_z(-z,p); // Nutation nutation(mjd,&dpsi,&deps,&eps); identity_matrix(n); rotate_x(eps,n); rotate_z(-dpsi,n); rotate_x(-eps-deps,n); // Equation of equinoxes identity_matrix(q); rotate_z(dpsi*cos(eps+deps),q); // Multiply matrices (left to right) matrix_multiply(q,n,b); matrix_multiply(b,p,a); return; }
/* Initialize astrometrical structures. */ void initastrom(picstruct *field) { wcsstruct *wcs; wcs = field->wcs; /* Test if the WCS is in use */ if (wcs->lng != wcs->lat) { if (FLAG(obj2.dtheta2000) || FLAG(obj2.dtheta1950)) { if (fabs(wcs->equinox-2000.0)>0.003) precess(wcs->equinox, 0.0, 90.0, 2000.0, &wcs->ap2000, &wcs->dp2000); else { wcs->ap2000 = 0.0; wcs->dp2000 = 90.0; } if (FLAG(obj2.theta1950) || FLAG(obj2.poserr_theta1950)) j2b(wcs->equinox, wcs->ap2000, wcs->dp2000, &wcs->ap1950, &wcs->dp1950); } } /* Override astrometric definitions only if user supplies a pixel-scale */ if (prefs.pixel_scale == 0.0) field->pixscale = wcs->pixscale*3600.0; /* in arcsec */ else field->pixscale = prefs.pixel_scale; return; }
// Read data file struct data read_data(char *filename,double mjd0) { int i=0,status; char line[LIM]; FILE *file; struct data d; int min; double ra,de,ra0,de0,r; double x,y,z; // Open file file=fopen(filename,"r"); if (file==NULL) { fprintf(stderr,"Failed to open %s\n",filename); exit(1); } // Count lines while (fgetline(file,line,LIM)>0) i++; d.n=i; // Allocate d.p=(struct point *) malloc(sizeof(struct point)*d.n); // Rewind file rewind(file); // Read data i=0; while (fgetline(file,line,LIM)>0) { status=sscanf(line,"%d,%lf,%lf,%lf",&min,&x,&y,&z); if (d.n==1008) min*=10; d.p[i].mjd=mjd0+(double) min/1440.0; // Precess position r=sqrt(x*x+y*y+z*z); ra0=atan2(y,x)*R2D; de0=asin(z/r)*R2D; precess(51544.5,ra0,de0,d.p[i].mjd,&ra,&de); d.p[i].r.x=r*cos(de*D2R)*cos(ra*D2R); d.p[i].r.y=r*cos(de*D2R)*sin(ra*D2R); d.p[i].r.z=r*sin(de*D2R); d.p[i].flag=0; i++; } // Close file fclose(file); return d; }
/////////////////////////////////////////// // center & zoom void CObjInfo::on_clb_center_zoom_clicked() /////////////////////////////////////////// { double ra = m_infoItem.radec.Ra; double dec = m_infoItem.radec.Dec; precess(&ra, &dec, JD2000, m_map->m_mapView.jd); m_map->centerMap(ra, dec, m_infoItem.zoomFov); done(DL_OK); }
void CObjInfo::on_clb_sync_clicked() //////////////////////////////////// { radec_t rd; precess(&m_infoItem.radec, &rd, JD2000, m_map->m_mapView.jd); double r = R2D(rd.Ra) / 15.0; double d = R2D(rd.Dec); QApplication::beep(); g_pTelePlugin->syncTo(r, d); }
/* Compute real FOCAL and WORLD windowed coordinates according to FITS info. */ void astrom_winpos(picstruct *field, objstruct *obj) { wcsstruct *wcs; double rawpos[NAXIS], wcspos[NAXIS]; int lng,lat; wcs = field->wcs; lng = wcs->lng; lat = wcs->lat; if (FLAG(obj2.winpos_xf)) { rawpos[0] = obj2->winpos_x; rawpos[1] = obj2->winpos_y; raw_to_red(wcs, rawpos, wcspos); obj2->winpos_xf = wcspos[0]; obj2->winpos_yf = wcspos[1]; } if (FLAG(obj2.winpos_xw)) { rawpos[0] = obj2->winpos_x; rawpos[1] = obj2->winpos_y; raw_to_wcs(wcs, rawpos, wcspos); obj2->winpos_xw = wcspos[0]; obj2->winpos_yw = wcspos[1]; if (lng != lat) { obj2->winpos_alphas = lng<lat? obj2->winpos_xw : obj2->winpos_yw; obj2->winpos_deltas = lng<lat? obj2->winpos_yw : obj2->winpos_xw; if (FLAG(obj2.winpos_alpha2000)) { if (fabs(wcs->equinox-2000.0)>0.003) precess(wcs->equinox, wcspos[0], wcspos[1], 2000.0, &obj2->winpos_alpha2000, &obj2->winpos_delta2000); else { obj2->winpos_alpha2000 = lng<lat? obj2->winpos_xw : obj2->winpos_yw; obj2->winpos_delta2000 = lng<lat? obj2->winpos_yw : obj2->winpos_xw; } if (FLAG(obj2.winpos_alpha1950)) j2b(wcs->equinox, obj2->winpos_alpha2000, obj2->winpos_delta2000, &obj2->winpos_alpha1950, &obj2->winpos_delta1950); } } } return; }
/* Compute real FOCAL and WORLD profit coordinates according to FITS info. */ void astrom_profpos(picstruct *field, objstruct *obj) { wcsstruct *wcs; double rawpos[NAXIS], wcspos[NAXIS]; int lng,lat; wcs = field->wcs; lng = wcs->lng; lat = wcs->lat; if (FLAG(obj2.xf_prof)) { rawpos[0] = obj2->x_prof; rawpos[1] = obj2->y_prof; raw_to_red(wcs, rawpos, wcspos); obj2->xf_prof = wcspos[0]; obj2->yf_prof = wcspos[1]; } if (FLAG(obj2.xw_prof)) { rawpos[0] = obj2->x_prof; rawpos[1] = obj2->y_prof; raw_to_wcs(wcs, rawpos, wcspos); obj2->xw_prof = wcspos[0]; obj2->yw_prof = wcspos[1]; if (lng != lat) { obj2->alphas_prof = lng<lat? obj2->xw_prof : obj2->yw_prof; obj2->deltas_prof = lng<lat? obj2->yw_prof : obj2->xw_prof; if (FLAG(obj2.alpha2000_prof)) { if (fabs(wcs->equinox-2000.0)>0.003) precess(wcs->equinox, wcspos[0], wcspos[1], 2000.0, &obj2->alpha2000_prof, &obj2->delta2000_prof); else { obj2->alpha2000_prof = lng<lat? obj2->xw_prof : obj2->yw_prof; obj2->delta2000_prof = lng<lat? obj2->yw_prof : obj2->xw_prof; } if (FLAG(obj2.alpha1950_prof)) j2b(wcs->equinox, obj2->alpha2000_prof, obj2->delta2000_prof, &obj2->alpha1950_prof, &obj2->delta1950_prof); } } } return; }
void CObjInfo::on_cb_copy1_clicked() //////////////////////////////////// { QClipboard *clipboard = QApplication::clipboard(); double ra, dec; ra = m_infoItem.radec.Ra; dec = m_infoItem.radec.Dec; precess(&ra, &dec, JD2000, m_map->m_mapView.jd); QString str = getStrRA(ra) + " " + getStrDeg(dec); clipboard->setText(str); }
/* coordinate transformation * from: * J2000.0 rectangular equatoreal ret[{0,1,2}] = {x,y,z} * to: * mean equinox of date spherical ecliptical ret[{0,1,2}] = {l,b,r} */ static void chap_trans ( double mj, /* destination epoch */ double *ret) /* vector to be transformed _IN PLACE_ */ { double ra, dec, r, eps; double sr, cr, sd, cd, se, ce; cartsph(ret[0], ret[1], ret[2], &ra, &dec, &r); precess(J2000, mj, &ra, &dec); obliquity(mj, &eps); sr = sin(ra); cr = cos(ra); sd = sin(dec); cd = cos(dec); se = sin(eps); ce = cos(eps); ret[0] = atan2( sr * ce + sd/cd * se, cr); /* long */ ret[1] = asin( sd * ce - cd * se * sr); /* lat */ ret[2] = r; /* radius */ }
void SkServer::getPos() { QByteArray data; CMapView *view = m_mainWin->getView(); double ra, dec; trfConvScrPtToXY(view->width() / 2., view->height() / 2., ra, dec); if (view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC) { precess(&ra, &dec, view->m_mapView.jd, JD2000); } data.append(QString::number(R2D(ra), 'f')); data.append(","); data.append(QString::number(R2D(dec), 'f')); sendData(data); }
void SkServer::setRA_Dec(const QString &data) { CMapView *view = m_mainWin->getView(); QStringList args = data.split(","); if (args.count() < 2 || args.count() > 3) { sendData(SKS_INVALID); return; } double ra, dec, fov = CM_UNDEF; if (args.count() >= 2) { ra = D2R(args[0].toDouble()); dec = D2R(args[1].toDouble()); } if (args.count() == 3) { fov = D2R(args[2].toDouble()); } rangeDbl(&ra, R360); dec = CLAMP(dec, -R90, R90); if (fov > CM_UNDEF) { fov = CLAMP(fov, MIN_MAP_FOV, MAX_MAP_FOV); } if (view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC) { precess(&ra, &dec, JD2000, view->m_mapView.jd); } view->centerMap(ra, dec, fov); sendData(SKS_OK); }
// Note: This method is one of the major rate determining factors in how fast the map pans / zooms in or out void SkyPoint::updateCoords( const KSNumbers *num, bool /*includePlanets*/, const dms *lat, const dms *LST, bool forceRecompute ) { //Correct the catalog coordinates for the time-dependent effects //of precession, nutation and aberration bool recompute, lens; // NOTE: The same short-circuiting checks are also implemented in // StarObject::JITUpdate(), even before calling // updateCoords(). While this is code-duplication, these bits of // code need to be really optimized, at least for stars. For // optimization purposes, the code is left duplicated in two // places. Please be wary of changing one without changing the // other. Q_ASSERT( std::isfinite( lastPrecessJD ) ); if( Options::useRelativistic() && checkBendLight() ) { recompute = true; lens = true; } else { recompute = ( Options::alwaysRecomputeCoordinates() || forceRecompute || fabs( lastPrecessJD - num->getJD() ) >= 0.00069444); // Update once per solar minute lens = false; } if( recompute ) { precess(num); nutate(num); if( lens ) bendlight(); // FIXME: Shouldn't we apply this on the horizontal coordinates? aberrate(num); lastPrecessJD = num->getJD(); Q_ASSERT( std::isfinite( RA.Degrees() ) && std::isfinite( Dec.Degrees() ) ); } if ( lat || LST ) qWarning() << i18n( "lat and LST parameters should only be used in KSPlanetBase objects." ) ; }
int main(){ V6 v6; v6 = v6init(SPHERICAL); v6SetR(v6, 1e9); v6SetAlpha(v6, d2r(34.1592)); v6SetDelta(v6, d2r(12.9638)); v6SetRDot(v6, -0.123); v6SetAlphaDot(v6, 0.382); v6SetDeltaDot(v6, 1.0); v6 = v6s2c(v6); v6 = precess(J2000, J1984, v6, PRECESS_FK5); v6 = v6c2s(v6); printf("R %.10f \tALPHA %.10f \tDELTA %.10f \nRDOT %.10f \tALPHADOT %.10f \tDELTADOT %.10f\n", v6GetR(v6), v6GetAlpha(v6), v6GetDelta(v6), v6GetRDot(v6), v6GetAlphaDot(v6), v6GetDeltaDot(v6)); return 0; }
void recenterHoldObject(CMapView *p, bool bRepaint) /////////////////////////////////////////////////// { pcMainWnd->centerSearchBox(false); if (!g_bHoldObject) { return; } if (g_HoldObject.objType == MO_PLANET) { orbit_t o; cAstro.setParam(&p->m_mapView); cAstro.calcPlanet(g_HoldObject.objIdx, &o); p->centerMap(o.lRD.Ra, o.lRD.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_EARTH_SHD) { orbit_t o, m; cAstro.setParam(&p->m_mapView); cAstro.calcPlanet(PT_MOON, &m); cAstro.calcEarthShadow(&o, &m); p->centerMap(o.lRD.Ra, o.lRD.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_TELESCOPE) { p->centerMap(pcMapView->m_lastTeleRaDec.Ra, pcMapView->m_lastTeleRaDec.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_ASTER) { asteroid_t *a = (asteroid_t *)g_HoldObject.objIdx; cAstro.setParam(&p->m_mapView); astSolve(a, pcMapView->m_mapView.jd); p->centerMap(a->orbit.lRD.Ra, a->orbit.lRD.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_COMET) { comet_t *a = (comet_t *)g_HoldObject.objIdx; cAstro.setParam(&p->m_mapView); comSolve(a, pcMapView->m_mapView.jd); p->centerMap(a->orbit.lRD.Ra, a->orbit.lRD.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_SATELLITE) { radec_t rd; satellite_t s; sgp4.solve(g_HoldObject.objIdx, &p->m_mapView, &s); cAstro.setParam(&p->m_mapView); cAstro.convAA2RDRef(s.azimuth, s.elevation, &rd.Ra, &rd.Dec); p->centerMap(rd.Ra, rd.Dec, CM_UNDEF); } else if (g_HoldObject.objType == MO_PLN_SAT) { int pln = g_HoldObject.objIdx & 0xffff; int index = (g_HoldObject.objIdx & 0xffff0000) >> 16; CPlanetSatellite planSat; planetSatellites_t sats; orbit_t earth, o; cAstro.setParam(&p->m_mapView); cAstro.calcPlanet(PT_EARTH, &earth, false, true, false); cAstro.calcPlanet(pln, &o); planSat.solve(p->m_mapView.jd - o.light, pln, &sats, &o, &earth); double ra = sats.sats[index].lRD.Ra; double dec = sats.sats[index].lRD.Dec; precess(&ra, &dec, JD2000, p->m_mapView.jd); p->centerMap(ra, dec, CM_UNDEF); }
int main(int argc,char *argv[]) { int i,j,k,l,m; struct transformation t; struct image img; char *fitsfile=NULL,*reffile=NULL,catfile[128],calfile[128]; FILE *outfile; struct catalog c; float mmin=10.0,rmin=10.0; double mjd0=51544.5,ra0,de0,ra1,de1; float q0,q1; float rmsmin; float x[NMAX],y[NMAX],rx[NMAX],ry[NMAX]; int arg=0,plot=0,add=0,track=0; char *env,starfile[128]; // Environment variables env=getenv("ST_DATADIR"); sprintf(starfile,"%s/data/tycho2.dat",env); // Decode options if (argc>1) { while ((arg=getopt(argc,argv,"f:r:m:R:hpnta"))!=-1) { switch (arg) { case 'f': fitsfile=optarg; break; case 'r': reffile=optarg; break; case 'm': mmin=atof(optarg); break; case 't': track=1; break; case 'R': rmin=atof(optarg); break; case 'p': plot=1; break; case 'a': add=1; break; case 'h': usage(mmin,rmin); return 0; default: usage(mmin,rmin); return 0; } } } else { usage(mmin,rmin); return 0; } // Check if minimum input is provided if (fitsfile==NULL || reffile==NULL) { usage(mmin,rmin); return 0; } // Check this is indeed a FITS file if (is_fits_file(fitsfile)!=1) { printf("%s is not a FITS file\n",fitsfile); return -1 ; } // Check this is indeed a FITS file if (is_fits_file(reffile)!=1) { printf("%s is not a FITS file\n",reffile); return -1 ; } // Read fits file img=read_fits(fitsfile); sprintf(catfile,"%s.cat",fitsfile); sprintf(calfile,"%s.cal",fitsfile); // Read reference transformation t=reference(reffile); // Correct astrometry for fixed or tracked setup if (track==0) { precess(mjd0,t.ra0,t.de0,t.mjd,&ra1,&de1); ra1=modulo(ra1+gmst(img.mjd)-gmst(t.mjd),360.0); precess(img.mjd,ra1,de1,mjd0,&t.ra0,&t.de0); } // Match catalog c=match_catalogs(catfile,starfile,t,img,rmin,mmin); // Plot if (plot==1) plot_image(img,t,c,catfile,mmin); // Do fit if (c.n>10) { for (l=0;l<10;l++) { for (j=0;j<5;j++) { // Transform for (i=0;i<c.n;i++) forward(t.ra0,t.de0,c.ra[i],c.de[i],&c.rx[i],&c.ry[i]); // Select for (i=0,k=0;i<c.n;i++) { if (c.usage[i]==1) { x[k]=c.x[i]; y[k]=c.y[i]; rx[k]=(float) c.rx[i]; ry[k]=(float) c.ry[i]; k++; } } // Fit lfit2d(x,y,rx,k,t.a); lfit2d(x,y,ry,k,t.b); // Move reference point reverse(t.ra0,t.de0,t.a[0],t.b[0],&ra0,&de0); t.ra0=ra0; t.de0=de0; } // Compute and plot residuals for (i=0,t.xrms=0.0,t.yrms=0.0,m=0;i<c.n;i++) { if (c.usage[i]==1) { c.xres[i]=c.rx[i]-(t.a[0]+t.a[1]*c.x[i]+t.a[2]*c.y[i]); c.yres[i]=c.ry[i]-(t.b[0]+t.b[1]*c.x[i]+t.b[2]*c.y[i]); c.res[i]=sqrt(c.xres[i]*c.xres[i]+c.yres[i]*c.yres[i]); t.xrms+=c.xres[i]*c.xres[i]; t.yrms+=c.yres[i]*c.yres[i]; t.rms+=c.xres[i]*c.xres[i]+c.yres[i]*c.yres[i]; m++; } } t.xrms=sqrt(t.xrms/(float) m); t.yrms=sqrt(t.yrms/(float) m); t.rms=sqrt(t.rms/(float) m); // Deselect outliers for (i=0;i<c.n;i++) { if (c.res[i]>2*t.rms) c.usage[i]=0; } } } else { t.xrms=0.0; t.yrms=0.0; t.rms=0.0; } // Print results outfile=fopen(calfile,"w"); for (i=0;i<c.n;i++) if (c.usage[i]==1) fprintf(outfile,"%10.4f %10.4f %10.6f %10.6f %8.3f %8.3f %8.3f %8.3f %8.3f\n",c.x[i],c.y[i],c.ra[i],c.de[i],c.vmag[i],c.imag[i],c.fb[i],c.fm[i],c.bg[i]); fclose(outfile); printf("%s %8.4lf %8.4lf ",fitsfile,t.ra0,t.de0); printf("%3d/%3d %6.1f %6.1f %6.1f\n",m,c.n,t.xrms,t.yrms,t.rms); // Add keywords if (add==1) add_fits_keywords(t,fitsfile); else modify_fits_keywords(t,fitsfile); return 0; }
void CEphList::on_pushButton_4_clicked() //////////////////////////////////////// { QList <int> columns; QStringList strCol; int obj; int type; bool isUT; double tz; double jdFrom; double jdTo; double step = 1; QString name; QListWidgetItem *com; QList <tableRow_t> rows; for (int i = 0; i < EL_COLUMN_COUNT; i++) { QListWidgetItem *item = ui->listWidget_2->item(i); if (item->checkState() == Qt::Checked && (item->flags() & Qt::ItemIsEnabled)) { columns.append(item->data(Qt::UserRole + 1).toInt()); } } if (columns.count() == 0) { msgBoxError(this, tr("There is no selected column!!!")); return; } switch (ui->tabWidget->currentIndex()) { case 0: type = MO_PLANET; obj = ui->listWidget->currentRow(); if (!showNoObjectSelected(obj)) return; break; case 1: type = MO_COMET; obj = ui->listWidget_3->currentRow(); if (!showNoObjectSelected(obj)) return; com = ui->listWidget_3->item(obj); obj = com->data(Qt::UserRole + 1).toInt(); break; case 2: type = MO_ASTER; obj = ui->listWidget_4->currentRow(); if (!showNoObjectSelected(obj)) return; com = ui->listWidget_4->item(obj); obj = com->data(Qt::UserRole + 1).toInt(); break; } isUT = ui->checkBox->isChecked(); if (isUT) tz = 0; else tz = m_view.geo.tz; QDateTime dt; dt = ui->dateTimeEdit->dateTime(); jdFrom = jdGetJDFrom_DateTime(&dt); dt = ui->dateTimeEdit_2->dateTime(); jdTo = jdGetJDFrom_DateTime(&dt); for (int i = 0; i < columns.count(); i++) { QString str = cELColumn[columns[i]]; strCol.append(str); } if (jdFrom >= jdTo) { msgBoxError(this, tr("Invalid date/time range!!!")); return; } double mul; switch (ui->comboBox->currentIndex()) { case 0: mul = JD1SEC * 60; break; case 1: mul = JD1SEC * 3600; break; case 2: mul = 1; break; } step = ui->spinBox->value() * mul; int count = (jdTo - jdFrom) / step; if (count > 1000) { if (QMessageBox::No == msgBoxQuest(this, tr("Calculation 1000+ positions. Do you want to continue?"))) return; } for (double jd = jdFrom; jd <= jdTo; jd += step) { bool isMoon = false; tableRow_t row; orbit_t o; m_view.jd = jd - tz; cAstro.setParam(&m_view); switch (type) { case MO_PLANET: cAstro.calcPlanet(obj, &o); name = cAstro.getName(obj); isMoon = (obj == PT_MOON); break; case MO_COMET: comSolve(&tComets[obj], m_view.jd); name = tComets[obj].name; o = tComets[obj].orbit; break; case MO_ASTER: astSolve(&tAsteroids[obj], m_view.jd); name = tAsteroids[obj].name; o = tAsteroids[obj].orbit; break; } for (int j = 0; j < columns.count(); j++) { QString str; double ra2000 = o.lRD.Ra; double dec2000 = o.lRD.Dec; precess(&ra2000, &dec2000, m_view.jd, JD2000); switch (columns[j]) { case 0: str = QString::number(m_view.jd, 'f', 6); break; case 1: str = getStrDate(m_view.jd, tz); break; case 2: str = getStrTime(m_view.jd, tz); break; case 3: str = getStrMag(o.mag); break; case 4: str = QString::number(o.phase, 'f', 3); break; case 5: str = QString::number(R2D(o.PA), 'f', 1) + "°"; break; case 6: str = QString::number(o.sx, 'f', 2) + "\""; break; case 7: str = QString::number(o.sy, 'f', 2) + "\""; break; case 8: str = getStrRA(o.lRD.Ra); break; case 9: str = getStrDeg(o.lRD.Dec); break; case 10: str = getStrRA(ra2000); break; case 11: str = getStrDeg(dec2000); break; case 12: str = getStrRA(o.gRD.Ra); break; case 13: str = getStrDeg(o.gRD.Dec); break; case 14: str = getStrDeg(o.lAzm); break; case 15: str = getStrDeg(o.lAlt); break; case 16: if (!isMoon) { str = QString::number(o.R, 'f', 6) + " AU"; } else { str = QString::number(o.r * EARTH_DIAM) + tr(" Km"); } break; case 17: if (!isMoon) { str = QString::number(o.r, 'f', 6) + " AU"; } else { str = tr("N/A"); } break; case 18: str = ((o.elongation >= 0) ? "+" : "") + QString::number(R2D(o.elongation), 'f', 2) + "°"; break; case 19: str = getStrDeg(o.hLon); break; case 20: str = getStrDeg(o.hLat); break; case 21: str = QString::number(o.hRect[0], 'f', 6) + " AU"; break; case 22: str = QString::number(o.hRect[1], 'f', 6) + " AU"; break; case 23: str = QString::number(o.hRect[2], 'f', 6) + " AU"; break; case 24: str = QString::number(o.light * 24. * 60., 'f', 2) + tr(" mins."); break; } row.row.append(str); } rows.append(row); } CEphTable dlg(this, name, strCol, rows); dlg.exec(); }
void SkServer::setExtFrame(const QString &data) { QStringList args = data.split(","); if (args.count() != 5) { sendData(SKS_INVALID); return; } double w; double h; double ra, dec; double angle; auto getVal = [this](const QString &str) -> double { QString tmp = str; if (str.endsWith("'")) { tmp.chop(1); return tmp.toDouble() * 60.0; } else if (str.endsWith("\"")) { tmp.chop(1); return tmp.toDouble(); } else { sendData(SKS_INVALID); return -1; } }; w = getVal(args[0]); if (w <= 0) return; h = getVal(args[1]); if (h <= 0) return; angle = args[2].toDouble(); ra = D2R(args[3].toDouble()); dec = D2R(args[4].toDouble()); radec_t rd; rangeDbl(&ra, R360); dec = CLAMP(dec, -R90, R90); CMapView *view = m_mainWin->getView(); if (!view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC) { precess(&ra, &dec, view->m_mapView.jd, JD2000); } rd.Ra = ra; rd.Dec = dec; w /= 3600.0; h /= 3600.0; w = D2R(w); h = D2R(h); g_cDrawing.insertExtFrame(&rd, w, h, angle, tr("External frame field")); sendData(SKS_OK); }
/* fill equatoreal and horizontal op-> fields; stern * * input: lam/bet/rho geocentric mean ecliptic and equinox of day * * algorithm at EOD: * ecl_eq --> ra/dec geocentric mean equatoreal EOD (via mean obliq) * deflect --> ra/dec relativistic deflection * nut_eq --> ra/dec geocentric true equatoreal EOD * ab_eq --> ra/dec geocentric apparent equatoreal EOD * if (PREF_GEO) --> output * ta_par --> ra/dec topocentric apparent equatoreal EOD * if (!PREF_GEO) --> output * hadec_aa --> alt/az topocentric horizontal * refract --> alt/az observed --> output * * algorithm at fixed equinox: * ecl_eq --> ra/dec geocentric mean equatoreal EOD (via mean obliq) * deflect --> ra/dec relativistic deflection [for alt/az only] * nut_eq --> ra/dec geocentric true equatoreal EOD [for aa only] * ab_eq --> ra/dec geocentric apparent equatoreal EOD [for aa only] * ta_par --> ra/dec topocentric apparent equatoreal EOD * precess --> ra/dec topocentric equatoreal fixed equinox [eq only] * --> output * hadec_aa --> alt/az topocentric horizontal * refract --> alt/az observed --> output */ static void cir_pos ( Now *np, double bet, /* geo lat (mean ecliptic of date) */ double lam, /* geo long (mean ecliptic of date) */ double *rho, /* in: geocentric dist in AU; out: geo- or topocentic dist */ Obj *op) /* object to set s_ra/dec as per equinox */ { double ra, dec; /* apparent ra/dec, corrected for nut/ab */ double tra, tdec; /* astrometric ra/dec, no nut/ab */ double lsn, rsn; /* solar geocentric (mean ecliptic of date) */ double ha_in, ha_out; /* local hour angle before/after parallax */ double dec_out; /* declination after parallax */ double dra, ddec; /* parallax correction */ double alt, az; /* current alt, az */ double lst; /* local sidereal time */ double rho_topo; /* topocentric distance in earth radii */ /* convert to equatoreal [mean equator, with mean obliquity] */ ecl_eq (mjed, bet, lam, &ra, &dec); tra = ra; /* keep mean coordinates */ tdec = dec; /* precess and save astrometric coordinates */ if (mjed != epoch) precess (mjed, epoch, &tra, &tdec); op->s_astrora = tra; op->s_astrodec = tdec; /* get sun position */ sunpos(mjed, &lsn, &rsn, NULL); /* allow for relativistic light bending near the sun. * (avoid calling deflect() for the sun itself). */ if (!is_planet(op,SUN) && !is_planet(op,MOON)) deflect (mjed, op->s_hlong, op->s_hlat, lsn, rsn, *rho, &ra, &dec); /* correct ra/dec to form geocentric apparent */ nut_eq (mjed, &ra, &dec); if (!is_planet(op,MOON)) ab_eq (mjed, lsn, &ra, &dec); op->s_gaera = ra; op->s_gaedec = dec; /* find parallax correction for equatoreal coords */ now_lst (np, &lst); ha_in = hrrad(lst) - ra; rho_topo = *rho * MAU/ERAD; /* convert to earth radii */ ta_par (ha_in, dec, lat, elev, &rho_topo, &ha_out, &dec_out); /* transform into alt/az and apply refraction */ hadec_aa (lat, ha_out, dec_out, &alt, &az); refract (pressure, temp, alt, &alt); op->s_alt = alt; op->s_az = az; /* Get parallax differences and apply to apparent or astrometric place * as needed. For the astrometric place, rotating the CORRECTIONS * back from the nutated equator to the mean equator will be * neglected. This is an effect of about 0.1" at moon distance. * We currently don't have an inverse nutation rotation. */ if (pref_get(PREF_EQUATORIAL) == PREF_GEO) { /* no topo corrections to eq. coords */ dra = ddec = 0.0; } else { dra = ha_in - ha_out; /* ra sign is opposite of ha */ ddec = dec_out - dec; *rho = rho_topo * ERAD/MAU; /* return topocentric distance in AU */ ra = ra + dra; dec = dec + ddec; } range(&ra, 2*PI); op->s_ra = ra; op->s_dec = dec; }
static bool comSolve2(comet_t *a, double jdt, bool lightCorrected = true) ///////////////////////////////////////////////////////////////////////// { double R = 0, r = 0, v = 0; double xe = 0; double ye = 0; double ze = 0; double rh[3] = {0,0,0}; // NOTE: komety a asteroidy maji uz deltaT v sobe double t = (jdt - a->perihelionDate); for (int i = 0; i < (lightCorrected ? 2 : 1); i++) { if (a->e < 1.0) { solveCometElliptic(a, t, r, v); } else if (a->e == 1.0) { solveCometParabolic(a, t, r, v); } else { solveCometHyperbolic(a, t, r, v); } //////////////////////////////////////////////// double n = a->w; double p = a->W; // Helio. ecliptic J2000.0 rh[0] = r * ( cos(n) * cos(v + p) - sin(n) * sin(v + p) * cos(a->i)); rh[1] = r * ( sin(n) * cos(v + p) + cos(n) * sin(v + p) * cos(a->i)); rh[2] = r * ( sin(v + p) * sin(a->i)); // helio eqt. J2000.0 a->orbit.hRect[0] = rh[0]; a->orbit.hRect[1] = rh[1]; a->orbit.hRect[2] = rh[2]; a->orbit.hLon = atan2(rh[1], rh[0]); a->orbit.hLat = atan2(rh[2], sqrt(rh[0] * rh[0] + rh[1] * rh[1])); rangeDbl(&a->orbit.hLon, MPI2); // geocentric ecl. J2000.0 double xg = rh[0] + xs; double yg = rh[1] + ys; double zg = rh[2] + zs; // geocentric eq. J2000.0 double ea = cAstro.getEclObl(JD2000); xe = xg; ye = yg * cos(ea) - zg * sin(ea); ze = yg * sin(ea) + zg * cos(ea); a->orbit.r = r; a->orbit.R = sqrt(xg * xg + yg * yg + zg *zg); R = a->orbit.R; a->orbit.light = SECTODAY(a->orbit.R * AU1 / LSPEED); t -= a->orbit.light; } // from skychart sw double D = ((qMax(0.0, 1 - log(a->orbit.r)) / qMax(1.0, a->H - 2.0)) * 30.0 / a->orbit.R) * 60; double L = qMax(0.0, 1. - log(a->orbit.r)) / pow(qMax(1.0, (double)a->H), 1.5); a->orbit.params[2] = D; a->orbit.params[3] = L * AU1; double d = 1 / sqrt(POW2(rh[0]) + POW2(rh[1]) + POW2(rh[2])); double nsx = rh[0] * d; double nsy = rh[1] * d; double nsz = rh[2] * d; double tx = rh[0] + nsx * L; double ty = rh[1] + nsy * L; double tz = rh[2] + nsz * L; tx += xs; ty += ys; tz += zs; double ea = cAstro.getEclObl(JD2000); double txe = tx; double tye = ty * cos(ea) - tz * sin(ea); double tze = ty * sin(ea) + tz * cos(ea); // tail end ra/dec a->orbit.params[0] = atan2(tye, txe); a->orbit.params[1] = atan2(tze, sqrt(txe * txe + tye * tye)); a->orbit.gRD.Ra = atan2(ye, xe); a->orbit.gRD.Dec = atan2(ze, sqrt(xe * xe + ye * ye)); rangeDbl(&a->orbit.gRD.Ra, MPI2); precess(&a->orbit.gRD.Ra, &a->orbit.gRD.Dec, JD2000, jdt); precess(&a->orbit.params[0], &a->orbit.params[1], JD2000, jdt); a->orbit.mag = a->H + 5 * log10(a->orbit.R) + 2.5 * a->G * log10(a->orbit.r); a->orbit.elongation = acos((sunOrbit.r * sunOrbit.r + R * R - r * r) / (2 * sunOrbit.r * R)); if ((sunOrbit.r * sunOrbit.r + R * R - r*r) < 0) { a->orbit.elongation = -a->orbit.elongation; } a->orbit.sx = 0; a->orbit.sy = 0; a->orbit.phase = 1; #pragma omp critical { cAstro.calcParallax(&a->orbit); cAstro.convRD2AARef(a->orbit.lRD.Ra, a->orbit.lRD.Dec, &a->orbit.lAzm, &a->orbit.lAlt); } return(true); }
/* Compute real FOCAL and WORLD coordinates according to FITS info. */ void astrom_pos(picstruct *field, objstruct *obj) { wcsstruct *wcs; double rawpos[NAXIS], wcspos[NAXIS], da,dd; int lng,lat; wcs = field->wcs; lng = wcs->lng; lat = wcs->lat; /* If working with WCS, compute FOCAL coordinates and local matrix */ if (FLAG(obj2.mxf)) { rawpos[0] = obj2->posx; rawpos[1] = obj2->posy; raw_to_red(wcs, rawpos, wcspos); obj2->mxf = wcspos[0]; obj2->myf = wcspos[1]; } /* If working with WCS, compute WORLD coordinates and local matrix */ if (FLAG(obj2.mxw)) { rawpos[0] = obj2->posx; rawpos[1] = obj2->posy; raw_to_wcs(wcs, rawpos, wcspos); obj2->mxw = wcspos[0]; obj2->myw = wcspos[1]; if (lng != lat) { obj2->alphas = lng<lat? obj2->mxw : obj2->myw; obj2->deltas = lng<lat? obj2->myw : obj2->mxw; if (FLAG(obj2.alpha2000)) { if (fabs(wcs->equinox-2000.0)>0.003) precess(wcs->equinox, wcspos[lng<lat?0:1], wcspos[lng<lat?1:0], 2000.0, &obj2->alpha2000, &obj2->delta2000); else { obj2->alpha2000 = lng<lat? obj2->mxw : obj2->myw; obj2->delta2000 = lng<lat? obj2->myw : obj2->mxw; } if (FLAG(obj2.dtheta2000)) { da = wcs->ap2000 - obj2->alpha2000; dd = (sin(wcs->dp2000*DEG) -sin(obj2->delta2000*DEG)*sin(obj2->deltas*DEG)) /(cos(obj2->delta2000*DEG)*cos(obj2->deltas*DEG)); dd = dd<1.0? (dd>-1.0?acos(dd)/DEG:180.0) : 0.0; obj2->dtheta2000 = (((da>0.0 && da<180.0) || da<-180.0)?-dd:dd); } if (FLAG(obj2.alpha1950)) { j2b(wcs->equinox, obj2->alpha2000, obj2->delta2000, &obj2->alpha1950, &obj2->delta1950); if (FLAG(obj2.dtheta1950)) { da = wcs->ap1950 - obj2->alpha1950; dd = (sin(wcs->dp1950*DEG) -sin(obj2->delta1950*DEG)*sin(obj2->deltas*DEG)) /(cos(obj2->delta1950*DEG)*cos(obj2->deltas*DEG)); dd = dd<1.0? (dd>-1.0?acos(dd)/DEG:180.0) : 0.0; obj2->dtheta1950 = (((da>0.0 && da<180.0) || da<-180.0)?-dd:dd); } } } } } /* Custom coordinate system for the MAMA machine */ if (FLAG(obj2.mamaposx)) { rawpos[0] = obj2->posx - 0.5; rawpos[1] = obj2->posy - 0.5; raw_to_wcs(wcs, rawpos, wcspos); obj2->mamaposx = wcspos[1]*(MAMA_CORFLEX+1.0); obj2->mamaposy = wcspos[0]*(MAMA_CORFLEX+1.0); } return; }
void zerospectra(int mode) { int i, j, yr, da, hr, mn, sc; double az, el, secs, ra, dec; secs = d1.secs; if (!mode) { for (i = 0; i < d1.nfreq; i++) avspec[i] = avspecoff[i] = avspecon[i] = 0; d1.pwron = d1.pwroff = 0; d1.numon = d1.numoff = d1.integ = 0; } if (d1.cmdfl && secs > d1.secstop && !d1.slew && !d1.scan && !d1.docal && mode) d1.secstop = cmdfile(); d1.vlsr = 0.0; az = -1; for (i = 0; d1.track >= 0 && i < d1.nsou; i++) { if (strstr(sounam[i], soutrack) && soutrack[0]) { toyrday(secs, &yr, &da, &hr, &mn, &sc); d1.year = yr; if (strstr(sounam[i], "Sun") || strstr(sounam[i], "Moon")) { if (strstr(sounam[i], "Sun")) sunradec(secs, &ra, &dec); else moonradec(secs, &ra, &dec); radec_azel(gst(secs) - ra - d1.lon, dec, d1.lat, &az, &el); } else if (soutype[i]) { az = ras[i] * PI / 180.0; el = decs[i] * PI / 180.0; azel_to_radec(secs, ras[i], decs[i], &ra, &dec); } else { precess(ras[i], decs[i], &ra, &dec, epoc[i], d1.year); radec_azel(gst(secs) - ra - d1.lon, dec, d1.lat, &az, &el); } d1.vlsr = vlsr(secs, ra, dec); sprintf(souinfo, "%s %4d", to_radecp(ra, dec), yr); } } if (d1.track && az >= 0.0) { if (d1.scan > 0) { i = (d1.scan - 1) / 5; j = (d1.scan - 1) % 5; d1.eloff = (i - 2) * d1.beamw * 0.5; d1.azoff = (j - 2) * d1.beamw * 0.5 / cos(el + d1.eloff * PI / 180.0); d1.scan++; if (d1.scan > 26) { d1.scan = 0; if (d1.displ) gtk_tooltips_set_tip(tooltips, button_npoint, "click to start npoint scan", NULL); d1.azoff = d1.eloff = 0; d1.domap = 1; } } if (d1.bsw == 1) d1.bswint = 0; if (d1.bsw > 0 && d1.bswint == 0) { if (d1.bsw == 1) d1.clearint = 1; i = (d1.bsw - 1) % 4; j = 0; if (i == 1) j = -1; if (i == 3) j = 1; d1.azoff = j * d1.beamw / cos(el); d1.bsw++; } } if (az >= 0 && d1.stow != 1) { d1.azcmd = az * 180.0 / PI + d1.azoff; d1.elcmd = el * 180.0 / PI + d1.eloff; // printf("inzero azcmd %f ellim2 %f\n",d1.azcmd,d1.ellim2); } else { azel_to_radec(secs, d1.azcmd, d1.elcmd, &ra, &dec); d1.vlsr = vlsr(secs, ra, dec); } if (mode == 0) { d1.integ = 0.0; pwr = 0.0; } }
void CGrid::renderGrid(int type, SKMATRIX *mat, mapView_t *mapView, CSkPainter *pPainter, bool eqOnly) ////////////////////////////////////////////////////////////////////////////////////////////////////// { double spc; double cx, cy; setSetFont(FONT_GRID, pPainter); trfGetScreenSize(scrWidth, scrHeight); QColor col = g_skSet.map.grid[type].color; pPainter->setPen(col); pPainter->drawRect(clipSize, clipSize, scrWidth - clipSize * 2, scrHeight - clipSize * 2); if (type == SMCT_ECL || type == SMCT_ALT_AZM) { radec_t rd; SKPOINT pt; double sx, sy; trfGetCenter(sx, sy); trfConvScrPtToXY(sx, sy, cx, cy); rd.Ra = cx; rd.Dec = cy; precess(&rd.Ra, &rd.Dec, mapView->jd, JD2000); SKMATRIX matInv; SKMATRIXInverse(&matInv, mat); trfRaDecToPointNoCorrect(&rd, &pt, &matInv); cx = -atan2(pt.w.x, pt.w.z); cy = atan2(-pt.w.y, sqrt(pt.w.x * pt.w.x + pt.w.z * pt.w.z)); rangeDbl(&cx, R360); if (type == SMCT_ALT_AZM) { cy += cAstro.getAtmRef(cy); } } else { double sx, sy; trfGetCenter(sx, sy); trfConvScrPtToXY(sx, sy, cx, cy); if (mapView->coordType == SMCT_RA_DEC && mapView->epochJ2000) { precess(&cx, &cy, mapView->jd, JD2000); } } if (mapView->fov > D2R(45)) spc = 10; else if (mapView->fov > D2R(10)) spc = 5; else if (mapView->fov > D2R(5)) spc = 2; else if (mapView->fov > D2R(1)) spc = 1; else if (mapView->fov > D2R(0.5)) spc = 0.5; else if (mapView->fov > D2R(0.25)) spc = 0.1; else spc = (0.05); mSet.clear(); double spcx = spc; double spcy = spc; if (qAbs(mapView->y) > D2R(80)) { spcx *= 40; } else if (qAbs(mapView->y) > D2R(60)) { spcx *= 5; } else if (qAbs(mapView->y) > D2R(45)) { spcx *= 2; } spcx = CLAMP(spcx, 0.25, 10); spcy = CLAMP(spcy, 0.25, 10); double x = R2D(cx - fmod(cx, D2R(spcx))); double y; if (cy >= 0) { y = R2D(cy - fmod(cy, D2R(spcy))); } else { y = -(R2D(qAbs(cy) - fmod(qAbs(cy), D2R(spcy))) + spcy); if (y < -90) y = -90; } depth = 0; ren = 0; render(type, mat, mapView, pPainter, eqOnly, FROMRA(x), FROMDEC(y), FROMRA(spcx), FROMRA(spcy)); }
/* Calculate geometric position of the Moon and apply * approximate corrections to find apparent position, * phase of the Moon, etc. for AA.ARC. */ int domoon() { int i, prtsav; double ra0, dec0, r; double x, y, z, lon0; double c, s, temp; double pp[3], qq[3]; double acos(); /* Compute obliquity of the ecliptic, coseps, and sineps */ epsiln(TDT); /* Run the orbit calculation twice, at two different times, * in order to find the rate of change of R.A. and Dec. */ /* Calculate for 0.001 day ago */ prtsav = prtflg; prtflg = 0; /* disable display */ moonll(TDT-0.001, moonpp, moonpol); /* lonlat( rearth, TDT, eapolar ); // precess earth to date // lonlat( rearth, TDT, eapolar, 1 ); */ ra0 = ra; dec0 = dec; lon0 = l; prtflg = prtsav; /* Calculate for present instant. */ moonll(TDT, moonpp, moonpol); /* The rates of change. These are used by altaz() to * correct the time of rising, transit, and setting. */ dradt = ra - ra0; if (dradt >= PI) dradt = dradt - 2.0 * PI; if (dradt <= -PI) dradt = dradt + 2.0 * PI; dradt = 1000.0 * dradt; ddecdt = 1000.0*(dec-dec0); /* Post the ecliptic longitude and latitude, in radians, * and the radius in au. */ obpolar[0] = l; obpolar[1] = B; r = 1.0/sin(p); /* distance in earth-radii */ ra0 = Rearth*r; /* factor is radius of earth in au */ obpolar[2] = ra0; /* Rate of change in longitude, degrees per day * used for phase of the moon */ lon0 = 1000.0*RTD*(l - lon0); /* convert to ecliptic rectangular coordinates */ z = ra0 * cos(B); x = z * cos(l); y = z * sin(l); z = ra0 * sin(B); /* convert to equatorial coordinates */ pp[0] = x; pp[1] = y * coseps - z * sineps; pp[2] = y * sineps + z * coseps; /* Find sun-moon-earth angles */ precess( rearth, TDT, -1 ); for( i=0; i<3; i++ ) qq[i] = rearth[i] + pp[i]; angles( pp, qq, rearth ); /* Display answers */ if( prtflg ) { /* Apparent ecliptic coordinates. The nutation in longitude is added to the ecliptic longitude. See AA page C2. First rotate the coordinate system about the x axis from mean equator to ecliptic. Then rotate about the z axis by the nutation in longitude. */ x = Mapp[0]; y = Mapp[1]; z = Mapp[2]; temp = coseps * y + sineps * z; z = -sineps * y + coseps * z; y = temp; c = cos(nutl); s = sin(nutl); temp = c * x - s * y; y = s * x + c * y; x = temp; Mapp[0] = zatan2( x, y ); Mapp[1] = asin( z ); Mapp[2] = Rem; printf( "Apparent geocentric longitude %.3f deg", RTD*Mapp[0] ); printf( " latitude %.3f deg\n", RTD*Mapp[1] ); printf( "Distance %.3f Earth-radii\n", r ); printf( "Horizontal parallax" ); dms( p ); printf( "Semidiameter" ); x = 0.272453 * p + 0.0799/RTS; /* AA page L6 */ dms( x ); x = RTD * acos(-ep); printf( "\nElongation from sun %.2f deg,", x ); x = 0.5 * (1.0 + pq); printf( " Illuminated fraction %.2f\n", x ); /* Find phase of the Moon by comparing Moon's longitude * with Earth's longitude. * * The number of days before or past indicated phase is * estimated by assuming the true longitudes change linearly * with time. These rates are estimated for the date, but * do not stay constant. The error can exceed 0.15 day in 4 days. */ /* Apparent longitude of sun. * Moon's longitude was already corrected for light time. */ y = eapolar[0] - 20.496/(RTS*eapolar[2]); x = obpolar[0] - y; x = modtp( x ) * RTD; /* difference in longitude */ i = x/90; /* number of quarters */ x = (x - i*90.0); /* phase angle mod 90 degrees */ /* days per degree of phase angle */ z = 1.0/(lon0 - (0.9856/eapolar[2])); if( x > 45.0 ) { y = -(x - 90.0)*z; if( y > 1.0 ) printf( "Phase %.1f days before ", y ); else printf( "Phase %.2f days before ", y ); i = (i+1) & 3; } else { y = x*z; if( y > 1.0 ) printf( "Phase %.1f days past ", y ); else printf( "Phase %.2f days past ", y ); } switch(i) { case 0: printf( "Full Moon\n" ); break; case 1: printf( "Third Quarter\n" ); break; case 2: printf( "New Moon\n" ); break; case 3: printf( "First Quarter\n" ); break; } } /* if prtflg */ printf( " Apparent: R.A." ); hms(ra); printf( "Declination" ); dms(dec); printf( "\n" ); /* Compute and display topocentric position (altaz.c) */ pp[0] = ra; pp[1] = dec; pp[2] = r * Rearth; altaz( pp, UT ); return(0); }
static int obj_fixed (Now *np, Obj *op) { double lsn, rsn; /* true geoc lng of sun, dist from sn to earth*/ double lam, bet; /* geocentric ecliptic long and lat */ double ha; /* local hour angle */ double el; /* elongation */ double alt, az; /* current alt, az */ double ra, dec; /* ra and dec at equinox of date */ double rpm, dpm; /* astrometric ra and dec with PM to now */ double lst; /* on the assumption that the user will stick with their chosen display * epoch for a while, we move the defining values to match and avoid * precession for every call until it is changed again. * N.B. only compare and store jd's to lowest precission (f_epoch). * N.B. maintaining J2k ref (which is arbitrary) helps avoid accum err */ if (0 /* disabled in PyEphem */ && epoch != EOD && epoch != op->f_epoch) { double pr = op->f_RA, pd = op->f_dec, fe = epoch; /* first bring back to 2k */ precess (op->f_epoch, J2000, &pr, &pd); pr += op->f_pmRA*(J2000-op->f_epoch); pd += op->f_pmdec*(J2000-op->f_epoch); /* then to epoch */ pr += op->f_pmRA*(fe-J2000); pd += op->f_pmdec*(fe-J2000); precess (J2000, fe, &pr, &pd); op->f_RA = pr; op->f_dec = pd; op->f_epoch = fe; } /* apply proper motion .. assume pm epoch reference equals equinox */ rpm = op->f_RA + op->f_pmRA*(mjd-op->f_epoch); dpm = op->f_dec + op->f_pmdec*(mjd-op->f_epoch); /* set ra/dec to astrometric @ equinox of date */ ra = rpm; dec = dpm; if (op->f_epoch != mjed) precess (op->f_epoch, mjed, &ra, &dec); /* compute astrometric @ requested equinox */ op->s_astrora = rpm; op->s_astrodec = dpm; if (op->f_epoch != epoch) precess (op->f_epoch, epoch, &op->s_astrora, &op->s_astrodec); /* convert equatoreal ra/dec to mean geocentric ecliptic lat/long */ eq_ecl (mjed, ra, dec, &bet, &lam); /* find solar ecliptical long.(mean equinox) and distance from earth */ sunpos (mjed, &lsn, &rsn, NULL); /* allow for relativistic light bending near the sun */ deflect (mjed, lam, bet, lsn, rsn, 1e10, &ra, &dec); /* TODO: correction for annual parallax would go here */ /* correct EOD equatoreal for nutation/aberation to form apparent * geocentric */ nut_eq(mjed, &ra, &dec); ab_eq(mjed, lsn, &ra, &dec); op->s_gaera = ra; op->s_gaedec = dec; /* set s_ra/dec -- apparent */ op->s_ra = ra; op->s_dec = dec; /* compute elongation from ecliptic long/lat and sun geocentric long */ elongation (lam, bet, lsn, &el); el = raddeg(el); op->s_elong = (float)el; /* these are really the same fields ... op->s_mag = op->f_mag; op->s_size = op->f_size; */ /* alt, az: correct for refraction; use eod ra/dec. */ now_lst (np, &lst); ha = hrrad(lst) - ra; hadec_aa (lat, ha, dec, &alt, &az); refract (pressure, temp, alt, &alt); op->s_alt = alt; op->s_az = az; return (0); }
bool CSearch::search(mapView_t *mapView, QString str, double &ra, double &dec, double &fov, mapObj_t &obj) { QString what = str.mid(0, 4); str = str.mid(4); QRegExp reg("\\b" + str + "\\b", Qt::CaseInsensitive); str = str.simplified(); cAstro.setParam(mapView); if (SS_CHECK_OR(SS_PLANET, what)) { if (!str.compare("es", Qt::CaseInsensitive)) { orbit_t o, m; cAstro.calcPlanet(PT_MOON, &m); cAstro.calcEarthShadow(&o, &m); ra = o.lRD.Ra; dec = o.lRD.Dec; fov = getOptObjFov(o.sx / 3600.0, o.sy / 3600.0); obj.type = MO_EARTH_SHD; return(true); } } if (SS_CHECK_OR(SS_STAR, what)) { if (str.startsWith("HD", Qt::CaseInsensitive)) { str = str.mid(2); int hd = str.toInt(); int reg, index; tychoStar_t *star; if (cTYC.findStar(NULL, TS_HD, 0, hd, 0, 0, 0, 0, 0, 0, reg, index)) { cTYC.getStar(&star, reg, index); ra = star->rd.Ra; dec = star->rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = DMS2RAD(10, 0, 0); obj.type = MO_TYCSTAR; obj.par1 = reg; obj.par2 = index; return true; } } if (str.startsWith("TYC", Qt::CaseInsensitive)) { str = str.mid(3); QStringList list = str.split("-"); if (list.count() == 3) { int t1 = list[0].toInt(); int t2 = list[1].toInt(); int t3 = list[2].toInt(); int reg, index; tychoStar_t *star; if (cTYC.findStar(NULL, TS_TYC, 0, 0, 0, 0, t1, t2, t3, 0, reg, index)) { cTYC.getStar(&star, reg, index); ra = star->rd.Ra; dec = star->rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = DMS2RAD(10, 0, 0); obj.type = MO_TYCSTAR; obj.par1 = reg; obj.par2 = index; return true; } } } if (str.startsWith("UCAC4", Qt::CaseInsensitive)) { str = str.mid(5); QStringList list = str.split("-"); if (list.count() == 2) { int zone = list[0].toInt(); int num = list[1].toInt(); ucac4Star_t star; if (cUcac4.searchStar(zone, num, &star)) { ra = star.rd.Ra; dec = star.rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = DMS2RAD(0, 30, 0); // FIX: region a poradi v GSC regionu /* obj.type = MO_UCAC4; obj.par1 = star.zone; obj.par2 = star.number; */ return true; } } return false; } if (str.startsWith("USNO2", Qt::CaseInsensitive)) { str = str.mid(5); QStringList list = str.split("-"); if (list.count() == 2) { int zone = list[0].toInt(); int num = list[1].toInt(); usnoStar_t star; if (usno.searchStar(zone, num, &star)) { ra = star.rd.Ra; dec = star.rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = DMS2RAD(0, 30, 0); // FIX: region a poradi v GSC regionu /* obj.type = MO_USNO2; obj.par1 = star.zone; obj.par2 = star.number; */ return true; } } return false; } if (str.startsWith("GSC", Qt::CaseInsensitive)) { str = str.mid(3); QStringList list = str.split("-"); if (list.count() == 2) { int reg = list[0].toInt(); int num = list[1].toInt(); int index; gsc_t *star; if (cGSC.searchStar(reg, num, &star, index)) { ra = star->Ra; dec = star->Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = DMS2RAD(0, 30, 0); obj.type = MO_GSCSTAR; obj.par1 = reg - 1; obj.par2 = index; return true; } } return false; } } if (SS_CHECK_OR(SS_POS, what)) { // ra/dec { QStringList list = str.split(' '); if (list.count() == 6) { double rah, ram, ras; double decd, decm, decs; bool ok; for (int i = 0; i < 6; i++) { list.at(0).toDouble(&ok); if (!ok) { break; } } if (ok) { rah = list.at(0).toDouble(); ram = list.at(1).toDouble(); ras = list.at(2).toDouble(); decd = list.at(3).toDouble(); decm = list.at(4).toDouble(); decs = list.at(5).toDouble(); double mra = HMS2RAD(qAbs(rah), qAbs(ram), qAbs(ras)); double mdec = DMS2RAD(qAbs(decd), qAbs(decm), qAbs(decs)); if (decd < 0) { mdec = -mdec; } if (mra >= 0 && mra <= R360 && mdec >= -R90 && mdec <= R90) { ra = mra; dec = mdec; fov = CM_UNDEF; if (mapView->epochJ2000 && mapView->coordType == SMCT_RA_DEC) { precess(&ra, &dec, JD2000, mapView->jd); } return true; } } } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_CONSTEL, what)) { // constellation if (constFind(str, ra, dec, fov, mapView->jd)) return(true); } QApplication::processEvents(); if (SS_CHECK_OR(SS_STAR_NAME, what)) { // star names for (int i = 0; i < cTYC.tNames.count(); i++) { int offs = cTYC.tNames[i]->supIndex; QString name = cTYC.getStarName(&cTYC.pSupplement[offs]); if (!str.compare(name, Qt::CaseInsensitive)) { ra = cTYC.tNames[i]->rd.Ra; dec = cTYC.tNames[i]->rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = D2R(30); int reg, index; if (cTYC.findStar(NULL, TS_TYC, 0, 0, 0, 0, cTYC.tNames[i]->tyc1, cTYC.tNames[i]->tyc2, cTYC.tNames[i]->tyc3, 0, reg, index)) { obj.type = MO_TYCSTAR; obj.par1 = reg; obj.par2 = index; } return(true); } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_PLANET, what)) { // search planet/sun/moon for (int i = PT_SUN; i <= PT_MOON; i++) { orbit_t o; cAstro.setParam(mapView); cAstro.calcPlanet(i, &o); QString name = o.name; QString english = o.englishName; if (!str.compare(name, Qt::CaseInsensitive) || !str.compare(english, Qt::CaseInsensitive)) { ra = o.lRD.Ra; dec = o.lRD.Dec; fov = getOptObjFov(o.sx / 3600.0, o.sy / 3600.0); obj.type = MO_PLANET; obj.par1 = i; obj.par2 = 0; return(true); } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_DSO, what)) { // dso dso_t *dso; int index; if (cDSO.findDSO((char *)qPrintable(str), &dso, index) != -1) { ra = dso->rd.Ra; dec = dso->rd.Dec; precess(&ra, &dec, JD2000, mapView->jd); fov = getOptObjFov(dso->sx / 3600., dso->sy / 3600.); obj.type = MO_DSO; obj.par1 = (qint64)dso; obj.par2 = 0; return(true); } } QApplication::processEvents(); if (SS_CHECK_OR(SS_ART_SAT, what)) { // satellites QString satName = str; sgp4.setObserver(mapView); for (int i = 0; i < sgp4.count(); i++) { satellite_t out; radec_t rd; if (sgp4.getName(i).compare(satName, Qt::CaseInsensitive) == 0) { if (sgp4.solve(i, mapView, &out)) { cAstro.convAA2RDRef(out.azimuth, out.elevation, &rd.Ra, &rd.Dec); ra = rd.Ra; dec = rd.Dec; fov = getOptObjFov(0, 0, D2R(2.5)); obj.type = MO_SATELLITE; obj.par1 = i; obj.par2 = 0; return true; } } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_ASTER, what)) { // asteroids for (int i = 0; i < tAsteroids.count(); i++) { asteroid_t *a = &tAsteroids[i]; if (!a->selected) continue; if (QString(a->name).contains(reg) || a->name == str) { qDebug() << a->name << reg; astSolve(a, mapView->jd); ra = a->orbit.lRD.Ra; dec = a->orbit.lRD.Dec; fov = AST_ZOOM; obj.type = MO_ASTER; obj.par1 = i; obj.par2 = (qint64)a; return(true); } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_COMET, what)) { // comets for (int i = 0; i < tComets.count(); i++) { comet_t *a = &tComets[i]; if (!a->selected) continue; if (QString(a->name).contains(reg) || a->name == str) { comSolve(a, mapView->jd); ra = a->orbit.lRD.Ra; dec = a->orbit.lRD.Dec; fov = qMin(COM_ZOOM, 8 * D2R(a->orbit.params[2] / 3600.)); obj.type = MO_COMET; obj.par1 = i; obj.par2 = (qint64)a; return(true); } } } QApplication::processEvents(); if (SS_CHECK_OR(SS_LUNAR_FEAT, what)) { if (cLunarFeatures.search(str, mapView, ra, dec, fov)) { return(true); } } return(false); }