This project provides a comprehensive Python script for analyzing temperature-dependent transport measurements of superconducting samples. The script specializes in plotting measurement data and calculating critical temperatures using the tangent intersection method.
The 17T_plots.py script is designed to process experimental data from superconducting samples measured at various temperatures and magnetic fields. It automatically handles:
- Temperature-dependent voltage measurements
- Critical temperature (Tc) calculations using tangent intersection method
- Publication-quality plotting with focused transition region views
- Automatic temperature correction for measurements taken before sensor calibration
- Support for multiple sample conditions (pristine, irradiated, annealed)
- Automatic Temperature Correction: Applies +0.45K correction to measurements taken before April 25, 2025
- Multiple File Format Support: Handles tab-separated .dat files with temperature, voltage, and timestamp data
- Flexible Data Input: Supports both custom folder paths and predefined sample selections
- Critical Temperature Calculation: Uses tangent intersection method to determine Tc
- Savitzky-Golay Filtering: Applies sophisticated smoothing for derivative calculations
- Transition Region Detection: Automatically identifies superconducting transition regions
- Dual Tc Values: Calculates both Tc_high (intersection) and Tc_low (x-intercept)
- Publication-Quality Plots: Generates high-resolution PDF outputs
- Focused View: Automatically centers plots around transition regions
- Color-Coded Analysis: Different colors for raw data, fits, and critical temperatures
- Comprehensive Legends: Clear labeling of all plot elements
- Condition Detection: Automatically identifies sample states from folder structure
- Batch Processing: Can process multiple measurement files simultaneously
- Flexible Naming: Supports custom sample names and automatic name extraction
Install the required dependencies using pip:
pip install -r requirements.txt- matplotlib (3.9.4): For plotting and visualization
- numpy (2.0.2): Numerical computations and array operations
- pandas (2.2.3): Data manipulation and analysis
- scipy (1.13.1): Scientific computing, especially Savitzky-Golay filtering
- python-dateutil (2.9.0.post0): Timestamp parsing for temperature correction
- Clone this repository:
git clone <repository-url>
cd 17T_Plots- Install dependencies:
pip install -r requirements.txt- Ensure your data follows the expected directory structure (see Data Format section)
# Analyze a specific sample with critical temperature calculation
python 17T_plots.py --ISet_SPSCS09_020 --calculate-tc
# Plot a specific measurement file
python 17T_plots.py --ISet_SPSCS09_021 --file 1 --calculate-tc
# Use a custom folder path
python 17T_plots.py --folder "ISet_SPSCS09_021/IRR1/il" --sample "Sample 021 (irradiated)" --calculate-tc| Option | Description | Example |
|---|---|---|
--folder PATH |
Custom data folder path | --folder "custom/path/il" |
--ISet_SPSCS09_XXX |
Use predefined sample (018-025, 027, 028) | --ISet_SPSCS09_020 |
--file NUMBER/all |
Plot specific file(s): 1, 2, 3, or "all" | --file 1 |
--sample NAME |
Custom sample name for plot title | --sample "My Sample" |
--calculate-tc |
Calculate and display critical temperature | --calculate-tc |
The script includes predefined paths for the following samples:
- ISet_SPSCS09_018 through ISet_SPSCS09_025
- ISet_SPSCS09_027
- ISet_SPSCS09_028
your_project/
βββ ISet_SPSCS09_XXX/
β βββ 0e22/ # Pristine samples
β β βββ il/
β βββ 0e22-ann/ # Pristine & annealed samples
β β βββ il/
β βββ IRR1/ # Irradiated samples
β β βββ il/
β βββ IRR1-ann/ # Irradiated & annealed samples
β βββ il/
βββ plots/ # Output directory (auto-created)
The script expects .dat files with tab-separated columns:
- Temperature [K]: Measurement temperature
- Voltage [V]: Measured voltage
- Timestamp [ISO8601]: Measurement timestamp for temperature correction
Example data file (0.000000e+00T_1.dat):
# Temperature Voltage Timestamp
4.2000 1.234e-06 2025-03-15T10:30:00+01:00
4.1500 1.189e-06 2025-03-15T10:31:00+01:00
...
- Location:
plots/directory (automatically created) - Format: High-resolution PDF files
- Naming:
{sample}_{condition}_0T_{file}_with_tc.pdf
- Location:
plots/directory - Format: Text files with detailed Tc calculations
- Naming:
{sample}_{condition}_tc_results.txt
Critical Temperature Results for SPSCS09 020 (pristine)
==================================================
File: 0.000000e+00T_1.dat
Tc_high: 4.157 K
Tc_low: 4.142 K
------------------------------
The script implements a robust tangent intersection method:
- Data Smoothing: Applies Savitzky-Golay filter to reduce noise
- Derivative Calculation: Computes first derivative to identify transition steepness
- Region Identification:
- Transition region: gradient > 60% of maximum
- Resistive region: gradient < 30% of maximum
- Linear Fitting: Fits straight lines to both regions
- Tc Determination:
- Tc_high: Intersection of transition and resistive fits
- Tc_low: X-intercept of transition fit
For measurements taken before April 25, 2025, the script automatically applies a +0.45K correction to account for sensor calibration changes.
This project was developed with significant assistance from AI (GitHub Copilot and Claude), which helped with:
- Algorithm Implementation: Critical temperature calculation using tangent intersection method
- Data Processing Logic: Robust file parsing and timestamp handling
- Code Structure: Modular design with clear separation of concerns
- Error Handling: Comprehensive exception handling and data validation
- Documentation: Detailed docstrings and comments throughout the code
- Best Practices: Following Python coding standards and scientific computing conventions
The AI assistance was particularly valuable for:
- Implementing the Savitzky-Golay filtering and derivative calculations
- Developing the robust timestamp parsing with timezone awareness
- Creating the flexible command-line interface
- Optimizing the plotting aesthetics for publication-quality figures
- Ensuring proper handling of edge cases in data processing
Human oversight ensured the scientific accuracy of the methods and validation against experimental requirements.
- Main Script:
17T_plots.py- Contains all functionality - Configuration: Command-line arguments for flexible usage
- Output Management: Automatic directory creation and file naming
calculate_Tc(): Core critical temperature calculationplot_cryostat_data(): Data visualization and plottingparse_args(): Command-line argument handling
The script includes comprehensive error handling for:
- Missing data files
- Malformed data
- Timestamp parsing failures
- Insufficient data for fitting
This project is developed for scientific research purposes. Please cite appropriately if used in publications.
Contributions are welcome! Please consider:
- Adding support for additional file formats
- Implementing alternative Tc calculation methods
- Improving visualization options
- Enhancing error handling
For questions about the scientific methodology or data format requirements, please refer to the detailed docstrings in the code or examine the example usage patterns provided.
This README was prepared with AI assistance to ensure comprehensive documentation of the project's capabilities and usage.