Scale internal units for echo tops and accumulation for GR compatibility

This commit is contained in:
Dan Paulat 2024-04-25 23:59:30 -05:00
parent 5ee2d10a1b
commit dccbf0d12f
5 changed files with 43 additions and 7 deletions

View file

@ -1,6 +1,7 @@
; NEXRAD Level-3 palette for product code 135 - EET - Enhanced Echo Tops
Units: KFT
Scale: 3.281 ; convert internal units (KM) to KFT
Color: 75 231 0 255
Color: 70 255 255 255
Color: 65 255 0 0

View file

@ -1,6 +1,6 @@
; NEXRAD Level-3 palette for product code 169, OHA, One Hour Precip, 16 Levels
Units IN
Units: IN
Scale: 0.03937 ; convert internal units (MM) to INCHES
Color: 4.0 255 255 255

View file

@ -406,12 +406,7 @@ std::optional<float> Level3ProductView::GetDataValue(std::uint16_t level) const
bool Level3ProductView::IgnoreUnits() const
{
// Don't display units on these products. The current method of displaying
// units is not accurate for these.
static const std::unordered_set<std::string> kIgnoreUnitsProducts_ {
"DAA", "DTA", "DU3", "DU6"};
return (kIgnoreUnitsProducts_.contains(p->product_));
return false;
}
} // namespace view

View file

@ -70,6 +70,8 @@ public:
float log_offset() const;
float log_scale() const;
float gr_scale() const;
std::uint8_t data_mask() const;
std::uint8_t topped_mask() const;

View file

@ -7,6 +7,8 @@
#include <set>
#include <string>
#include <units/length.h>
namespace scwx
{
namespace wsr88d
@ -86,6 +88,23 @@ static const std::unordered_map<int, unsigned int> yResolutionMap_ {{37, 1000},
{98, 4000},
{166, 250}};
// GR uses different internal units than defined units in level 3 products
static const std::unordered_map<std::int16_t, float> grScale_ {
{78, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{79, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{80, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{81, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{82, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{41, ((units::feet<float> {1} * 1000.0f) / units::kilometers<float> {1})},
{135, ((units::feet<float> {1} * 1000.0f) / units::kilometers<float> {1})},
{169, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{170, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{171, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{172, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{173, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{174, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})},
{175, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})}};
class ProductDescriptionBlockImpl
{
public:
@ -654,6 +673,19 @@ float ProductDescriptionBlock::log_scale() const
return logScale;
}
float ProductDescriptionBlock::gr_scale() const
{
float grScale = 1.0f;
auto it = grScale_.find(p->productCode_);
if (it != grScale_.cend())
{
grScale = it->second;
}
return grScale;
}
std::uint8_t ProductDescriptionBlock::data_mask() const
{
std::uint8_t dataMask = 0xff;
@ -1138,6 +1170,12 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const
}
}
// Scale for GR compatibility
if (f.has_value())
{
f = f.value() * gr_scale();
}
return f;
}