How to use the pvlib.solarposition.get_solarposition function in pvlib

To help you get started, we’ve selected a few pvlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pvlib / pvlib-python / pvlib / modelchain.py View on Github external
elif orientation_strategy is not None:
        surface_tilt, surface_azimuth = \
            get_orientation(orientation_strategy, latitude=latitude)
    else:
        raise ValueError('orientation_strategy or surface_tilt and '
                         'surface_azimuth must be provided')

    if altitude is None and pressure is None:
        altitude = 0.
        pressure = 101325.
    elif altitude is None:
        altitude = atmosphere.pres2alt(pressure)
    elif pressure is None:
        pressure = atmosphere.alt2pres(altitude)

    solar_position = solarposition.get_solarposition(
        times, latitude, longitude, altitude=altitude, pressure=pressure,
        method=solar_position_method, **kwargs)

    # possible error with using apparent zenith with some models
    airmass = atmosphere.get_relative_airmass(
        solar_position['apparent_zenith'], model=airmass_model)
    airmass = atmosphere.get_absolute_airmass(airmass, pressure)
    dni_extra = pvlib.irradiance.get_extra_radiation(solar_position.index)

    aoi = pvlib.irradiance.aoi(surface_tilt, surface_azimuth,
                               solar_position['apparent_zenith'],
                               solar_position['azimuth'])

    if irradiance is None:
        linke_turbidity = clearsky.lookup_linke_turbidity(
            solar_position.index, latitude, longitude)
github sandialabs / pecos / examples / pv / pv_model.py View on Github external
quality control test before running the model (using pm.cleaned_data). Check range 
    on DC power relative error and normalized efficiency. Compute PV metrics.  
    """
    index = pm.cleaned_data.index
    
    # Extract data into Pandas series
    dcpower = pm.cleaned_data[pm.trans['DC Power']].sum(axis=1)
    acpower = pm.cleaned_data[pm.trans['AC Power']].sum(axis=1)
    wind = pm.cleaned_data[pm.trans['Wind Speed']].squeeze()
    temperature = pm.cleaned_data[pm.trans['Ambient Temperature']].squeeze()
    poa = pm.cleaned_data[pm.trans['POA']].squeeze()
    poa_diffuse = pd.Series(data=0, index=index)
    dni = pm.cleaned_data[pm.trans['DNI']].squeeze()
    
    # Compute sun position
    solarposition = pvlib.solarposition.get_solarposition(index, location['Latitude'], 
                                                  location['Longitude'])
    
    # Compute cell temperature
    celltemp = pvlib.pvsystem.sapm_celltemp(poa, wind, temperature)

    # Compute absolute airmass
    airmass_relative  = pvlib.atmosphere.get_relative_airmass(solarposition['zenith'])
    airmass_absolute = pvlib.atmosphere.get_absolute_airmass(airmass_relative)
    
    # Compute aoi
    aoi = pvlib.irradiance.aoi(location['Latitude'], 180, solarposition['zenith'], 
                               solarposition['azimuth'])
    
    # Compute effective irradiance
    Ee = pvlib.pvsystem.sapm_effective_irradiance(poa, poa_diffuse, airmass_absolute, 
                                                  aoi, sapm_parameters)
github oemof / feedinlib / feedinlib / models.py View on Github external
References
        ----------
        .. [2] `pvlib solarposition `_.

        See Also
        --------
        solarposition : calculates the position of the sun at a given time
        """
        data_5min = pd.DataFrame(
            index=pd.date_range(data.index[0],
                                periods=data.shape[0]*12, freq='5Min',
                                tz=kwargs['weather'].timezone))

        data_5min = pvlib.solarposition.get_solarposition(
            time=data_5min.index, latitude=location.latitude,
            longitude=location.longitude, method='ephemeris')

        return pd.concat(
            [data, data_5min.clip_lower(0).resample('H').mean()],
            axis=1, join='inner')