r.sun automated code with DEM

hello everyone, I’m new to Grass gis and find the sonnenenegry analysis very good but don’t know my way around.
I am in the process of writing an automated code.
So, if the DEM is inserted I take:
r.slope.aspect elevation=testDEM slope=slope aspect=aspect

and now it gets complicated. i want to do an annual analysis in kWh. How should i proceed so that the computing power is not too high. my approach is

r.sun elevation=testDEM slope=slope aspect=aspect latitude=50 day=79 output=daily_solar_mar20
r.sun elevation=testDEM slope=slope aspect=aspect latitude=50 day=172 output=daily_solar_jun21
r.sun elevation=testDEM slope=slope aspect=aspect latitude=50 day=265 output=daily_solar_sep22
r.sun elevation=testDEM slope=slope aspect=aspect latitude=50 day=355 output=daily_solar_dec21

r.mapcalc “annual_solar_approx = (daily_solar_mar20 + daily_solar_jun21 + daily_solar_sep22 + daily_solar_dec21) / 4 * 365”

Visualization
d.rast map=annual_solar_approx
d.rast.edit map=annual_solar_approx color=bpy64 # or another suitable color palette
d.redraw

But there’s a problem somewhere. I am sure that this “trivial” question will find an answer with you :slight_smile:

There is no output parameter, use e.g. glob_rad as output parameter. If you are running it in a project with defined coordinate reference system, you don’t need latitude. Just check the r.sun documentation.

Regarding the visualization, you are using the graphical user interface, or trying to script it? You need r.colors, not d.rast.edit.

@annakrat Thank you for the answer. I have some more :slight_smile:

I used
r.slope.aspect elevation=xDEM slope=x_slope aspect=x_aspect --overwrite

r.sun elevation=xDEM slope=x_slope aspect=x_aspect day=1-365 step=5 glob_rad=solar_rad_year linke_value=3. 0 albedo_value=0.2 --overwrite

r.out.gdal input=solar_rad_year output=C:/GRASS_EXPORT/solar_rad_year.tif format=GTiff --overwrite

  1. for the export I would like to integrate this in cesium. for this I have to make a gdal file. Can I do this directly in grass gis?

  2. does r.sun take the topography (mountains, terrain etc.) into account?

  3. the value stands for one pixel as far as i understand?

r.out.gdal can export different formats using gdal library, not sure which format specifically you need

yes

the unit is Wh per m^2 per day, see documentation

1 Like

when I work with this code
r.in.gdal input=“C:\GRASS_EXPORT\m.tif” output=mDEM --overwrite

r.slope.aspect elevation=mDEM slope=mf_slope aspect=m_aspect --overwrite

r.sun elevation=mDEM slope=m_slope aspect=m_aspect day=1-365 step=5 glob_rad=solar_rad_year linke_value=3.0 albedo_value=0.2 --overwrite

r.out.gdal input=solar_rad_year output=C:/GRASS_EXPORT/solar_rad_year.tif format=GTiff --overwrite

Location is Zürich. when I have a roof for example, 30°, south, I should get verry roughly 1’200kWh /m2. but Grass Gis show me 2670 (2.670kWh/m2). And this is not possible. Is there a Bug or I understand the Value wrong?

Is this even running? It should be an integer:

Also I am not sure about the albedo and linke values, but they would influence the results.

@annakrat I tried to calculate the total energy in one year with a python. But the calculation takes a very long time.
is there a way to calculate a specific day and interpolate / multiply the annual energy?

my goal is kWh/m2/year. but it seem, taht this can be complicatetd or need much calculation power :wink:

Well, in your first question you suggested an approach to average it from multiple days throughout the year and that seems like a decent approach.