Script for predictive solar output

had some time today --for shading add this to panelconf –


LAT=xxxxx        #your latitude and longitude 
LON=xxxxx 

altitude=$(python3 -W ignore altitude.py -lon $LON -lat $LAT -t $2)
#altitude=$( printf "%.0f" $altitude)
#echo $altitude

####SHADING####################
SHADING1=1 #
SHADING2=1 #
SHADING3=1 #
###group1#####
UPPER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)    ### 1/2 hr blocks  3,2,1 depicts noon location
LOWER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
PERCENT=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#####PROCESS######
upper=$(echo ${UPPER[$1]}  )

lower=$(echo ${LOWER[$1]}  )
if (( $upper != 0 )); then
percent=$(echo ${PERCENT[$1]}  )

percent=$(echo "($percent) / 100"| bc -l)

x=$(echo " $upper - $lower "| bc -l)

y=$(echo "$upper - $altitude"| bc -l)

FACTOR=$(echo "(($y/$x))"| bc -l)

SHADING1=$(echo "(1-($FACTOR*$percent))"| bc -l)

FACTOR=$(echo "scale=0; $FACTOR*100 /1" |bc)  # scaling  to remove decimal and float

if ((  $FACTOR > 100 )); then SHADING1=$percent;  fi
if ((  $FACTOR <= 0  )); then SHADING1=1;  fi
fi
#echo  shading1 $SHADING1

###group2#####
UPPER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)    ### 1/2 hr blocks  3,2,1 depicts noon location
LOWER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
PERCENT=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#####PROCESS######
upper=$(echo ${UPPER[$1]}  )

lower=$(echo ${LOWER[$1]}  )

percent=$(echo ${PERCENT[$1]}  )
if (( $upper != 0 )); then


percent=$(echo "$percent / 100"| bc -l)

x=$(echo " $upper - $lower "| bc -l)

y=$(echo "$upper - $altitude"| bc -l)

FACTOR=$(echo "(($y/$x))"| bc -l)

SHADING2=$(echo "(1-($FACTOR*$percent))"| bc -l)

FACTOR=$(echo "scale=0; $FACTOR*100 /1" |bc)  # scaling  to remove decimal and float

if ((  $FACTOR > 100 )); then SHADING2=$percent;  fi
if ((  $FACTOR <= 0  )); then SHADING2=1;  fi
fi
#echo  shading2 $SHADING2


###group3#####
UPPER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)    ### 1/2 hr blocks  3,2,1 depicts noon location
LOWER=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
PERCENT=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#####PROCESS######
upper=$(echo ${UPPER[$1]}  )

lower=$(echo ${LOWER[$1]}  )

percent=$(echo ${PERCENT[$1]}  )
if (( $upper != 0 )); then

percent=$(echo "$percent / 100"| bc -l)

x=$(echo " $upper - $lower "| bc -l)

y=$(echo "$upper - $altitude"| bc -l)

FACTOR=$(echo "(($y/$x))"| bc -l)

SHADING3=$(echo "(1-($FACTOR*$percent))"| bc -l)

FACTOR=$(echo "scale=0; $FACTOR*100 /1" |bc)  # scaling  to remove decimal and float

if ((  $FACTOR > 100 )); then SHADING3=$percent;  fi
if ((  $FACTOR <= 0  )); then SHADING3=1;  fi
fi
#echo  shading3 $SHADING3

and then modify the second last line in panelconf to this

TOTAL=$( echo "((($Group3*$SHADING3)+($G3w * $albedo/100)) + (($Group2*$SHADING2)+($G2w * $albedo/100)) + (($Group1*$SHADING1)+($G1w * $albedo/100))) * $inverter" | bc -l)

and you have to modify the solar API on the potential variable there are three to each solar-api

potential=$(./panelconf1 $numberA $Time)

and copy radiation.py and rename to altitude.py
commentt out the last line in it and uncomment
#print(altitude_deg) as mentioned above

here an test example from my yard that I determined using protractor and using a right angle triangle calculator
I have tree line on my east side and clump tree to the south
: so basically from 4am to
8:30 bush line if the sun is <= 7 degrees a 100% of my panel is covered and when over 10 degrees the panels is fully exposed

the clump of trees from 10am to 11 am it covers a maximum of 50% of my panel when <= 11 degrees and fully exposed when the sun is higher then 22

UPPER=(0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 10 0 0 22 22 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)    ### 1/2 hr blocks  3,2,1 depicts noon location
LOWER=(0 0 0 0 0 0 0 0 7 7 7 7 7 7 7 7 7 7 0 0 11 11 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
PERCENT=(0 0 0 0 0 0 0 100 100 100 100 100 100 100 100 100 100 100 0 0 50 50 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

do not worry about the number 3,2,1 in array upper,lower and percent i am just using it to mark noon ( the lowest my sun goes is about 15 degrees so it never use them)

I can not test it accuracy as I only have a small window in the morning when the sun is low and solar out put is very low. I . currently it about 1-hr window in the morning where it full shaded. then about a 20 minutes more then fully exposed so the predictive does not even register it at this time of year… a littler later from now i will see it better-- some times in late july early august when the sun rises more farther to the south and not behind my panels as it is currently

You are a legend Stephen,

We are in the middle of Winter now so I will have plenty of time to test this (once I can wrap my head around it all)

Just in the middle of a home battery deployment now that is taking all my brain power and then this will come back to the fore – will report back

Thank you for being so responsive on this

Craig

you’re welcome

if you want here a small tool that makes it easier to get the angle degree just create the shell script in your prediction folder and create the above mentioned altitude.py

#!/bin/bash
LAT=xx.xxx        #your latitude and longitude 
LON=-xx.xxx 

TIME=$(date +%s)
altitude=$(python3 -W ignore altitude.py -lon $LON -lat $LAT -t $TIME)
echo $altitude

just run it when the shadow just hits the top of your panels ( or it maximum point) and again when they are just fully expose … it give you the upper and lower degree for your shading array

update:
uploaded to github the new version of prediction with shading options