@@ -170,34 +170,27 @@ def _create_spectrum_measurement(
170170
171171
172172def _create_measurements (plate_block : PlateBlock , position : str ) -> list [Measurement ]:
173-
174- measurement_type = plate_block .measurement_type
175173 data_elements = list (plate_block .iter_data_elements (position ))
176174
177175 # Handle spectrum measurements - create single measurement with spectrum_data_cube
178- if measurement_type in (
179- MeasurementType .ULTRAVIOLET_ABSORBANCE_CUBE_SPECTRUM ,
180- MeasurementType .EMISSION_FLUORESCENCE_CUBE_SPECTRUM ,
181- MeasurementType .EXCITATION_FLUORESCENCE_CUBE_SPECTRUM ,
182- MeasurementType .EMISSION_LUMINESCENCE_CUBE_SPECTRUM ,
183- MeasurementType .EXCITATION_LUMINESCENCE_CUBE_SPECTRUM ,
184- ):
176+ if plate_block .measurement_type .is_spectrum :
185177 measurement = _create_spectrum_measurement (plate_block , data_elements )
186178 if not measurement :
187179 return []
188180 return [measurement ]
189181
190182 return [
191183 Measurement (
192- type_ = measurement_type ,
184+ type_ = plate_block . measurement_type ,
193185 identifier = data_element .uuid ,
194186 absorbance = (
195187 (
196188 data_element .value
197189 if data_element .value is not None
198190 else NEGATIVE_ZERO
199191 )
200- if measurement_type == MeasurementType .ULTRAVIOLET_ABSORBANCE
192+ if plate_block .measurement_type
193+ is MeasurementType .ULTRAVIOLET_ABSORBANCE
201194 else None
202195 ),
203196 fluorescence = (
@@ -206,7 +199,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
206199 if data_element .value is not None
207200 else NEGATIVE_ZERO
208201 )
209- if measurement_type == MeasurementType .FLUORESCENCE
202+ if plate_block . measurement_type is MeasurementType .FLUORESCENCE
210203 else None
211204 ),
212205 luminescence = (
@@ -215,7 +208,7 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
215208 if data_element .value is not None
216209 else NEGATIVE_ZERO
217210 )
218- if measurement_type == MeasurementType .LUMINESCENCE
211+ if plate_block . measurement_type is MeasurementType .LUMINESCENCE
219212 else None
220213 ),
221214 profile_data_cube = _get_data_cube (plate_block , data_element ),
@@ -299,12 +292,22 @@ def create_calculated_data(data: StructureData) -> list[CalculatedDocument]:
299292def _get_calc_docs_data_sources (
300293 plate_block : PlateBlock , position : str
301294) -> list [DataSource ]:
295+ data_elements = list (plate_block .iter_data_elements (position ))
296+
297+ if plate_block .measurement_type .is_spectrum :
298+ return [
299+ DataSource (
300+ reference = Referenceable (data_elements [0 ].uuid ),
301+ feature = plate_block .header .read_mode ,
302+ )
303+ ]
304+
302305 return [
303306 DataSource (
304307 reference = Referenceable (data_source .uuid ),
305308 feature = plate_block .header .read_mode ,
306309 )
307- for data_source in plate_block . iter_data_elements ( position )
310+ for data_source in data_elements
308311 ]
309312
310313
0 commit comments