Returns a fixed star from the ephemeris.
174050
def getFixedStar(ID, date):
    
    star = eph.getFixedStar(ID, date.jd)
    return FixedStar.fromDict(star)
669317
def sweFixedStar(star, jd):
    
    sweList = swisseph.fixstar_ut(star, jd)
    mag = swisseph.fixstar_mag(star)
    return {
        'id': star, 
        'mag': mag,
        'lon': sweList[0],
        'lat': sweList[1]
    }
1355660
function Star( x, y, starSize, ctx, fgCanvas, analyser, streamData ){
	this.x = x;
	this.y = y;
	this.angle = Math.atan( Math.abs(y) / Math.abs(x) );
	this.starSize = starSize;
	this.ctx = ctx;
	this.high = 0;
	this.fgCanvas = fgCanvas;
	this.analyser = analyser;
	this.streamData = streamData;
}
685924
def from_bundle(cls, b, feature):
        

        feature_ps = b.get_feature(feature)

        colat = feature_ps.get_value('colat', unit=u.rad)
        longitude = feature_ps.get_value('long', unit=u.rad)

        if len(b.hierarchy.get_stars())>=2:
            star_ps = b.get_component(feature_ps.component)
            orbit_ps = b.get_component(b.hierarchy.get_parent_of(feature_ps.component))
            syncpar = star_ps.get_value('syncpar')
            period = orbit_ps.get_value('period')
            dlongdt = (syncpar - 1) / period * 2 * np.pi
        else:
            star_ps = b.get_component(feature_ps.component)
            dlongdt = star_ps.get_value('freq', unit=u.rad/u.d)
            longitude = np.pi/2

        radius = feature_ps.get_value('radius', unit=u.rad)
        relteff = feature_ps.get_value('relteff', unit=u.dimensionless_unscaled)

        t0 = b.get_value('t0', context='system', unit=u.d)

        return cls(colat, longitude, dlongdt, radius, relteff, t0)
1092398
def satellite(self,stellar_mass,distance_modulus,mc_source_id=1,seed=None,**kwargs):
        
        if seed is not None: np.random.seed(seed)

        isochrone = kwargs.pop('isochrone',self.isochrone)
        kernel    = kwargs.pop('kernel',self.kernel)

        for k,v in kwargs.items():
            if k in kernel.params.keys(): setattr(kernel,k,v)

        mag_1, mag_2 = isochrone.simulate(stellar_mass, distance_modulus)
        lon, lat     = kernel.simulate(len(mag_1))
 
        logger.info("Simulating %i satellite stars..."%len(mag_1))
        pix = ang2pix(self.config['coords']['nside_pixel'], lon, lat)

        # There is probably a better way to do this step without creating the full HEALPix map
        mask = -1. * np.ones(hp.nside2npix(self.config['coords']['nside_pixel']))
        mask[self.roi.pixels] = self.mask.mask_1.mask_roi_sparse
        mag_lim_1 = mask[pix]
        mask = -1. * np.ones(hp.nside2npix(self.config['coords']['nside_pixel']))
        mask[self.roi.pixels] = self.mask.mask_2.mask_roi_sparse
        mag_lim_2 = mask[pix]

        mag_err_1 = self.photo_err_1(mag_lim_1 - mag_1)
        mag_err_2 = self.photo_err_2(mag_lim_2 - mag_2)

        # Randomize magnitudes by their errors
        mag_obs_1 = mag_1+np.random.normal(size=len(mag_1))*mag_err_1
        mag_obs_2 = mag_2+np.random.normal(size=len(mag_2))*mag_err_2
        #mag_obs_1 = mag_1
        #mag_obs_2 = mag_2

        #select = np.logical_and(mag_obs_1 < mag_lim_1, mag_obs_2 < mag_lim_2)
        select = (mag_lim_1>mag_obs_1)&(mag_lim_2>mag_obs_2)

        # Make sure objects lie within the original cmd (should also be done later...)
        #select &= (ugali.utils.binning.take2D(self.mask.solid_angle_cmd, mag_obs_1 - mag_obs_2, mag_obs_1,self.roi.bins_color, self.roi.bins_mag) > 0)

        #return mag_1_obs[cut], mag_2_obs[cut], lon[cut], lat[cut]
        logger.info("Clipping %i simulated satellite stars..."%(~select).sum())
        mc_source_id = mc_source_id * np.ones(len(mag_1))
        
        hdu = ugali.observation.catalog.makeHDU(self.config,mag_obs_1[select],mag_err_1[select],
                                                mag_obs_2[select],mag_err_2[select], 
                                                lon[select],lat[select],mc_source_id[select])
        catalog = ugali.observation.catalog.Catalog(self.config, data=hdu.data)
        return catalog
1290900
def ephemeris(self, **kwargs):
        

        for orb in self.iter(inclusive=True, **kwargs):
            yield orb
492467
def to(self, unit):
        """"""
        from astropy.units import au, d
        return (self.au_per_d * au / d).to(unit)
1241362
def energ_orb(m1,m2,r):
    ''' 
    
        
    '''
    epo = -grav_const * m1 * m2 * msun_g**2 / (r * rsun_cm)
    return epo
226714
public static Position getSubSolarPoint(Calendar time) {

		// convert time to Julian Day Number

		double jd = TimeUtil.getJulianDayNumber(time);
		// Julian centuries since Jan 1, 2000, 12:00 UTC

		double T = (jd - 2451545.0) / 36525;

		// mean anomaly, degree
		double M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048
				* T * T * T;

		// mean longitude, degree
		double L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T;

		double DL = (1.914600 - 0.004817 * T - 0.000014 * T * T)
				* Math.sin(Math.toRadians(M)) + (0.019993 - 0.000101 * T)
				* Math.sin(Math.toRadians(2.0 * M)) + 0.000290
				* Math.sin(Math.toRadians(3.0 * M));

		// true longitude, degree
		double L = L0 + DL;

		// obliquity eps of ecliptic in degrees:
		double eps = 23.0 + 26.0 / 60.0 + 21.448 / 3600.0
				- (46.8150 * T + 0.00059 * T * T - 0.001813 * T * T * T)
				/ 3600.0;

		double X = Math.cos(Math.toRadians(L));
		double Y = Math.cos(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
		double Z = Math.sin(Math.toRadians(eps)) * Math.sin(Math.toRadians(L));
		double R = Math.sqrt(1.0 - Z * Z);

		double delta = Math.toDegrees(Math.atan(Z / R)); // in degrees
		double p = Y / (X + R);
		double ra = Math.toDegrees(Math.atan(p));
		double RA = (24.0 / 180.0) * ra; // in hours

		// sidereal time (in hours)

		double theta0 = 280.46061837 + 360.98564736629 * (jd - 2451545.0)
				+ 0.000387933 * T * T - T * T * T / 38710000.0;
		double sidTime = (theta0 % 360) / 15.0;

		// lon and lat of sun

		double sunHADeg = ((sidTime - RA) * 15.0) % 360.0;
		double lon = 0.0;
		if (sunHADeg < 180.0) {
			lon = -sunHADeg;
		} else {
			lon = 360.0 - sunHADeg;
		}
		double lat = delta;

		log.info("Sidereal time is " + sidTime + ", Sun RA/Dec is " + RA + "/"
				+ delta + ", subSolar lat/long is " + lat + "/" + lon);

		return new Position(lat, lon);

	}
308509
def get_ci(theta_star, blockratio=1.0):
    
    # get rid of nans while we sort
    b_star = np.sort(theta_star[~np.isnan(theta_star)])
    se = np.std(b_star) * np.sqrt(blockratio)
    # bootstrap 95% CI based on empirical percentiles
    ci = [b_star[int(len(b_star) * .025)], b_star[int(len(b_star) * .975)]]
    return ci
851297
def sky(lon=None,lat=None,size=1):
    
    if lon is None:
        umin,umax = 0,1
    else:
        lon = np.asarray(lon)
        lon = np.radians(lon + 360.*(lon<0))
        if   lon.size==1: umin=umax=lon/(2*np.pi)
        elif lon.size==2: umin,umax=lon/(2*np.pi)
        else: raise Exception('...')
        
    if lat is None:
        vmin,vmax = -1,1
    else:
        lat = np.asarray(lat)
        lat = np.radians(90 - lat)
        if   lat.size==1: vmin=vmax=np.cos(lat)
        elif lat.size==2: vmin,vmax=np.cos(lat)
        else: raise Exception('...')

    phi = 2*np.pi*np.random.uniform(umin,umax,size=size)
    theta = np.arcsin(np.random.uniform(vmin,vmax,size=size))
    return np.degrees(phi),np.degrees(theta)
339549
def getFixedStarList(IDs, date):
    
    starList = [getFixedStar(ID, date) for ID in IDs]
    return FixedStarList(starList)
364183
def process_star(filename, output, *, extension, star_name, period, shift,
                 parameters, period_label, shift_label, **kwargs):
    
    if star_name is None:
        basename = path.basename(filename)
        if basename.endswith(extension):
            star_name = basename[:-len(extension)]
        else:
            # file has wrong extension
            return
    if parameters is not None:
        if period is None:
            try:
                period = parameters[period_label][star_name]
            except KeyError:
                pass
            if shift is None:
                try:
                    shift = parameters.loc[shift_label][star_name]
                except KeyError:
                    pass

    result = get_lightcurve_from_file(filename, name=star_name,
                                      period=period, shift=shift,
                                      **kwargs)
    if result is None:
        return
    if output is not None:
        plot_lightcurve(star_name, result['lightcurve'], result['period'],
                        result['phased_data'], output=output, **kwargs)

    return result
1180088
def prevSolarEclipse(date):
    

    eclipse = swe.solarEclipseGlobal(date.jd, backward=True)
    return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
1084220
def to(self, unit):
        """"""
        from astropy.units import rad
        return (self.radians * rad).to(unit)

        # Or should this do:
        from astropy.coordinates import Angle
        from astropy.units import rad
        return Angle(self.radians, rad).to(unit)
1165297
def galactic_latlon(self):
        """"""
        vector = _GALACTIC.dot(self.position.au)
        d, lat, lon = to_polar(vector)
        return (Angle(radians=lat, signed=True),
                Angle(radians=lon),
                Distance(au=d))
207176
public Moonlight on(CalendarDate date) {

        // initialization
        PlainDate d = SolarTime.toGregorian(date);
        Timezone tz = Timezone.of(this.observerZoneID);
        Moment start =
            ((tz.getHistory() == null)
                ? d.at(PlainTime.midnightAtStartOfDay()).in(tz)
                : d.atFirstMoment(this.observerZoneID));

        double mjd0 = JulianDay.ofMeanSolarTime(start).getMJD();
        double longitudeRad = Math.toRadians(this.longitude);
        double cosLatitude = Math.cos(Math.toRadians(this.latitude));
        double sinLatitude = Math.sin(Math.toRadians(this.latitude));
        double geodeticAngle = StdSolarCalculator.TIME4J.getGeodeticAngle(this.latitude, this.altitude);
        double refraction = AstroUtils.refractionFactorOfStdAtmosphere(this.altitude) * SolarTime.STD_REFRACTION / 60;
        double deltaT = TimeScale.deltaT(d);
        double hour = 1.0;
        double y_minus = sinAlt(mjd0, 0.0, longitudeRad, cosLatitude, sinLatitude, geodeticAngle, refraction, deltaT);
        double[] result = new double[4];

        // declaration of result data
        boolean above = (y_minus > 0.0); // at start of day
        boolean rises = false;
        boolean sets = false;
        double risingHour = Double.NaN;
        double settingHour = Double.NaN;

        // loop over 2-hour-search-intervals applying quadratic interpolation
        do {
            double y_0 =
                sinAlt(mjd0, hour, longitudeRad, cosLatitude, sinLatitude, geodeticAngle, refraction, deltaT);
            double y_plus =
                sinAlt(mjd0, hour + 1, longitudeRad, cosLatitude, sinLatitude, geodeticAngle, refraction, deltaT);
            int count =
                interpolate(y_minus, y_0, y_plus, result);
            if (count == 1) {
                double root = result[2];
                if (Double.isNaN(root)) {
                    root = result[3];
                }
                if (y_minus < 0.0) {
                    risingHour = hour + root;
                    rises = true;
                } else {
                    settingHour = hour + root;
                    sets = true;
                }
            } else if (count == 2) {
                if (result[1] < 0.0) {
                    risingHour = hour + result[3];
                    settingHour = hour + result[2];
                } else {
                    risingHour = hour + result[2];
                    settingHour = hour + result[3];
                }
                rises = true;
                sets = true;
            }
            y_minus = y_plus;
            hour += 2.0;
        } while (!((hour > 25.0) || (rises && sets))); // (> 25.0)-condition cares about possible 25-h-day (end-of-DST)

        // evaluate moonrise and moonset
        Moment rising = null;
        Moment setting = null;

        if (rises) {
            rising = add(start, risingHour);
            if (!rising.toZonalTimestamp(this.observerZoneID).getCalendarDate().equals(d)) {
                rising = null;
                // rises = false;
            }
        }
        if (sets) {
            setting = add(start, settingHour);
            if (!setting.toZonalTimestamp(this.observerZoneID).getCalendarDate().equals(d)) {
                setting = null;
                // sets = false;
            }
        }

        return new Moonlight(d, this.observerZoneID, rising, setting, above);

    }