Official Documentation
PetroPyQAPF User Manual
Complete guide for reproducible igneous rock classification using IUGS-QAPF modal logic, CIPW normative contrast, domain ML support, and formal technical reporting.
Introduction
What is PetroPyQAPF?
PetroPyQAPF is a Python desktop application designed to support reproducible igneous rock classification and technical reporting. The software separates the formal modal decision from geochemical contrast, probabilistic support, interpretive synthesis, mineral reference, petrographic image review, and report presentation.
Who Should Use PetroPyQAPF?
- Students learning igneous petrology and rock classification
- Geologists conducting petrographic analysis in academic research
- Teachers demonstrating IUGS-QAPF classification methods
- Researchers requiring reproducible and traceable classification workflows
Installation & Setup
System Requirements
- Windows 10/11 (64-bit)
- 4 GB RAM minimum (8 GB recommended)
- 500 MB available disk space
- Microsoft Word (for PDF report generation)
- Internet connection (for authentication and optional AI features)
Installation Steps
- Download the latest release from the official website
- Extract the ZIP file to your preferred location
- Run
PetroPyQAPF.exefrom the extracted folder - On first launch, authenticate with your academic Google account
- Select your preferred language (Spanish or English)
Authentication
PetroPyQAPF uses Google/Firebase authentication to verify academic access. Only authorized email addresses can run the application. Authentication does not transmit samples, chemical data, or generated reports—it only validates your access credentials.
Getting Started
Creating Your First Project
- Launch PetroPyQAPF
- Click "New Project" in the main menu
- Enter a project name and optional description
- Choose between Manual Entry or Import from CSV/Excel
Manual Sample Entry
For individual sample classification:
- Click "Add Sample"
- Enter sample identification (name, location, date)
- Select domain: Plutonic or Volcanic
- Input modal mineralogy (Q, A, P, F percentages)
- Optionally add auxiliary petrographic data (M, Pl, An, Px, Ol, Anf)
- Optionally input major oxide geochemistry for CIPW comparison
Batch Import from CSV/Excel
For multiple samples:
- Prepare your data file with columns: Sample_ID, Q, A, P, F, Domain
- Click "Import Batch"
- Select your CSV or Excel file
- Map columns to PetroPyQAPF fields
- Review and confirm imported samples
Modal Classification
Understanding IUGS-QAPF Logic
The IUGS-QAPF system classifies igneous rocks based on the relative proportions of four mineral groups:
- Q - Quartz and quartz-equivalent minerals
- A - Alkali feldspars (orthoclase, microcline, sanidine, etc.)
- P - Plagioclase feldspars
- F - Feldspathoids (nepheline, leucite, etc.)
Domain Selection
PetroPyQAPF separates plutonic (coarse-grained, intrusive) and volcanic (fine-grained, extrusive) domains. Each domain has specific nomenclature:
- Plutonic: Granite, Granodiorite, Tonalite, Diorite, Gabbro, etc.
- Volcanic: Rhyolite, Dacite, Andesite, Basalt, Trachyte, etc.
Specialized Routing
For rocks outside the standard QAPF range:
- Ultramafic rocks (M > 90%): Uses Ol-Opx-Cpx ternary diagrams
- Gabbroic rocks: Specialized Pl-Px-Ol and Pl-Px-Anf ternaries
- Foidolite classification: For F-rich feldspathoid-bearing rocks
Interpretation of Results
After entering modal data, PetroPyQAPF provides:
- Official rock name from IUGS-QAPF position
- Position coordinates within the ternary diagram
- Validation warnings if data quality or consistency issues are detected
- Alternative names for boundary cases
CIPW Normative Comparison
What is CIPW?
The CIPW norm calculates an idealized, anhydrous mineral assemblage from whole-rock geochemical data. It provides a secondary compositional perspective that complements modal observation.
Entering Oxide Data
Input major oxide percentages (wt%):
- SiO₂, TiO₂, Al₂O₃, Fe₂O₃, FeO, MnO, MgO, CaO, Na₂O, K₂O, P₂O₅
Modal vs. CIPW Comparison
PetroPyQAPF projects CIPW normative minerals onto the QAPF diagram and calculates:
- Distance: Euclidean distance between modal and normative positions
- Consistency level: High, Moderate, or Low agreement
- Warnings: Flags for significant discrepancies that may indicate alteration, analytical issues, or magmatic complexity
Why Modal and CIPW May Differ
- Alteration: Weathering or hydrothermal alteration changes mineral chemistry
- Magmatic history: Cumulate textures, crystal fractionation, or mixing
- Analytical uncertainty: Errors in modal counting or geochemical analysis
- CIPW assumptions: The norm assumes idealized equilibrium conditions
Machine Learning Support
ML Model Architecture
PetroPyQAPF uses domain-specific ML models trained on regional geochemical datasets:
- Volcanic domain: XGBoost classifier
- Plutonic domain: Random Forest classifier
Reading ML Output
For each sample, the ML layer provides:
- Top prediction: Most probable rock class based on geochemistry
- Confidence score: Probability of the top prediction (0-100%)
- Alternative classes: Second and third most likely classes with scores
- Agreement indicator: Whether ML prediction matches modal classification
When ML Disagrees with Modal
If ML and modal classifications differ significantly:
- Review modal counting accuracy
- Check for alteration or weathering
- Verify oxide analytical quality
- Consider magmatic complexity (mixing, cumulates)
- Consult the NIM interpretation for context
Normalized Interpretation Model (NIM)
What is NIM?
NIM synthesizes evidence from modal, CIPW, and ML layers into a coherent interpretation. It quantifies:
- Support level: Agreement across classification methods
- Uncertainty: Confidence in the formal classification
- Evidence factors: Weights for modal, geochemical, and probabilistic data
- Recommendations: Suggested follow-up actions (recount, re-analyze, etc.)
Support Levels
- High: All methods agree; classification is robust
- Moderate: Some disagreement; review recommended
- Low: Significant conflicts; petrographic re-evaluation needed
Using NIM Effectively
NIM does not reclassify rocks. It helps you understand the quality and coherence of your classification. Use NIM recommendations to prioritize samples for detailed review or re-analysis.
Petrographic Viewer
Loading Photomicrographs
- Select a sample in your project
- Click "Attach Image" in the Viewer panel
- Choose PPL (plane-polarized light) or XPL (cross-polarized light)
- Browse to your photomicrograph file (JPG, PNG, TIFF)
- Repeat to load both PPL and XPL images for comparison
Comparison Tools
When both PPL and XPL images are loaded:
- Side-by-side mode: View images next to each other
- Slider mode: Vertical or horizontal divider to compare registered images
- Zoom and pan: Synchronized navigation across both views
Scale Calibration
- Click "Calibrate Scale"
- Draw a line across a known diameter (e.g., field of view, scale bar)
- Enter the actual measurement in micrometers (µm) or millimeters (mm)
- Measurements and annotations will now display calibrated dimensions
Annotations and Measurements
- Point markers: Identify mineral grains
- Line measurements: Grain size, twin spacing
- Text labels: Annotate mineral names or features
- Area selection: Highlight zones of interest
Capturing for Reports
Click "Capture View" to save the current viewer state (including annotations) as an image. Captured images are automatically included in exported reports.
Mineral Atlas
Accessing the Atlas
Click "Mineral Atlas" in the main toolbar to open the integrated reference guide for rock-forming minerals.
Search and Browse
- Name search: Find minerals by common or systematic names
- Formula search: Search by chemical formula (e.g., SiO₂, CaAl₂Si₂O₈)
- Category filter: Browse by mineral group (feldspars, pyroxenes, amphiboles, etc.)
Mineral Information Cards
Each mineral entry includes:
- Chemical formula and crystal system
- Optical properties: Relief, birefringence, extinction angle, pleochroism
- Common occurrences: Typical rock types and geological settings
- Distinguishing features: Key identification criteria
- Visual references: PPL and XPL photomicrograph examples
Bilingual Support
The mineral atlas is available in Spanish and English. Content automatically switches to match your selected application language.
Reports and Export
Report Generation
- Select one or more samples in your project
- Click "Generate Report"
- Choose report format:
- JSON: Machine-readable data for archival or integration
- Text: Plain-text summary for quick review
- PDF: Formal technical report with diagrams and images
PDF Report Contents
The formal PDF report includes:
- Project and sample metadata
- Modal classification results with QAPF diagram position
- CIPW normative data and comparison metrics
- ML predictions and confidence scores
- NIM interpretation and recommendations
- Petrographic viewer captures (if attached)
- Data tables and validation warnings
Project Package Export
Export your entire project as a ZIP archive containing:
- .gisgeo project file: Full project data in JSON format
- Summary CSV/Excel: Tabular data for all samples
- Individual JSON reports: One per sample
- Attached images: PPL/XPL photomicrographs and captures
Opening Saved Projects
Click "Open Project" and select a .gisgeo file to restore your work. All sample data, images, annotations, and settings are preserved.
AI-Assisted Interpretation (Optional)
Configuring AI Backends
PetroPyQAPF can integrate with AI services for natural-language interpretation:
- Local Ollama: Run models on your own machine
- OpenAI API: GPT-4 or other OpenAI models
- Anthropic API: Claude models
To configure:
- Open Settings → AI Configuration
- Select your preferred backend
- Enter API credentials (if using cloud services)
- Test connection
Using GPKE (Geological Petrological Knowledge Engine)
GPKE synthesizes modal, geochemical, and probabilistic evidence into natural-language hypotheses:
- Petrogenetic scenarios (magmatic evolution, mixing, contamination)
- Tectonic setting inferences
- Alteration or weathering interpretations
- Quality assessment and data review suggestions
Important Limitations
- AI interpretations are not peer-reviewed scientific conclusions
- GPKE does not reclassify rocks—it provides context and hypotheses
- Always validate AI suggestions against petrographic observations and geological context
Troubleshooting
Authentication Issues
Problem: Cannot log in with Google account
- Verify your email is registered for academic access at /portfolio/petropyqapf/register
- Check internet connection
- Ensure firewall allows PetroPyQAPF to access Firebase servers
- Contact jordanzav@gisgeo.dev if access is denied after registration
Data Import Errors
Problem: CSV/Excel import fails or produces incorrect results
- Verify column headers match expected field names (Q, A, P, F, Domain)
- Check for missing or non-numeric values in mineral percentage columns
- Ensure file encoding is UTF-8 (especially for Spanish characters)
- Use the provided CSV template as a reference
CIPW Calculation Warnings
Problem: CIPW norm fails or shows "Invalid composition"
- Check oxide total: should be 98-102%
- Verify all required oxides are entered (SiO₂, Al₂O₃, FeO, MgO, CaO, Na₂O, K₂O)
- Ensure no negative values or extreme outliers
- Review Fe₂O₃/FeO ratio—both should not be zero
PDF Export Fails
Problem: Cannot generate PDF reports
- Ensure Microsoft Word is installed and activated
- Close any open Word documents before exporting
- Check write permissions for the output directory
- Try exporting to a different folder (avoid system directories)
Petrographic Viewer Issues
Problem: Images won't load or display incorrectly
- Supported formats: JPG, PNG, TIFF, BMP
- Maximum file size: 50 MB per image
- Try reducing image resolution if file is very large
- Verify file path has no special characters
Frequently Asked Questions
Can I use PetroPyQAPF for commercial projects?
No. The academic license covers only non-profit educational and research use. Commercial, consulting, corporate, or government use requires a separate commercial license. Contact jordanzav@gisgeo.dev for licensing inquiries.
Does PetroPyQAPF work offline?
Partially. After initial authentication, core classification features (QAPF, CIPW, ML) work offline. However, authentication requires internet access, and optional AI features need connectivity or a local Ollama setup.
Can I export my data for use in other software?
Yes. Projects export to CSV/Excel for tabular data and JSON for complete structured data. These formats are compatible with R, Python pandas, QGIS, and other geoscience tools.
How accurate are the ML predictions?
ML models are trained on regional datasets and provide statistical likelihoods, not ground truth. Accuracy depends on how similar your samples are to the training data. Always prioritize modal classification over ML predictions.
Can I add my own mineral atlas entries?
Currently, the mineral atlas is read-only. Custom knowledge base editing is planned for future releases. For now, you can reference external resources or add notes to sample metadata.
Why does CIPW differ from modal classification?
CIPW calculates an idealized, anhydrous mineral assemblage from bulk chemistry. It can differ from observed mineralogy due to alteration, magmatic complexity, crystallization conditions, or analytical uncertainty. Disagreement is normal and geologically informative.
Is my petrographic data stored on external servers?
No. All sample data, images, and reports remain on your local machine. Authentication only verifies your access credentials—it does not upload scientific data. Optional AI features send only the specific data you choose to interpret.
Can I cite PetroPyQAPF in academic publications?
Yes. A formal citation format and DOI will be provided after peer-reviewed publication. For now, reference the software as: "PetroPyQAPF v[version] (2026), available at https://gisgeo.dev/portfolio/petropyqapf/"
Support & Contact
Technical Support
For bugs, feature requests, or technical questions:
Email: jordanzav@gisgeo.dev
Academic Registration
To register for academic access:
Request Academic Access
Commercial Licensing
For enterprise, consulting, or institutional use:
Email: jordanzav@gisgeo.dev
Documentation Updates
This manual is updated with each software release. Check the PetroPyQAPF homepage for the latest version.