mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:20:04 +00:00 
			
		
		
		
	Index volume scan by time, change internal data structure from unordered to ordered map
This commit is contained in:
		
							parent
							
								
									e78231ac48
								
							
						
					
					
						commit
						efeb87baaa
					
				
					 9 changed files with 104 additions and 71 deletions
				
			
		|  | @ -42,7 +42,9 @@ public: | |||
|    std::vector<float> coordinates0_5Degree_; | ||||
|    std::vector<float> coordinates1Degree_; | ||||
| 
 | ||||
|    std::deque<std::shared_ptr<wsr88d::Ar2vFile>> level2Data_; | ||||
|    std::map<std::chrono::system_clock::time_point, | ||||
|             std::shared_ptr<wsr88d::Ar2vFile>> | ||||
|       level2VolumeScans_; | ||||
| }; | ||||
| 
 | ||||
| RadarProductManager::RadarProductManager() : | ||||
|  | @ -67,9 +69,9 @@ std::shared_ptr<const wsr88d::Ar2vFile> RadarProductManager::level2_data() const | |||
| { | ||||
|    std::shared_ptr<const wsr88d::Ar2vFile> level2Data = nullptr; | ||||
| 
 | ||||
|    if (p->level2Data_.size() > 0) | ||||
|    if (p->level2VolumeScans_.size() > 0) | ||||
|    { | ||||
|       level2Data = p->level2Data_.back(); | ||||
|       level2Data = p->level2VolumeScans_.crbegin()->second; | ||||
|    } | ||||
| 
 | ||||
|    return level2Data; | ||||
|  | @ -173,28 +175,22 @@ void RadarProductManager::LoadLevel2Data(const std::string& filename) | |||
|       return; | ||||
|    } | ||||
| 
 | ||||
|    // TODO: Sort and index these
 | ||||
|    if (p->level2Data_.size() >= MAX_LEVEL2_FILES - 1) | ||||
|    { | ||||
|       p->level2Data_.pop_front(); | ||||
|    } | ||||
|    p->level2Data_.push_back(ar2vFile); | ||||
|    p->level2VolumeScans_[ar2vFile->start_time()] = ar2vFile; | ||||
| 
 | ||||
|    emit Level2DataLoaded(); | ||||
| } | ||||
| 
 | ||||
| std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> | ||||
| std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> | ||||
| RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | ||||
|                                    uint8_t                    elevationIndex, | ||||
|                                    std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> | ||||
|       radarData; | ||||
|    std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> radarData; | ||||
| 
 | ||||
|    if (p->level2Data_.size() > 0) | ||||
|    if (p->level2VolumeScans_.size() > 0) | ||||
|    { | ||||
|       // TODO: Pull this from the database
 | ||||
|       radarData = p->level2Data_[0]->radar_data()[elevationIndex]; | ||||
|       radarData = | ||||
|          p->level2VolumeScans_.crbegin()->second->radar_data()[elevationIndex]; | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|  |  | |||
|  | @ -33,7 +33,7 @@ public: | |||
|    void Initialize(); | ||||
|    void LoadLevel2Data(const std::string& filename); | ||||
| 
 | ||||
|    std::unordered_map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> | ||||
|    std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> | ||||
|    GetLevel2Data(wsr88d::rda::DataBlockType            dataBlockType, | ||||
|                  uint8_t                               elevationIndex, | ||||
|                  std::chrono::system_clock::time_point time = {}); | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| #include <scwx/qt/view/level2_product_view.hpp> | ||||
| #include <scwx/common/constants.hpp> | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| #include <boost/log/trivial.hpp> | ||||
| #include <boost/range/irange.hpp> | ||||
|  | @ -34,9 +35,6 @@ static const std::unordered_map<common::Level2Product, | |||
|       {common::Level2Product::ClutterFilterPowerRemoved, | ||||
|        wsr88d::rda::DataBlockType::MomentCfp}}; | ||||
| 
 | ||||
| static std::chrono::system_clock::time_point | ||||
| TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds); | ||||
| 
 | ||||
| class Level2ProductViewImpl | ||||
| { | ||||
| public: | ||||
|  | @ -250,7 +248,8 @@ void Level2ProductView::ComputeSweep() | |||
|    const std::vector<float>& coordinates = | ||||
|       p->radarProductManager_->coordinates(radialSize); | ||||
| 
 | ||||
|    auto momentData0     = radarData[0]->moment_data_block(p->dataBlockType_); | ||||
|    auto radarData0      = radarData[0]; | ||||
|    auto momentData0     = radarData0->moment_data_block(p->dataBlockType_); | ||||
|    p->momentDataBlock0_ = momentData0; | ||||
| 
 | ||||
|    if (momentData0 == nullptr) | ||||
|  | @ -260,11 +259,11 @@ void Level2ProductView::ComputeSweep() | |||
|       return; | ||||
|    } | ||||
| 
 | ||||
|    auto volumeData0 = radarData[0]->volume_data_block(); | ||||
|    auto volumeData0 = radarData0->volume_data_block(); | ||||
|    p->latitude_     = volumeData0->latitude(); | ||||
|    p->longitude_    = volumeData0->longitude(); | ||||
|    p->sweepTime_    = TimePoint(radarData[0]->modified_julian_date(), | ||||
|                              radarData[0]->collection_time()); | ||||
|    p->sweepTime_    = util::TimePoint(radarData0->modified_julian_date(), | ||||
|                                    radarData0->collection_time()); | ||||
| 
 | ||||
|    // Calculate vertices
 | ||||
|    timer.start(); | ||||
|  | @ -307,16 +306,16 @@ void Level2ProductView::ComputeSweep() | |||
|    //   1 = 0.5 degrees
 | ||||
|    //   2 = 1.0 degrees
 | ||||
|    const float radialMultiplier = | ||||
|       2.0f / | ||||
|       std::clamp<int8_t>(radarData[0]->azimuth_resolution_spacing(), 1, 2); | ||||
|       2.0f / std::clamp<int8_t>(radarData0->azimuth_resolution_spacing(), 1, 2); | ||||
| 
 | ||||
|    const float    startAngle  = radarData[0]->azimuth_angle(); | ||||
|    const float    startAngle  = radarData0->azimuth_angle(); | ||||
|    const uint16_t startRadial = std::lroundf(startAngle * radialMultiplier); | ||||
| 
 | ||||
|    for (uint16_t radial = 0; radial < radials; ++radial) | ||||
|    for (auto radialPair : radarData) | ||||
|    { | ||||
|       auto radialData = radarData[radial]; | ||||
|       auto momentData = radarData[radial]->moment_data_block(p->dataBlockType_); | ||||
|       uint16_t radial     = radialPair.first; | ||||
|       auto     radialData = radialPair.second; | ||||
|       auto     momentData = radialData->moment_data_block(p->dataBlockType_); | ||||
| 
 | ||||
|       if (momentData0->data_word_size() != momentData->data_word_size()) | ||||
|       { | ||||
|  | @ -481,17 +480,6 @@ std::shared_ptr<Level2ProductView> Level2ProductView::Create( | |||
|    return std::make_shared<Level2ProductView>(product, radarProductManager); | ||||
| } | ||||
| 
 | ||||
| static std::chrono::system_clock::time_point | ||||
| TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds) | ||||
| { | ||||
|    using namespace std::chrono; | ||||
|    using sys_days       = time_point<system_clock, days>; | ||||
|    constexpr auto epoch = sys_days {1969y / December / 31d}; | ||||
| 
 | ||||
|    return epoch + (modifiedJulianDate * 24h) + | ||||
|           std::chrono::milliseconds {milliseconds}; | ||||
| } | ||||
| 
 | ||||
| } // namespace view
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat