Merged
Conversation
Contributor
There was a problem hiding this comment.
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 ofnp.ndarrayto anxr.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 anxr.Dataset, but several helper methods in this class still document their inputs as "Output from run()" and type them asnp.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.
Co-authored-by: Copilot <[email protected]>
K20shores
requested changes
Jan 23, 2026
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
K20shores
approved these changes
Jan 23, 2026
boulderdaze
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modifies the TUV-x run function to return results in an XArray dataset.
closes #602