def main(): if len(sys.argv) < 2: run() elif sys.argv[1] == "init": make_toml("./") elif sys.argv[1] == "run": run() else: LOG.critical("Can't interpret CLI parameters.")
def get_capacities(self, datatreatment): """ Returns capacity in a potential interval for each cycle. Appends to filename "./capacities.txt" """ if not len(datatreatment['print_capacities']) % 2 == 0: LOG.critical( "You wanted to get the potential-interval capacities, but you inserted an odd number of boundaries. You need two boundaries for each range, eg: [3.5, 4.4, 4.4, 5.0] will be two ranges from 3.5->4.4 and 4.4->5.0. The capacities will not be printed." ) else: intervals = [] for i, pot in enumerate(datatreatment['print_capacities']): if i % 2 != 0: #if the index number is odd, we are making a range of it intervals.append( (datatreatment['print_capacities'][i - 1], pot)) LOG.info( "Found intervals for capacity print: {}".format(intervals)) if self.GCdata: data = self.GCdata elif self.CVdata: data = self.CVdata else: self.edit_GC() import numpy as np def _find_charge(chg, interval): start, stop = interval cap, pot = chg pot = np.asarray(pot) idxstart = (np.abs(pot - start)).argmin() idxstop = (np.abs(pot - stop)).argmin() capdiff = cap[idxstop] - cap[idxstart] return abs(capdiff) # Format list like: [chg, dchg], chg = [cap in interval 1, cap in interval 2, cap in interval n] caps = {self.name: {}} for interval in intervals: caps[self.name][str(interval)] = { "charge": [], "discharge": [] } if self.specific_cycles: for i, cycle in enumerate(data): if i in self.specific_cycles: chg, dchg = cycle for interval in intervals: caps[self.name][str(interval)]["charge"].append( _find_charge(chg, interval)) caps[self.name][str(interval)]["discharge"].append( _find_charge(dchg, interval)) else: for i, cycle in enumerate(data): chg, dchg = cycle for interval in intervals: caps[self.name][str(interval)]["charge"].append( _find_charge(chg, interval)) caps[self.name][str(interval)]["discharge"].append( _find_charge(dchg, interval)) return caps