estimate the eddy turn-over time in days
512687
def _calc_eddy_time(self):
        
        ens = .5*self.H * self.spec_var(self.wv2*self.ph)
        return 2.*pi*np.sqrt( self.H / ens ) / year
262365
def _gti_dirint_lt_90(poa_global, aoi, aoi_lt_90, solar_zenith, solar_azimuth,
                      times, surface_tilt, surface_azimuth, pressure=101325.,
                      use_delta_kt_prime=True, temp_dew=None, albedo=.25,
                      model='perez', model_perez='allsitescomposite1990',
                      max_iterations=30):
    
    I0 = get_extra_radiation(times, 1370, 'spencer')
    cos_zenith = tools.cosd(solar_zenith)
    # I0h as in Marion 2015 eqns 1, 3
    I0h = I0 * np.maximum(0.065, cos_zenith)

    airmass = atmosphere.get_relative_airmass(solar_zenith, model='kasten1966')
    airmass = atmosphere.get_absolute_airmass(airmass, pressure)

    # these coeffs and diff variables and the loop below
    # implement figure 1 of Marion 2015

    # make coeffs that is at least 30 elements long so that all
    # coeffs can be assigned as specified in Marion 2015.
    # slice below will limit iterations if necessary
    coeffs = np.empty(max(30, max_iterations))
    coeffs[0:3] = 1
    coeffs[3:10] = 0.5
    coeffs[10:20] = 0.25
    coeffs[20:] = 0.125
    coeffs = coeffs[:max_iterations]  # covers case where max_iterations < 30

    # initialize diff
    diff = pd.Series(9999, index=times)
    best_diff = diff

    # initialize poa_global_i
    poa_global_i = poa_global

    for iteration, coeff in enumerate(coeffs):

        # test if difference between modeled GTI and
        # measured GTI (poa_global) is less than 1 W/m^2
        # only test for aoi less than 90 deg
        best_diff_lte_1 = best_diff <= 1
        best_diff_lte_1_lt_90 = best_diff_lte_1[aoi_lt_90]
        if best_diff_lte_1_lt_90.all():
            # all aoi < 90 points have a difference <= 1, so break loop
            break

        # calculate kt and DNI from GTI
        kt = clearness_index(poa_global_i, aoi, I0)  # kt from Marion eqn 2
        disc_dni = np.maximum(_disc_kn(kt, airmass)[0] * I0, 0)
        kt_prime = clearness_index_zenith_independent(kt, airmass)
        # dirint DNI in Marion eqn 3
        dni = _dirint_from_dni_ktprime(disc_dni, kt_prime, solar_zenith,
                                       use_delta_kt_prime, temp_dew)

        # calculate DHI using Marion eqn 3 (identify 1st term on RHS as GHI)
        # I0h has a minimum zenith projection, but multiplier of DNI does not
        ghi = kt * I0h                  # Kt * I0 * max(0.065, cos(zen))
        dhi = ghi - dni * cos_zenith    # no cos(zen) restriction here

        # following SSC code
        dni = np.maximum(dni, 0)
        ghi = np.maximum(ghi, 0)
        dhi = np.maximum(dhi, 0)

        # use DNI and DHI to model GTI
        # GTI-DIRINT uses perez transposition model, but we allow for
        # any model here
        all_irrad = get_total_irradiance(
            surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
            dni, ghi, dhi, dni_extra=I0, airmass=airmass,
            albedo=albedo, model=model, model_perez=model_perez)

        gti_model = all_irrad['poa_global']

        # calculate new diff
        diff = gti_model - poa_global

        # determine if the new diff is smaller in magnitude
        # than the old diff
        diff_abs = diff.abs()
        smallest_diff = diff_abs < best_diff

        # save the best differences
        best_diff = diff_abs.where(smallest_diff, best_diff)

        # on first iteration, the best values are the only values
        if iteration == 0:
            best_ghi = ghi
            best_dni = dni
            best_dhi = dhi
            best_kt_prime = kt_prime
        else:
            # save new DNI, DHI, DHI if they provide the best consistency
            # otherwise use the older values.
            best_ghi = ghi.where(smallest_diff, best_ghi)
            best_dni = dni.where(smallest_diff, best_dni)
            best_dhi = dhi.where(smallest_diff, best_dhi)
            best_kt_prime = kt_prime.where(smallest_diff, best_kt_prime)

        # calculate adjusted inputs for next iteration. Marion eqn 4
        poa_global_i = np.maximum(1.0, poa_global_i - coeff * diff)
    else:
        # we are here because we ran out of coeffs to loop over and
        # therefore we have exceeded max_iterations
        import warnings
        failed_points = best_diff[aoi_lt_90][~best_diff_lte_1_lt_90]
        warnings.warn(
            ('%s points failed to converge after %s iterations. best_diff:\n%s'
             % (len(failed_points), max_iterations, failed_points)),
            RuntimeWarning)

    # return the best data, whether or not the solution converged
    return best_ghi, best_dni, best_dhi, best_kt_prime
193359
def st_atime(self):
        """"""
        atime = self._st_atime_ns / 1e9
        return atime if self.use_float else int(atime)
235807
def actualize(self):
        
        current_time = timeutils.now(timeformat='unix')
        for w in self._weathers:
            if w.get_reference_time(timeformat='unix') < current_time:
                self._weathers.remove(w)
588567
private long winterOnOrBefore(long utcDays) {
        ZonalOffset offset = this.getOffset(utcDays);
        PlainDate date = PlainDate.of(utcDays, EpochDays.UTC);
        int year = (((date.getMonth() <= 11) || (date.getDayOfMonth() <= 15)) ? date.getYear() - 1 : date.getYear());
        Moment winter = AstronomicalSeason.WINTER_SOLSTICE.inYear(year);
        PlainDate d = winter.toZonalTimestamp(offset).getCalendarDate();
        if (d.isAfter(date)) {
            winter = AstronomicalSeason.WINTER_SOLSTICE.inYear(year - 1);
            d = winter.toZonalTimestamp(offset).getCalendarDate();
        }
        return d.getDaysSinceEpochUTC();
    }
1096170
def configuration(t0: date, t1: Optional[date] = None,  
                  steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]:
    
    # Default steps_per_day = 1
    if steps_per_day is None:
        steps_per_day = 1
        
    # Time step dt is 1.0 over steps per day
    dt: float = 1.0 / float(steps_per_day)

    # Default t1 to one day after t0
    if t1 is not None:
        # Convert t to a julian day
        jd0: int = julian_day(t0)
        jd1: int = julian_day(t1)
    else:
        jd0: int = julian_day(t0)
        jd1: int = jd0 + dt

    # Pass the times as an array of julian days
    jd: np.ndarray = np.arange(jd0, jd1, dt)

    # Number of time steps
    N: int = len(jd)
    
    # bodies is a list of the celestial bodies considered; should be in an enclosing scope
    # Number of bodies
    B: int = len(bodies)
    # Number of dimensions
    dims: int = B * 3
    
    # Initialize empty arrays for position q and velocity v
    q: np.ndarray = np.zeros((N, dims))
    v: np.ndarray = np.zeros((N, dims))

    # Position and velocity of the sun as arrays of length 3
    body_ids: List[int] = [jpl_body_id[body] for body in bodies]

    # Fill in the position and velocity for each body in order
    for i, body_id in enumerate(body_ids):
        # The slice of columns for this body (same in q and v)
        slice_i = slice(3*i, 3*(i+1))
        # Extract the position and velocity from jpl
        qi, vi = jpl_kernel[0, body_id].compute_and_differentiate(jd)
        # Convert positions from km to meters (multiply by km2m)
        q[:, slice_i] = qi.T * km2m
        # Convert velocities from km / day to meters / sec (multiply by km2m, divide by day2sec)
        v[:, slice_i] = vi.T * (km2m / day2sec)

    # Return tuple of Tx6 arrays for position q and velocity v
    return q, v
1097444
def _days_to_seconds(cls, val, **kwargs):
        '''
        
        '''
        zero_value = kwargs.get('zero_value', 0)
        if val is not None:
            if val == 0:
                return zero_value
            return val * 86400
        else:
            return 'Not Defined'
19494
def days(self,local=False):
        
        delta = self.delta(local)
        return delta.days
1046047
def hourly_dew_point(self):
        """"""
        dpt_data = self._humidity_condition.hourly_dew_point_values(
            self._dry_bulb_condition)
        return self._get_daily_data_collections(
            temperature.DewPointTemperature(), 'C', dpt_data)
1371816
def estimate_flux(self):
        

        from .epsf import _interpolate_missing_data

        if np.any(self.mask):
            data_interp = _interpolate_missing_data(self.data, method='cubic',
                                                    mask=self.mask)
            data_interp = _interpolate_missing_data(data_interp,
                                                    method='nearest',
                                                    mask=self.mask)
            flux = np.sum(data_interp, dtype=np.float64)

        else:
            flux = np.sum(self.data, dtype=np.float64)

        return flux
169182
def store_serauxtrend(reg_type, poly_order, equation, r_squared)  # :nodoc:
    record     = 0x104B     # Record identifier.
    length     = 0x001C     # Number of bytes to follow.
    # reg_type              # Regression type.
    # poly_order            # Polynomial order.
    # equation              # Display equation.
    # r_squared             # Display R-squared.
    # intercept             # Forced intercept.
    # forecast              # Forecast forward.
    # backcast              # Forecast backward.

    # TODO. When supported, intercept needs to be NAN if not used.
    # Also need to reverse doubles.
    intercept = ['FFFFFFFF0001FFFF'].pack('H*')
    forecast  = ['0000000000000000'].pack('H*')
    backcast  = ['0000000000000000'].pack('H*')

    header = [record, length].pack('vv')
    data  = [reg_type].pack('C')
    data += [poly_order].pack('C')
    data += intercept
    data += [equation].pack('C')
    data += [r_squared].pack('C')
    data += forecast
    data += backcast

    append(header, data)
  end
108560
def configuration_ES(t0: date, t1: Optional[date] = None, 
                     steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]:
    
    # Default steps_per_day = 1
    if steps_per_day is None:
        steps_per_day = 1
        
    # Time step dt is 1.0 over steps per day
    dt: float = 1.0 / float(steps_per_day)

    # Default t1 to one day after t0
    if t1 is not None:
        # Convert t to a julian day
        jd0: int = julian_day(t0)
        jd1: int = julian_day(t1)
    else:
        jd0: int = julian_day(t0)
        jd1: int = jd0 + dt
    # Pass the times as an array of julian days
    jd: np.ndarray = np.arange(jd0, jd1, dt)

    # Position and velocity of the sun as arrays of length 3
    sun_id: int = jpl_body_id['sun']
    pos_sun, vel_sun = jpl_kernel[0, sun_id].compute_and_differentiate(jd)

    # Position and velocity of the earth as arrays of length 3
    earth_id: int = jpl_body_id['earth']
    pos_earth, vel_earth = jpl_kernel[0, earth_id].compute_and_differentiate(jd)

    # Convert positions from km to meters (multiply by km2m)
    q = np.vstack([pos_sun, pos_earth]).T * km2m
    # Convert velocities from km / day to meters / sec (multiply by km2m, divide by day2sec)
    v = np.vstack([vel_sun, vel_earth]).T * (km2m / day2sec)

    # Return tuple of Tx6 arrays for position q and velocity v
    return q, v
563224
def rhochange(self):
        """"""

        self.lu, self.piv = sl.cho_factor(self.D, self.rho)
        self.lu = np.asarray(self.lu, dtype=self.dtype)
877820
private static BigDecimal daysPlusSeconds(BigInteger days, BigDecimal seconds) {
    return seconds.add(new BigDecimal(days.multiply(BigInteger.valueOf(24*60*60))));
  }
1338654
def dst(self, dt):
        """"""
        tt = _localtime(_mktime((dt.year, dt.month, dt.day,
                 dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
        if tt.tm_isdst > 0: return _dstdiff
        return _zero
1176200
def _temp_dew_dirint(temp_dew, times):
    
    if temp_dew is not None:
        # Perez eqn 4
        w = pd.Series(np.exp(0.07 * temp_dew - 0.075), index=times)
    else:
        # do not change unless also modifying _dirint_bins
        w = pd.Series(-1, index=times)
    return w
837273
def dayOfWeek(year, month, day):
    ""
    hr = 12  #make sure you fall into right day, middle is save
    t = time.mktime((year, month, day, hr, 0, 0.0, 0, 0, -1))
    pyDow = time.localtime(t)[6]
    gpsDow = (pyDow + 1) % 7
    return gpsDow