pyphyschemtools packageï
The pyphyschemtools library provides a comprehensive suite of utilities for Physical Chemistry, ranging from spectroscopic unit management to kinetic modeling and cheminformatics.
- pyphyschemtools.get_ppct_data(file: str, main_folder: str = 'data_examples') Pathï
Retrieves the absolute path to a pyphyschemtools resource. Compatible with Python 3.11+ using importlib.resources. Works across all platforms (Windows, Linux, MacOS) and Google Colab.
- Parameters:
file (str) â The path and name of the file (e.g., âMolecules/betaCD-closed.xyzâ).
main_folder (str) â The resource subfolder inside the package (defaults to âdata_examplesâ).
- Returns:
A pathlib.Path object pointing to the absolute location of the file.
- Return type:
Path
Submodulesï
pyphyschemtools.Chem3D moduleï
- class pyphyschemtools.Chem3D.XYZData(symbols, positions)ï
Bases:
objectObject containing molecular coordinates and symbols extracted by molView. Allows for geometric calculations without reloading data.
- get_bounding_sphere(include_vdw=True, scale=1.0)ï
Calculates the center and radius of the bounding sphere using ASE. scale: multiplication factor (e.g., 0.6 to match a reduced CPK style).
- get_cage_volume(grid_spacing=0.5, return_spheres=False)ï
Calculates the internal cavity volume of a molecular cage using CageCavityCalc.
This method interfaces with the CageCavityCalc library by generating a temporary PDB file of the current structure. It can also retrieve the coordinates of the âdummy atomsâ (points) that fill the detected void.
- Parameters:
grid_spacing (float, optional) â The resolution of the grid used for volume integration in Ă . Smaller values provide higher precision (default: 0.5).
return_spheres (bool, optional) â If True, returns both the volume and an ase.Atoms object containing the dummy atoms representing the cavity (default: False).
- Returns:
volume (float or None) â The calculated cavity volume in Ă Âł. Returns None if the calculation fails.
cavity_atoms (ase.Atoms, optional) â Returned only if return_spheres is True. An ASE Atoms object representing the internal void space.
- get_cavity_dimensions(cavity_atoms)ï
Calculates the principal dimensions (Length, Width, Height) of the cavity points.
This method uses Principal Component Analysis (PCA) to find the natural axes of the cavity, making it independent of the moleculeâs orientation. Percentiles are used instead of absolute Max-Min to filter out potential outliers or âleakingâ points at the openings.
- Parameters:
cavity_atoms (ase.Atoms) â The Atoms object containing the âdummy atomsâ generated by the cavity calculation.
- Returns:
The dimensions (L, W, H) sorted from largest to smallest.
- Return type:
tuple (float, float, float)
- get_center_of_geometry()ï
Calculates the arithmetic mean of the atomic positions (Centroid).
- get_center_of_mass()ï
- class pyphyschemtools.Chem3D.molView(mol, source=None, style='bs', displayHbonds=True, cpk_scale=0.6, w=600, h=400, supercell=(1, 1, 1), display_now=True, detect_BondOrders=True, viewer=True, zoom=None)ï
Bases:
objectInitializes a molecular/crystal viewer and coordinate extractor.
This class acts as a bridge between various molecular data sources and the py3Dmol interactive viewer. It can operate in âFullâ mode (display + analysis) or âHeadlessâ mode (analysis only) by toggling the viewer parameter.
The class automatically extracts geometric data into the self.data attribute (an XYZData object), allowing for volume, dimension, and cavity calculations.
Display molecular and crystal structures in py3Dmol from various sources:
XYZ/PDB/CIF local files
XYZ-format string
PubChem CID
ASE Atoms object
COD ID
RSCB PDB ID
Three visualization styles are available:
âbsâ : ball-and-stick (default)
âcpkâ : CPK space-filling spheres (with adjustable size)
âcartoonâ: protein backbone representation
Upon creation, an interactive 3D viewer is shown directly in a Jupyter notebook cell, unless the headless viewer parameter is set to False.
- Parameters:
mol (str or ase.Atoms) â
The molecular structure to visualize.
If source=âfileâ, this should be a path to a structure file (XYZ, PDB, etc.)
If source=âmolâ, this should be a string containing the structure (XYZ, PDBâŠ)
If source=âcifâ, this should be a cif file (string)
If source=âcidâ, this should be a PubChem CID (string or int)
If source=ârscbâ, this should be a RSCB PDB ID (string)
If source=âcodâ, this should be a COD ID (string)
If source=âaseâ, this should be an ase.Atoms object
source ({'file', 'mol', 'cif', 'cid', 'rscb', 'ase'}, optional) â The type of the input mol (default: âfileâ).
style ({'bs', 'cpk', 'cartoon'}, optional) â
Visualization style (default: âbsâ).
âbsâ â ball-and-stick
âcpkâ â CPK space-filling spheres
- âcartoonâ â draws a smooth tube or ribbon through the protein backbone
(default for pdb structures)
displayHbonds (plots hydrogen bonds (default: True))
cpk_scale (float, optional) â Overall scaling factor for sphere size in CPK style (default: 0.5). Ignored when style=âbsâ.
supercell (tuple of int) â Repetition of the unit cell (na, nb, nc). Default is (1, 1, 1).
w (int, optional) â Width of the viewer in pixels (default: 600).
h (int, optional) â Height of the viewer in pixels (default: 400).
detect_BondOrders (bool, optional) â If True (default) and input is XYZ, uses RDKit to perceive connectivity and bond orders (detects double/triple bonds). Requires the rdkit library. If False, fallback to standard 3Dmol distance-based single bonds.
display_now (bool, optional) â If True (default), renders the molecule immediately. Set to False to prevent immediate display when you plan to call further visualization methods provided by the molView class
viewer (bool, optional) â If True (default), initializes the py3Dmol engine and prepares the 3D model. If False, operates in âheadlessâ mode: only geometric data is processed for analysis (volume, CM, etc.), saving significant memory for high-throughput processing.
zoom (None, optional) â scaling factor
- dataï
Container for atomic symbols and positions, used for geometric analysis.
- Type:
XYZData or None
- vï
The 3Dmol.js viewer instance (None if viewer=False).
- Type:
py3Dmol.view or None
Examples
>>> molView("molecule.xyz", source="file") >>> molView(xyz_string, source="mol") >>> molView(2244, source="cid") # PubChem aspirin >>> from ase.build import molecule >>> molView(molecule("H2O"), source="ase") >>> molView.view_grid([2244, 2519, 702], n_cols=3, source='cid', style='bs') >>> molView.view_grid(xyzFiles, n_cols=3, source='file', style='bs', titles=titles, w=500, sync=True) >>> # Headless mode for high-throughput volume calculations >>> mv = molView("cage.xyz", viewer=False) >>> vol = mv.data.get_cage_volume()
- show_bounding_sphere(color='gray', opacity=0.2, scale=1.0)ï
Calculates and displays the VdW bounding sphere in one go.
- show_cage_cavity(grid_spacing=0.5, color='cyan', opacity=0.5)ï
Calculates cavity with CageCavityCalc and displays it as a single model.
- classmethod view_grid(mol_list, n_cols=3, titles=None, **kwargs)ï
Displays a list of molecular structures in an interactive n_rows x n_cols grid.
This method uses ipywidgets.GridspecLayout to organize multiple 3D viewers into a clean matrix. It automatically calculates the required number of rows based on the length of the input list.
- Parameters:
mol_list (list) â A list containing the molecular data to visualize. Elements should match the expected âmolâ input for the class (paths, CIDs, strings, etc.).
n_cols (int, optional) â Number of columns in the grid (default: 3).
titles (list of str, optional) â Custom labels for each cell. If None, the string representation of the âmolâ input is used as the title.
**kwargs (dict) â Additional arguments passed to the molView constructor: - source : {âfileâ, âmolâ, âcifâ, âcidâ, ârscbâ, âaseâ} - style : {âbsâ, âcpkâ, âcartoonâ} - displayHbonds : plots hydrogen bonds (default: True) - w : width of each individual viewer in pixels (default: 300) - h : height of each individual viewer in pixels (default: 300) - supercell : tuple (na, nb, nc) for crystal structures - cpk_scale : scaling factor for space-filling spheres
- Returns:
A widget object containing the grid of molecular viewers.
- Return type:
ipywidgets.GridspecLayout
Examples
>>> files = ["mol1.xyz", "mol2.xyz", "mol3.xyz", "mol4.xyz"] >>> labels = ["Reactant", "TS", "Intermediate", "Product"] >>> molView.view_grid(files, n_cols=2, titles=labels, source='file', w=400)
pyphyschemtools.ML moduleï
- pyphyschemtools.ML.categorizeY_2ohe(Ctot, y1, y2)ï
one-hot-encodes a pandas column of categorical data
input: - Ctot is the reference pandas column, necessary to find all unique categories in this column - y1 and y2 are the actual pandas column that will be categorized. y1 and y2 are supposed to be the ytest and ytrain subsets of Ctot output: - y1ohe and y2ohe are the numpy arrays returned by this routine
- pyphyschemtools.ML.y2c(mc2i, y)ï
pyphyschemtools.PeriodicTable moduleï
- class pyphyschemtools.PeriodicTable.TableauPeriodiqueï
Bases:
objectClasse permettant de manipuler et dâafficher les donnĂ©es du tableau pĂ©riodique.
Cette classe utilise la bibliothĂšque âmendeleevâ pour rĂ©cupĂ©rer les donnĂ©es chimiques et âbokehâ pour la visualisation interactive. Elle francise les noms et corrige certaines classifications de familles chimiques.
Initialise lâobjet TableauPeriodique en chargeant les donnĂ©es de la bibliothĂšque mendeleev.
- afficher()ï
GénÚre et affiche le tableau périodique interactif dans un notebook Jupyter.
Le tableau permet de visualiser les propriétés au survol de la souris.
- nomsFr = ['HydrogĂšne', 'HĂ©lium', 'Lithium', 'BĂ©ryllium', 'Bore', 'Carbone', 'Azote', 'OxygĂšne', 'Fluor', 'NĂ©on', 'Sodium', 'MagnĂ©sium', 'Aluminium', 'Silicium', 'Phosphore', 'Soufre', 'Chlore', 'Argon', 'Potassium', 'Calcium', 'Scandium', 'Titane', 'Vanadium', 'Chrome', 'ManganĂšse', 'Fer', 'Cobalt', 'Nickel', 'Cuivre', 'Zinc', 'Gallium', 'Germanium', 'Arsenic', 'SĂ©lĂ©nium', 'Brome', 'Krypton', 'Rubidium', 'Strontium', 'Yttrium', 'Zirconium', 'Niobium', 'MolybdĂšne', 'TechnĂ©tium', 'RuthĂ©nium', 'Rhodium', 'Palladium', 'Argent', 'Cadmium', 'Indium', 'Ătain', 'Antimoine', 'Tellure', 'Iode', 'XĂ©non', 'CĂ©sium', 'Baryum', 'Lanthane', 'CĂ©rium', 'PrasĂ©odyme', 'NĂ©odyme', 'PromĂ©thium', 'Samarium', 'Europium', 'Gadolinium', 'Terbium', 'Dysprosium', 'Holmium', 'Erbium', 'Thulium', 'Ytterbium', 'Lutetium', 'Hafnium', 'Tantale', 'TungstĂšne', 'RhĂ©nium', 'Osmium', 'Iridium', 'Platine', 'Or', 'Mercure', 'Thallium', 'Plomb', 'Bismuth', 'Polonium', 'Astate', 'Radon', 'Francium', 'Radium', 'Actinium', 'Thorium', 'Protactinium', 'Uranium', 'Neptunium', 'Plutonium', 'Americium', 'Curium', 'Berkelium', 'Californium', 'Einsteinium', 'Fermium', 'Mendelevium', 'Nobelium', 'Lawrencium', 'Rutherfordium', 'Dubnium', 'Seaborgium', 'Bohrium', 'Hassium', 'Meitnerium', 'Darmstadtium', 'Roentgenium', 'Copernicium', 'Nihonium', 'Flerovium', 'Moscovium', 'Livermorium', 'Tennesse', 'Oganesson']ï
- patch_elements()ï
Ce patch, appliquĂ© Ă self.elements, créé par lâappel Ă create_vis_dataframe(), va servir Ă : - ajouter des informations en français : les noms des Ă©lĂ©ments et des sĂ©ries (familles) auxquelles ils appartiennent - retirer les Ă©lĂ©ments du groupe 12 de la famille des mĂ©taux de transition, qui est le choix CONTESTABLE par dĂ©faut de la bibliothĂšque mendeleev
input : elements est un dataframe pandas préalablement créé par la fonction create_vis_dataframe() de mendeleev.vis
output : elements avec deux nouvelles colonnes name_seriesFr et nom, qui contient dorĂ©navant les noms des Ă©lĂ©ments en français + correction des donnĂ©es name_series et series_id pour les Ă©lĂ©ments Zn, Cd, Hg, Cn + de nouvelles colonnes qui contiennent lâĂ©nergie de premiĂšre ionisation et les isotopes naturels
- prop(elt_id)ï
Affiche les propriĂ©tĂ©s dĂ©taillĂ©es dâun Ă©lĂ©ment chimique.
- Parameters:
elt_id (str ou int) â Symbole de lâĂ©lĂ©ment (ex: âOâ) ou numĂ©ro atomique (ex: 8).
- trad = {'Actinides': 'Actinide', 'Alkali metals': 'MĂ©tal alcalin', 'Alkaline earth metals': 'MĂ©tal alcalino-terreux', 'Halogens': 'HalogĂšne', 'Lanthanides': 'Lanthanide', 'Metalloids': 'MĂ©talloĂŻde', 'Metals': 'MĂ©tal', 'Noble gases': 'Gaz noble', 'Nonmetals': 'Non mĂ©tal', 'Poor metals': 'MĂ©tal pauvre', 'Transition metals': 'MĂ©tal de transition'}ï
pyphyschemtools.aithermo moduleï
- class pyphyschemtools.aithermo.aiThermo(folder_path=None, color_scales=None)ï
Bases:
objectA class to handle thermodynamic surface stability analysis and visualization within the tools4pyPhysChem framework. Initialize the aiThermo object.
- Parameters:
folder_path (str or Path) â Path to the working directory.
color_scales (list, optional) â List of plotly-compatible color scales.
- ListOfStableSurfaceCompositions(vib)ï
Identify and list the relevant thermodynamic data files for the current analysis.
This method scans the working directory for data files matching specific naming conventions (TPcoverage or TPcoveragevib). It cross-references these with a local configuration file âListOfStableSurfaces.datâ to extract surface names and legend labels.
- Parameters:
vib (bool) â If True, filters for files including vibrational corrections (prefixed with
vib_). If False, looks for standard thermodynamic data.- Returns:
A triplet containing: - file_paths (list of str): Absolute or relative paths to the .dat files. - names (list of str): Internal identifiers for each surface phase. - legends (list of str): LaTeX-formatted or plain text labels for graphical legends.
- Return type:
tuple
Notes
The lists are returned in reverse order to ensure correct layering during 3D plotting.
Relies on âListOfStableSurfaces.datâ existing in the folder_path.
- plot_palette(angle=0, save_png=None)ï
Visualize the 1D color palette used for surface identification.
This method generates a horizontal bar of colors corresponding to the different surface phases defined in the instance. Each color is labeled with its numerical index, allowing for quick cross-referencing between the palette and the 3D surface plot.
- Parameters:
angle (int, optional) â Rotation angle of the x-axis tick labels (indices). Defaults to 0.
save_png (str, optional) â Filename (including .png extension) to save the palette image to the working directory. Defaults to None (display only).
- Returns:
Displays the plot using matplotlib.pyplot.show().
- Return type:
None
Notes
Requires âseabornâ for the palplot generation.
If âsave_pngâ is provided, the image is saved with a resolution of 300 DPI and a transparent background.
- plot_surface(saveFig=None, vib=True, texLegend=False, xLegend=0.5, yLegend=0.4)ï
Generate an interactive 3D thermodynamic stability map using Plotly.
This method visualizes multiple Gibbs free energy surfaces as a function of Temperature (X) and Pressure (Y). It automatically handles log-scale transformations for the pressure axis and projects reference experimental conditions and phase boundaries onto the plot.
- Parameters:
saveFig (str, optional) â The filename (without extension) to export the resulting plot as a PNG image. Defaults to None (no save).
vib (bool) â Whether to use vibration-corrected data. Defaults to True.
texLegend (bool) â If True, uses LaTeX legends extracted from the configuration file. Defaults to False.
xLegend (float) â Horizontal position of the legend box (0 to 1). Defaults to 0.5.
yLegend (float) â Vertical position of the legend box (0 to 1). Defaults to 0.4.
- Returns:
- An interactive widget containing
the 3D surfaces, experimental markers, and reference lines.
- Return type:
plotly.graph_objects.FigureWidget
- Workflow:
Scans data files and parses Temperature/Pressure/Energy grids.
Traces individual 3D surfaces with mapped color scales.
Calculates and plots intersection boundaries between surface phases.
Overlays experimental markers (e.g., specific T/P conditions).
Optionally exports and crops the resulting image using Pillow.
pyphyschemtools.cheminformatics moduleï
- class pyphyschemtools.cheminformatics.easy_rdkit(smiles, canonical=True, lang='En')ï
Bases:
objectA helper class to analyze and visualize molecules using RDKit. Provides tools for Lewis structure analysis and advanced 2D drawing. Initialize the molecule object from a SMILES string.
- Parameters:
smiles (str) â The SMILES representation of the molecule.
canonical (bool) â If True, converts the SMILES to its canonical form to ensure consistent atom numbering and uniqueness.
lang (str) â Language for headers and messages of the Lewis analyzis(âEnâ (default) or âFrâ).
- analyze_lewis()ï
Performs a Lewis structure analysis for each atom in the molecule. Calculates valence electrons, lone pairs, formal charges, and octet rule compliance.
- Returns:
A table containing detailed Lewis electronic data per atom.
- Return type:
pd.DataFrame
- property descriptorsï
Compute and return a dictionary of key molecular descriptors.
- fetch_pubchem_data()ï
Retrieves CID and IUPAC name from PubChem based on the current SMILES. Useful for molecules initialized directly via SMILES.
- classmethod from_cid(cid)ï
Create an easy_rdkit instance directly from a PubChem CID.
Parameters:ï
- cidint or str
The PubChem Compound ID.
- static plot_grid_from_df(df, smiles_col='SMILES', legend_cols='IUPAC Name', mols_per_row=4, size=(250, 250), save_img=None)ï
Generates a grid image of molecular structures from a pandas DataFrame.
This method extracts SMILES strings from the specified column, generates 2D representations, and arranges them in a grid. It supports multi-line legends by passing a list of column names, and can export the result to external files.
- Parameters:
df (pd.DataFrame) â DataFrame containing the molecular data.
smiles_col (str) â Name of the column containing SMILES strings. Defaults to âSMILESâ.
legend_cols (str or list) â Column name(s) to display as legends below each molecule. If a list is provided, each value is displayed on a new line (e.g., [âIUPAC Nameâ, âMWâ, âLogPâ]). Defaults to âIUPAC Nameâ.
mols_per_row (int) â Number of molecules to display in each row. Defaults to 4.
size (tuple) â Dimensions (width, height) in pixels for each individual molecule panel. Defaults to (250, 250).
save_img (str, optional) â File path to save the resulting image. Supports â.svgâ (vector) and â.pngâ (raster) extensions. Defaults to None.
- Returns:
An SVG object for rich display in Jupyter/Colab environments.
- Return type:
IPython.display.SVG
Note
PNG export requires the Cairo backend to be available in the RDKit installation.
- show_descriptors()ï
Print all computed descriptors in a formatted table.
- show_mol(size: tuple = (400, 400), show_Lewis: bool = False, plot_conjugation: bool = False, plot_aromatic: bool = False, show_n: bool = False, show_hybrid: bool = False, show_H: bool = False, rep3D: bool = False, macrocycle: bool = False, highlightAtoms: list = [], legend: str = '')ï
Renders the molecule in 2D SVG format with optional property overlays.
- Parameters:
size (tuple) â Drawing dimensions in pixels.
show_Lewis (bool) â Annotates atoms with Lone Pairs and Vacancies.
plot_conjugation (bool) â Highlights conjugated bonds in blue.
plot_aromatic (bool) â Highlights aromatic rings in red.
show_n (bool) â Displays atom indices.
show_hybrid (bool) â Displays atom hybridization (sp3, sp2, etc.).
show_H (bool) â Adds explicit Hydrogens to the drawing.
rep3D (bool) â Computes a 3D-like conformation before drawing.
macrocycle (bool) â Uses CoordGen for better rendering of large rings (e.g., Cyclodextrins).
highlightAtoms (list) â List of indices to highlight.
legend (str) â Title or legend text for the drawing.
- to_dict(auto_fetch=False)ï
Export identity and descriptors as a flat dictionary. If auto_fetch is True, it will attempt to find missing CID/Name on PubChem.
pyphyschemtools.core moduleï
- pyphyschemtools.core.centerTitle(content=None)ï
centers and renders as HTML a text in the notebook font size = 16px, background color = dark grey, foreground color = white
- pyphyschemtools.core.centertxt(content=None, font='sans', size=12, weight='normal', bgc='#000000', fgc='#ffffff')ï
centers and renders as HTML a text in the notebook
input: - content = the text to render (default: None) - font = font family (default: âsansâ, values allowed = âsans-serifâ | âserifâ | âmonospaceâ | âcursiveâ | âfantasyâ | âŠ) - size = font size (default: 12) - weight = font weight (default: ânormalâ, values allowed = ânormalâ | âboldâ | âbolderâ | âlighterâ | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 ) - bgc = background color (name or hex code, default = â#ffffffâ) - fgc = foreground color (name or hex code, default = â#000000â)
- pyphyschemtools.core.crop_images(input_files, process_folder=False)ï
Trims whitespace or transparency from image files and saves the results.
If process_folder is True, input_files is treated as a directory path, and all images within (excluding those ending in -C) are processed. Otherwise, input_files is treated as a single file path or a list of paths.
The function preserves original image metadata (DPI, ICC profiles).
- Parameters:
input_files (str, Path, or list) â File path(s) or a directory path.
process_folder (bool) â If True, treats input_files as a directory to crawl.
- Returns:
Prints status messages to the console for each file processed.
- Return type:
None
- pyphyschemtools.core.save_data(df, path_with_name: str, **kwargs)ï
Saves a Pandas DataFrame to CSV or Excel, automatically creating missing directories.
- Parameters:
df (pd.DataFrame) â The DataFrame to save.
path_with_name (str) â The path and filename (e.g., âdata/results.csvâ).
**kwargs â Additional arguments passed to to_csv or to_excel (e.g., index=True).
- pyphyschemtools.core.save_fig(path_with_name: str, fig=None, dpi: int = 300, **kwargs)ï
Saves a figure to a path, automatically creating missing directories. Works with the current plt or a specific figure object.
- Parameters:
path_with_name (str) â The path and filename (e.g., âresults/plots/energy.svgâ).
fig (matplotlib.figure.Figure, optional) â A specific figure object. If None, uses plt.gcf().
dpi (int) â Resolution for raster formats. Defaults to 300.
**kwargs â Additional arguments passed to savefig (e.g., transparent=True).
- pyphyschemtools.core.smart_trim(img)ï
Determines the bounding box of the meaningful content in an image.
This function automatically detects if the image has transparency (Alpha channel). If it does, it calculates the bounding box based on non-transparent pixels. If the image is opaque, it assumes a white background and calculates the bounding box by detecting differences from a pure white canvas.
- Parameters:
img (PIL.Image.Image) â The source image object.
- Returns:
- A 4-tuple (left, upper, right, lower) defining the crop box,
or None if the image is uniform/empty.
- Return type:
tuple
pyphyschemtools.kinetics moduleï
- class pyphyschemtools.kinetics.KORD(t_exp=None, G_exp=None, headers=('Time / s', 'G'), a0=1.0, alpha=1.0, beta=1.0, k_guess=None, G_0_guess=None, G_inf_guess=None, b_inf_guess=None, t_simul_max=15, verbose=True)ï
Bases:
objectInitialize the kinetic study with experimental data. Reaction: alpha A = beta B
- Parameters:
t_exp (-) â Time values.
G_exp (-) â Measured physical quantity (Absorbance, Conductivity, etc.).
- Fixed Parameters:
alpha (float): Stoichiometric coefficient for A reactant (smallest positive integer). Default is 1.0.
beta (float): Stoichiometric coefficient for B product (smallest positive integer). Default is 1.0.
a0 (float): Initial concentration. Note: G_theo is independent of a0 for Order 1. Default is 1.0.
- Adjustable Variables (Initial Guesses):
k_guess (float, optional): Initial estimate for the rate constant. Default is 0.01.
G_0_guess (float, optional): Initial estimate for the initial measured value (G at t=0). if None, it will be initialized as G_exp[0]
G_inf_guess (float, optional): Initial estimate for the final measured value (G at infinity). if None, it will be initialized as G_exp[-1]
b_inf_guess (float, optional): Initial estimate for the final concentration of B ([B] at infinity). if None, it will be initialized as [A](t=0), i.e. a0
- Other Args:
t_simul_max (float): the maximum time duration for theoretical simulations. It defines the range of the time vector [0, t_simul_max}] used to simulate and plot kinetic curves with simulate_plot
verbose (bool): If True defaulk), enables detailed optimization logs (recommended).
headers (tuple of strings): headers of the t_exp and G_exp arrays read in the excel file
- G0_theo(t, k, G0, Ginf, binf)ï
Model for Order 0 kinetics
- G1_theo(t, k, G0, Ginf)ï
Model for Order 1 kinetics
- G2_theo(t, k, G0, Ginf, binf)ï
Model for Order 2 kinetics
- concentrations(order, t, binf, k)ï
Calculate the time-dependent concentrations of reactant A and product B.
This method derives the initial concentration (a0) from the fitted final product concentration (binf) using the stoichiometric ratio alpha/beta. It then computes the concentration profiles based on the integrated rate laws for the specified kinetic order.
- Parameters:
order (int) â Kinetic order (0, 1, or 2).
t (array-like) â Time vector for the calculation.
binf (float) â Final concentration of product B at t=infinity.
k (float) â Rate constant.
- Returns:
- (a, b) where âaâ is the concentration array of reactant A
and âbâ is the concentration array of product B.
- Return type:
tuple
Notes
Order 0: Linear decay/formation until reactant exhaustion.
Order 1: Exponential decay/formation.
Order 2: Hyperbolic progression based on the 1/[A] linear relationship.
- fit(k_guess, G_0_guess, G_inf_guess, A_0_guess, order=1)ï
Fits the selected kinetic model (Order 0, 1, or 2) to the experimental data.
This method uses non-linear least squares (scipy.optimize.curve_fit) to simultaneously optimize the rate constant (k), the initial and final physical property values (G0, Ginf), and the final product concentration (binf). Physical constraints are applied via parameter bounds to ensure k and binf remain positive.
It includes automated âSmart Guessingâ for k, based on initial rates and computes information criteria (AIC/BIC) for model selection.
- Parameters:
k_guess (float) â Initial estimate for the rate constant (k).
G_0_guess (float) â Initial estimate for the physical property at t=0.
G_inf_guess (float) â Initial estimate for the physical property at t=infinity.
b_inf_guess (float) â Initial estimate for the final product concentration [B].
order (int, optional) â Kinetic order of the reaction (0, 1, or 2). Defaults to 1.
- Returns:
- A dictionary containing the optimized parameters (âkâ, âG0â, âGinfâ, âbinfâ)
and statistical metrics (âRMSEâ, âR2â, ât_halfâ). Returns None if optimization fails to converge.
- Return type:
dict
Notes
For Order 1, the timing is independent of binf, and alpha is coupled with k; hence binf is kept fixed during optimization.
For Orders 0 and 2, binf and stoichiometry (alpha, beta) explicitly define the reactionâs capacity and end-point timing, ensuring physical consistency between the plateau and the slope.
- get_best_order(verbose=True)ï
Determines and prints the best model based on the lowest RMSE.
- halflife(order, binf, k)ï
Calculate the half-life (t1/2) for the reaction based on the kinetic order.
The half-life represents the time required for the reactant concentration to reach half of its initial value (a0/2).
- Parameters:
order (int) â Kinetic order (0, 1, or 2).
k (float) â The optimized or guessed rate constant.
- Returns:
The calculated half-life value.
- Return type:
float
Notes
Order 0: t1/2 = a0 / (2 * alpha * k) -> Dependent on a0.
Order 1: t1/2 = ln(2) / (alpha * k) -> Independent of a0.
Order 2: t1/2 = 1 / (alpha * k * a0) -> Inversely proportional to a0.
- static load_from_excel(file_path, exp_number, sheet_name=0, show_data=True)ï
Static method to extract data from an Excel file. Selects the pair of columns (t, G) corresponding to the experiment number. Also loads parameters (a0, alpha, beta)
- Format:
Row 1: Headers for t and G
Row 2: [A]0 value (in the G column)
Row 3: alpha value (in the G column)
Row 4: beta value (in the G column)
Row 5+: [t, G] data points
- plot_all_fits(save_img=None)ï
Plots experimental data and all three kinetic models for visual comparison. If save_img is provided, saves the plot (png, svg, jpg, pdf according to the extension). Vectorial svg is recommended
- simulate_plot(save_img=None)ï
Plots the initial guesses for all three kinetic orders (0, 1, 2), for example to visualize the starting point of a fit.
If save_img is provided, saves the plot (png, svg, jpg, pdf according to the extension). Vectorial svg is recommended
pyphyschemtools.spectra moduleï
- class pyphyschemtools.spectra.SpectrumSimulator(sigma_ev=0.3, plotWH=(12, 8), fontSize_axisText=14, fontSize_axisLabels=14, fontSize_legends=12, fontsize_peaks=12, colorS='#3e89be', colorVT='#469cd6')ï
Bases:
objectInitializes the spectrum simulator
- Parameters:
sigma_ev (-) â Gaussian half-width at half-maximum in electron-volts (eV). Default is 0.3 eV (GaussView default is 0.4 eV).
plotWH (-) â Width and Height of the matplotlib figures in inches. Default is (12,8).
colorS (-) â color of the simulated spectrum (default =â#3e89beâ)
colorVT (-) â color of the vertical transition line (default = â#469cd6â)
- Returns:
This method initializes the instance attributes.
- Return type:
None
- Calculates:
sigmanm = half-width of the Gaussian band, in nm
- plotAbs_lambda_TDDFT(datFiles=None, C0=1e-05, lambdamin=200, lambdamax=800, Amax=2.0, titles=None, linestyles=[], annotateP=[], tP=0.1, resetColors=False, save_img=None)ï
Plots a simulated TDDFT VUV absorbance spectrum (transitions summed with gaussian functions) between lambdamin and lambdamax (sum of states done in the range [lambdamin-50, lambdamlax+50] nm)
- Parameters:
datFiles â list of pathway/name to files generated by âGParser Gaussian.log -Sâ
C0 â list of concentrations needed to calculate A = epsilon x l x c (in mol.L-1)
lambdamin â plot range (x axis)
lambdamax â plot range (x axis)
Amax â y axis graph limit
titles â list of titles (1 per spectrum plot)
linestyles â list of line styles(default = â-â, i.e. a continuous line)
annotateP â list of Boolean (annotate lambda max True or False. Default = True)
tP â threshold for finding the peaks (default = 0.1)
resetColors (bool) â If True, resets the matplotlib color cycle to the first color. This allows different series (e.g., gas phase vs. solvent) to share the same color coding for each molecule across multiple calls. Default: False
save â saves in a png file (300 dpi) if True (default = False)
save_img â saves figure in a 300 dpi png file if not None (default), with save_img=full pathway
- plotAbs_lambda_exp(csvFiles, C0, lambdamin=200, lambdamax=800, Amax=2.0, titles=None, linestyles=[], annotateP=[], tP=0.1, save_img=None)ï
Plots an experimental VUV absorbance spectrum read from a csv file between lambdamin and lambdamax
- Parameters:
superpose (-) â False = plots a new graph, otherwise the plot is superposed to a previously created one (probably with plotAbs_lambda_TDDFT())
csvfiles (-) â list of pathway/name to experimental csvFiles (see examples for the format)
C0 (-) â list of experimental concentrations, i.e. for each sample
lambdamin (-) â plot range (x axis)
lambdamax â plot range (x axis)
Amax (-) â graph limit (y axis)
titles (-) â list of titles (1 per spectrum plot)
linestyles (-) â list of line styles(default = âââ, i.e. a dashed line)
annotateP (-) â list of Boolean (annotate lambda max True or False. Default = True)
tP (-) â threshold for finding the peaks (default = 0.1)
save (-) â saves in a png file (300 dpi) if True (default = False)
save_img (-) â saves figure in a 300 dpi png file if not None (default), with save_img=full pathway
- plotEps_lambda_TDDFT(datFile, lambdamin=200, lambdamax=800, epsMax=None, titles=None, tP=10, ylog=False, save_img=None)ï
Plots a TDDFT VUV simulated spectrum (vertical transitions and transitions summed with gaussian functions) between lambdamin and lambdamax
The sum of states is done in the range [lambdamin-50, lambdamax+50] nm.
- Parameters:
datFile â list of pathway/names to âXXX_ExcStab.datâ files generated by âGParser Gaussian.log -Sâ
lambdamin â plot range
lambdamax â plot range
epsMax â y axis graph limit
titles â list of titles (1 per spectrum plot)
tP â threshold for finding the peaks (default = 10 L. mol-1 cm-1)
ylog â y logarithmic axis (default: False).
save â saves in a png file (300 dpi) if True (default = False)
save_img â saves figure in a 300 dpi png file if not None (default), with save_img=full pathway
- plotTDDFTSpectrum(wavel, sumInt, wavelTAB, feTAB, tP, ylog, labelSpectrum, colorS='#0000ff', colorT='#0000cf')ï
Called by plotEps_lambda_TDDFT. Plots a single simulated UV-Vis spectrum, i.e. after gaussian broadening, together with the TDDFT vertical transitions (i.e. plotted as lines)
- Parameters:
wavel â array of gaussian-broadened wavelengths, in nm
sumInt â corresponding molar absorptiopn coefficients, in L. mol-1 cm-1
wavelTAB â wavelength of TDDFT, e.g. discretized, transitions
ylog â log plot of epsilon
tP â threshold for finding the peaks
feTAB â TDDFT oscillator strength for each transition of wavelTAB
labelSpectrum â title for the spectrum
pyphyschemtools.survey moduleï
- class pyphyschemtools.survey.SurveyApp(mode='participant', base_dir='ML-survey')ï
Bases:
object- analyze_text_columns(df=None, columns=None, top_n=20)ï
Basic textual analysis: show frequent words, word clouds, and per-question summary.
- build_admin_dashboard()ï
- build_participant_form()ï
- enable_slider_css()ï
Inject CSS for hover/active color effects on sliders.
- get_or_create_user_id()ï
Return a persistent anonymous ID (stored in .survey_id).
- list_drafts()ï
- load_all_responses()ï
Load and merge all .csv survey responses into a DataFrame.
- load_draft(b)ï
- load_questions()ï
- plot_spider_multi(df, title='Participant and Mean Scores per Block', savepath=None, figsize=(12, 8))ï
Draw radar (spider) chart with per-participant transparency and block names instead of AâF.
- print_questions_summary()ï
Affiche la liste des questions par bloc et leur type (Numérique/Texte).
- run()ï
- save_draft(b)ï
- semantic_analysis(df=None, columns=None, n_clusters=3)ï
Perform semantic clustering on open-ended responses using sentence-transformers.
- submit_form(b)ï
- summarize_by_block(df)ï
Compute average score per block (AâF) for numeric questions.
pyphyschemtools.sympyUtilities moduleï
- pyphyschemtools.sympyUtilities.PrintLatexStyleSymPyEquation(spe)ï
Function that displays a SymPy expression (spe) in a jupyter notebbok after its conversion into a LaTeX / Math output
Input: spe= SymPy expression
Output: Pretty printing of spe
- pyphyschemtools.sympyUtilities.e2Lists(eigenvectors, sort=False)ï
returns two separate lists from the list of tuples returned by the eigenvects() function of SymPy
input: - the list of tuples returned by eigenvects - sort (default: False): returns sorted eigenvalues and corresponding eigenvectors if True
output - list of eigenvalues, sorted or not - list of corresponding eigenvectors
pyphyschemtools.units moduleï
- class pyphyschemtools.units.Energy(value, unit='J')ï
Bases:
objectAn advanced utility class for Energy management in Physical Chemistry.
This class handles the conversion between standard energy units (J, eV), thermal energy (K), and spectroscopic units (wavelengths in m/nm/Ă or wavenumbers in cm-1).
Features: - Supports scalar values and NumPy arrays. - Automatic handling of SI prefixes (milli, micro, kilo, etc.). - Seamless conversion between energy (E) and wavelength (lambda) using E = hc/lambda. - Support for reciprocal space units (unit-1) and molar units (unit/mol). - Integrated error guidance for users
Accessing numerical values: - Use float(obj) to get the scalar value. - Use obj.value to get the NumPy array.
- classmethod list_prefixes()ï
- classmethod list_units()ï
- classmethod parse(query)ï
Parses strings like â13.6 eVâ or â500 nmâ.
- classmethod show_available_tools()ï
Displays available units and prefixes as styled DataFrames.
- classmethod show_constants_metadata()ï
Displays a styled table of the physical constants used for calculations, including their current CODATA values, units, and uncertainties.
- to(target)ï
Converts the current Energy instance to a target unit.
- Parameters:
target (str) â Target unit string. Examples: - Any SI prefix + âJâ, âeVâ, âcalâ, or âmâ (e.g., âfJâ, âPeVâ, âymâ, âdamâ) - Molar versions (e.g., âMJ/molâ, âueV/molâ, âncal/molâ) - Reciprocal versions (e.g., âcm-1â, âpm-1â, âam-1â) - Special units: âKâ, âhartreeâ, âĂ â, âĂ -1â
Example
>>> e = Energy(500, 'nm') >>> e.to('eV') 2.4798 eV
pyphyschemtools.misc moduleï
- class pyphyschemtools.misc.QRCodeGenerator(box_size=40, border=1, version=4)ï
Bases:
objectA utility class to generate QR codes with embedded logos for pyphyschemtools. Initialize the generator with specific QR parameters.
- Parameters:
box_size (int) â The size of each box in the QR code grid.
border (int) â The thickness of the white border.
version (int) â The complexity of the QR code (1 to 40).
- generate(url, logo_path, fill_color='#1a525f', back_color='white', save_path=None, logo_ratio=4, width=250, flatten=False)ï
Creates a QR code with a centered logo, saves it to disk, and displays it.
If save_path is not provided, the image is saved in the logoâs directory with a
qrcode_prefix.- Parameters:
url (str) â The target URL for the QR code.
logo_path (str) â Path to the logo image file.
fill_color (str) â Hex code or name for the QR code color.
back_color (str) â Background color.
save_path (str, optional) â Custom path to save the PNG. Defaults to None.
logo_ratio (float) â Ratio of logo size relative to QR code size (default 1/4).
width (int) â Display width for Jupyter Notebook rendering.
flatten (bool) â If True, removes transparency by placing the logo on a solid white background. Defaults to False.
- Returns:
The generated QR code image object.
- Return type:
PIL.Image
pyphyschemtools.tools4AS moduleï
- pyphyschemtools.tools4AS.ApplySecondeChance(df, nomCC, nomCCSC, nomCCdelaSC)ï
modification du dataframe df
- entrée :
df = dataframe auquel on va ajouter une nouvelle colonne nomCCSC qui va contenir la note de la colonne nomCC soit celle de la colonne nomCCdelaSC, si cell-ci est supérieure à la notede nomCC
nomCC = nom de la colonne Ă laquelle on applique la seconde chance
nomCCSC = nom de la nouvelle colonne qui contient la note du CC aprĂšs application de la seconde chance
nomCCdelaSC = nom de la colonne qui contient la note âseconde chance
- sortie :
moyenne aprĂšs application de la seconde chance
écart-type aprÚs application de la seconde chance
- pyphyschemtools.tools4AS.BoiteAMoustachesByMentionEtParcours(df, Moyenne, Mention, Parcours, NomGraphique)ï
- pyphyschemtools.tools4AS.BoiteAMoustachesByMentionEtParcoursHue(df, Moyenne, Mention, Parcours, NomGraphique)ï
- pyphyschemtools.tools4AS.ComparaisonMoyennesDMCC(df, nomCC1, nomCC2, SeuilBadDMCC1, SeuilGoodDMCC1)ï
- entrée :
df = dataframe avec uniquement les Ă©tudiants AJ ou ADM, câest-Ă -dire quâil nây a aucun fantĂŽme
nomCC1 = en-tĂȘte de la colonne de df qui contient la note du premier CC
nomCC2 = en-tĂȘte de la colonne de df qui contient la note du 2nd CC
SeuilBadDMCC1 = Seuil en-dessous duquel la note au nomCC1 est considérée comme médiocre
SeuilGoodDMCC1 = Seuil au-deçà duquel la note au nomCC1 est considérée comme bonne
- affichage :
- moyenne au nomCC2 de la cohorte dâĂ©tudiant(e)s
en-dessous du SeuilBadDMCC1 au nomCC1
au-dessus du SeuilGoodDMCC1 au nomCC1
entre les deux seuils au nomCC1
jointplot entre nomCC1 et nomCC2 uniquement pour les étudiant(e)s dont la note au CC1 est considérée comme médiocre
- pyphyschemtools.tools4AS.CreationDfADMAJGH(df, note, Seuil, prefix, MD, Parc, IDApoG)ï
- entrée :
df = dataframe avec les mentions/parcours/moyennes
note = nom de la colonne qui contient la moyenne globale
Seuil = seuil de réussite pour départager ADM & AJ
prefix = prĂ©fixe du nom de fichier temporaire, incluant ou nom le nom dâun sous-rĂ©pertoire de sauvegarde
MD = nom de la colonne qui contient la dĂ©nomination simplifiĂ©e de la mention de diplĂŽme (âMentionDâ)
Parc = nom de la colonne qui contient le parcours
IDApoG = nom de la colonne qui contient lâID des Ă©tudiants
- sortie :
dfADM = dataframe des admis
dfAJ = dataframe des ajournés
dfGhosts = dataframe des fantĂŽmes (aka Ghosts ; i.e. nâont passĂ© aucun des CC)
affichage : stats rapides (describe & sum) de chacun des sous-ensembles ADM, AJ, Ghosts
sauvegarde : fichier excel tmp{Note}.xlsx avec 3 onglets (ADM, AJ, Ghosts)
- pyphyschemtools.tools4AS.Histogrammes(df, nomCC, Moyenne, NomGraphique, w, moy, std, moyT, stdT, legende)ï
- entrée :
df = dataframe qui contient ID, Noms, Prénoms, notes de CC, et Moyenne pondérée
nomCC = liste qui contient noms dâen-tĂȘtes des colonnes qui contiennent les notes de CC
Moyenne = nom de lâen-tĂȘte de la colonne qui contient la moyenne
NomGraphique = nom du fichier png qui va contenir la figure
w = liste qui contient les coeffs des CC
moy = liste qui contient la moyenne de chaque CC
std = liste qui contient lâĂ©cart-type calculĂ© pour chaque CC
moyT = moyenne des 4 CC
stdT = écart-type calculé pour la note globale
legende = titre qui sera affichĂ© sur lâhistogramme principal
- affichage :
1 petit histogramme /CC
1 grand histogramme avec la moyenne
- sauvegarde :
fichier graphique âNomGraphiqueâ avec 1 petit histogramme par CC + 1 grand histogramme avec la moyenne
- pyphyschemtools.tools4AS.MentionAuModule(note, Seuil)ï
- entrée :
note = valeur numérique ou NaN
Seuil = seuil de réussite
- sortie :
m = mention au module (AJ, P, AB, B, TB ou PB!! dans le cas oĂč la colonne contiendrait une valeur numĂ©rique non comprise entre 0 et 20, ou bien toute autre contenu (caractĂšres etc)
- pyphyschemtools.tools4AS.RenameDfHeader(dfCC, dfCCname, labelNoteCC, nomCC)ï
- entrée :
dfCC = dataframe dont 1 colonne contient les notes de CC
dfCCname = nom (string) du dataframe. Il est recommandĂ© dâutiliser fâ{dfCC=}â.split(â=â)[0]
labelNoteCC = label de la colonne qui contient les notes
nomCC = label de lâĂ©preuve de CC (ex CC1), utilisĂ© pour lâaffichage
sortie : aucune
la fonction change le nom âlabelNoteCCâ en ânomCCâ
- pyphyschemtools.tools4AS.ReplaceABSByNan(df, nomCC)ï
- entrée :
dataframe qui contient les notes
nom des colonnes qui contiennent les notes
- sortie
nouveau dataframe oĂč toutes les notes des colonnes nomCC = ABS sont remplacĂ©es par des nan
- pyphyschemtools.tools4AS.ReplaceNanBy0(df, nomCC)ï
- pyphyschemtools.tools4AS.ReplaceNanBy0OLD(df, nomCC)ï
- entrée :
df = dataframe avec les notes
nomCC = liste des en-tĂȘtes de colonnes qui contiennt les notes
- sortie :
le dataframe avec Nan remplacé par 0 pour chaque étudiant qui a au moins une note de CC
- pyphyschemtools.tools4AS.StackedBarPop(df, ListCols, ylabel, NomGraphique)ï
- entrée :
df : dataframe contenant lâanalyse statistique globale, dont les moyennes, effectifs, etc. i.e. le dataframe renvoyĂ© par StatsRĂ©ussiteParMentionOuParcours()
ListCols = liste avecles labels des colonnes contenant les valeurs numĂ©riques quâon veut tracer comme un histogramme empilĂ©
ylabel = label de lâaxe des y
NomGraphique = nom du fichier png qui va ĂȘtre sauvĂ©
- affichage :
bar plot empilé de pandas
- sauvegarde :
fichier graphique âNomGraphiqueâ au format png
- pyphyschemtools.tools4AS.StackedBarPopPO(dfRef, Mention, Parcours, NomGraphique)ï
- entrée :
dfRef : dataframe contenant la liste des étudiants avec leur Mention et leur otpion, tel que généré par mentionD()
Mention = nom de la colonne qui contient le nom simplifiĂ© dâune Mention
Parcours = nom de la colonne qui contient la version simplifiĂ©e dâun Parcours
NomGraphique = nom du fichier png qui va ĂȘtre sauvĂ©
- affichage :
histplot âhueâ de seaborn, cĂ d les effectifs par Parcours empilĂ©s pour chaque Mention
- sauvegarde :
fichier graphique âNomGraphiqueâ au format png
- pyphyschemtools.tools4AS.StatsRĂ©ussiteParMentionOuParcours(dfT, dfADM, dfAJ, dfGhosts, Category, note)ï
- entrée :
dfT = dataframe qui contient toutes les notes, ainsi quâau moins une catĂ©gorisation (exemple : Mention ou Parcours ou Section etcâŠ)
dfADM = dataframe qui contient uniquement les étudiants admis
dfAJ = dataframe qui contient uniquement les étudiants ajournés (sans les fantÎmes)
dfGhosts = dataframe qui contient la liste des fantĂŽmes
Category = nom de la colonne sur laquelle on veut faire des analyses statistiques
note = nom de la colonne qui contient la note quâon veut analyser par catĂ©gorie (gĂ©nĂ©ralement la moyenne finale)
- sortie :
dfStats
affichage :
- pyphyschemtools.tools4AS.StatsRĂ©ussiteParMentionOuParcoursWithAb(dfT, dfADM, dfAJ, dfGhosts, dfAb, Category, note)ï
- entrée :
dfT = dataframe qui contient toutes les notes, ainsi quâau moins une catĂ©gorisation (exemple : Mention ou Parcours ou Section etcâŠ)
dfADM = dataframe qui contient uniquement les étudiants admis
dfAJ = dataframe qui contient uniquement les étudiants ajournés (sans les fantÎmes)
dfGhosts = dataframe qui contient la liste des fantĂŽmes
dfAb = dataframe qui contient la liste des étudiants qui ont abandonné
Category = nom de la colonne sur laquelle on veut faire des analyses statistiques
note = nom de la colonne qui contient la note quâon veut analyser par catĂ©gorie (gĂ©nĂ©ralement la moyenne finale)
- sortie :
dfStats
affichage :
- pyphyschemtools.tools4AS.checkNoID_DuplicateID(df, dfname, ID, nom, NomPrenom)ï
- pyphyschemtools.tools4AS.concat2ApoG(df2Complete, ID_ApoG, dfCC, Col2SaveInCC, IDCC, nomCC)ï
- entrée :
- df2Complete = dataframe Ă complĂ©ter (merge = âleftâ)
au premier appel, ce soit ĂȘtre le fichier de RĂ©fĂ©rence
ensuite câest le fichier de notes lui-mĂȘme, en cours dâupdate
ID_ApoG = label de la colonne qui contient les numéros étudiants dans le fichier de référence
dfCC = dataframe dont 1 colonne contient les notes de CC
Col2SaveInCC = liste avec les en-tĂȘtes de colonnes qui contiennent les colonnes de dfCC Ă reporter dans dfNotes
IDCC = label de la colonne qui contient les numéros étudiants dans le fichier de notes
nomCC = Ă ce stade, câest aussi bien le label de la colonne qui contient les notes que le label de lâĂ©preuve de CC (ex CC1), utilisĂ© pour lâaffichage
- sortie :
le dataframe dfNotes. Contient la version concatĂ©nĂ©e du dataframe dâentrĂ©e df2complete et certaines colonnes du dataframe des notes dfCC ([Col2SaveInCC + IDCC + nomCC])
un dataframe dfnotFoundInRef qui contient la liste des étudiants qui sont dans le fichier de notes et pas dans le fichier de référence
- affichages :
liste des étudiants qui sont dans le fichier de notes et pas dans le fichier de référence
- pyphyschemtools.tools4AS.css_styling()ï
- pyphyschemtools.tools4AS.dropColumnsByIndex(df, idropC)ï
- entrée :
df = dataframe dont on veut supprimer des colonnes
idropC = indices des colonnes dont on veut se débarasser
- sortie :
dfCleaned = dataframe originel dont les colonnes indexées par idropC ont été supprimées
- pyphyschemtools.tools4AS.kdePlotByMentionEtParcours(df, Moyenne, Mention, Parcours, NomGraphique)ï
- entrée :
df = dataframe qui contient ID, Noms, Prénoms, notes de CC, Moyenne pondérée, Mention et Parcours
Mention = nom de lâen-tĂȘte de la colonne qui contient la Mention de diplĂŽme simplifiĂ©e dâun Ă©tudiant
Parcours = nom de lâen-tĂȘte de la colonne qui contient le parcours suivi par un Ă©tudiant
- affichage :
1 graphe avec des plots kde par Mention
1 graphe avec des plots kde par Parcours
- sauvegarde :
fichier graphique âNomGraphiqueâ avec les 2 graphes
- pyphyschemtools.tools4AS.mentionD(row, Mention)ï
- pyphyschemtools.tools4AS.parcours(row, Parcours)ï
- pyphyschemtools.tools4AS.plotTauxADMasBars(dfwoSC, dfwSC, xCol, hueCol, NomGraphique)ï
- entrée :
dfwoSC = dataframe contenant les stats ADM/AJ/Ghosts avant lâapplication de la seconde chance
dfwSC = dataframe contenant les stats ADM/AJ/Ghosts aprĂšs lâapplication de la seconde chance
xCol = nom de la colonne qui contient les taux de réussite
hueCol = nom de la colonne qui contient les paramĂštres avant ou aprĂšs seconde chance
NomGraphique = nom du fichier png qui va ĂȘtre sauvĂ©
- affichage :
bar plot de seaborn
- sauvegarde :
fichier graphique âNomGraphiqueâ au format png
- pyphyschemtools.tools4AS.read_excel(xlFile, decimal, name)ï
- entrée :
xlFile = nom du ficher excel
decimal = â.â ou â,â selon le cas
name = label du dataframe, utilisĂ© pour lâaffichage
- sortie :
le dataframe qui contient lâintĂ©gralitĂ© du fichier excel
le nombre de lignes de ce tableau (Ă lâexclusion de lâen-tĂȘte des colonnes)
- affichage :
statistiques descriptives (describe) de toutes les colonnes, y compris celles qui ne contiennent pas de valeurs numériques
- pyphyschemtools.tools4AS.verifNotes(dfCC, labelNoteCC, nomCC, NI, absents='aabs')ï
- Parameters:
CC (- nomCC = label de l'épreuve de)
notes (- labelNoteCC = label de la colonne qui contient les)
CC
module (- NI = nombre d'inscrits dans le)
absents (-) â
âaabsâ : analyser sâil y a des Ă©tudiants qui nâont pas Ă©tĂ© pointĂ©s au CC (dĂ©faut)
- ânoabsâne pas analyser sâil y a des Ă©tudiants qui nâont pas Ă©tĂ© pointĂ©s au CC
(ça nâa plus de sens une fois les fichiers concatĂ©nĂ©s)
- Returns:
la moyenne et la déviation standard de liste de notes contenues dans le dataframe dfCC
le nombre dâĂ©tudiants qui nâont pas composĂ© au CC
Note
Affiche le nombre dâĂ©tudiants avec le label âABSâ et signale les Ă©tudiants sans note ni label, ce qui nĂ©cessite une vĂ©rification du PV.
pyphyschemtools.visualID_Eng moduleï
- pyphyschemtools.visualID_Eng.apply_css_style()ï
Explicitly reads and applies the visualID CSS stylesheet from the package resources.
- class pyphyschemtools.visualID_Eng.bgï
Bases:
object- DARKRED = '\x1b[38;5;231;48;5;52m'ï
- DARKREDB = '\x1b[38;5;231;48;5;52;1m'ï
- LIGHTBLUE = '\x1b[48;5;117m'ï
- LIGHTBLUEB = '\x1b[48;5;117;1m'ï
- LIGHTGREEN = '\x1b[48;5;156m'ï
- LIGHTGREENB = '\x1b[48;5;156;1m'ï
- LIGHTRED = '\x1b[48;5;217m'ï
- LIGHTREDB = '\x1b[48;5;217;1m'ï
- LIGHTYELLOW = '\x1b[48;5;228m'ï
- LIGHTYELLOWB = '\x1b[48;5;228;1m'ï
- OFF = '\x1b[0m'ï
- pyphyschemtools.visualID_Eng.chrono_show()ï
- pyphyschemtools.visualID_Eng.chrono_start()ï
- pyphyschemtools.visualID_Eng.chrono_stop(hdelay=False)ï
- class pyphyschemtools.visualID_Eng.colorï
Bases:
object- BLUE = '\x1b[94m'ï
- BOLD = '\x1b[1m'ï
- CYAN = '\x1b[96m'ï
- DARKCYAN = '\x1b[36m'ï
- GREEN = '\x1b[92m'ï
- OFF = '\x1b[0m'ï
- PURPLE = '\x1b[95m'ï
- RED = '\x1b[91m'ï
- UNDERLINE = '\x1b[4m'ï
- YELLOW = '\x1b[93m'ï
- pyphyschemtools.visualID_Eng.display_md(text)ï
- pyphyschemtools.visualID_Eng.end()ï
Terminates the notebook session: displays duration, end time, and the termination logo from package resources.
- class pyphyschemtools.visualID_Eng.fgï
Bases:
object- BLACK = '\x1b[30m'ï
- BLUE = '\x1b[94m'ï
- CYAN = '\x1b[96m'ï
- DARKCYAN = '\x1b[36m'ï
- DARKGRAY = '\x1b[90m'ï
- GREEN = '\x1b[92m'ï
- LIGHTGRAY = '\x1b[37m'ï
- OFF = '\x1b[0m'ï
- PURPLE = '\x1b[95m'ï
- RED = '\x1b[91m'ï
- WHITE = '\x1b[38;5;231m'ï
- YELLOW = '\x1b[93m'ï
- pyphyschemtools.visualID_Eng.hdelay(sec)ï
- pyphyschemtools.visualID_Eng.hdelay_ms(delay)ï
- class pyphyschemtools.visualID_Eng.hlï
Bases:
object- BLINK = '\x1b[5m'ï
- BOLD = '\x1b[1m'ï
- ITALIC = '\x1b[3m'ï
- OFF = '\x1b[0m'ï
- UNDERL = '\x1b[4m'ï
- blink = '\x1b[25m'ï
- bold = '\x1b[21m'ï
- italic = '\x1b[23m'ï
- underl = '\x1b[24m'ï
- pyphyschemtools.visualID_Eng.init(which=None)ï
Initializes the notebook environment: applies CSS, displays the banner, and shows hostname/time.