Misc
Overview Structs
Overview Functions
GEMS._int
GEMS.aggregate_df
GEMS.aggregate_dfs
GEMS.aggregate_dfs_multcol
GEMS.county
GEMS.district
GEMS.foldercount
GEMS.group_by_age
GEMS.id
GEMS.in_county
GEMS.in_district
GEMS.in_state
GEMS.is_county
GEMS.is_district
GEMS.is_state
GEMS.isunset
GEMS.municipality
GEMS.print_aggregates
GEMS.printinfo
GEMS.remove_kw
GEMS.state
GEMS.subinfo
AGS
Constructors
GEMS.AGS
— TypeAGS
Struct to represent Germany's Community Identification Number (Amtlicher Gemeindeschlüssel).
Taken from Wikipedia (https://en.wikipedia.org/wiki/Community_Identification_Number):
The municipality key consists of eight digits, which are generated as follows: The first two digits designate the individual German state. The third digit designates the government district (in areas without government districts a zero is used instead). The fourth and fifth digits designate the number of the urban area (in a district-free city) or the district (in a city with districts). In GEMS they are called 'counties'. The sixth, seventh, and eighth digits indicate the municipality or the number of the unincorporated area.
Example
münster = AGS("05515000")
The above code generates the community identification number for the city of Münster.
- The first two digits identify the state of North Rhine-Westphalia (05)
- The third digit identifies the government district Münster (5)
- The fourth and fifth digit identify the district-free city of Münster (15)
Being a district-free city, Münster does not have a municipality code. Examples for municipalities are: Emsdetten (05566008), Warendorf (05570052), or Steinfurt (05566084).
There are multiple helper functions to navigate through the hierarchical AGS structure such as: state
, district
, county
, or municiaplity
which each return the AGS
of the respective geographic level. The is_state
, is_district
, and is_county
return true, if the provided AGS
is on the respective geographic level. Moreover, in_state
, in_district
, and in_county
verify whether a provided AGS
is contained in a parent region.
AGS
are directly comparable (==
) and broadcastable (.==
).
Note:
There is no is_municiaplity
function as this could be confused as a check wether the AGS is on the lowest geographic level. However, as there are district-free cities which are technically municipalities but without the last three digits given, this check could only be done with context information on the actual region. Based purely on the number, we do not know which county has contains municipalites and which conty is a district-free city.
Functions
GEMS.county
— Methodcounty(ags::AGS)
Returns the parent county's Community Identification Number (AGS) of the provided AGS
.
GEMS.district
— Methoddistrict(ags::AGS)
Returns the parent district's Community Identification Number (AGS) of the provided AGS
.
GEMS.id
— Methodid(ags::AGS)
Retuns the AGS
s internal number (int).
GEMS.in_county
— Methodin_county(ags::AGS, parent::AGS)
Returns true if the county-section of both Community Identification Numbers (AGS) match. Both AGSs are in the same county.
GEMS.in_district
— Methodin_district(ags::AGS, parent::AGS)
Returns true if the district-section of both Community Identification Numbers (AGS) match. Both AGSs are in the same district.
GEMS.in_state
— Methodin_state(ags::AGS, parent::AGS)
Returns true if the state-section of both Community Identification Numbers (AGS) match. Both AGSs are in the same state.
GEMS.is_county
— Methodis_district(ags::AGS)
Returns true if the Community Identification Number (AGS) belongs to a conty. First five digits given, last three being 0s.
GEMS.is_district
— Methodis_district(ags::AGS)
Returns true if the Community Identification Number (AGS) belongs to a governmental district. First three digits given, everything else being 0s.
GEMS.is_state
— Methodis_state(ags::AGS)
Returns true if the Community Identification Number (AGS) belongs to a state. First two digits given, everything else being 0s.
GEMS.isunset
— Methodisunset(ags::AGS)
Returns true
if the AGS
is the "empty" default and does not actually belongs to a any geographic region.
GEMS.municipality
— Methodmunicipality(ags::AGS)
Returns the Community Identification Number (AGS) regardless of its geographic level.
GEMS.state
— Methodstate(ags::AGS)
Returns the parent state's Community Identification Number (AGS) of the provided AGS
.
Utils
GEMS._int
— Function_int(f::Function)
Wrapper to enforce Integer returns of anonymous functions.
GEMS.aggregate_df
— Functionaggregate_df(df::DataFrame, key::Symbol)
Groups dataframes (with numerical values) on the provided key
column and applies the aggregate_values
function to each of them. The resulting dataframe has all initial columns supplemented with the suffixes min
, max
, mean
, lower_95
, upper_95
, and std
GEMS.aggregate_dfs
— Functionaggregate_dfs(dfs::Vector{DataFrame}, key::Symbol)
Joins the input vector of dataframes
on the key
and aggregates the residual data. Requires all dataframes to provide the exact same columns and column names.
GEMS.aggregate_dfs_multcol
— Functionaggregate_dfs_multcol(dfs::Vector{DataFrame}, key::Symbol)
Aggregates data on the columns of the dataframes contained in the provided vector for each value in the key column. All dataframes must have identical columnnames. Returns a dictionary with the columnnames as keys and a dataframe as the value.
GEMS.foldercount
— Methodfoldercount(directory)
Returns the number of subfolders in a directory.
GEMS.group_by_age
— Methodgroup_by_age(df::DataFrame)
Groups a dataframe by its "age" column. The column "sum" contains the sum of each individual in this age. This also adds rows for each age from 0 till the maximum age in the "age" column.
Returns
- returns a DataFrame with an additional column "sum". This column contains the count of the age in the DataFrame.
GEMS.print_aggregates
— Functionprint_aggregates(agg; unit, multiplier, digits)
Pretty-prints the outcomes of an aggregate_values()
function call.
GEMS.printinfo
— Methodprintinfo(str::String)
Prints an @info-Text with the provided string and a HH:MM:SS timestamp.
GEMS.remove_kw
— Functionremove_kw(to_remove::Symbol, kwrds)
Removes a particular keyword from a Named Tuple keyword ist. This is mainly used to exclude certain keywords in plots when passing plotargs...
to subplots.
Example
function my_function(;args...)
new_kwrds = remove_kw(:a, args)
my_other_function(new_kwrds...)
end
If you call the above function with my_function(a = 2, b = 3)
, it will call the inner function with my_other_function(b = 3)
.
GEMS.subinfo
— Methodsubinfo(str::String)
Returns a string with a "sub-line-hook" indicating subtasks of an @info task (as generated by printinfo()
)