void csurvey2gal(double lambda, double eta, double *glon, double *glat) { double ra, dec, g_lon, g_lat; csurvey2eq(lambda,eta,&ra,&dec); eq2gal(ra,dec,&g_lon,&g_lat); if (g_lon > 360.0) g_lon -= 360.0; *glon = g_lon; *glat = g_lat; }
/* dist (kpc) and returns proper motion in Galactic coordinates with errors */ int find_galcoord_equatorial(double ra2000,double dec2000,double pmra,double pmraerr,double pmdec,double pmdecerr, double dist,double *mul,double *mulerr,double *mub,double *muberr) { double l2000,b2000; double cel2gal[3][3],cel[3],gal[3],covmat[3][3]; double covar=0.0,covmatgal[3][3],covargal; double galcart[4],gcr,ddtemp,pmlerr,pmberr; double p[4],q[4],r[4],vsl,vsb,vgal[4]; double pml,pmb,thetagal,vrgal,pmlrot,pmbrot,cosb; int i; /* angles in mas/yr to kms/s (along with distances in kpc) */ double dang2vel = 4.7405; /* Oort's consts */ double a=14.5,b=-12.0,r0=8.5,v0gal,vsun[4]; /* Solar veloctiy */ vsun[1]=9.2; vsun[2]=10.5; vsun[3]=6.9; /* Galactic rotation velocty at the Earth */ v0gal = 225.0; /* Using flat rotation curve */ /* Calculate L and B */ eq2gal(ra2000,dec2000,&l2000,&b2000,cel2gal); cel[1]=pmra; cel[2]=pmdec; /* Calculate the position in galactic cartesian coordinates */ /* x increasing towards the galactic centre */ cosb=cos(b2000); galcart[1] = cos(l2000)*cosb; galcart[2] = sin(l2000)*cosb; galcart[3] = sin(b2000); for (i=1;i<=3;i++) galcart[i]=galcart[i]*dist; /* Calculate the projected galactocentric distance to the source */ gcr=sqrt(pow(r0-galcart[1],2)+pow(galcart[2],2)); /* Calculate the proper motions in galactic coords */ matx2v(cel2gal,cel,gal); /* Form the covarience matrix */ covmat[1][1] = pmraerr*pmraerr; covmat[2][2] = pmdecerr*pmdecerr; covmat[1][2] = covar*pmraerr*pmdecerr; covmat[2][1] = covar*pmraerr*pmdecerr; /* Postmultiply by the conversion matrix */ multiply(covmat,cel2gal,covmatgal); /* Premultiply by the transpose of the conversion matrix */ ddtemp = cel2gal[1][2]; cel2gal[1][2] = cel2gal[2][1]; cel2gal[2][1]=ddtemp; multiply(cel2gal,covmatgal,covmatgal); pmlerr = sqrt(fabs(covmatgal[1][1])); pmberr = sqrt(fabs(covmatgal[2][2])); covargal = covmatgal[1][2]/fabs(pmlerr)/fabs(pmdecerr); /* Calculate orthogonal vectors */ p[1] = -sin(l2000); p[2] = cos(l2000); p[3] = 0.0; q[1] = -sin(b2000)*cos(l2000); q[2] = -sin(b2000)*sin(l2000); q[3] = cos(b2000); r[1] = cos(b2000)*cos(l2000); r[2] = cos(b2000)*sin(l2000); r[3] = sin(b2000); /* Form dot product with the sun's velocity vector */ vsl = -product(p,vsun)/dist/dang2vel; vsb = -product(q,vsun)/dist/dang2vel; /* Find the proper motions expected from galactic rotation using rotation */ /* curve model */ thetagal = atan2(galcart[2],r0-galcart[1]); vrgal = v0gal; /* Use flat rotation curve */ vgal[1] = vrgal*sin(thetagal); vgal[2] = vrgal*cos(thetagal)-v0gal; vgal[3] = 0.0; pmlrot=product(p,vgal)/dist/dang2vel; pmbrot=product(q,vgal)/dist/dang2vel; /* Take the galactiv rotation and solar motion off the galactic pm */ pmb = gal[2]; pml = gal[1]; pmb = pmb-pmbrot-vsb; pml = pml-pmlrot-vsl; *mul=pml; *mulerr = pmlerr; *mub = pmb; *muberr = pmberr; }