def load_qa_data(self, remove=False, multi_root=None): """ Load the QA data files for a given exposure (currently yaml) Args: remove: bool, optional Remove QA frame files multi_root: str, optional If provided, load the QA from a slurped file (preferred because it is fast) """ if multi_root is None: qafiles = desiio.get_files(filetype='qa_' + self.type, night=self.night, expid=self.expid, specprod_dir=self.specprod_dir) # Load into frames for camera, qadata_path in qafiles.items(): qa_frame = desiio.load_qa_frame(qadata_path) # Remove? if remove: os.remove(qadata_path) # Test for key in ['expid', 'night']: assert getattr(qa_frame, key) == getattr(self, key) # Save self.data['frames'][camera] = qa_frame.qa_data else: # Load mdict = load_qa_multiexp(os.path.join(self.qaprod_dir, multi_root)) self.parse_multi_qa_dict(mdict)
def load_data(self, inroot=None): """ Load QA data from disk """ from desispec.io import load_qa_multiexp # Init if inroot is None: inroot = self.qaexp_outroot # Load self.data = load_qa_multiexp(inroot)
def slurp_into_file(self, multi_root): """ Write the data of an Exposure object into a JSON file Args: multi_root: Returns: """ # Load mdict_root = os.path.join(self.qaprod_dir, multi_root) mdict = load_qa_multiexp(mdict_root) # Check on night if self.night not in mdict.keys(): mdict[self.night] = {} # Insert idict = write_qa_exposure('foo', self, ret_dict=True) mdict[self.night][str(self.expid)] = idict[self.night][self.expid] # Write write_qa_multiexp(mdict_root, mdict)