Handling Biomass Data
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 10 | |
Author | ||
License | CC Attribution - ShareAlike 4.0 International: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Publisher | ||
Release Date | ||
Language | ||
Production Year | 2023 | |
Production Place | Aachen |
Content Metadata
Subject Area | |
Genre |
1
2
3
5
7
10
00:00
Computer animationTable
00:31
Computer animation
08:33
Computer animation
16:36
Computer animation
Transcript: English(auto-generated)
00:06
Now we move into Spyder, so one thing is very important, we want to, for example, read this sheet, which is like the core sheet that we want to read, if we want to do a new TS2, so we have to remember what is this sheet called, so we can directly access it.
00:29
So the first thing we're going to do is, again, we have to push the data into here, and then we save the location, and we can read a specific sheet name.
00:47
So if I execute this, we will get the variables, or we should get it in a second, as the file is kind of big.
01:06
So now, if I select my biomass, again, as before, I see I get a data frame, which is huge in this case, but
01:21
it's exactly the file that we had before with the available biomass by scenario, and with the units, and exactly how the access sheet was, we have all the access to these columns.
01:44
I will now introduce some filters, so for example, I just want to, for example, have a certain amount of years, so in this case, for demonstration purpose, I will just take 2013.
02:01
Then I also want to have a certain set of biomass, in this case, use this one, and I also have to select the scenario, in this case, we take the ENS underscore height.
02:42
So now, what I have to do is, as we did up here, for example, similar way, we have to filter for the scenario, for example, I will just enter this one, as it is straightforward, we just do the same lookup as we did before, and we just check that the scenario is the scenario.
03:13
What I will do now, for example, I want to see how much biomass in the specific year of specific biomass is there, and put it on the map.
03:26
So what I will do, I will iterate over the biomass, and I will also iterate over the years, and get these, and get the next two filters I am just copying in now.
03:56
So, I want these for the biomass, which I am doing here, copying them into a new variable, and then, this is very important here, I am not
04:13
working on this one anymore, but I am going to this one, and I am going to the filter on the one that is already filtered for the biomass.
04:22
So if I run this, I should get, and I will inspect this one, I should get a lot smaller data frame, which will only have the data for a year, a scenario, a specific E commodity.
04:49
What I have here in this level, I actually have for certain in UTS2, I will have multiple commodities, because they are developed like, they are written like that, so what I will actually have to do, what I want
05:07
to do if I just want to have the commodity, since it is one thing, I have to sum these up. These I can do also quite handily by a group, so what I can just do, I can do biomass, UTS, and
05:29
this one I want to have it grouped by S2, and what I want to do is, I want to sum them.
05:57
Actually, there is a typo in the Excel sheet, and it is called NAST2, but actually that is not how it should
06:11
be written, but you have to confine to what is written in the Excel sheet, or you have to change the Excel sheet.
06:23
What I will do in the next step, I will actually going to merge the geographical data here with my data that I have down here, as the data is not named the same. I have to answer also this line, which is basically in this data frame, I just have a NAST ID, and here I just have this.
06:51
It is very important to look into detail into the data, so what I am actually going to do, I am going to introduce a new field NAST into the NAST here, and then I can merge on them.
07:07
There is a very handy function, where I will just use the bio, year, year, and
07:21
mass, and I want to define this as a merge of the geographical data with this data, and I just have to define on which column I am going to merge them, and this will
07:47
be NAST2, also written wrongly, but here, as I put it up here, it will merge just fine. So if I run this, I should get a new data frame, which should now have the geometries attached to the biomass data.
08:12
So if I go in here now, I actually have my biomass data with the available commodity, which
08:25
is also summed up, because I did the group, by function, and exactly I have the polygons here. So now I can plot the whole thing, so I will just use this, and I am going to plot it.
08:51
What I can do, I actually can do some nice color coding, which says on a certain column, take me the
09:03
values, and create a color map, where it is the deeper the color as it is, as the more biomass there is. So I can select the column for this, then I can give it a color map, which I will call greens, to show them clearer from each other.
09:40
I will also define an edge color, which I will use black. So if I run this, I should now get a map of the last standard TS2, with color coded for how much of the given biomass is in which region for the year 2013.
10:12
We will now run this, we remove the old plotting, we just introduced the new plotting, and now we should get the map here.
10:30
If you are questioning why we don't have to select again by countries, and the biomass we have filtered by the countries, as we have done up here, this is handled by the merge.
10:44
We are merging on this one here, we are only putting in what is already in this one. If you don't want to do this on this way, because you have filtered here, the merge is going to filter it, but you could also easily filter here.
11:01
As we now see, we have the map with a deeper color, depending on where we have the most potential. For example, we see up here in the north of Germany, we have the most potential for this specific biomass in this specific year.
11:22
Now obviously we cannot see the biomass, and if we also want to represent this in the map, we could easily plot this, and we would just write again the centroids.
11:46
We have to do the same as we did before with the centroids, as we did here with the others. We have to use this kind of projection, and then we have to take the values, we have to get the values, and this is again this kind of column.
12:05
I will just get off the biomass a specific column. If I just want to access a specific column, I can really and truly just copy
12:23
this and enter it, and then the values will be just that specific column, nothing else. To show something on the map, we have to use the function called annotate, and to annotate we actually have to zip our values.
12:53
So what we are going to do is we want to have all the centroid x parts, then we want to have our centroid y parts, and we want to have the values.
13:10
So if I run this now, what we will see is that the values is a line
13:27
of just the potential biocommodities, and zip over the zip, it's kind of a data structure in Python.
13:40
So zip object, we can iterate. There's all kinds of documentation about it. If you're interested, read about that. The important thing is what we can do. We can iterate of it like this, or we take the xe, xy, and the text,
14:06
which is our value, and we can now use the annotate function I was speaking about. What we do, we take the text, and we want to format it into a floating variable with zero points after the dot.
14:36
So we use text, and we use the xy value, where it should be.
14:52
Okay, then we take xe and ye, which are our latitude and longitude, xy, corns equal to data.
15:12
We're also bringing in a small offset. If you're really interested in all the details, I really suggest you to look up into the documentation and
15:28
see the nice things that you can do with matplotlib, and see all the details on what I'm doing here.
15:52
Now I have my function. I think, yeah, this is one bracket too much.
16:04
We have this. I can execute it. This should provide me with a nice plot, where now we will see in the centroids of each region with the bioavailability.
16:21
That's exactly what we see here, like 16 petajoules or the other availabilities in each region.