@@ -45,6 +45,9 @@ def read_cropreporter(filename):
4545 # Light-adapted measurements
4646 _process_psl_data (ps = ps , metadata = metadata_dict )
4747
48+ # NPQ measurements
49+ _process_npq_data (ps = ps , metadata = metadata_dict )
50+
4851 # Dark-adapted PAM measurements
4952 _process_pmd_data (ps = ps , metadata = metadata_dict )
5053
@@ -158,6 +161,63 @@ def _process_psl_data(ps, metadata):
158161 col_wrap = int (np .ceil (ps .ojip_light .frame_label .size / 4 )))
159162
160163
164+ def _process_npq_data (ps , metadata ):
165+ """
166+ Create an xarray DataArray for a NPQ dataset.
167+
168+ Parameters
169+ ----------
170+ ps : plantcv.plantcv.classes.PSII_data
171+ PSII_data instance
172+ metadata : dict
173+ INF file metadata dictionary
174+ """
175+ bin_filepath = _dat_filepath (dataset = "NPQ" , datapath = ps .datapath , filename = ps .filename )
176+ if os .path .exists (bin_filepath ):
177+ img_cube , frame_labels , frame_nums = _read_dat_file (dataset = "NPQ" , filename = bin_filepath ,
178+ height = int (metadata ["ImageRows" ]),
179+ width = int (metadata ["ImageCols" ]))
180+ # Add the OJIP dark frames
181+ frame_labels [0 ] = 'Fdark'
182+ frame_labels [1 ] = 'F0'
183+ frame_labels [2 ] = 'Fm'
184+ psd = xr .DataArray (
185+ data = img_cube [:, :, 0 :3 , None ],
186+ dims = ('x' , 'y' , 'frame_label' , 'measurement' ),
187+ coords = {'frame_label' : frame_labels [0 :3 ],
188+ 'frame_num' : ('frame_label' , frame_nums [0 :3 ]),
189+ 'measurement' : ['t0' ]},
190+ name = 'ojip_dark'
191+ )
192+ psd .attrs ["long_name" ] = "OJIP dark-adapted measurements"
193+ ps .add_data (psd )
194+
195+ _debug (visual = ps .ojip_dark .squeeze ('measurement' , drop = True ),
196+ filename = os .path .join (params .debug_outdir , f"{ str (params .device )} _PSD-frames.png" ),
197+ col = 'frame_label' ,
198+ col_wrap = int (np .ceil (ps .ojip_dark .frame_label .size / 4 )))
199+
200+ # Add the OJIP light frames
201+ frame_labels [3 ] = 'Flight'
202+ frame_labels [4 ] = 'Fp'
203+ frame_labels [5 ] = 'Fmp'
204+ psd = xr .DataArray (
205+ data = img_cube [:, :, 3 :6 , None ],
206+ dims = ('x' , 'y' , 'frame_label' , 'measurement' ),
207+ coords = {'frame_label' : frame_labels [3 :6 ],
208+ 'frame_num' : ('frame_label' , frame_nums [3 :6 ]),
209+ 'measurement' : ['t0' ]},
210+ name = 'ojip_light'
211+ )
212+ psd .attrs ["long_name" ] = "OJIP light-adapted measurements"
213+ ps .add_data (psd )
214+
215+ _debug (visual = ps .ojip_light .squeeze ('measurement' , drop = True ),
216+ filename = os .path .join (params .debug_outdir , f"{ str (params .device )} _PSL-frames.png" ),
217+ col = 'frame_label' ,
218+ col_wrap = int (np .ceil (ps .ojip_light .frame_label .size / 4 )))
219+
220+
161221def _process_pmd_data (ps , metadata ):
162222 """
163223 Create an xarray DataArray for a PMD dataset.
0 commit comments