Tuesday, December 19, 2017

Python version problems.



Python version problems

Different versions of Python have enough differences to be troublesome.

Version 2.7.4 calculations use implicit integer types where version 3.6.0 uses implicit float types.
The following examples illustrate the problem:
V2: 7/5=1; -7/5= -2
V3: 7/5=1.4;-7/5= -1.4
Adding a decimal to numbers in V2 converts them to floats:
V2: 7.0/5=1.4
A manual conversion also works:
V2 float(7)/5=1.4

The problem, for me, is version 2.7.4 has the ephemeris module installed. In the computer’s Raspbian operating system, version 2.4 is installed and installing version 3.6 has to be without modules. Hence, the ephemeris module will be absent with 3.6.0. Again, the problem? Different scripts are written with different versions of Python. One or two large sophisticated programs require simultaneous versions of Python.
I decided to use my translation of an Excel spreadsheet instead of the ephemeris. Only version 3.6.0 is required and is summoned with:
“python3.6 NOAA.py”
My calculations of solar incident and solar module irradiation are compatible with version 3.6.0.



Wednesday, December 13, 2017

An instance of translation from Excel to Python.

This is an instance of the translation of an Excel spreadsheet formula into the Python equivalent.


EXCEL:
#AH2=Sun Azimuth degrees clockwise from North
=IF(AC2>0,MOD(DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2)))))+180,360),MOD(540-DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2))))),360))



PYTHON:
#AH2=Sun Azimuth degrees clockwise from North
AH2a1=math.acos(((math.sin((B3/r)) * math.cos((AD2/r))) - math.sin((T2/r))) / ((math.cos((B3/r)) * math.sin(AD2/r))))*r + 180
AH2b1=360
AH2a2=540-math.acos(((math.sin(B3/r)*math.cos(AD2/r))-math.sin(T2/r))/((math.cos(B3/r)*math.sin(AD2/r))))*r
AH2b2=AH2b1
if AC2 > 0 : AH2=AH2a1-int(AH2a1/AH2b1)*AH2b1
else : AH2=AH2a2-int(AH2a2/AH2b2)*AH2b2

Tuesday, December 12, 2017

NOAA equations for solar data (sunrise, sunset, elevation, azimuth, Julian Day, Equation of Time, etc..



   In a recent post I presented the equation for energy incident on a solar panel (Sm).
Here I present the set of equations used to calculate sunrise, sunset, and solar elevation and azimuth.

=============================================================

#This particular set was extracted from an Excel spreadsheet made available by NOAA.

#360 deg/2*pi=57.29578
#if in radians, do sin(x/r) to get degrees
#sin(45d)=.7071
#sin(45r)=0.8509

LT: Local Tiime
UT:Universal Time
TZ:Time Zone
LT=UT+TZ

JDg1=367*Y-int(7*(Y+int((M+9)/12))/4)-int(3*(int((Y+(M-9)/7)/100)+1)/4)+int(275*M/9)+D+1721028.5+UT/24
JDg2=367*Y-int(7*(Y+int((M+9)/12))/4)+int(275*M/9)+D+1721013.5+UT/24

#For the Day:
#B3=Latitude, + to N
#B4=Longitude + to E
#B5=Time Zone + to E    ( calculations use TZ)
#B7=Date
#H=Blank
#--------------------------

#D2=date
=date, mm/dd/yyyy , Calculations use JD

#E2=T past local midnight (used in TST and Elev refraction calc)
#sum of 0.1/24 from midnight to current with .1/24 increments (fraction of the day in tenths of an hour ; 6 min = 0.0041666 day)
=LT/24
# In the JD, the previous day +.5 is midnight since the calendar sarts at noon.
#F2=Julian Day
=D2+2415018.5+E2-TimeZone(TZ)/24
JDg2=D2+2415018.5+E2-TimeZone(TZ)/24


#G=Julian , used in other functions, translated into radians. Functions that make up S and T use G (P,R,Q).
=(F2-2451545)/36525

#H=Blank

#I=Geom Mean Long Sun
=MOD(280.46646+G2*(36000.76983+G2*0.0003032),360)
#mod()=a-int(a/b)*b

#J=Geometric Mean Anomaly of the Sun
=357.52911+G2*(35999.05029-0.0001537*G2)

#K=Eccentricity of Earth orbit
=0.016708634-G2*(0.000042037+0.0000001267*G2)

#L=Sun Eq of Ctr
=SIN(RADIANS(J2))*(1.914602-G2*(0.004817+0.000014*G2))+SIN(RADIANS(2*J2))*(0.019993-0.000101*G2)+SIN(RADIANS(3*J2))*0.000289

#M=Sun True Long degrees
=I2+L2

#N=Sun True Anomaly degrees
=J2+L2

#O=Sun Radius Vector, A.U.
=(1.000001018*(1-K2*K2))/(1+K2*COS(RADIANS(N2)))

#P=Sun Apparent Long
=M2-0.00569-0.00478*SIN(RADIANS(125.04-1934.136*G2))

#Q=Mean Oblique Ecliptic degrees
=23+(26+((21.448-G2*(46.815+G2*(0.00059-G2*0.001813))))/60)/60

#R=Oblique Correction factor
=Q2+0.00256*COS(RADIANS(125.04-1934.136*G2))

#S=Right Ascension degrees
=DEGREES(ATAN2(COS(RADIANS(P2)),COS(RADIANS(R2))*SIN(RADIANS(P2))))

#T=Declination in degrees
=DEGREES(ASIN(SIN(RADIANS(R2))*SIN(RADIANS(P2))))

#U=var y
=TAN(RADIANS(R2/2))*TAN(RADIANS(R2/2))

#V=EoT minutes
=4*DEGREES(U2*SIN(2*RADIANS(I2))-2*K2*SIN(RADIANS(J2))+4*K2*U2*SIN(RADIANS(J2))*COS(2*RADIANS(I2))-0.5*U2*U2*SIN(4*RADIANS(I2))-1.25*K2*K2*SIN(2*RADIANS(J2)))

#W=HA Sunrise degrees
=DEGREES(ACOS(COS(RADIANS(90.833))/(COS(RADIANS(Lat))*COS(RADIANS(T2)))-TAN(RADIANS(Lat))*TAN(RADIANS(T2))))

#X=Sun noon LST
=(720-4*Lon-V2+TZ*60)/1440

#Y=Sunrise time
#Y=Sunrise time
Y2=X-W*4/1440
#Z=Sunset time
Z2=X+W*4/1440

#AA2=Sunlight duration
=8*W2

#AB2=TST
=MOD(E2*1440+V2+4*Lon-60*TZ,1440)

#AC2=Hour Angle
=IF(AB2/4<0,AB2/4+180,AB2/4-180)

#AD2=Zenith
=DEGREES(ACOS(SIN(RADIANS(Lat))*SIN(RADIANS(T2))+COS(RADIANS(Lat))*COS(RADIANS(T2))*COS(RADIANS(AC2))))

#AE2= Sun elevation in degrees
90-AD2

#AF2=Atmospheric refraction un degrees
=IF(AE2>85,0,IF(AE2>5,58.1/TAN(RADIANS(AE2))-0.07/POWER(TAN(RADIANS(AE2)),3)+0.000086/POWER(TAN(RADIANS(AE2)),5),IF(AE2>-0.575,1735+AE2*(-518.2+AE2*(103.4+AE2*(-12.79+AE2*0.711))),-20.772/TAN(RADIANS(AE2)))))/3600

#AG2=Sun Elevation corrected for refraction
=AE2+AF2

#AH2=Sun Azimuth degrees clockwise from North
=IF(AC2>0,MOD(DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2)))))+180,360),MOD(540-DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2))))),360))









=====================================================================





Friday, December 1, 2017

Linear actuator installed. Possible changes.



   I've been building my power station with n eye to minimizing the cost without sacrificing quality.
I've mounted the array on a one inch steel pipe leaning against an  aluminum ladder. The ladder was damaged beyond intended use, so I've re-purposed the ladder, for the time being, as a support frame for the array. I drilled holes to mount a piece of wood to strengthen the weak area. I also drilled holes to attach the linear actuator. I've mounted the linear actuator in the first trial position. The actuator is a heavy duty, hazardous environment, model suitable for outdoors, all season use. The unit can push or pull 10 kN, or 10000 N. That is equivalent to 2,200 pounds, or, a little over one ton (2000 lbs). The unit is working with a small load which will drain little power from the battery bank, even on a cloudy day.
   I will be able to program the tracking to follow the sun using calculations, mm/rpm specs from the manufacturer, and a solar detector composed of four small solar cells attached to the array. If the day is cloudy, the sensor will respond with characteristic data that can be responded to in program.
   The motor power wiring has to be run from the indoor station to the unit unless the control computer is mounted near the array in a weather proof box.
   The idea of moving the entire station out to the array is appealing. The problem I have is the battery bank. What is the effect of low temperatures on flooded lead-acid batteries? My first thought is to build an enclosure big enough to insulate. The minicomputer I'm using was not necessarily designed for harsh environments, though electronic circuitry tends to be very hardy. There is a more utilitarian version of the computer that may be a better choice. I may place the mini computer and charge controller at the array and keep the battery bank and inverter indoors. That makes powering the mini computer an issue. The unit is currently powered by the battery bank. Running DC power lines to the array for the unit seems impractical. A smaller battery dedicated to the mini computer would be a better choice. In fact, I have a left over charge controller and inverter that could supply the unit. A small solar panel could be added to the array specifically for the computer. The mini computer, RPi, typically uses onlly 5 watts of power and that makes powering the unit inexpensive and simple.
   The charge controller is a Zantrex 60A PWM model. The inverter is a 300 watt pure sine wave type. Add a small battery and a solar panel and the parts list is complete.
   The second power supply will, like the RPi, need to be enclosed in a weatherproof container.
   The mini computer is a Raspberry Pi 3B with USB ports, WiFi, and GPIO ports. Software installed includes the Apache web server, PHP, Python, an RTL hardware clock driver, a USB driver for the charge controller, WiFi access point software, and a small 16Gb SD card and reader.