# Diff of /trunk/downunder/py_src/domainbuilder.py

revision 4432 by caltinay, Tue May 7 04:56:59 2013 UTC revision 4433 by gross, Fri May 31 12:09:58 2013 UTC
# Line 299  class DomainBuilder(object): Line 299  class DomainBuilder(object):
299
300      def setBackgroundMagneticFluxDensity(self, B):      def setBackgroundMagneticFluxDensity(self, B):
301          """          """
302          Sets the background magnetic flux density B=(B_North, B_East, B_Vertical)          Sets the background magnetic flux density B=(B_East, B_North, B_Vertical)
303          """          """
304          self.__background_magnetic_field=B          self.__background_magnetic_field=B
305
# Line 308  class DomainBuilder(object): Line 308  class DomainBuilder(object):
308          Returns the background magnetic flux density.          Returns the background magnetic flux density.
309          """          """
310          B = self.__background_magnetic_field          B = self.__background_magnetic_field
311          if self.__dim<3:          if self.__dim < 3 :
312              return np.array([B[0], B[2]])              return np.array([B[0], B[2]])
313          else:          else:
314              return np.array(B)              return np.array(B)
# Line 438  class DomainBuilder(object): Line 438  class DomainBuilder(object):
438          if self.getReferenceSystem().isCartesian():          if self.getReferenceSystem().isCartesian():
439              # rounding will give us about meter-accuracy with UTM coordinates              # rounding will give us about meter-accuracy with UTM coordinates
440              self._dom_origin = [np.floor(oi) for oi in origin]              self._dom_origin = [np.floor(oi) for oi in origin]
441                f=[1.,1.,1.]
442          else:          else:
443              # this should give us about meter-accuracy with lat/lon coords              # this should give us about meter-accuracy with lat/lon coords
444              self._dom_origin = [1e-5*np.floor(oi*1e5) for oi in origin]              self._dom_origin = [1e-5*np.floor(oi*1e5) for oi in origin]
445                f=[1.,1.,  1./self.getReferenceSystem().getHeightUnit() ]
446          # cell size / point spacing          # cell size / point spacing
447          spacing = DX + [np.floor((self._v_depth+self._v_air_layer)/self._v_num_cells)]          spacing = DX + [np.floor((self._v_depth+self._v_air_layer)/self._v_num_cells)]
448          #self._spacing = [float(np.floor(si)) for si in spacing]          #self._spacing = [float(np.floor(si)) for si in spacing]
449          self._spacing = spacing          self._spacing = spacing
450
451          lo=[(self._dom_origin[i], self._dom_origin[i]+NE[i]*self._spacing[i]) for i in range(self.__dim)]
452            lo=[(self._dom_origin[i] * f[i], (self._dom_origin[i]+NE[i]*self._spacing[i]) * f[i]) for i in range(self.__dim)]
453
454          if self.__dim==3:          if self.__dim==3:
455              dom=Brick(*NE, l0=lo[0], l1=lo[1], l2=lo[2])              dom=Brick(*NE, l0=lo[0], l1=lo[1], l2=lo[2])
456          else:          else:
457              dom=Rectangle(*NE, l0=lo[0], l1=lo[1])              dom=Rectangle(*NE, l0=lo[0], l1=lo[2])
458
459          # ripley may internally adjust NE and length, so recompute          # ripley may internally adjust NE and length, so recompute
460          self._dom_len=[sup(dom.getX()[i])-inf(dom.getX()[i]) for i in range(self.__dim)]          self._dom_len=[sup(dom.getX()[i])-inf(dom.getX()[i]) for i in range(self.__dim)]
461          self._dom_NE=[int(self._dom_len[i]/self._spacing[i]) for i in range(self.__dim)]          self._dom_NE=[int(self._dom_len[i]/(self._spacing[i]* f[i])) for i in range(self.__dim)]
462
463          self.logger.debug("Domain size: "+str(self._dom_NE))          self.logger.debug("Domain size: "+str(self._dom_NE))
464          self.logger.debug("     length: "+str(self._dom_len))          self.logger.debug("     length: "+str(self._dom_len))

Legend:
 Removed from v.4432 changed lines Added in v.4433