PubPart#

Class to generate the PubPart report.

By default the report contains the following visualizations: * InstitutionsLineageCollaborations * TopicsCollaborations * TopicsPotentialCollaborations * WorksCollaborations: name = “citationsnormalized”, metric = “citationsnormalized” * WorksCollaborations: name = “citationscount”, metric = “cited_by_count”

This comes from the default value of default_visualizations :

default_visualizations = {
    "InstitutionsLineageCollaborations": [{}],
    "TopicsCollaborations": [{}],
    "TopicsPotentialCollaborations": [{}],
    "WorksCollaborations": [
        {
            "name": "citationsnormalized",
            "metric": "citation_normalized_percentile"
        },
        {
            "name": "citationscount",
            "metric": "cited_by_count"
        },
    ],
}

The PubPart Class#

class dibisoreporting.pubpart.PubPart(entity_id: str, year: int | str | None = None, entity_openalex_filter_field: str = 'authorships.institutions.lineage', secondary_entity_id: str | list[str] | None = None, secondary_entity_filter_field: str | list[str] | None = 'authorships.institutions.lineage', entities_acronym: str = '', entities_full_name: str = '', latex_main_file_path: str | None = None, latex_main_file_url: str | None = None, latex_biblio_file_path: str | None = None, latex_biblio_file_url: str | None = None, latex_template_path: str | None = None, latex_template_url: str | None = None, max_entities: int | None = 100000, max_plotted_entities: int = 25, plot_main_color: str | None = None, root_path: str | None = None, watermark_text: str = '', **kwargs)#

Bases: DibisoReporting

Class to generate the PubPart report

Variables:
  • class_mapping – Dictionary that maps class names to actual classes

  • default_plot_main_color – Default color for the main plot (#004e7d)

  • default_visualizations – Dictionary contains each type of plot to include in the report with the parameters of each plot.

__init__(entity_id: str, year: int | str | None = None, entity_openalex_filter_field: str = 'authorships.institutions.lineage', secondary_entity_id: str | list[str] | None = None, secondary_entity_filter_field: str | list[str] | None = 'authorships.institutions.lineage', entities_acronym: str = '', entities_full_name: str = '', latex_main_file_path: str | None = None, latex_main_file_url: str | None = None, latex_biblio_file_path: str | None = None, latex_biblio_file_url: str | None = None, latex_template_path: str | None = None, latex_template_url: str | None = None, max_entities: int | None = 100000, max_plotted_entities: int = 25, plot_main_color: str | None = None, root_path: str | None = None, watermark_text: str = '', **kwargs)#

Initialize the PubPart class with the given parameters.

Parameters:
  • entity_id (str) – The HAL collection identifier. This usually refers to the entity acronym.

  • year (int | str | None, optional) – The year for which to fetch data. If None, uses the current year.

  • entity_openalex_filter_field (str, optional) – Field to filter on in the OpenAlex API. Default to ‘authorships.institutions.lineage’. The list of possible values can be found in the OpenAlex documentation: https://docs.openalex.org/api-entities/works/filter-works

  • secondary_entity_id (str | list[str] | None, optional) – The OpenAlex ID for the secondary entity or entities to analyze the topics of collaborations. If a work is present in several entities, it is counted only once.

  • secondary_entity_filter_field (str | list[str] | None, optional) – The OpenAlex filter field for the secondary entity or entities. If None, use the same as for the main entity. If a single string is provided, it is used for all secondary entities.

  • entities_acronym (str) – The acronym of the entities.

  • entities_full_name (str) – The full name of the entities.

  • latex_main_file_path (str | None, optional) – Path to a single LaTeX main file. This file is the one to use to compile the report. It will copy the main file to root_path. Default to None. If None, doesn’t try getting the main file from the path. If both latex_main_file_path and latex_main_file_url are not None, the library will first try to get the main file from the path.

  • latex_main_file_url (str | None, optional) – URL to download a single LaTeX main file. It will download the file directly to root_path. Default to None. If None, doesn’t try getting the main file from the URL.

  • latex_biblio_file_path (str | None, optional) – Path to a single LaTeX biblio file. This file is the one to use to compile the bibliography. It will copy the biblio file to root_path. Default to None. If None, doesn’t try getting the biblio file from the path. If both latex_biblio_file_path and latex_biblio_file_url are not None, the library will first try to get the biblio file from the path.

  • latex_biblio_file_url (str | None, optional) – URL to download a single LaTeX biblio file. It will download the file directly to root_path. Default to None. If None, doesn’t try getting the biblio file from the URL.

  • latex_template_path (str | None, optional) – Path to the LaTeX template files. It will copy the templates files to root_path. Default to None. If None, doesn’t try getting the template from the path. If both latex_template_path and latex_template_url are not None, the library will first try to get the template from the path.

  • latex_template_url (str | None, optional) – URL to a GitHub repository containing the template. It will get the latest repository release and extract it to get the template files. Default to None. If None, doesn’t try getting the template from the URL.

  • max_entities (int | None, optional) – Default maximum number of entities used to create the plot. Default 1000. Set to None to disable the limit. This value limits the number of queried entities when doing analysis. For example, when creating the collaboration map, it limits the number of works to query from HAL to extract the collaborating institutions from.

  • max_plotted_entities (int, optional) – Maximum number of bars in the plot or rows in the table. Default to 25.

  • plot_main_color (str, optional) – Main color used in the plots. Default to “blue”. Plotly color.

  • root_path (str) – Path to the root directory where the report and figures will be generated.

  • watermark_text (str) – The text to be used as a watermark in the report. Default to “” (no watermark).

add_marco(name: str, value)#

Add a LaTeX macro to the report.

Parameters:
  • name (str) – Name of the macro.

  • value – Value of the macro.

Returns:

class_mapping = {'InstitutionsLineageCollaborations': <class 'dibisoplot.pubpart.pubpart.InstitutionsLineageCollaborations'>, 'TopicsCollaborations': <class 'dibisoplot.pubpart.pubpart.TopicsCollaborations'>, 'TopicsPotentialCollaborations': <class 'dibisoplot.pubpart.pubpart.TopicsPotentialCollaborations'>, 'WorksCollaborations': <class 'dibisoplot.pubpart.pubpart.WorksCollaborations'>}#
create_default_latexmkrc_file()#

Create the default latexmkrc file in the root path of the project.

default_latexmkrc_file_content = "$pdflatex = 'lualatex %O %S --shell-escape';\n$pdf_mode = 1;\n$postscript_mode = $dvi_mode = 0;\n"#
default_plot_main_color = '#004e7d'#
default_visualizations = {'InstitutionsLineageCollaborations': [{}], 'TopicsCollaborations': [{}], 'TopicsPotentialCollaborations': [{}], 'WorksCollaborations': [{'metric': 'citation_normalized_percentile', 'name': 'citationsnormalized'}, {'metric': 'cited_by_count', 'name': 'citationscount'}]}#
figures_dir_name = 'figures'#
generate_report(visualizations_to_make: dict[str, list[dict]] | None = None, import_default_visualizations=True)#

Generate the report by calling the specified functions with their parameters to create the desired visualizations. To select which visualization to make and configure them, you can use visualizations_to_make as follows:

visualizations_to_make = {
    "PubInstitutions": [
        { "name": "PubInstitutions1", "param1": "value1", "param2": "value2" },
        { "name": "PubInstitutions2", "param1": "value3", "param2": "value4" }
    ],
    "InstitutionsLineageCollaborations": [
        { "name": "ilc", "param1": "value1", "param2": "value2" }
    ],
    "TopicsCollaborations": [
        {}
    ],
    "TopicsPotentialCollaborations": []
}
This example, will create:
  • 2 PubInstitutions visualizations (with the parameters defined in the dictionaries)

  • 1 InstitutionsLineageCollaborations visualization (with the parameters defined in the dictionary)

  • 1 TopicsCollaborations visualizations

  • 0 TopicsPotentialCollaborations visualizations (as the list is empty)

Parameters:
  • visualizations_to_make (list[dict[str, Any]]) – A dictionary specifying which visualizations to make and their parameters.

  • import_default_visualizations (bool) – Whether to import default visualizations settings. Defaults to True. To not generate a plot, set its dictionary in import_default_visualizations to an empty list. Example: If you don’t want to generate the Conferences visualization, you can set import_default_visualizations as follows: import_default_visualizations = {"Conferences": []}.

get_file_from_path(file_path: str, file_type: str)#

If file_path is not None, get the file from a local path. It copies the file from the specified path to the root path of the project. Checks the file type based on its extension and rename latexmkrc files.

Parameters:
  • file_path (str) – The path to the file.

  • file_type (str) – The file type (“tex” or “latexmkrc”).

Returns:

The path to the LaTeX main file.

get_file_from_url(file_url: str, file_type: str)#

If file_url is not None, get the file from a URL. It downloads the file from the specified URL to the root path of the project. Checks the file type based on its extension and rename latexmkrc files.

Parameters:
  • file_url (str) – The URL of the file.

  • file_type (str) – The file type (“tex” or “latexmkrc”).

Returns:

The path to the LaTeX main file.

get_latex_template_from_github()#

Get the LaTeX template either from a GitHub repository release. It saves the template in the root path of the project.

get_latex_template_from_path()#

Get the LaTeX template from a local path. It copies the template files from the specified path to the root path of the project.