def get_base_filenames(self, ls="all", extension='', single_file=False, output_dir=None): """ Get a dict of time:base_filename pairs for outputting things to. If single_file is true, then returns a single string. Warning: This doesn't check that ls is an actual lifestage. """ if output_dir is None: output_dir = os.path.join(self.instance.experiment.base_dir, "output") else: output_dir = os.path.normpath(output_dir) fn = outputformats.create_filename(self) if single_file: result = os.path.join(output_dir, fn + "_ls_" + ls) if extension: result += extension else: result = {} env = self.get_saved_maps(ls) # If there are no occupancy envelopes return None if env is None: return None times = env.keys() times.sort(key=lambda x: float(x)) for t in times: result[t] = os.path.join(output_dir, fn + "_ls_" + ls + "_" + str(t)) if extension: result[t] += extension return result
def get_occ_envelope_img_filenames(self, ls="all", extension=True, gif=False, dir=None): if dir is None: output_dir = os.path.join(self.experiment.base_dir, "output") else: output_dir = os.path.normpath(dir) fn = outputformats.create_filename(self) if gif: result = os.path.join(output_dir, fn + "_ls_" + ls + "_anim") if extension: result += '.gif' else: result = {} env = self.get_occupancy_envelopes() # If there are no occupancy envelopes return None if env is None: return None times = env[ls].keys() times.sort(key=lambda x: float(x)) for t in times: result[t] = os.path.join(output_dir, fn + "_ls_" + ls + "_" + str(t)) if extension: result[t] += '.png' return result
def get_occ_envelope_img_filenames(self, ls="all", extension=True, gif=False, dir=None): if dir is None: output_dir = os.path.join(self.experiment.base_dir,"output") else: output_dir = os.path.normpath(dir) fn = outputformats.create_filename(self) if gif: result = os.path.join(output_dir, fn + "_ls_" + ls + "_anim") if extension: result += '.gif' else: result = {} env = self.get_occupancy_envelopes() # If there are no occupancy envelopes return None if env is None: return None times = env[ls].keys() times.sort(key=lambda x: float(x)) for t in times: result[t] = os.path.join(output_dir, fn + "_ls_" + ls + "_" + str(t)) if extension: result[t] += '.png' return result
def _make_filename(self,rep): mdig_config = config.get_config() nodes = self.xml_node.xpath("output/file") if len(nodes) == 0: self.log.error("File to output analysis to is not defined") sys.exit(3) node = nodes[0] # text in file element is the prefix to the generated name prefix = "" if node.text is not None: prefix=node.text.strip() # Find out if we generate anything to add to prefix is_generate = True if "generate" in node.attrib.keys(): if node.attrib["generate"].lower() == "false": is_generate = False # Get extension if specified ext = "" if "ext" in node.attrib.keys(): ext = node.attrib["ext"] # check whether we are appending to the same file is_append = self.is_append() if rep.instance.experiment.base_dir is None: generated = mdig_config.analysis_dir else: generated = os.path.join( rep.instance.experiment.base_dir, mdig_config.analysis_dir) generated = os.path.join(generated, prefix) generated += outputformats.create_filename(rep) if not is_append: generated += "_t_" + repr(rep.current_t) if len(ext) > 0: generated += ext return generated
def _make_filename(self, rep): mdig_config = config.get_config() nodes = self.xml_node.xpath("output/file") if len(nodes) == 0: self.log.error("File to output analysis to is not defined") sys.exit(3) node = nodes[0] # text in file element is the prefix to the generated name prefix = "" if node.text is not None: prefix = node.text.strip() # Find out if we generate anything to add to prefix is_generate = True if "generate" in node.attrib.keys(): if node.attrib["generate"].lower() == "false": is_generate = False # Get extension if specified ext = "" if "ext" in node.attrib.keys(): ext = node.attrib["ext"] # check whether we are appending to the same file is_append = self.is_append() if rep.instance.experiment.base_dir is None: generated = mdig_config.analysis_dir else: generated = os.path.join(rep.instance.experiment.base_dir, mdig_config.analysis_dir) generated = os.path.join(generated, prefix) generated += outputformats.create_filename(rep) if not is_append: generated += "_t_" + repr(rep.current_t) if len(ext) > 0: generated += ext return generated