Esempio n. 1
0
/*================== POWDER Implementation ===========================*/
int calcTasPowderAngles(ptasMachine machine, tasQEPosition qe,
			ptasAngles angles){
  double cos2t;
  int status;
  tasReflection r;

  status = maCalcTwoTheta(machine->monochromator,qe.ki, 
			  &angles->monochromator_two_theta);
  if(status != 1){
    return status;
  }

  cos2t = (qe.ki*qe.ki + qe.kf*qe.kf - qe.qm*qe.qm)/(2. * ABS(qe.ki) * ABS(qe.kf));
  if(cos2t > 1.){
    return TRIANGLENOTCLOSED;
  }
  angles->sample_two_theta = machine->ss_sample*Acosd(cos2t);
  

  status = maCalcTwoTheta(machine->analyzer,qe.kf,&
			  angles->analyzer_two_theta);
  if(status != 1){
    return status;
  }

  return 1;
}
Esempio n. 2
0
        double SunTimes::DayLen(int year, int month, int day, double lon, double lat,
            double altit, int upper_limb)
        {
            double d,  /* Days since 2000 Jan 0.0 (negative before) */
                obl_ecl,    /* Obliquity (inclination) of Earth's axis */
                //黄赤交角,在2000.0历元下国际规定为23度26分21.448秒,但有很小的时间演化。

                sr,         /* Solar distance, astronomical units */
                slon,       /* True solar longitude */
                sin_sdecl,  /* Sine of Sun's declination */
                //太阳赤纬的正弦值。
                cos_sdecl,  /* Cosine of Sun's declination */
                sradius,    /* Sun's apparent radius */
                t;          /* Diurnal arc */

            /* Compute d of 12h local mean solar time */
            d = Days_since_2000_Jan_0(year, month, day) + 0.5 - lon / 360.0;

            /* Compute obliquity of ecliptic (inclination of Earth's axis) */
            obl_ecl = 23.4393 - 3.563E-7 * d;
            //这个黄赤交角时变公式来历复杂,很大程度是经验性的,不必追究。

            /* Compute Sun's position */
            slon = 0.0;
            sr = 0.0;
            Sunpos(d,  slon,  sr);

            /* Compute sine and cosine of Sun's declination */
            sin_sdecl = Sind(obl_ecl) * Sind(slon);
            cos_sdecl = sqrt(1.0 - sin_sdecl * sin_sdecl);
            //用球面三角学公式计算太阳赤纬。

            /* Compute the Sun's apparent radius, degrees */
            sradius = 0.2666 / sr;
            //视半径,同前。

            /* Do correction to upper limb, if necessary */
            if (upper_limb != 0)
                altit -= sradius;

            /* Compute the diurnal arc that the Sun traverses to reach */
            /* the specified altitide altit: */
            //根据设定的地平高度判据计算周日弧长。
            double cost;
            cost = (Sind(altit) - Sind(lat) * sin_sdecl) /
                (Cosd(lat) * cos_sdecl);
            if (cost >= 1.0)
                t = 0.0;                      /* Sun always below altit */
            //极夜。
            else if (cost <= -1.0)
                t = 24.0;                     /* Sun always above altit */
            //极昼。
            else t = (2.0 / 15.0) * Acosd(cost); /* The diurnal arc, hours */
            //周日弧换算成小时计。
            return t;

        }
Esempio n. 3
0
/*-------------------------------------------------------------------------------*/
int calcTasQAngles(MATRIX UB, MATRIX planeNormal, int ss,  tasQEPosition qe, 
		   ptasAngles angles){
  MATRIX R, QC;
  double om, q, theta, cos2t;
  int errorCode = 1;

  R = buildRMatrix(UB, planeNormal, qe, &errorCode);
  if(R == NULL){
    return errorCode;
  }
  

  angles->sgl = Asind(-R[2][0]);
  if(ABS(angles->sgl -90.) < .5){
  	mat_free(R);
    return BADUBORQ;
  }
  /*
    Now, this is slightly different then in the publication by M. Lumsden.
    The reason is that the atan2 helps to determine the sign of om
    whereas the sin, cos formula given by M. Lumsden yield ambiguous signs 
    especially for om.
    sgu = atan(R[2][1],R[2][2]) where:
      R[2][1] = cos(sgl)sin(sgu)
      R[2][2] = cos(sgu)cos(sgl)
    om = atan(R[1][0],R[0][0]) where:
      R[1][0] = sin(om)cos(sgl)
      R[0][0] = cos(om)cos(sgl)
    The definitions of th R components are taken from M. Lumsden
    R-matrix definition.
  */

  om = Atan2d(R[1][0],R[0][0]);
  angles->sgu = Atan2d(R[2][1],R[2][2]);

  QC = tasReflectionToQC(qe,UB);
  if(QC == NULL){
  	mat_free(R);
    return UBNOMEMORY;
  }

  q = vectorLength(QC);
  q = 2.*PI*vectorLength(QC); 
  cos2t = (qe.ki*qe.ki + qe.kf*qe.kf - q*q)/(2. * ABS(qe.ki) * ABS(qe.kf));
  if(ABS(cos2t) > 1.){
  	mat_free(R);
  	killVector(QC);
    return TRIANGLENOTCLOSED;
  }
  angles->sample_two_theta = ss*Acosd(cos2t);
  
  theta = calcTheta(qe.ki, qe.kf,angles->sample_two_theta);
  
  angles->a3 = om + theta;
  /*
    put a3 into -180, 180 properly. We cal always turn by 180 because the
    scattering geometry is symmetric in this respect. It is like looking at
    the scattering plane from the other side
  */
  angles->a3 -= 180.;
  if(angles->a3 < -180.){
    angles->a3 += 360.;
  }

  killVector(QC);
  mat_free(R);

  return 1;
}
Esempio n. 4
0
         int SunTimes::SunRiset(int year, int month, int day, double lon, double lat,
            double altit, int upper_limb,  double &trise,  double &tset)
        {
            double d,  /* Days since 2000 Jan 0.0 (negative before) */
                //以历元2000.0起算的日数。

                sr,         /* Solar distance, astronomical units */
                //太阳距离,以天文单位计算(约1.5亿公里)。

                sRA,        /* Sun's Right Ascension */
                //同前,太阳赤经。

                sdec,       /* Sun's declination */
                //太阳赤纬。

                sradius,    /* Sun's apparent radius */
                //太阳视半径,约16分(受日地距离、大气折射等诸多影响)

                t,          /* Diurnal arc */
                //周日弧,太阳一天在天上走过的弧长。

                tsouth,     /* Time when Sun is at south */
                sidtime;    /* Local sidereal time */
            //当地恒星时,即地球的真实自转周期。比平均太阳日(日常时间)长3分56秒。

            int rc = 0; /* Return cde from function - usually 0 */

            /* Compute d of 12h local mean solar time */
            d = Days_since_2000_Jan_0(year, month, day) + 0.5 - lon / 360.0;
            //计算观测地当日中午时刻对应2000.0起算的日数。

            /* Compute local sideral time of this moment */
            sidtime = Revolution(GMST0(d) + 180.0 + lon);
            //计算同时刻的当地恒星时(以角度为单位)。以格林尼治为基准,用经度差校正。

            /* Compute Sun's RA + Decl at this moment */
            sRA = 0.0;
            sdec = 0.0;
            sr = 0.0;
            Sun_RA_dec(d,  sRA,  sdec,  sr);
            //计算同时刻太阳赤经赤纬。

            /* Compute time when Sun is at south - in hours UT */
            tsouth = 12.0 - Rev180(sidtime - sRA) / 15.0;
            //计算太阳日的正午时刻,以世界时(格林尼治平太阳时)的小时计。

            /* Compute the Sun's apparent radius, degrees */
            sradius = 0.2666 / sr;
            //太阳视半径。0.2666是一天文单位处的太阳视半径(角度)。

            /* Do correction to upper limb, if necessary */
            if (upper_limb != 0)
                altit -= sradius;
            //如果要用上边缘,就要扣除一个视半径。

            /* Compute the diurnal arc that the Sun traverses to reach */
            //计算周日弧。直接利用球面三角公式。如果碰到极昼极夜问题,同前处理。
            /* the specified altitide altit: */

            double cost;
            cost = (Sind(altit) - Sind(lat) * Sind(sdec)) /
                (Cosd(lat) * Cosd(sdec));
            if (cost >= 1.0)
            {
                rc = -1;
                t = 0.0;
            }
            else
            {
                if (cost <= -1.0)
                {
                    rc = +1;
                    t = 12.0;      /* Sun always above altit */
                }
                else
                    t = Acosd(cost) / 15.0;   /* The diurnal arc, hours */
            }


            /* Store rise and set times - in hours UT */
            trise = tsouth - t;
            tset = tsouth + t;

            return rc;
        }