@@ -146,11 +146,7 @@ def dls_pose(self):
146146 return yaw , pitch , roll
147147
148148 def dls_irradiance (self ):
149- if self .get_item ('XMP:SpectralIrradiance' ) is not None :
150- irr = float (self .get_item ('XMP:SpectralIrradiance' ))
151- else :
152- irr = 0.0
153- return irr
149+ return self .spectral_irradiance ()
154150
155151 def rig_relatives (self ):
156152 if self .get_item ('XMP:RigRelatives' ) is not None :
@@ -266,17 +262,32 @@ def __float_or_zero(self, str):
266262 else :
267263 return 0.0
268264
265+ # due to calibration differences between DLS1 and DLS2, we need to account for a scale factor
266+ # change in their respective units. This scale factor is pulled from the image metadata, or, if
267+ # the metadata doesn't give us the scale, we assume one based on a known combination of tags
268+ def irradiance_scale_factor (self ):
269+ if self .get_item ('XMP:IrradianceScaleToSIUnits' ) is not None :
270+ # the metadata contains the scale
271+ scale_factor = self .__float_or_zero (self .get_item ('XMP:IrradianceScaleToSIUnits' ))
272+ elif self .get_item ('XMP:HorizontalIrradiance' ) is not None :
273+ # DLS2 but the metadata is missing the scale, assume 0.01
274+ scale_factor = 0.01
275+ else :
276+ # DLS1, so we use a scale of 1
277+ scale_factor = 1.0
278+ return scale_factor
279+
269280 def spectral_irradiance (self ):
270- return self .__float_or_zero (self .get_item ('XMP:SpectralIrradiance' ))
281+ return self .__float_or_zero (self .get_item ('XMP:SpectralIrradiance' ))* self . irradiance_scale_factor ()
271282
272283 def horizontal_irradiance (self ):
273- return self .__float_or_zero (self .get_item ('XMP:HorizontalIrradiance' ))/ 100.0
284+ return self .__float_or_zero (self .get_item ('XMP:HorizontalIrradiance' ))* self . irradiance_scale_factor ()
274285
275286 def scattered_irradiance (self ):
276- return self .__float_or_zero (self .get_item ('XMP:ScatteredIrradiance' ))
287+ return self .__float_or_zero (self .get_item ('XMP:ScatteredIrradiance' ))* self . irradiance_scale_factor ()
277288
278289 def direct_irradiance (self ):
279- return self .__float_or_zero (self .get_item ('XMP:DirectIrradiance' ))
290+ return self .__float_or_zero (self .get_item ('XMP:DirectIrradiance' ))* self . irradiance_scale_factor ()
280291
281292 def solar_azimuth (self ):
282293 return self .__float_or_zero (self .get_item ('XMP:SolarAzimuth' ))
0 commit comments