mirror of
https://github.com/woheller69/solxpect.git
synced 2025-12-16 09:20:12 +01:00
improved shading calculation (6 steps per hour)
This commit is contained in:
parent
975065f84f
commit
84224c863f
8 changed files with 34 additions and 16 deletions
|
|
@ -67,11 +67,38 @@ public class SolarPowerPlant {
|
||||||
efficiency = Math.max(0, efficiency); //scalar product is negative if sun points to back of module. set 0 in this case
|
efficiency = Math.max(0, efficiency); //scalar product is negative if sun points to back of module. set 0 in this case
|
||||||
|
|
||||||
if (efficiency > 0) {
|
if (efficiency > 0) {
|
||||||
//Calculate shading in 10 degree ranges, total 36 ranges
|
double shFactor=0;
|
||||||
int shadingIndex = ((((int) Math.round((solarAzimuth + 5) / 10)) - 1) % 36 + 36) % 36;
|
Instant sh;
|
||||||
if (shadingElevation[shadingIndex] > solarElevation) {
|
ZonedDateTime shDateTime;
|
||||||
efficiency *= (double) (100 - shadingOpacity[shadingIndex])/100;
|
AzimuthZenithAngle shPosition;
|
||||||
|
double shSolarAzimuth;
|
||||||
|
double shSolarElevation;
|
||||||
|
|
||||||
|
//Calculate shading in 6 intervals per hour -> 10min steps xx:05 / xx:15 / xx:25 / xx:35 / xx:45 / xx:55
|
||||||
|
int numSteps = 6;
|
||||||
|
long interval = 3600 / numSteps;
|
||||||
|
for (int j=0; j<numSteps;j++){
|
||||||
|
sh = Instant.ofEpochSecond(epochTimeSeconds-(numSteps-1)*interval/2+j*interval);
|
||||||
|
shDateTime = ZonedDateTime.ofInstant(sh, ZoneId.of("GMT")); //currentTimeMillis is in GMT
|
||||||
|
|
||||||
|
shPosition = Grena3.calculateSolarPosition(
|
||||||
|
shDateTime,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
DeltaT.estimate(shDateTime.toLocalDate())); // delta T (s)
|
||||||
|
|
||||||
|
shSolarAzimuth = shPosition.getAzimuth();
|
||||||
|
shSolarElevation = 90 - shPosition.getZenithAngle();
|
||||||
|
|
||||||
|
//shading values are provided in 10 degree ranges -> total of 36 ranges
|
||||||
|
int shadingIndex = ((((int) Math.round((shSolarAzimuth + 5) / 10)) - 1) % 36 + 36) % 36;
|
||||||
|
if (shadingElevation[shadingIndex] > shSolarElevation) {
|
||||||
|
shFactor += (double) (100 - shadingOpacity[shadingIndex])/(numSteps*100);
|
||||||
|
} else {
|
||||||
|
shFactor += (double) 100/(numSteps*100); //numSteps iterations with no shading give 100%
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
efficiency *= shFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.woheller69.weather.ui.RecycleList;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
@ -338,20 +337,11 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
||||||
mCourseOfDay.getLayoutManager().scrollToPosition(i);
|
mCourseOfDay.getLayoutManager().scrollToPosition(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
highlightSelected(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void highlightSelected(View view) {
|
|
||||||
for (int j=0;j<courseDayList.size();j++){ //reset all items
|
|
||||||
if (holder.recyclerView.getLayoutManager().getChildAt(j)!=null){
|
|
||||||
holder.recyclerView.getLayoutManager().getChildAt(j).setBackground(ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
view.setBackground(ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_highlight,null)); //highlight selected item
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onLongItemClick(View view, int position) {
|
public void onLongItemClick(View view, int position) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class CourseOfDayAdapter extends RecyclerView.Adapter<CourseOfDayAdapter.
|
||||||
this.courseOfDayList = courseOfDayList;
|
this.courseOfDayList = courseOfDayList;
|
||||||
this.recyclerViewHeader=recyclerViewHeader;
|
this.recyclerViewHeader=recyclerViewHeader;
|
||||||
this.recyclerView=recyclerView;
|
this.recyclerView=recyclerView;
|
||||||
if (courseOfDayList.size()!=0 && courseOfDayList.get(0)!=null) {
|
if (courseOfDayList!=null && courseOfDayList.size()!=0 && courseOfDayList.get(0)!=null) {
|
||||||
this.courseOfDayHeaderDate = new Date(courseOfDayList.get(0).getLocalForecastTime(context));
|
this.courseOfDayHeaderDate = new Date(courseOfDayList.get(0).getLocalForecastTime(context));
|
||||||
}else this.courseOfDayHeaderDate=new Date(); //fallback if no data available
|
}else this.courseOfDayHeaderDate=new Date(); //fallback if no data available
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,8 @@ public class CourseOfDayAdapter extends RecyclerView.Adapter<CourseOfDayAdapter.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return courseOfDayList.size();
|
if (courseOfDayList==null) return 0;
|
||||||
|
else return courseOfDayList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
class CourseOfDayViewHolder extends RecyclerView.ViewHolder {
|
class CourseOfDayViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Loading…
Add table
Add a link
Reference in a new issue