Skip to content

solarposition. correctness of calculations #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stepanenkopaul opened this issue Apr 22, 2018 · 1 comment
Closed

solarposition. correctness of calculations #452

stepanenkopaul opened this issue Apr 22, 2018 · 1 comment

Comments

@stepanenkopaul
Copy link

stepanenkopaul commented Apr 22, 2018

I would like to clarify how correct my calculations are and whether I used the function correctly to calculate the zenith of the sun?

import pvlib
import pandas
import calendar
import re

f = open('_dni.txt','w')

#set year
y=2017

doy = 0#day of year counter

for m in range(1,2):
dc=calendar.monthrange(y,m)[1]

for d in range(1,dc+1):
   doy=doy+1 
   for h in range(0,24):
       s_time='{0}-{1}-{2} {3}:00'.format(y,m,d,h)
       time = pandas.Timestamp(s_time,tz='America/Phoenix')
  
       zenith=pvlib.solarposition.get_solarposition(time=time,
                                                 latitude=33.4333,
                                                 longitude=-112.017,
                                                 altitue=None,
                                                 pressure=None,
                                                 method='nrel_numpy',
                                                 temperature=12)
       
       f_zenith=float(zenith.zenith)

       print(s_time+"\t"+str(f_zenith)+"\n")
 

       f.write(s_time+"\t"+str(f_zenith)+"\n")

f.close()

As the source data (coordinates, time zone and GHI), I use the model data of the SAM application (System Advisor Model).

But when I try to calc DNI and DHI via pvlib, my findings are completely different from those of the model.

For example, in the model on the first day of the year at 10 o'clock, the values of GHI, DNI, DHI are as follows:
GHI: 457
DNI: 901
DHI: 53

The calculated zenith angle is equal to 66.9732005775

I try to calculate the DNI and GHI as follows:
#---------------------

#day of year
doy=1
i_ghi=457
f_zenith=66.9732005775

f_dni=pvlib.irradiance.erbs(i_ghi,f_zenith,doy)["dni"]
f_dhi=pvlib.irradiance.erbs(i_ghi,f_zenith,doy)["dhi"]

#---------------------

The values of DNI and GHI are as follows:
DNI: 975.5429981466746
GHI: 75.405

These values are far from the values of model.
How much do I correctly calculate?

@cwhanse
Copy link
Member

cwhanse commented Apr 23, 2018

It appears that you are comparing the output of a model (Erbs) to TMY values. I would not expect the Erbs output to be the same as the TMY values. Erbs operates on GHI to estimate DNI and DHI: Erbs(GHI = 475) gives the values you posted. The TMY values are hourly averages mostly likely from a different model. I don't know why the TMY2 values for AZ/Phoenix don't 'close' : GHI = 457 <> DNI * cosd(69) + DHI. But that's a problem with TMY2, not with pvlib or the way you are using it.

Happy to help. For the future, we prefer that user help questions go to the google group

https://groups.google.com/forum/#!forum/pvlib-python

rather than GitHub, which is meant for code development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants