kconnour / pyRT_DISORT

A Python package for helping to compute input arrays to DISORT.
https://kconnour.github.io/pyRT_DISORT/
BSD 3-Clause "New" or "Revised" License
14 stars 5 forks source link

Disort build-in tests failed #16

Open AStcherbinine opened 2 years ago

AStcherbinine commented 2 years ago

Hello,

I've tried to implement the build-in test 16 (pseudo-spherical correction) using the disort wrapper and get some array dimension errors. But then I've noticed that a similar error is raised when I try to run the tests implemented in the pyRT_DISORT/tests/disort_tests folder. Do you know where it comes from?

Output for python3 disotest1a.py

ValueError: 0-th dimension must be fixed to 16 but got 6

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/aurelien/python_modules/pyRT_DISORT/tests/disort_tests/disotest1a.py", line 63, in <module>
    rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = disort.disort(usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber, deltamplus, do_pseudo_sphere, dtauc, ssalb,
ValueError: failed in converting 30th argument `rhou' of disort.disort to C/Fortran array

Output for python3 disotest9.py

ValueError: 0-th dimension must be fixed to 8 but got 4

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/aurelien/python_modules/pyRT_DISORT/tests/disort_tests/disotest9.py", line 63, in <module>
    rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = disort.disort(usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber,
ValueError: failed in converting 30th argument `rhou' of disort.disort to C/Fortran array
kconnour commented 2 years ago

I think I know the problem, and if so all the tests should fail. I believe problem is essentially that there appear to be discrepancies throughout the native DISORT code in the definition of RHOU (and to a lesser extent, its partner RHOQ). In DISOBRDF.f (the file that populates these arrays), they define the array shapes on lines 95 and 96. The comments defining whatever these variables are (all I really know is that they're the key arrays to defining the surface phase function) are in lines 51--57, and the comments don't really match what the code does. The bigger issue is that DISORT.f defines the shape of these arrays on lines 434 and 435 in a way that's inconsistent with the shapes used in DISOBRDF.f. When I compiled the native DISORT code using f2py, absolutely nothing worked.

After chatting with Mike about it, we collectively decided the array shapes in DISORBRDF.f were correct and consequently, the shape of RHOU in DISORT.f needed modified to interface with that code. So, I modified the shape of RHOU in line 435 of DISORT.f. It now appears that all the code works together well, but the tests that come with DISORT make the RHOU arrays assuming the DISORT.f shape was originally correct---so they should all fail now. I'm a bit uneasy about this modification because I think they surely should've caught it, but it's the best we've got until we find the time to more adequately resolve it.

The disotest.py files were something Mike recommended that I do when starting this project and predate the cause of the issue, so they should also fail. I actually think they're a bit worthless because they simply copy the fortran code and test the same thing... but I left them in because they aren't hurting anything. FYI, in the disort4.0.99 folder, I created a README_pyRT_DISORT.txt file that describes all the changes I made to the source code. This is really the only modification, though I did add some surface phase function stuff.