Skip to content

Adds XArray output for TUV-x#748

Merged
K20shores merged 4 commits intoNCAR:mainfrom
mattldawson:develop-602-tuvx-xarray
Jan 23, 2026
Merged

Adds XArray output for TUV-x#748
K20shores merged 4 commits intoNCAR:mainfrom
mattldawson:develop-602-tuvx-xarray

Conversation

@mattldawson
Copy link
Copy Markdown
Collaborator

This PR modifies the TUV-x run function to return results in an XArray dataset.

closes #602

Copilot AI review requested due to automatic review settings January 23, 2026 16:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Python TUV-x interface so TUVX.run() returns results as an xarray.Dataset rather than raw NumPy arrays, aligning with issue #602.

Changes:

  • Changed TUVX.run() return type from a tuple of np.ndarray to an xr.Dataset.
  • Added xarray dataset construction with named dimensions/coordinates for layers and rate categories.
  • Updated integration tests to validate the new dataset-based output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
python/musica/tuvx/tuvx.py Switches run() to return an xarray.Dataset with labeled variables/coords.
python/test/integration/test_tuvx.py Updates integration assertions to use dataset variables/coords instead of tuple outputs.
Comments suppressed due to low confidence (1)

python/musica/tuvx/tuvx.py:156

  • run() now returns an xr.Dataset, but several helper methods in this class still document their inputs as "Output from run()" and type them as np.ndarray. That API/documentation mismatch will confuse callers and can lead to incorrect return types (xarray DataArray vs ndarray). Update the helper method signatures/docs to accept the Dataset/DataArray (or provide a separate method that returns raw numpy arrays if you want to keep both APIs).
    def run(self, sza: float, earth_sun_distance: float) -> xr.Dataset:
        """
        Run the TUV-x photolysis calculator.

        All parameters (solar zenith angle, Earth-Sun distance, atmospheric profiles,
        etc.) are read from the JSON configuration file.

        Args:
            sza: Solar zenith angle in radians
            earth_sun_distance: Earth-Sun distance in astronomical units (AU)

        Returns:
            XArray Dataset with data variables:
            - photolysis_rate_constants: Shape (n_layers, n_reactions) [s^-1]
            - heating_rates: Shape (n_layers, n_heating_rates) [K s^-1]
            - dose_rates: Shape (n_layers, n_dose_rates) [W m^-2]
        """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.63%. Comparing base (04f45a5) to head (0d1c657).

Files with missing lines Patch % Lines
src/tuvx/tuvx.cpp 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #748      +/-   ##
==========================================
+ Coverage   74.58%   74.63%   +0.05%     
==========================================
  Files         109      109              
  Lines        8090     8106      +16     
==========================================
+ Hits         6034     6050      +16     
  Misses       2056     2056              
Flag Coverage Δ
cpp_fortran 68.49% <66.66%> (ø)
javascript 92.56% <ø> (ø)
python 78.47% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@K20shores K20shores requested a review from boulderdaze January 23, 2026 17:58
@K20shores K20shores merged commit 44383fd into NCAR:main Jan 23, 2026
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XArray output from Python TUV-x

5 participants