Commit b32b1d76 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Polish graphs/citations.

parent b3770ab9
......@@ -5,7 +5,10 @@ import base64
import io
from matplotlib.figure import Figure
from citations_tools import (PLOT_ALL,
PLOT_PER_DOMAIN,
PLOT_PER_PROJECT,
PLOT_PER_TEAM)
from gluon import current
from gluon.storage import Storage
from graph_tools import (FROM_TO,
......@@ -13,6 +16,7 @@ from graph_tools import (FROM_TO,
linechart,
mplstyle,
stackchart)
from matplotlib.figure import Figure
from models.selector import YEAR_SUBMIT
......@@ -58,22 +62,22 @@ def citations():
#
acl = get_acl(db, selector)
if selector.graphs == "all":
if selector.graphs == T(PLOT_ALL):
cols = ["id_publication", "scan", "citations"]
idx = ["id_publication"]
fgroupby = False
elif selector.graphs == "per domain":
elif selector.graphs == T(PLOT_PER_DOMAIN):
cols = ["id_publication", "scan", "citations", "domain"]
idx = ["id_publication", "domain"]
fgroupby = True
elif selector.graphs == "per team":
elif selector.graphs == T(PLOT_PER_TEAM):
cols = ["id_publication", "scan", "citations", "team"]
idx = ["id_publication", "team"]
fgroupby = True
elif selector.graphs == "per project":
elif selector.graphs == T(PLOT_PER_PROJECT):
cols = ["id_publication", "scan", "citations", "project"]
idx = ["id_publication", "project"]
fgroupby = True
......
......@@ -40,6 +40,7 @@
'agencies': 'agences',
'agency': 'agence',
'All': 'Tous',
'all articles': 'tous les articles',
'All fields of the form have to be defined !!!': 'Tous les champs doivent ếtre définis !!!',
'Already in the database': 'Publication déjà enregistré dans la base de donnée',
'An article already exists with the same:': 'Un article existe déja avec le même:',
......@@ -478,6 +479,9 @@
'Password reset': 'Password reset',
'patent': 'brevet',
'PDF file url': 'URL du pdf',
'per domain': 'par domaine',
'per project': 'par projet',
'per team': 'par équipe',
'Period': 'Période',
'period:': 'periode: ',
'PHD ': 'PHD ',
......
......@@ -10,6 +10,11 @@ from gluon import current
from matplotlib.figure import Figure
import matplotlib.ticker as ticker
PLOT_ALL = "all articles"
PLOT_PER_DOMAIN = "per domain"
PLOT_PER_TEAM = "per team"
PLOT_PER_PROJECT = "per project"
def estimator_versus_time(ts,
last_scan,
......@@ -215,7 +220,7 @@ def histogram(citations, last_scan, legend):
df = pd.DataFrame({el[0]: el[1][0] for el in xx.items()})
df = df[sorted(df.columns)]
flegend = True
fstack = False
fstack = True
# histogram all publications
else:
......@@ -263,7 +268,7 @@ def histogram(citations, last_scan, legend):
txt.extend([
f"$\sum${T('citations:')}: {citations.sum()}",
f"{T('citations/article (avg):')} {citations.mean():.1f}",
# f"h-index: {h_index(citations):.1f}"
f"h-index: {h_index(citations):.1f}"
])
ax.text(
......
"""Definitions of the selector(s)
"""
from citations_tools import (PLOT_ALL,
PLOT_PER_DOMAIN,
PLOT_PER_PROJECT,
PLOT_PER_TEAM)
from gluon import current
from gluon.validators import (IS_IN_DB,
IS_LENGTH,
IS_INT_IN_RANGE,
IS_IN_SET)
from harvest_tools import DRY_RUN
from .harvester import CONTROLLERS, STORES
from pydal import Field
......@@ -295,6 +297,8 @@ class Selector(object):
pyDAL.Table
"""
plot_all = T(PLOT_ALL)
table = virtdb.define_table(
"graph_citation_selector",
Field("year_start", "integer"),
......@@ -302,16 +306,16 @@ class Selector(object):
Field("id_teams", "reference teams", label="Team"),
Field("id_projects", "reference projects", label="Project"),
Field("id_authors_roles", "reference authors_roles", label="Role"),
Field("graphs", "string", default="all", label="Graph"))
Field("graphs", "string", default=plot_all, label="Graph"))
table.id_authors_roles.requires = IS_IN_DB(db, "authors_roles.role")
table.id_projects.requires = IS_IN_DB(db, "projects.project")
table.id_teams.requires = IS_IN_DB(db, "teams.team")
table.graphs.requires = IS_IN_SET(["all",
"per domain",
"per team",
"per project"])
table.graphs.requires = IS_IN_SET([plot_all,
T(PLOT_PER_DOMAIN),
T(PLOT_PER_TEAM),
T(PLOT_PER_PROJECT)])
return table
......
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