def __init__(self, **kwargs): #standard #required self.file_name = None self.dim_seperator = None #optional self.data_type = "unknown" self.len_dat_file = 0 self._readout_every_n_line = 1 self.folder = "" self.buffer = int(10e6) self.silent_readout = False #individual self.setArgs(**kwargs) _utils.checkRequiredArgs({"file":self.file_name, "dimSeperator":self.dim_seperator}) #init baseClass super(plainText,self).__init__(self.data_type) #count lines self._setReadoutEveryNLine(self._readout_every_n_line) #helper-values self.n_line = 0
def __init__(self, **kwargs): ##standard #required self.file_name = None self.sheet_name_or_number= None #optional self.folder= "" self._readout_every_n_line = 1 self.data_type = "unknown" self.ignore_empty_cells = True self.silent_readout = False #individual self.setArgs(**kwargs) _utils.checkRequiredArgs({ "file":self.file_name, "sheet":self.sheet_name_or_number}) super(libreOfficeCalc,self).__init__(self.data_type) #helpers self.empty_cell_list = [] self.finished_building_empty_cell_list = False self._index_counter = -1 #helps to indices the dimensions self.coord_list = []
def __init__(self, source, **kwargs): super(basisDimension,self).__init__(source) #standard self.name = None self.index = None self.resolution = None self.unit = None self.prefix = "" self._includeAll() #helpers self._take_all_values = True self._include_chronic = False self._include_range = [None, None] self._recent_position = 0 #will be updated by target-class self._plot_range = slice(None,None,None) self._update_sort_range = True self._is_folder = False self._str_folder_values = None #indivídual self.setArgs(**kwargs) _utils.checkRequiredArgs({ "name":self.name, "index":self.index, "resolution":self.resolution, "unit":self.unit}) if self._is_folder: self._getFolderValues()
def __init__(self, **kwargs): ##standard #required self.file_name = None self.dim_seperator = None self.stop_via = None #optional self.data_type = "unknown" self.folder = "" self.key_to_end_process = "" self.run_in_shell = False self._readout_every_n_line = 1 self._infoEveryNLines = 1000 self.start_via = "" self._print_readoutEverNLine = False self.silent_readout = False #individual self.setArgs(**kwargs) _utils.checkRequiredArgs({ "command":self.command, "file":self.file_name, "dimSeparator":self.dim_seperator, "stopVia":self.stop_via}) super(stream,self).__init__(self.data_type) #helpers self.engine = None self._calc_readoutEverNLine = False self._old_stream_len = 0
def __init__(self, source, **kwargs): super(mergeDimension,self).__init__(source) #standard self.name = None self.index = None self.resolution = None self.unit = None self.prefix = None self._mergeMethod = mergeMethods.last() #individual self.setArgs(**kwargs) _utils.checkRequiredArgs({ "name":self.name, "index":self.index, "unit":self.unit }) self._alias = _aliasContainer(self)
def save(self, **kwargs): ''' Save the following matrices (of all mergeDimensions) to file: * basisMatrix * mergeMatrix * densityMatrix **Required kwargs** ("keyword arguments") are: ================== =============== ============= ================ Keyword Type Example Description ================== =============== ============= ================ *name* string "test" prename of the saved files. ================== =============== ============= ================ Optional kwargs ("keyword arguments") are: ================== ======== ======= ============================ Keyword Type Default Description ================== ======== ======= ============================ *folder* string "" Name of the folder to save in ================== ======== ======= ============================ ''' ## *ftype* string "bin" "bin": output is saved in computer-readable binary-form, "txt": output is saved in a human-readable-form #standard file_name = None folder_name = "" #save_type = "bin" #individual for key in kwargs: if key == "name": file_name = str(kwargs[key]) elif key == "folder": folder_name = str(kwargs[key]) #elif key == "ftype": #if kwargs[key] == "bin": #save_type = "bin" #elif kwargs[key] == "txt": #save_type = "txt" #else: #raise KeyError("ERROR: target.save 'type' must be 'bin' or 'txt'") else: raise KeyError("keyword '%s' not known" %key) _utils.checkRequiredArgs({ "name":file_name}) print "saving matrix ..." file_name = _utils.prepareFileSystem(file_name, folder_name)#combining file and folder file_name = _utils.prepareFileSystem("",file_name)#creating file-folder #print file_name #if save_type == "bin": for i in range(self.nMerge): f = "%s%s_merge" %(file_name, self._merge_dim[i].name) numpy.save(f, self.mergeMatrix[i]) numpy.savetxt(f, self.mergeMatrix[i], fmt = "%10.5f") print "created %s" %f f = "%s%s_density" %(file_name, self._merge_dim[i].name) numpy.save(f, self.densityMatrix[i]) numpy.savetxt(f, self.densityMatrix[i], fmt = "%10.5f") print "created %s" %f f = "%sbasis" %(file_name) numpy.save(f, self.basisMatrix) numpy.savetxt(f, numpy.array(self.basisMatrix), fmt = "%10.5f") print "created %s" %f
def autoZoom(self, **kwargs): ''' **Required kwargs** ("keyword arguments") are: ================== =============== ============= ================ Keyword Type Example Description ================== =============== ============= ================ *mergeName* str myMergeName the name of the merge-dim to do the method on *value* float/string *max* The merge-value to zoom in. Type 'min' or 'max' to use the equivalent extrem-value in the matrix *scale* string *'relative'* **OR** *'absolute'* *level* float 0.3 The relative zoom-level 0.3 means +-30% around the zoom-point ================== =============== ============= ================ **Optional kwargs** ("keyword arguments") are: ================== ================= ============ ================ Keyword Type Default Description ================== ================= ============ ================ *basisNames* list(basisNames) [{all}] Which basisDimensions get a new scale. *operator* string "==" The zoom-point is defined as the first point in matrix where a value in "==" (equal), ">" (bigger) etc. than the given *value* ================== ================= ============ ================ ''' #standard mergeDim = None value=None scale=None level=None operator = "==" basisDim = range(self.nBasis) #individual for key in kwargs: if key == "mergeName": if kwargs[key] not in self.mergeNames: raise KeyError("ERROR: mergeName %s not known" %kwargs[key]) mergeDim = self.mergeNames.index(kwargs[key]) elif key == "value": if type(kwargs[key]) == str: if kwargs[key] != "max" and kwargs[key] != "min": exit("ERROR: 'value' can only be 'max', 'min' or a float") value = kwargs[key] else: value = str(kwargs[key]) elif key == "scale": if kwargs[key] != "absolute" and kwargs[key] != "relative": exit("ERROR: 'scale' in method 'autoZoom' has to be 'absolute' or 'relative'") scale = str(kwargs[key]) elif key == "level": level = abs(float(kwargs[key])) elif key == "operator": operator = str(kwargs[key]) elif key == "basisNames": basisDim = list(kwargs[key]) for n,b in enumerate(basisDim): if b not in self.basisNames: exit("ERROR: the given basisDimension %s does not belong to those from target" %b) basisDim[n] = self.basisNames.index(b) else: raise KeyError("keyword '%s' not known" %key) _utils.checkRequiredArgs({ "mergeName":mergeDim, "value":value, "scale":scale, "level":level}) #which mergeMatrix is involved? m=self.mergeMatrix[mergeDim] #prepare value if value=="max": value = bn.nanmax(m) elif value=="min": value = bn.nanmin(m) if np.isnan(value): raise ValueError("cannot autoZoom to nan") #get position in matrix #try: positions=np.argwhere(eval(str(value) + operator + "m"))[0] print "\n... do autoZoom for basisDimensions at a mergeValue of %s" %value for n,p in enumerate(positions): if n in basisDim: #get basis-values at those positions zoompoint = self.basisMatrix[n][p] #calc. the new range if scale == "relative": basis_range = self._basis_dim[n]._include_range[1]-self._basis_dim[n]._include_range[0] zoomrange=[zoompoint-abs(basis_range*level),zoompoint+abs(basis_range*level)] ampl = zoomrange[1]-zoomrange[0] elif scale == "absolute": zoomrange=[zoompoint-level,zoompoint+level] #define a new include_range-range for that basisDim print "%s --> %s (offset: %s, amplitude: %s)" %(self._basis_dim[n].name,zoomrange, zoompoint, ampl) self._basis_dim[n]._includeRange(zoomrange) else: print "ignored %s for autozoom" %self._basis_dim[n].name