Satellite Application Facility for Numerical Weather Prediction › Forums › RTTOV › Older Versions › RTTOV v13 › RTTOV v13 General Discussion › Issue with pyrttov wrapper (ValueError: Incorrect dimension) with RTTOV v13.2
Tagged: pyrttov
- This topic has 1 reply, 2 voices, and was last updated 4 days, 7 hours ago by
James Hocking.
-
AuthorPosts
-
July 23, 2025 at 1:36 pm #51064
Kohei Mizobata
ParticipantDear RTTOV Support Team,
I am encountering a persistent ValueError: Incorrect dimension when trying to use the pyrttov Python wrapper with my RTTOV v13.2 installation.
My Setup:
RTTOV Version: 13.2
Python Version: 3.10.13 (managed with pyenv)
Operating System: Linux (Ubuntu 24.04 LTS)
Python Environment Configuration (from Makefile.local):
PYTHON_VERSION = 3.10
F2PY = /home/kmizobata/.pyenv/shims/f2py
PYTHON_EXEC = /home/kmizobata/.pyenv/versions/3.10.13/bin/python
Problem Description: The error occurs when assigning profile data, specifically for the Skin attribute. The traceback is as follows:
Traceback (most recent call last):
File “/home/kmizobata/software/rttov132/EXE/rttov_run_v22.py”, line 157, in main
profiles.Skin = Skin
File “/home/kmizobata/software/rttov132/wrapper/pyrttov/decorator.py”, line 55, in thesetattr
object.__setattr__(self, name, value)
File “/home/kmizobata/software/rttov132/wrapper/pyrttov/descriptor.py”, line 60, in __set__
self._target_init(instance, value)
File “/home/kmizobata/software/rttov132/wrapper/pyrttov/descriptor.py”, line 269, in _target_init
raise ValueError(“Incorrect dimension”)
ValueError: Incorrect dimension
Debugging Information: Based on my script’s debug output and pyrttov’s source code:profiles.Nprofiles is 1.
The Skin array being assigned has a shape of (1, 6) and dtype=numpy.float32.
The pyrttov/profile.py source defines the Skin descriptor with a leadingdim=6.
For the S2m attribute, which has a shape of (1, 5) (matching its leadingdim=5 descriptor), the assignment completes successfully without error.
My Confusion: Given that the Python-level dimensions and data types of the Skin array appear to correctly match the pyrttov descriptor’s expectations ((instance.Nprofiles, self._leadingdim) and float32), I am perplexed why the ValueError(“Incorrect dimension”) is still being raised from descriptor.py line 269. This suggests the error is not a direct mismatch in Python array dimensions, but rather a deeper issue at the Fortran-Python interface (f2py binding).
Steps Taken So Far: I have attempted to reinstall pyrttov by navigating to the rttov132/wrapper/pyrttov directory within my RTTOV v13.2 distribution and running python setup.py install within my active pyenv environment. I’ve also noticed that the pyrttov source files (e.g., descriptor.py, decorator.py, profile.py, rttype.py, __init__.py) all contain a copyright notice from 2016, EUMETSAT. This leads me to suspect a potential version incompatibility between this pyrttov wrapper and the RTTOV v13.2 Fortran core.
Request for Assistance: Could you please provide guidance on:
Why this ValueError: Incorrect dimension persists for Skin despite the Python array’s dimensions seemingly matching the pyrttov descriptor?
How can I ensure that my pyrttov Python wrapper is correctly compiled and fully compatible with my RTTOV v13.2 Fortran core, especially considering the older copyright dates on the pyrttov source files?
Are there any specific compilation flags, environment variables, or known issues related to f2py or numpy versions for RTTOV v13.2 that could cause this behavior?
Thank you for your time and assistance.
Sincerely,
Kohei
July 24, 2025 at 11:28 am #51066James Hocking
KeymasterHi Kohei,
In RTTOV v13.2, the Skin member of the Profiles class has shape [9,nprofiles] so the leading dimension is 9 rather than 6.
The contents of the Skin array for each profile should be:
Skin T, salinity, snow_fraction, foam_fraction, fastem_coefs(1:5)The S2m member has shape [6,nprofiles], so the fact that you can successfully assign an array with leading dimension 5 to S2m suggests you are using some other version of the code perhaps? The S2m member of the ProfilesScatt class (used for RTTOV-SCATT simulations, i.e., MW scattering), has leading dimension 5, but the Skin member has leading dimension 8 rather than 6.
Can you confirm you are using the RTTOV wrapper/ code from the RTTOV v13.2 release package?
You can also take a look at the pyrttov_example.py and associated example_data.py: these demonstrate a call to pyrttov.
Best wishes,
James -
AuthorPosts
- You must be logged in to reply to this topic.