Last active
March 26, 2017 06:51
-
-
Save hannorein/5638999 to your computer and use it in GitHub Desktop.
The functions parameters are:
gjd - geocentric JD based on UTC
ra - right ascension (J2000)
de - declination The function returns heliocentric correction helcor. Using helcor, you can computed Heliocentric JD from Geocentric JD. The relation is: HJD = GJD + helcor.
We do not compute Barycentric JD (BJD).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function computeHELCOR($gjd, $ra, $de) { | |
// $eps=23.45*Pi()/180; | |
$ra = EREgI_Replace(" ", "", $ra); | |
$de = EREgI_Replace(" ", "", $de); | |
$ra_hh = IntVal(substr($ra, 0, 2)); | |
$ra_mm = IntVal(substr($ra, 2, 2)); | |
$ra_vv = DoubleVal(substr($ra, 4, 4)); | |
$de_dd = IntVal(substr($de, 0, 3)); | |
$de_mm = IntVal(substr($de, 3, 2)); | |
$de_ss = DoubleVal(substr($de, 5, 4)); | |
$prevod = DoubleVal(57.29577951); | |
$eps = DoubleVal(0.408988821); | |
$ra_mm /= 60; | |
$ra_ss /= 3600; | |
$ra_hh = $ra_hh + $ra_mm + $ra_ss; | |
$d_ra_hh = 15*$ra_hh; // RA in degrees | |
$alfa = Deg2Rad($d_ra_hh); // RA in rads | |
$de_mm /= 60; | |
$de_ss /= 3600; | |
$de_dd = $de_dd + $de_mm + $de_ss; // DE in degrees | |
$delta = Deg2Rad($de_dd); // DE in rads | |
$ra=$alfa; | |
$de=$delta; | |
if (abs(cos($de))<0.0000000001) { | |
if (sin($de)>0.0) { $de=Pi()/2-0.000000001; } | |
else { $de=-Pi()/2+0.000000001; } | |
} | |
if (abs(cos($ra))<0.0000000001) $ra=Pi()/2+0.0000000001; | |
$sinbeta=cos($eps)*sin($de)-sin($eps)*cos($de)*sin($ra); | |
$tanlam=(sin($de)*sin($eps)+cos($de)*cos($eps)*sin($ra))/(cos($de)*cos($ra)); | |
if ($sinbeta<1.0) $cosbeta=sqrt(1-$sinbeta*$sinbeta); | |
else $cosbeta=0.0000000001; | |
$coslam=cos($de)*cos($ra)/$cosbeta; | |
$lam=atan($tanlam); | |
if ($coslam<0) $lam=$lam+pi(); | |
if ($lam<0) $lam=$lam+2*pi(); | |
$tanbeta=$sinbeta/$cosbeta; | |
$bet=atan($tanbeta); | |
if ($gjd > 2400000) { | |
$t = $gjd - 2400000; | |
} else { | |
$t = $gjd; | |
} | |
$t=-51545.0+$t; | |
$tt=1+$t/36525.0; | |
$ls=(0.779072+0.00273790931*$t)*2*pi(); | |
$ms=(0.993126+0.00273777850*$t)*2*pi(); | |
$lm=(0.606434+0.03660110129*$t)*2*pi(); | |
$m2=(0.140023+0.00445036173*$t)*2*pi(); | |
$m4=(0.053856+0.00145561327*$t)*2*pi(); | |
$m5=(0.056531+0.00023080893*$t)*2*pi(); | |
$lams=$ls/Pi()*180*3600+6910.0*sin($ms)+72.0*sin(2*$ms) | |
-17.0*$tt*sin($ms) | |
-7*cos($ms-$m5) | |
+6*sin($lm-$ls)+5*sin(4*$ms-8*$m4+3*$m5) | |
-5*cos(2*$ms-2*$m2)-4*sin($ms-$m2) | |
+4*cos(4*$ms-8*$m4+3*$m5)+3*sin(2*$ms-2*$m2) | |
-3*sin($m5)-3*sin(2*$ms-2*$m5); | |
$r=1.00014-0.01675*cos($ms)-0.00014*cos(2*$ms); | |
$lams=$lams*pi()/(3600*180); | |
$helcor=-0.00577552*$r*cos($bet)*cos($lam-$lams); | |
return Sprintf("%.5f", $helcor); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Hanno!
Have you tested if this function works ok with a big amount of test cases?
I'm working on an astronomical tool to help an Observatory compute their observation, and i've been searching for a complete heliocentric correction procedure like this one.
It's OK to you if I take this one and make it part of our tool?
Thanks!