Skip to content

incorrect horizon test in tracker.singleaxis #569

Description

@cwhanse

Describe the bug
wid[zp <= 0] = np.nan sets the tracker rotation angle to np.nan when the sun is behind the array plane, but the array plane is not yet defined. At this line, the array plane is defined only by the tracker tilt and azimuth, but not its rotation.

To Reproduce

import pvlib
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

loc = pvlib.location.Location(latitude=30, longitude=110)
sat = pvlib.tracking.SingleAxisTracker(axis_tilt=90, axis_azimuth=180, backtrack=False, max_angle=180)
sat.localize(location=loc)

solar_azimuth = pd.Series(data=np.arange(0.0, 359.0))
solar_zenith = 45.0 * solar_azimuth / solar_azimuth

df = sat.singleaxis(apparent_zenith=solar_zenith, apparent_azimuth=solar_azimuth)

p1 = plt.plot(df)
plt.legend(df.columns)

The plot shows that the tracker rotation tracker_theta is limited to between -90 and 90.

Expected behavior
In the above example, the sun rotates in azimuth at 45 zenith. The vertical tracker without rotation limit should follow the sun around the complete circle.

Screenshots
test_sat

Versions:

  • pvlib.__version__: 0.5.2

Additional context

One fix would be to substitute a test for solar zenith, so that the tracker rotation is not set when the sun is below the visible horizon. I also wonder if we should set the rotation to 0 (stow position) instead of np.nan in this case.

wid[z <= 0] = np.nan
wid[z <= 0] = 0.0

Activity

  1. wholmgren commented on Sep 10, 2018

    @wholmgren
    Member

    Other than 0 vs. nan, I believe this follows pvl_singleaxis.m lines 167-171:

    % filter for sun above panel horizon)
    u = zp>0;
    
    % apply limits to ideal rotation angle
    wid(~u) = 0;  % set horizontal if zenith<0, sun is below panel horizon

    Or did I mix things up when implementing singleaxis?

    On 0 vs. nan, I believe my thinking at the time was that it might not be safe to always assume a 0 stow position and in any case a user could always replace the nan with 0s if they cared. I'm generally ok with changing it, though.

  2. cwhanse commented on Sep 10, 2018

    @cwhanse
    MemberAuthor

    The Matlab function has the same error.

  3. wholmgren commented on Sep 10, 2018

    @wholmgren
    Member

    Ok, so singleaxis lines 413-414

        # filter for sun above panel horizon
        wid[zp <= 0] = np.nan

    become

        # filter for sun above horizon
        wid[apparent_zenith >= 90] = np.nan  # or 0 if you prefer

    Sounds good to me.

    Would be best to add a new test that uses the same input data as above but with the singleaxis function rather than the object method.

  4. added this to the 0.6.0 milestone on Sep 10, 2018
  5. wholmgren commented on Sep 11, 2018

    @wholmgren
    Member

    @cwhanse I can do this this afternoon if you're not already on it. Would like to finish off 0.6.0...

  6. cwhanse commented on Sep 11, 2018

    @cwhanse
    MemberAuthor
  7. adriesse commented on Sep 12, 2018

    @adriesse
    Member

    On the topic of "zero vs nan": I wonder whether we could maintain a master list somewhere describing all the cases where a value is special, such as being out of range or non-physical, and how it is encoded, such as zero, nan, -99.99, 7999, or whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions