mdsplus icon indicating copy to clipboard operation
mdsplus copied to clipboard

jTraverser2 fails to display VMS floating point numbers (DTYPE_F)

Open santorofer opened this issue 2 years ago • 3 comments

Affiliation MIT / PSFC

Version(s) Affected MDSplus Release: alpha_release_7.139.33

Platform Ubuntu 20

Describe the bug jTraverser2 fails to display VMS floating point numbers (DTYPE_F).

For example, when opening CMOD tree for a particular shot number, the node TSTART should contain the value -4. While instead, it contains the value 69.414721F-42, see screenshot below:

Screenshot 2023-05-17 at 5 07 26 PM

While, if the same node is accessed using Python:

>>> import MDSplus
>>> t=MDSplus.Tree('cmod', 1160909001)
>>> t.TSTART.data()
-4.0
>>>

To Reproduce Steps to reproduce the behavior:

  1. Start jTraverser2
  2. Open a CMOD shot.
  3. Hover over the node TSTART
  4. See the erroneous value being displayed

Expected behavior The node value shown by jTraverser should be a correct floating point number, in this case, -4.0

santorofer avatar May 17 '23 21:05 santorofer

thisbius expected as non ieee floats have not been implemented yet.. one would have to convert them based on dtype before creating Float32Arrays or Float32 or implement a wrapping class e.g. FloatVMS* that handles those dtypes. same holds for other exotic float types.

zack-vii avatar Jul 07 '23 07:07 zack-vii

Timo, we have been debugging (jTraverser2 and mdsplus-api) this issue for a while, and found that it stems from ByteBuffer being used to read the floats from their binary representation. We want to add a call to TDI's FT_FLOAT/FS_FLOAT, but couldn't figure out where to put it. Since you are more familiar with that API, can you take a crack at it?.

santorofer avatar Sep 05 '23 19:09 santorofer

the conversion could be done during deserialization https://github.com/MDSplus/mdsplus/blob/0df72258c108db26df57160e483796c98d941d81/java/mdsplus-api/src/main/java/mds/data/descriptor/Descriptor_S.java#L19

here as an example for scalars the dtype is used to map to the appropriate java class. one could either convert here before passing the buffer to the Float32. or one could make a dedicated FFloat class that handles the conversion in getValue().

same could be done for the DFloat (same as FC, DC, G, and GC).

I will try to find some time to give the getValue() attempt a try.. I would implement the conversion in java though rather than relying on tdi if its not too complicated.

zack-vii avatar Sep 05 '23 19:09 zack-vii