mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	derived/energy: Fix energy calculation
Correctly detect whether or not the energy should be calculated from power or extracted directly. Previously both methods were being used at the same time, resulting in incorrect total energy values.
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							335fa77e4e
						
					
				
				
					commit
					078f0dc641
				
			@@ -30,13 +30,13 @@ class DerivedEnergyMeasurements(DerivedMeasurements):
 | 
				
			|||||||
        # Determine sites to calculate energy for
 | 
					        # Determine sites to calculate energy for
 | 
				
			||||||
        channel_map = defaultdict(list)
 | 
					        channel_map = defaultdict(list)
 | 
				
			||||||
        for channel in measurements_csv.channels:
 | 
					        for channel in measurements_csv.channels:
 | 
				
			||||||
            channel_map[channel].append(channel.kind)
 | 
					            channel_map[channel.site].append(channel.kind)
 | 
				
			||||||
        for channel, kinds in channel_map.iteritems():
 | 
					 | 
				
			||||||
            if 'power' in kinds and not 'energy' in kinds:
 | 
					 | 
				
			||||||
                should_calculate_energy.append(channel.site)
 | 
					 | 
				
			||||||
            if channel.site == 'timestamp':
 | 
					            if channel.site == 'timestamp':
 | 
				
			||||||
                use_timestamp = True
 | 
					                use_timestamp = True
 | 
				
			||||||
                time_measurment = channel.measurement_type
 | 
					                time_measurment = channel.measurement_type
 | 
				
			||||||
 | 
					        for site, kinds in channel_map.iteritems():
 | 
				
			||||||
 | 
					            if 'power' in kinds and not 'energy' in kinds:
 | 
				
			||||||
 | 
					                should_calculate_energy.append(site)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if measurements_csv.sample_rate_hz is None and not use_timestamp:
 | 
					        if measurements_csv.sample_rate_hz is None and not use_timestamp:
 | 
				
			||||||
            msg = 'Timestamp data is unavailable, please provide a sample rate'
 | 
					            msg = 'Timestamp data is unavailable, please provide a sample rate'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user