Commit 3b26bef3 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update lbfr_report_rh.py to handle domain information.

parent d11f5864
......@@ -86,6 +86,10 @@ def df_people_fte(year):
"%s %s" % (people.first_name, people.last_name),
row.history.fte))
# reset the selector
selector.reset_period()
selector.set_year(year)
# build the data frame
columns = ["year",
"team",
......@@ -157,6 +161,15 @@ def df_people_start_leave(year):
# people leaving
if row1.history.is_end:
query = db.history.id_events == id_people
query &= db.history.id_people == row1.history.id_people
myset = db(query).select(orderby=db.history.start_date)
end_date = myset.last().end_date
if end_date is None or end_date.year > year:
continue
data.append((
row1.teams.team,
"%s %s" % (row1.people.first_name, row1.people.last_name),
......@@ -186,6 +199,9 @@ def do_pdf(year):
year (int):
"""
db = current.globalenv['db']
selector = current.selector
style()
base_pdf = "lbfr_rh_%s" % NOW.strftime("%y%m%d")
......@@ -193,29 +209,37 @@ def do_pdf(year):
# ........................................................................
#
# Status on people starting / leaving and on CDD funding
# RH
# - Status on people starting / leaving
# - Status on CDD funding
# - Status on number of people, fte, population content
#
df = df_people_start_leave(year)
for row in db(db.domains.id > 1).iterselect():
domain = row.domain
selector.id_domains = row.id
df_start = df_people_start_leave(year)
page_people_starting_leaving(df_start, year, domain)
pdf.savefig()
page_cdd_funding(df_start, year, domain)
pdf.savefig()
page_people_starting_leaving(df, year)
pdf.savefig()
df_people = df_people_fte(year)
page_cdd_funding(df, year)
pdf.savefig()
page_population(df_people, year, domain)
pdf.savefig()
# ........................................................................
#
# Status on number of people, fte, ..
# THE END
#
df = df_people_fte(year)
page_population(df, year)
pdf.savefig()
pdf.close()
def page_cdd_funding(df, year):
def page_cdd_funding(df, year, domain):
"""Page showing the funding of cdd.
Args:
......@@ -223,12 +247,21 @@ def page_cdd_funding(df, year):
columns are "team", "name", "category", "start",
"leave", "date", "agency", "cdd"
year(int):
domain (str):
"""
title = u"Financement des CDDs en %i (%s)" % (year, domain)
fig = plt.figure()
header_footer(fig, u"Financement des CDDs en %i" % year)
header_footer(fig, title)
print "."*80, "\nFUNDING CDD", domain.upper(), ":\n"
print "."*80, "\nFUNDING CDD:\n"
if df.empty:
print "\nSkip since the data frame is empty"
return
print df
# ........................................................................
#
......@@ -253,34 +286,37 @@ def page_cdd_funding(df, year):
#
# PhdStudent
#
ax = plt.subplot(221)
if "PhdStudent" in df1:
ax = plt.subplot(221)
query = (df1.PhdStudent > 0)
df1.PhdStudent[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
query = (df1.PhdStudent > 0)
df1.PhdStudent[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
# ........................................................................
#
# Postdoc
#
ax = plt.subplot(222)
if "PostDoc" in df1:
ax = plt.subplot(222)
query = (df1.PostDoc > 0)
df1.PostDoc[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
query = (df1.PostDoc > 0)
df1.PostDoc[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
# ........................................................................
#
# Ingenieur
# IT
#
ax = plt.subplot(223)
if "IT" in df1:
ax = plt.subplot(223)
query = (df1.Ingenieur > 0)
df1.Ingenieur[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
query = (df1.IT > 0)
df1.IT[query].plot.pie(ax=ax,
autopct="%.0f%%",
colormap="Pastel1")
# ........................................................................
#
......@@ -292,7 +328,7 @@ def page_cdd_funding(df, year):
table_only(ax, mytable)
def page_people_starting_leaving(df, year):
def page_people_starting_leaving(df, year, domain):
"""List and plot of people starting of leaving during the given year.
Args:
......@@ -300,12 +336,20 @@ def page_people_starting_leaving(df, year):
columns are "team", "name", "category", "start",
"leave", "date", "agency"
year (int):
domain (str):
"""
title = u"Arrivé(s) et départ(s) en %i (%s)" % (year, domain)
fig = plt.figure()
header_footer(fig, u"Arrivé(s) et départ(s) en %i" % year)
header_footer(fig, title)
print "."*80, "\nPEOPLE STARTING LEAVING IN", year, domain.upper(), "\n"
if df.empty:
print "\nSkip since the data frame is empty"
return
print "."*80, "\nPEOPLE STARTING LEAVING IN", year, "\n"
print df
# ........................................................................
......@@ -349,7 +393,7 @@ def page_people_starting_leaving(df, year):
table_only(ax, mytable)
def page_population(df, year):
def page_population(df, year, domain):
"""Page showing the number of person, fte for the given year -2 and +2
as well as the evolution of the physicists population.
......@@ -357,12 +401,18 @@ def page_population(df, year):
df (pandas.DataFrame):
columns are "year", "team", "topcat", "category", "name", "fte".
year (int):
domain (str):
"""
title = u"Population LHCb France en %i (%s)" % (year, domain)
fig = plt.figure()
header_footer(fig, u"Population LHCb France en %i" % year)
header_footer(fig, title)
print "."*80, "\nPOPULATION", domain.upper(), ":\n"
print "."*80, "\nPOPULATION\n"
if df.empty:
print "\nSkip since the data frame is empty"
return
# ........................................................................
#
......@@ -413,7 +463,7 @@ def page_population(df, year):
#
# view the content of the physicist population
#
query = (df.category != "Emérite") & (df.category != "Ingénieur")
query = (df.category != "Emérite") & (df.category != "IT")
df3 = df[query].groupby(("year", "category")).sum()
df3 = df3.unstack(level=1)
......@@ -430,7 +480,7 @@ def page_population(df, year):
rot=0,
stacked=True,
width=1.,
ylim=(0, 60))
ylim=(0, 50))
ticks_and_labels(ax, u"Année", u"Physiciens [ETP]")
......@@ -456,6 +506,7 @@ def setup_selector(year):
myvars.SelectorData = ''
myvars.SelectorId = ''
myvars.SelectorId_domains = ''
myvars.SelectorId_fundings = ''
myvars.SelectorId_object_categories = ''
myvars.SelectorId_object_code = ''
......@@ -510,7 +561,7 @@ def top_category(category):
str
"""
if category == "Ingénieur":
if category in ("IT", "PhdEngineer"):
topcat = "IT"
elif category == "Emérite":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment