mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:40:04 +00:00 
			
		
		
		
	Add VIL-specific data level conversions
This commit is contained in:
		
							parent
							
								
									0a1754db84
								
							
						
					
					
						commit
						24062d0417
					
				
					 2 changed files with 32 additions and 4 deletions
				
			
		|  | @ -66,6 +66,7 @@ public: | ||||||
|    std::optional<DataLevelCode> data_level_code(std::uint8_t level) const; |    std::optional<DataLevelCode> data_level_code(std::uint8_t level) const; | ||||||
|    std::optional<float>         data_value(std::uint8_t level) const; |    std::optional<float>         data_value(std::uint8_t level) const; | ||||||
| 
 | 
 | ||||||
|  |    std::uint16_t log_start() const; | ||||||
|    float         log_offset() const; |    float         log_offset() const; | ||||||
|    float         log_scale() const; |    float         log_scale() const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <array> | #include <array> | ||||||
| #include <istream> | #include <istream> | ||||||
|  | #include <numbers> | ||||||
| #include <set> | #include <set> | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
|  | @ -591,6 +592,20 @@ uint16_t ProductDescriptionBlock::number_of_levels() const | ||||||
|    return numberOfLevels; |    return numberOfLevels; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::uint16_t ProductDescriptionBlock::log_start() const | ||||||
|  | { | ||||||
|  |    std::uint16_t logStart = std::numeric_limits<std::uint16_t>::max(); | ||||||
|  | 
 | ||||||
|  |    switch (p->productCode_) | ||||||
|  |    { | ||||||
|  |    case 134: | ||||||
|  |       logStart = p->halfword(33); | ||||||
|  |       break; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return logStart; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| float ProductDescriptionBlock::log_offset() const | float ProductDescriptionBlock::log_offset() const | ||||||
| { | { | ||||||
|    float logOffset = 0.0f; |    float logOffset = 0.0f; | ||||||
|  | @ -598,7 +613,7 @@ float ProductDescriptionBlock::log_offset() const | ||||||
|    switch (p->productCode_) |    switch (p->productCode_) | ||||||
|    { |    { | ||||||
|    case 134: |    case 134: | ||||||
|       logOffset = util ::DecodeFloat16(p->halfword(35)); |       logOffset = util::DecodeFloat16(p->halfword(35)); | ||||||
|       break; |       break; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | @ -612,7 +627,7 @@ float ProductDescriptionBlock::log_scale() const | ||||||
|    switch (p->productCode_) |    switch (p->productCode_) | ||||||
|    { |    { | ||||||
|    case 134: |    case 134: | ||||||
|       logScale = util ::DecodeFloat16(p->halfword(34)); |       logScale = util::DecodeFloat16(p->halfword(34)); | ||||||
|       break; |       break; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | @ -1007,6 +1022,18 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | ||||||
|          f = (level - dataOffset) / dataScale; |          f = (level - dataOffset) / dataScale; | ||||||
|          break; |          break; | ||||||
| 
 | 
 | ||||||
|  |       case 134: | ||||||
|  |          if (level < log_start()) | ||||||
|  |          { | ||||||
|  |             f = (level - dataOffset) / dataScale; | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             f = static_cast<float>(std::pow<double>( | ||||||
|  |                std::numbers::e, (level - log_offset()) / log_scale())); | ||||||
|  |          } | ||||||
|  |          break; | ||||||
|  | 
 | ||||||
|       default: |       default: | ||||||
|          f = level * dataScale + dataOffset; |          f = level * dataScale + dataOffset; | ||||||
|          break; |          break; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat