Exemple #1
0
def test_gh865_read_tmy3_feb_leapyear_hr24():
    """correctly parse the 24th hour if the tmy3 file has a leap year in feb"""
    data, meta = read_tmy3(TMY3_FEB_LEAPYEAR)
    # just to be safe, make sure this _IS_ the Greensboro file
    greensboro = {
        'USAF': 723170,
        'Name': '"GREENSBORO PIEDMONT TRIAD INT"',
        'State': 'NC',
        'TZ': -5.0,
        'latitude': 36.1,
        'longitude': -79.95,
        'altitude': 273.0}
    assert meta == greensboro
    # February for Greensboro is 1996, a leap year, so check to make sure there
    # aren't any rows in the output that contain Feb 29th
    assert data.index[1414] == pd.Timestamp('1996-02-28 23:00:00-0500')
    assert data.index[1415] == pd.Timestamp('1996-03-01 00:00:00-0500')
    # now check if it parses correctly when we try to coerce the year
    data, _ = read_tmy3(TMY3_FEB_LEAPYEAR, coerce_year=1990)
    # if get's here w/o an error, then gh865 is fixed, but let's check anyway
    assert all(data.index.year == 1990)
    # let's do a quick sanity check, are the indices monotonically increasing?
    assert all(np.diff(data.index[:-1].astype(int)) == 3600000000000)
    # according to the TMY3 manual, each record corresponds to the previous
    # hour so check that the 1st hour is 1AM and the last hour is midnite
    assert data.index[0].hour == 1
    assert data.index[-1].hour == 0
Exemple #2
0
def test_from_tmy_3():
    from test_tmy import tmy3_testfile
    from pvlib.iotools import read_tmy3
    data, meta = read_tmy3(tmy3_testfile)
    loc = Location.from_tmy(meta, data)
    assert loc.name is not None
    assert loc.altitude != 0
    assert loc.tz != 'UTC'
    assert_frame_equal(loc.tmy_data, data)
Exemple #3
0
def test_from_tmy_3():
    from test_tmy import TMY3_TESTFILE
    from pvlib.iotools import read_tmy3
    data, meta = read_tmy3(TMY3_TESTFILE)
    loc = Location.from_tmy(meta, data)
    assert loc.name is not None
    assert loc.altitude != 0
    assert loc.tz != 'UTC'
    assert_frame_equal(loc.weather, data)
def test_from_tmy_3():
    from test_tmy import tmy3_testfile
    from pvlib.iotools import read_tmy3
    data, meta = read_tmy3(tmy3_testfile)
    loc = Location.from_tmy(meta, data)
    assert loc.name is not None
    assert loc.altitude != 0
    assert loc.tz != 'UTC'
    assert_frame_equal(loc.tmy_data, data)
Exemple #5
0
    def _activate(self, system: System, **kwargs) -> None:
        from pvlib.iotools import read_tmy2, read_tmy3

        dir = os.path.dirname(self.file)
        if not os.path.isdir(dir):
            os.makedirs(dir, exist_ok=True)

        if self.version == 3:
            self.data, self.meta = read_tmy3(filename=self.file,
                                             coerce_year=self.year)

        elif self.version == 2:
            self.data, self.meta = read_tmy2(self.file)
        else:
            raise ValueError('Invalid TMY version: {}'.format(self.version))
Exemple #6
0
def greensboro_rain():
    # get TMY3 data with rain
    greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990)
    return greensboro.Lprecipdepth
def greensboro_rain():
    # get TMY3 data with rain
    greensboro = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990)
    # NOTE: can't use Sand Point, AK b/c Lprecipdepth is -9900, ie: missing
    return greensboro[0].Lprecipdepth
Exemple #8
0
# manual cleaning.
#
# Threshold
# ---------
# The example shown here demonstrates how the threshold affects soiling.
# Because soiling depends on rainfall, loading weather data is always the first
# step.

from datetime import datetime
from matplotlib import pyplot as plt
from pvlib.iotools import read_tmy3
from pvlib.losses import soiling_kimber
from pvlib.tests.conftest import DATA_DIR

# get TMY3 data with rain
greensboro = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990)
# NOTE: can't use Sand Point, AK b/c Lprecipdepth is -9900, ie: missing
greensboro_rain = greensboro[0].Lprecipdepth
# calculate soiling with no wash dates
THRESHOLD = 25.0
soiling_no_wash = soiling_kimber(greensboro_rain,
                                 cleaning_threshold=THRESHOLD,
                                 istmy=True)
soiling_no_wash.name = 'soiling'
# daily rain totals
daily_rain = greensboro_rain.iloc[:-1].resample('D').sum()
plt.plot(daily_rain.index.to_pydatetime(), daily_rain.values / 25.4,
         soiling_no_wash.index.to_pydatetime(), soiling_no_wash.values * 100.0)
plt.hlines(THRESHOLD / 25.4,
           xmin=datetime(1990, 1, 1),
           xmax=datetime(1990, 12, 31),
# seasonal irradiance collection.

import pvlib
from pvlib import location
from pvlib import irradiance
from pvlib import tracking
from pvlib.iotools import read_tmy3
import pandas as pd
from matplotlib import pyplot as plt
import pathlib

# get full path to the data directory
DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data'

# get TMY3 dataset
tmy, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990)
# TMY3 datasets are right-labeled (AKA "end of interval") which means the last
# interval of Dec 31, 23:00 to Jan 1 00:00 is labeled Jan 1 00:00. When rolling
# up hourly irradiance to monthly insolation, a spurious January value is
# calculated from that last row, so we'll just go ahead and drop it here:
tmy = tmy.iloc[:-1, :]

# create location object to store lat, lon, timezone
location = location.Location.from_tmy(metadata)

# calculate the necessary variables to do transposition.  Note that solar
# position doesn't depend on array orientation, so we just calculate it once.
# Note also that TMY datasets are right-labeled hourly intervals, e.g. the
# 10AM to 11AM interval is labeled 11.  We should calculate solar position in
# the middle of the interval (10:30), so we subtract 30 minutes:
times = tmy.index - pd.Timedelta('30min')