pvlib : time convention issue with cumulated GHI - pvlib

I have a question regarding time conventions in pvlib.
As far as I understand, all the computations are made using instantaneous timestep convention. Instant weather will produce instant electric power.
However, in the weather models like GFS, GHI parameter is cumulated over the last hour. This makes inconsitant the solar radiation and astronomical parameters (zenith, azimuth...).
For example, if I take a look at the ERBS function, used to compute DHI and DHI from GHI :
df_dni_dhi_kt = pvlib.irradiance.erbs(ghi, zenith, ghi.index)
Here, all parameters are hourly timeseries, but the because of the convention, the output may be inaccurate.
ghi : cumulated radiation over last hour
zenith : zenith angle at exact hour (instantaneous)
ghi.index : hourly DateTimeIndex
At the end of the power conversion process, a shift is observed between observations and model (please don't care about the amplitude difference, only time shift matters).
Any idea about using cumulated GHI as input of the library ?

When using hourly data there definitely is a dilemma in how to calculate the solar position. The most common method is to calculate the solar position for the middle of the time step. This is definitely an improvement to using either the start or end of the hour (as shown in your example). However, around sunset and sunrise this poses an issue, as the sun may be below the horizon at the middle of the hour. Thus some calculate the sun position for the middle where the period is defined as the part of the hour where the sun is above the horizon - but that adds complexity.
There's a good discussion on the topic here: https://pvlib-python.readthedocs.io/en/stable/gallery/irradiance-transposition/plot_interval_transposition_error.html

Related

Calculating Time of Use value for solar panels?

I am trying to apply Time of Use metering rates to calculate the dollar value of the energy produced by a solar panel array. (San Diego Gas and Electric's EV-TOU-5 rate, in particular). The value changes according to the time of day, day of week, and holidays during the year. This will be part of a larger model that factors in savings from EV charging at off-peak rates after midnight, etc. So just displaying kwh/month misses the full picture, which I'm trying to model.
Rather than jump into coding this from scratch with PVLIB, I would appreciate any pointers to existing software.

Calculating deceleration and acceleration in and out of a hard acute/obtuse change of direction

I have an animated athlete (football player) running at an average speed (calculated by 40 yard dash time) that is asked to change direction at ANY acute or obtuse angle. What is the formula(s) that would calculate deceleration/acceleration in/out of the "hard" change of direction? For example; How would I calculate the rate of deceleration into a 90 degree turn right after sprinting 15 yards (assuming 4.6 seconds in a 40 yard dahs) and acceleration afterwards back to full speed?
I guess I'm looking for some sort of algorithm or function that would help me calculate change of direction ability. This only having 40 yard dash time, along with Height and Weight of the athlete. I also have times related to change of direction drills, but difficult to equate simple route turns with multiple change of direction drills.
Ultimately I want to create a character that doesn't look like its running at full speed throughout the route, but must account for slow down and speed up with a change of direction. The best athletes can do this rather quickly and without much effort.
My apologies if I've tagged this incorrectly.

Estimate diffuse and direct component from global irradiance

I am looking to separate the diffuse and direct component of global irradiance and found the Erbs model to do this in pvlib (see pvlib.irradiance.erbs) however, I am getting very strange results. I would expect the Direct Normal Irradiance (DNI) to be lower than the Global Horizontal Irradiance (GHI); or am I missing something? Values of GHI are not above 800 W m^2 for these days.
EDIT: As per Cliff H advice, I have limited the solar zenith to less than 85 arc degrees; the results have improved however, there are large spikes in DNI values that do not appear very reasonable, e.g. start of 07-16.
DNI > GHI is common at low solar elevation. GHI decreases much faster than DNI as solar elevation decreases. For example, think of a clear day with the sun right near the horizon. DNI will large because it's measured on a plane normal to the sun vector, but GHI will be near zero.
The values of DNI that are much greater than 1000 W/m2 are likely at very high zenith, since the Erbs model basically divides by cos(zenith). In practice, I limit using decomposition models like Erbs to zenith<85 degrees, to avoid the non-physical results.

How to exploit periodicity to reduce noise of a signal?

100 periods have been collected from a 3 dimensional periodic signal. The wavelength slightly varies. The noise of the wavelength follows Gaussian distribution with zero mean. A good estimate of the wavelength is known, that is not an issue here. The noise of the amplitude may not be Gaussian and may be contaminated with outliers.
How can I compute a single period that approximates 'best' all of the collected 100 periods?
Time-series, ARMA, ARIMA, Kalman Filter, autoregression and autocorrelation seem to be keywords here.
UPDATE 1: I have no idea how time-series models work. Are they prepared for varying wavelengths? Can they handle non-smooth true signals? If a time-series model is fitted, can I compute a 'best estimate' for a single period? How?
UPDATE 2: A related question is this. Speed is not an issue in my case. Processing is done off-line, after all periods have been collected.
Origin of the problem: I am measuring acceleration during human steps at 200 Hz. After that I am trying to double integrate the data to get the vertical displacement of the center of gravity. Of course the noise introduces a HUGE error when you integrate twice. I would like to exploit periodicity to reduce this noise. Here is a crude graph of the actual data (y: acceleration in g, x: time in second) of 6 steps corresponding to 3 periods (1 left and 1 right step is a period):
My interest is now purely theoretical, as http://jap.physiology.org/content/39/1/174.abstract gives a pretty good recipe what to do.
We have used wavelets for noise suppression with similar signal measured from cows during walking.
I'm don't think the noise is so much of a problem here and the biggest peaks represent actual changes in the acceleration during walking.
I suppose that the angle of the leg and thus accelerometer changes during your experiment and you need to account for that in order to calculate the distance i.e you need to know what is the orientation of the accelerometer in each time step. See e.g this technical note for one to account for angle.
If you need get accurate measures of the position the best solution would be to get an accelerometer with a magnetometer, which also measures orientation. Something like this should work: http://www.sparkfun.com/products/10321.
EDIT: I have looked into this a bit more in the last few days because a similar project is in my to do list as well... We have not used gyros in the past, but we are doing so in the next project.
The inaccuracy in the positioning doesn't come from the white noise, but from the inaccuracy and drift of the gyro. And the error then accumulates very quickly due to the double integration. Intersense has a product called Navshoe, that addresses this problem by zeroing the error after each step (see this paper). And this is a good introduction to inertial navigation.
Periodic signal without noise has the following property:
f(a) = f(a+k), where k is the wavelength.
Next bit of information that is needed is that your signal is composed of separate samples. Every bit of information you've collected are based on samples, which are values of f() function. From 100 samples, you can get the mean value:
1/n * sum(s_i), where i is in range [0..n-1] and n = 100.
This needs to be done for every dimension of your data. If you use 3d data, it will be applied 3 times. Result would be (x,y,z) points. You can find value of s_i from the periodic signal equation simply by doing
s_i(a).x = f(a+k*i).x
s_i(a).y = f(a+k*i).y
s_i(a).z = f(a+k*i).z
If the wavelength is not accurate, this will give you additional source of error or you'll need to adjust it to match the real wavelength of each period. Since
k*i = k+k+...+k
if the wavelength varies, you'll need to use
k_1+k_2+k_3+...+k_i
instead of k*i.
Unfortunately with errors in wavelength, there will be big problems keeping this k_1..k_i chain in sync with the actual data. You'd actually need to know how to regognize the starting position of each period from your actual data. Possibly need to mark them by hand.
Now, all the mean values you calculated would be functions like this:
m(a) :: R->(x,y,z)
Now this is a curve in 3d space. More complex error models will be left as an excersize for the reader.
If you have a copy of Curve Fitting Toolbox, localized regression might be a good choice.
Curve Fitting Toolbox supports both lowess and loess localized regression models for curve and curve fitting.
There is an option for robust localized regression
The following blog post shows how to use cross validation to estimate an optimzal spaning parameter for a localized regression model, as well as techniques to estimate confidence intervals using a bootstrap.
http://blogs.mathworks.com/loren/2011/01/13/data-driven-fitting/

how can i perform discrete integration of gyroscope data?

gyroscopes which measure rate of rotation of angles when integrated produce angles right?
my question is how do i do this? what im doing so far is just adding all the angles ive detected and that seems to be very wrong
AngleIntegrated = GyroDegPersec * (1/GyroBandWidth);
suggestions are very welcome. thanks
You need to integrate with respect to time. So ideally you should sample the gyroscope at regular (fixed) time intervals, T, and then incorporate that sampling interval, T, into your integral calculation.
Note that T needs to be small enough to satisfy the Nyquist criterion.
You can integrate in discrete domain. Suppose the angular rate is da, it's time integral is a.
k is the discrete step number.
a(k) = a(k-1) + T*0.5*(da(k) + da(k-1))
For example, da(k) is current angular rate reading. da(k-1) is previoud angular rate reading. a(k-1) is the previous step's integration value(rotation angle). T is sampling rate. If the sensor outputs in every 1 millisecond, T becomes 0.001.
You can use this formula when k>0. The initial value, a(0), must be given.
Knowing that of course you can't count on having a correct value in the long run (by integration your error window will always increase over time) what I would do is reading the gyroscope, interpolating the current read and previous few ones to get a smooth curve (e.g. a parabola using current read and previous two) and then computing the integral of that parabola from last read time and current time.