Returns times and fluxes of eclipse i (centered at t=0)
425373
def eclipse_new(self, i, secondary=False, npoints=200, width=3,
                texp=None):
        
        texp = self.cadence
        s = self.stars.iloc[i]

        e = s['ecc']
        P = s['P']
        if secondary:
            mu1, mu2 = s[['u1_2', 'u2_2']]
            w = np.mod(np.deg2rad(s['w']) + np.pi, 2*np.pi)
            mass_central, radius_central = s[['mass_2','radius_2']]
            mass_body, radius_body = s[['mass_1','radius_1']]
            b = s['b_sec'] * s['radius_1']/s['radius_2']
            frac = s['fluxfrac_2']
        else:
            mu1, mu2 = s[['u1_1', 'u2_1']]
            w = np.deg2rad(s['w'])
            mass_central, radius_central = s[['mass_1','radius_1']]
            mass_body, radius_body = s[['mass_2','radius_2']]
            b = s['b_pri']
            frac = s['fluxfrac_1']


        central_kwargs = dict(mass=mass_central, radius=radius_central,
                              mu1=mu1, mu2=mu2)
        central = Central(**central_kwargs)

        body_kwargs = dict(radius=radius_body, mass=mass_body, b=b,
                           period=P, e=e, omega=w)
        body = Body(**body_kwargs)

        logging.debug('central: {}'.format(central_kwargs))
        logging.debug('body: {}'.format(body_kwargs))

        s = System(central)
        s.add_body(body)

        # As of now, body.duration returns strictly circular duration
        dur = body.duration

        logging.debug('duration: {}'.format(dur))

        ts = np.linspace(-width/2*dur, width/2*dur, npoints)
        fs = s.light_curve(ts, texp=texp)
        fs = 1 - frac*(1-fs)
        return ts, fs
926458
def timeinfo(self):
        
        if self.istep not in self.sdat.tseries.index:
            return None
        return self.sdat.tseries.loc[self.istep]
553179
def flux_v2(v_vars: List[fl.Var], i: int):
    """"""
    # Index with the base of (v_x, v_y, v_z) for body i
    k = 3*i
    # The speed squared of body i
    return fl.square(v_vars[k+0]) + fl.square(v_vars[k+1]) + fl.square(v_vars[k+2])
158276
def get_time(self, loc4d=None):
        
        if loc4d is None:
            raise ValueError("Location4D object can not be None")

        if self.pattern == self.PATTERN_CYCLE:
            c = SunCycles.cycles(loc=loc4d)
            if self.cycle == self.CYCLE_SUNRISE:
                r = c[SunCycles.RISING]
            elif self.cycle == self.CYCLE_SUNSET:
                r = c[SunCycles.SETTING]
            td = timedelta(hours=self.time_delta)
            if self.plus_or_minus == self.HOURS_PLUS:
                r = r + td
            elif self.plus_or_minus == self.HOURS_MINUS:
                r = r - td
            return r
        elif self.pattern == self.PATTERN_SPECIFICTIME:
            return self._time.replace(year=loc4d.time.year, month=loc4d.time.month, day=loc4d.time.day)
598779
def radiation_values(self, location, timestep=1):
        
        # create sunpath and get altitude at every timestep of the design day
        sp = Sunpath.from_location(location)
        altitudes = []
        dates = self._get_datetimes(timestep)
        for t_date in dates:
            sun = sp.calculate_sun_from_date_time(t_date)
            altitudes.append(sun.altitude)
        dir_norm, diff_horiz = ashrae_clear_sky(
            altitudes, self._month, self._clearness)
        glob_horiz = [dhr + dnr * math.sin(math.radians(alt)) for
                      alt, dnr, dhr in zip(altitudes, dir_norm, diff_horiz)]
        return dir_norm, diff_horiz, glob_horiz
2388
private int nAdjacentCentres(int i) {
        int n = 0;
        for (IAtom atom : tetrahedralElements[i].getLigands())
            if (tetrahedralElements[atomToIndex.get(atom)] != null) n++;
        return n;
    }
376029
def _tle_to_keplerian_mean(cls, coord, center):
        
        i, Ω, e, ω, M, n = coord
        a = (center.µ / n ** 2) ** (1 / 3)

        return np.array([a, e, i, Ω, ω, M], dtype=float)
442654
def _calculate_solar_geometry(self, datetime):
        
        month = datetime.month
        day = datetime.day
        hour = datetime.hour
        minute = datetime.minute
        year = 2016 if self.is_leap_year else 2017

        def find_fraction_of_24(hour, minute):
            """
            This function calculates the fraction of the 24 hour
            the provided time represents
            1440 is total the number of minutes in a 24 hour cycle.
            args
                hour: Integer. Hour between 0 - 23
                minute: Integer. Minute between 0 - 59
            return: Float.
                The fraction of the 24 hours the provided time represents
            """
            return round((minute + hour * 60) / 1440.0, 2)

        def days_from_010119(year, month, day):
            """
            This function calculates the number of days from 01-01-1900 \
            to the provided date
            args :
                year: Integer. The year in the date
                month: Integer. The month in the date
                day: Integer. The date
            return: The number of days from 01-01-1900 to the date provided
            """

            # Making a list of years from the year 1900
            years = range(1900, year)

            def is_leap_year(year):
                """Determine whether a year is a leap year."""
                return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

            # Number of days in a year are 366 if it is a leap year
            days_in_year = []
            for item in years:
                if is_leap_year(item):
                    days_in_year.append(366)
                else:
                    days_in_year.append(365)

            # Making the total of all the days in preceding years
            days_in_precending_years = 0
            for days in days_in_year:
                days_in_precending_years += days

            if is_leap_year(year):
                month_dict = {1: 31, 2: 29, 3: 31, 4: 30, 5: 31, 6: 30,
                              7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
            else:
                month_dict = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30,
                              7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}

            """Making the total of all the days in preceding months\
            in the same year"""
            keys = tuple(month_dict.keys())
            days_in_precending_months = 0
            for i in range(month - 1):
                days_in_precending_months += month_dict[keys[i]]

            return days_in_precending_years + days_in_precending_months + day + 1

        julian_day = days_from_010119(year, month, day) + 2415018.5 + \
            find_fraction_of_24(hour, minute) - (float(self.time_zone) / 24)

        julian_century = (julian_day - 2451545) / 36525

        # degrees
        geom_mean_long_sun = (280.46646 + julian_century *
                              (36000.76983 + julian_century * 0.0003032)
                              ) % 360
        # degrees
        geom_mean_anom_sun = 357.52911 + julian_century * \
            (35999.05029 - 0.0001537 * julian_century)

        eccent_orbit = 0.016708634 - julian_century * \
            (0.000042037 + 0.0000001267 * julian_century)

        sun_eq_of_ctr = math.sin(
            math.radians(geom_mean_anom_sun)) * \
            (1.914602 - julian_century * (0.004817 + 0.000014 * julian_century)
             ) +\
            math.sin(math.radians(2 * geom_mean_anom_sun)) * \
            (0.019993 - 0.000101 * julian_century) + \
            math.sin(math.radians(3 * geom_mean_anom_sun)) * \
            0.000289

        # degrees
        sun_true_long = geom_mean_long_sun + sun_eq_of_ctr

        # degrees
        sun_app_long = sun_true_long - 0.00569 - 0.00478 * \
            math.sin(math.radians(125.04 - 1934.136 * julian_century))

        # degrees
        mean_obliq_ecliptic = 23 + \
            (26 + ((21.448 - julian_century * (46.815 + julian_century *
                                               (0.00059 - julian_century *
                                                0.001813)))) / 60) / 60

        # degrees
        oblique_corr = mean_obliq_ecliptic + 0.00256 * \
            math.cos(math.radians(125.04 - 1934.136 * julian_century))

        # RADIANS
        sol_dec = math.degrees(math.asin(math.sin(math.radians(oblique_corr)) *
                                         math.sin(math.radians(sun_app_long))))

        var_y = math.tan(math.radians(oblique_corr / 2)) * \
            math.tan(math.radians(oblique_corr / 2))

        # minutes
        eq_of_time = 4 \
            * math.degrees(
                var_y * math.sin(2 * math.radians(geom_mean_long_sun)) -
                2 * eccent_orbit * math.sin(math.radians(geom_mean_anom_sun)) +
                4 * eccent_orbit * var_y *
                math.sin(math.radians(geom_mean_anom_sun)) *
                math.cos(2 * math.radians(geom_mean_long_sun)) -
                0.5 * (var_y ** 2) *
                math.sin(4 * math.radians(geom_mean_long_sun)) -
                1.25 * (eccent_orbit ** 2) *
                math.sin(2 * math.radians(geom_mean_anom_sun))
            )

        return sol_dec, eq_of_time
430330
def solarzenithangle(time: datetime, glat: float, glon: float, alt_m: float) -> tuple:
    
    time = totime(time)

    obs = EarthLocation(lat=glat*u.deg, lon=glon*u.deg, height=alt_m*u.m)
    times = Time(time, scale='ut1')
    sun = get_sun(times)
    sunobs = sun.transform_to(AltAz(obstime=times, location=obs))

    return 90 - sunobs.alt.degree, sun, sunobs
571259
def _compute_full_ts(self, data):
        """"""
        # Get results at each desired timestep and spatial point.
        full_ts, dt = self._compute(data)
        # Vertically integrate.
        vert_types = ('vert_int', 'vert_av')
        if self.dtype_out_vert in vert_types and self.var.def_vert:
            dp = self._get_input_data(_DP_VARS[self.dtype_in_vert],
                                      self.start_date, self.end_date)
            full_ts = utils.vertcoord.int_dp_g(full_ts, dp)
            if self.dtype_out_vert == 'vert_av':
                ps = self._get_input_data(utils.vertcoord.ps,
                                          self.start_date, self.end_date)
                full_ts *= (GRAV_EARTH / ps)
        return full_ts, dt
1134372
def Z(self):
    
    if not self.timezone:
      return 0
    offset = self.timezone.utcoffset(self.data)
    # Only days can be negative, so negative offsets have days=-1 and
    # seconds positive. Positive offsets have days=0
    return offset.days * 86400 + offset.seconds
1087085
def get_time_variable(ds):
    '''
    
    '''
    for var in ds.variables:
        if getattr(ds.variables[var], 'axis', '') == 'T':
            return var
    else:
        candidates = ds.get_variables_by_attributes(standard_name='time')
        if len(candidates) == 1:
            return candidates[0].name
        else:  # Look for a coordinate variable time
            for candidate in candidates:
                if candidate.dimensions == (candidate.name,):
                    return candidate.name

    # If we still haven't found the candidate
    time_variables = set(get_time_variables(ds))
    coordinate_variables = set(get_coordinate_variables(ds))
    if len(time_variables.intersection(coordinate_variables)) == 1:
        return list(time_variables.intersection(coordinate_variables))[0]

    auxiliary_coordinates = set(get_auxiliary_coordinate_variables(ds))
    if len(time_variables.intersection(auxiliary_coordinates)) == 1:
        return list(time_variables.intersection(auxiliary_coordinates))[0]
    return None
1153147
def calcPeriod(self):
        

        return eq.KeplersThirdLaw(self.a, self.star.M).P
1013037
def trajectory(self):
        
        traj = np.zeros((2, self.times.size))
        for t, time in enumerate(self.times):
            traj[:, t] = self.center_of_mass(time)
        return traj
660233
def I(self):
    "'"
    if self.timezone and self.timezone.dst(self.data):
      return u'1'
    else:
      return u'0'
1225343
def get_time(self, idx=0):
        
        thetime = super(SingleData, self).get_time(idx=0)
        return thetime
774523
def prevLunarEclipse(date):
    

    eclipse = swe.lunarEclipseGlobal(date.jd, backward=True)
    return Datetime.fromJD(eclipse['maximum'], date.utcoffset)