suncasa / suncasa-src

Source code of the suncasa——CASA-based Python package for reducing, analyzing, and visualizing solar dynamic spectroscopic imaging data at radio wavelengths
BSD 2-Clause "Simplified" License
17 stars 23 forks source link

split stackplotX to a new repo #273

Open sageyu123 opened 8 months ago

sageyu123 commented 8 months ago

To make stackplotX independent of Suncasa and more flexible for future uses:

  1. Create a New Repository:

    • Extract stackplotX from the current Suncasa repository.
    • Initialize a new Git repository for stackplotX.
    • Ensure all dependencies are documented in a requirements.txt file or a setup.py file for easier installation.
  2. Refactor the Code:

    • Decouple the calculation logic from the plotting backend.
    • Define a clear interface for the calculation code, enabling it to be used as a standalone module.
    • Encapsulate Matplotlib-specific code within its own module or class, allowing for optional use.
  3. Enhance Compatibility:

    • Update the code to be compatible with sunpy version 5 or higher.
    • Replace any deprecated sunpy functionality with current APIs.
  4. Documentation and Examples:

    • Provide comprehensive documentation explaining how to use the calculation module independently.
    • Include examples demonstrating how to integrate the module with different UI frameworks or plotting libraries.
# calculation_module.py

class StackPlotXCalculator:
    def __init__(self, data):
        self.data = data

    def extract_intensity_along_path(self, path):
        """
        Extracts the intensity along a given path from the data.

        Parameters:
        path : array_like
            The path along which to extract intensity.

        Returns:
        intensity : array_like
            The extracted intensity values along the path.
        """
        # Implementation of intensity extraction.
        pass

And a separate plotting module using Matplotlib:

# matplotlib_backend.py
import matplotlib.pyplot as plt
from calculation_module import StackPlotXCalculator

class StackPlotXMatplotlib:
    def __init__(self, calculator: StackPlotXCalculator):
        self.calculator = calculator

    def plot(self, path):
        intensity = self.calculator.extract_intensity_along_path(path)
        plt.figure()
        plt.plot(intensity)
        plt.show()