Skip to content

rayanc72/PDFStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧪 PDFStream

A Streamlit web application that provides an interactive interface to preprocess and analyze .chi files using PDFgetX3. The app enables file upload, parameter customization, plotting, and visualization of processed outputs such as S(q), F(q), and G(r).


📋 Features

  • Upload .chi data and background files
  • Select and preview uploaded files
  • Customize preprocessing parameters:
    • Data format, wavelength, Q-range, R-range, etc.
  • Interactive Q vs I plot
  • Automatically generate pdfgetx3.cfg
  • Run pdfgetx3 via the app backend
  • Visualize and download processed outputs:
    • .fq, .sq, and .gr plots
  • One-click cleanup for uploaded data

🚀 Getting Started

🔧 Prerequisites

Make sure you have the following installed:

pip install streamlit plotly numpy

You must also ensure pdfgetx3 is available in your system’s $PATH or installed via conda:

conda install -c diffpy pdfgetx3

📁 File Structure

pdf_processor_app/
│
├── pdfapp.py              # Streamlit app
├── pdfgetx3.cfg           # Template config file (will be modified per run)
├── pdfgetx3_temp/         # Temporary directory for processing (created automatically)
├── data_chi_files/        # Stores uploaded data files (created automatically)
├── LICENSE                # Details on MIT license
└── README.md              # You're reading it!

💻 Usage

1. Run the app:

streamlit run pdfapp.py

2. Upload Files:

  • Upload multiple data files (.chi) and a background file (.chi).
  • Select one of the data files from the dropdown.
  • Optionally, upload a json configuration file to set parameters from a previous run.

3. Set Parameters:

  • Input material composition (e.g., C8N2H22PbI4)
  • Choose:
    • Data format: twotheta, QA, or Qnm
    • Wavelength
    • Q-range and R-range
    • rstep, rpoly, qmaxinst

4. Run:

The app runs automatically.

Expand the tabs to

  • modify background subtraction
  • Display:
    • Q vs I plot
    • F(q), S(q), G(r) plots
    • Downloadable output files

5. Clear Uploads:

Click "Clear uploaded data files" to clean up temporary files and reset the session.


📊 Output Files

The app generates:

  • .fq → Fourier transformed function F(Q)
  • .sq → Structure factor S(Q)
  • .gr → Real-space pair distribution function G(r)
  • .json → Configuration file with parameters used for processing

The PDF output files can be visualized directly within the app and downloaded.


🛠️ Under the Hood

Key Components

  • st.file_uploader() – Upload and store data/background files
  • pdfgetx3.cfg – Configuration file for PDFgetX3, auto-modified
  • run_command() – Executes shell command for pdfgetx3
  • plot_chi_file() and plot_gr_file() – Plotting utilities for uploaded and processed data

📌 Notes

  • pdfgetx3 must be installed and callable in the shell. Before running the streamlit command, please make sure pdfgetx3 works fine, by running: pdfgetx3 --version
  • Common issues with pdfgetx3 installation can usually be fixed by correcting the required python version (at the time of writing, pdfgetx3 requires Python v3.8). The python version can be checked by running: python --version
  • The pdfgetx3.cfg file should be available in the app directory and will be modified on-the-fly.
  • This app creates two working folders:
    • pdfgetx3_temp/ – Temporary for each run
    • data_chi_files/ – Stores uploaded .chi files

🧹 Cleanup

All temporary data files are stored locally and can be deleted manually or via the Clear uploaded data files button.


📄 License

This project is open-source and free to use for academic or personal research purposes (see LICENSE for more info).

About

An interactive app for end-to-end conversion of total scattering intensity to pair distribution function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages