NRC-Research / SNAP-issues

This repository was created to provide a public location to record and display the status of "issues" for the SNAP application. The SNAP developers will acknowledge, provide (and maybe request) feedback on the reported issues, and in general use the information to improve SNAP code.
3 stars 0 forks source link

AptPlot engineering unit codes support - NRC Databank Files #96

Closed AndrewIrelandNRC closed 1 month ago

AndrewIrelandNRC commented 1 month ago

AptPlot supports engineering unit codes up to at least 522 in NRC Databank files. The AptPlot stream step gives errors for unit codes above 518. Maybe AptBatch is not consistent with AptPlot? (FYI, unit codes in this range are used in the APEX databank files.)

From aptplot.screen

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 518 java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 519 java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 520 java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 521

AndrewIrelandNRC commented 1 month ago

This error does not occur for APEX, but does for a dummy file with all unit codes. I will investigate further.

AndrewIrelandNRC commented 1 month ago

Closing until I have more info.

NRCgg commented 1 month ago

@WDunsford Can you see if you can help @AndrewIrelandNRC with this issue?

WDunsford commented 1 month ago

So, looking at the code the EUCode is how AptPlot identifies engineering units for NRC Databank format. AptPlot has supported 519 different engineering units since 2011 when the initial support was added to AptPlot. As an example, EU code 518 is "Heater Power" with "kW" and "Btu/s" being the unit labels for SI and British respectively with "9.478171200e-1" as the conversion factor.

It's relatively simple to add new units, if the format has been changed to include additional units. Are those documented somewhere?

AndrewIrelandNRC commented 1 month ago

This came to my attention because we have our in-house python script for reading the databank files. When it was given APEX data to chew on, it threw errors due to unrecognized unit codes. The unit codes I had been using were derived from old ACGrace source, which only went up to unit code 518 like you said.

But, the APEX test pib contains unit codes 519 through 522. When I created a dummy pib with all units up to 522, that's where I get the errors in the SNAP stream. APTPlot standalone still works okay for those units and seems to support up to unit code 522. (523 will cause problems.)

If you reverse engineer them from APTPlot, they are these...

units.addUnitCode(519,1,  "Differential Pressure",      "in h2o",           "cm h2o",           2.540               )
units.addUnitCode(520,1,  "Water Level",                "in",               "cm",               2.540               )
units.addUnitCode(521,1,  "Steam Flow Rate",            "cfm",              "m^3/min",          2.831685e-2         )
units.addUnitCode(522,1,  "Wall Temperature",           "F",                "K",                -2.0                )

I can send you the dummy pib file, but I'm not sure about APEX. Maybe you already have access to it somehow. (Rename from .log to .bin) all_units.log

WDunsford commented 1 month ago

This is resolved for AptPlot 8.0.5 which will be released 8/27/2024

AndrewIrelandNRC commented 1 month ago

Is there an updated list of unit codes supported in the pib spec? I only have documentation of the original 450 codes from back in 1997.

NRC Databank PIB Format.pdf

WDunsford commented 1 month ago

NRCDB.pdf

This is from the AptPlot source code. The conversion factor is a multiplier from SI to British.

AndrewIrelandNRC commented 1 month ago

Excellent! Thank you!

Incidentally, I think your columns should be something like "Native Unit" / "Converted Unit" instead of "British" / "SI". The conversion factor is from "Native Unit" to "Converted Unit" if I understand it correctly.