def __init__ (self,original_datashape,datashape,subtiling,solve_ifrs,opts, use_float=False,init_value=1,verbose=0, force_subtiling=False,**kw): """original_datashape gives the unpadded datashape. This is the one that ought to be used to estimate convergence quotas. datashape is the real, padded, datashape. subtiling gives the subtiling.""" # init base datatiler class DataTiler.__init__(self,datashape,subtiling,original_datashape=original_datashape,force_subtiling=force_subtiling); _verbosity.set_verbose(verbose); _verbosity.enable_timestamps(True,modulo=6000); self._solve_ifrs = solve_ifrs; self.opts = opts; # init empty parms self._antennas = set(); for ifr in self._solve_ifrs: self._antennas.update(ifr); self._float = opts.use_float self._dtype = numpy.complex64 if float else numpy.complex128 self._zero = numpy.zeros(self.subshape, dtype=self._dtype) self._unity = numpy.ones(self.subshape, dtype=self._dtype) self._nullflag = numpy.zeros(self.subshape,dtype=bool); self.gainflags = {}; # init_value=1: init each parm with a unity Jones term # if init_value is a dict, use it to initialize each array with a different value # as a starting point if isinstance(init_value,dict): # init values will write into arrays, so make a copy self.gain = dict([(p,[self._unity.copy(),self._zero.copy(),self._zero.copy(),self._unity.copy()]) for p in self._antennas]); for p,values in init_value.iteritems(): gmat = self.gain.get(p); if gmat is not None: for i,(g,value) in enumerate(zip(gmat,values)): if is_null(value): gmat[i] = 0; elif numpy.isscalar(value) or value.ndim == 1: g[numpy.newaxis,...] = value; else: # just being defensive if shapes are different slc = tuple([ slice(0,min(a,b)) for a,b in zip(g.shape,value.shape) ]); g[slc] = value[slc]; # else assume scalar init value, and use it to initialize default array # subsequent steps create new arrays, so sufficient to use the same initial value object for all antennas else: ## default = numpy.empty(self.subshape,dtype=complex); ## default[...] = init_value; self.gain = dict([ (p,(init_value,0,0,init_value)) for p in self._antennas ]); ## self.gain = dict([ (p,(default,self._zero,self._zero,default)) for p in self._antennas ]); # setup convergence targets self.convergence_target = round(self.real_slots*opts.convergence_quota); self._reset(); dprint(1,"convergence target %d of %d real slots"%(self.convergence_target,self.real_slots));
def __init__ (self,original_datashape,datashape,subtiling,solve_ifrs,opts, init_value=1,verbose=0, force_subtiling=False, **kw): # init base datatiler class DataTiler.__init__(self,datashape,subtiling,original_datashape=original_datashape,force_subtiling=force_subtiling); _verbosity.set_verbose(verbose); _verbosity.enable_timestamps(True,modulo=6000); self._solve_ifrs = solve_ifrs; self.opts = opts; # init empty parms self._antennas = set(); self._parms = parms = set(); for ifr in self._solve_ifrs: self._antennas.update(ifr); self._parms.update([(p,i) for p in ifr for i in range(2)]); self._float = opts.use_float self._dtype = numpy.float64 if opts.real_only else (numpy.complex64 if self._float else numpy.complex128) self._unity = numpy.ones(self.subshape,dtype=self._dtype); # init_value=1: init each parm with the _unity array # subsequent steps create new arrays, so sufficient to use the same initial value object for all antennas if init_value == 1: self.gain = dict([ (pp,self._unity) for pp in parms ]); # if init_value is a dict, use it to initialize each array with a different value # presumably this happens when going to the next tile -- we use the previous tile's solution # as a starting point elif isinstance(init_value,dict): self.gain = dict([ (pp,self._unity.copy()) for pp in parms ]); for p,value in init_value.iteritems(): g = self.gain.get(p); if g is not None: if value.ndim == 1: g[numpy.newaxis,...] = value; else: # just being defensive if shapes are different slc = tuple([ slice(0,min(a,b)) for a,b in zip(g.shape,value.shape) ]); g[slc] = value[slc]; # else assume scalar init value, and use it to initialize default array else: default = numpy.empty(self.subshape,dtype=complex); default[...] = init_value; self.gain = dict([ (pp,default) for pp in parms ]); # setup gain flags self.gainflags = {} # setup convergence targets self.convergence_target = round(self.real_slots*opts.convergence_quota); self._reset(); dprint(1,"convergence target %d of %d real slots"%(self.convergence_target,self.real_slots));
def __init__(self, original_datashape, datashape, subtiling, solve_ifrs, opts, init_value=1, verbose=0, force_subtiling=False, **kw): """original_datashape gives the unpadded datashape. This is the one that ought to be used to estimate convergence quotas. datashape is the real, padded, datashape. subtiling gives the subtiling.""" # init base datatiler class DataTiler.__init__(self, datashape, subtiling, original_datashape=original_datashape, force_subtiling=force_subtiling) _verbosity.set_verbose(verbose) _verbosity.enable_timestamps(True, modulo=6000) self._solve_ifrs = solve_ifrs self.opts = opts # init empty parms self._antennas = set() for ifr in self._solve_ifrs: self._antennas.update(ifr) self._zero = numpy.zeros(self.subshape, dtype=complex) self._unity = numpy.ones(self.subshape, dtype=complex) self._nullflag = numpy.zeros(self.subshape, dtype=bool) self.gainflags = {} # init_value=1: init each parm with a unity Jones term # if init_value is a dict, use it to initialize each array with a different value # as a starting point if isinstance(init_value, dict): # init values will write into arrays, so make a copy self.gain = dict([(p, [ self._unity.copy(), self._zero.copy(), self._zero.copy(), self._unity.copy() ]) for p in self._antennas]) for p, values in init_value.iteritems(): gmat = self.gain.get(p) if gmat is not None: for i, (g, value) in enumerate(zip(gmat, values)): if is_null(value): gmat[i] = 0 elif numpy.isscalar(value) or value.ndim == 1: g[numpy.newaxis, ...] = value else: # just being defensive if shapes are different slc = tuple([ slice(0, min(a, b)) for a, b in zip(g.shape, value.shape) ]) g[slc] = value[slc] # else assume scalar init value, and use it to initialize default array # subsequent steps create new arrays, so sufficient to use the same initial value object for all antennas else: ## default = numpy.empty(self.subshape,dtype=complex); ## default[...] = init_value; self.gain = dict([(p, (init_value, 0, 0, init_value)) for p in self._antennas]) ## self.gain = dict([ (p,(default,self._zero,self._zero,default)) for p in self._antennas ]); # setup convergence targets self.convergence_target = round(self.real_slots * opts.convergence_quota) self._reset() dprint( 1, "convergence target %d of %d real slots" % (self.convergence_target, self.real_slots))
def __init__(self, original_datashape, datashape, subtiling, solve_ifrs, opts, init_value=1, verbose=0, force_subtiling=False, **kw): # init base datatiler class DataTiler.__init__(self, datashape, subtiling, original_datashape=original_datashape, force_subtiling=force_subtiling) _verbosity.set_verbose(verbose) _verbosity.enable_timestamps(True, modulo=6000) self._solve_ifrs = solve_ifrs self.opts = opts # init empty parms self._antennas = set() self._parms = parms = set() for ifr in self._solve_ifrs: self._antennas.update(ifr) self._parms.update([(p, i) for p in ifr for i in range(2)]) self._unity = numpy.ones( self.subshape, dtype=complex if not opts.real_only else float) # init_value=1: init each parm with the _unity array # subsequent steps create new arrays, so sufficient to use the same initial value object for all antennas if init_value == 1: self.gain = dict([(pp, self._unity) for pp in parms]) # if init_value is a dict, use it to initialize each array with a different value # presumably this happens when going to the next tile -- we use the previous tile's solution # as a starting point elif isinstance(init_value, dict): self.gain = dict([(pp, self._unity.copy()) for pp in parms]) for p, value in init_value.iteritems(): g = self.gain.get(p) if g is not None: if value.ndim == 1: g[numpy.newaxis, ...] = value else: # just being defensive if shapes are different slc = tuple([ slice(0, min(a, b)) for a, b in zip(g.shape, value.shape) ]) g[slc] = value[slc] # else assume scalar init value, and use it to initialize default array else: default = numpy.empty(self.subshape, dtype=complex) default[...] = init_value self.gain = dict([(pp, default) for pp in parms]) # setup gain flags self.gainflags = {} # setup convergence targets self.convergence_target = round(self.real_slots * opts.convergence_quota) self._reset() dprint( 1, "convergence target %d of %d real slots" % (self.convergence_target, self.real_slots))