Beispiel #1
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     name = self.axis_name[dimension]
     buff = np.full((size[1], size[0]), np.nan, dtype="f8")
     if name == "theta":
         pixelize_cylinder(
             buff,
             data_source["px"],
             data_source["pdx"],
             data_source["py"],
             data_source["pdy"],
             data_source[field],
             bounds,
         )
     elif name == "phi":
         # Note that we feed in buff.T here
         pixelize_cylinder(
             buff.T,
             data_source["px"],
             data_source["pdx"],
             data_source["py"],
             data_source["pdy"],
             data_source[field],
             bounds,
         )
     else:
         raise RuntimeError
     self.sanitize_buffer_fill_values(buff)
     return buff
Beispiel #2
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     offset, factor = self._retrieve_radial_offset(data_source)
     r = factor * data_source["py"] + offset
     # Because of the axis-ordering, dimensions 0 and 1 both have r as py
     # and the angular coordinate as px.  But we need to figure out how to
     # convert our coordinate back to an actual angle, based on which
     # dimension we're in.
     pdx = data_source["pdx"].d * np.pi / 180
     if self.axis_name[self.x_axis[dimension]] == "latitude":
         px = (data_source["px"].d + 90) * np.pi / 180
         do_transpose = True
     elif self.axis_name[self.x_axis[dimension]] == "longitude":
         px = (data_source["px"].d + 180) * np.pi / 180
         do_transpose = False
     else:
         # We should never get here!
         raise NotImplementedError
     buff = np.full((size[1], size[0]), np.nan, dtype="f8")
     pixelize_cylinder(buff, r, data_source["pdy"], px, pdx,
                       data_source[field], bounds)
     if do_transpose:
         buff = buff.transpose()
     self.sanitize_buffer_fill_values(buff)
     return buff
Beispiel #3
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
     buff = np.full((size[1], size[0]), np.nan, dtype="f8")
     pixelize_cylinder(buff, data_source['px'], data_source['pdx'],
                       data_source['py'], data_source['pdy'],
                       data_source[field], bounds)
     self.sanitize_buffer_fill_values(buff)
     return buff
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias, dimension):
     if dimension == 1:
         buff = pixelize_cylinder(
             data_source["px"],
             data_source["pdx"],
             data_source["py"],
             data_source["pdy"],
             size,
             data_source[field],
             bounds,
         )
     elif dimension == 2:
         buff = pixelize_cylinder(
             data_source["px"],
             data_source["pdx"],
             data_source["py"],
             data_source["pdy"],
             size,
             data_source[field],
             bounds,
         )
         buff = buff.transpose()
     else:
         raise RuntimeError
     return buff
Beispiel #5
0
 def __getitem__(self, item) :
     if item in self.data: return self.data[item]
     buff = np.zeros(self.buff_size, dtype="f8")
     pixelize_cylinder(buff, self.data_source["r"], self.data_source["dr"],
                       self.data_source["theta"], self.data_source["dtheta"],
                       self.data_source[item].astype("float64"), self.radius)
     self[item] = buff
     return buff
Beispiel #6
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
     buff = np.zeros((size[1], size[0]), dtype="f8")
     pixelize_cylinder(buff,
                       data_source['px'],
                       data_source['pdx'],
                       data_source['py'],
                       data_source['pdy'],
                       data_source[field], bounds)
     return buff
Beispiel #7
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     if dimension == 1:
         buff = pixelize_cylinder(data_source['px'], data_source['pdx'],
                                  data_source['py'], data_source['pdy'],
                                  size, data_source[field], bounds)
     elif dimension == 2:
         buff = pixelize_cylinder(data_source['px'], data_source['pdx'],
                                  data_source['py'], data_source['pdy'],
                                  size, data_source[field], bounds)
         buff = buff.transpose()
     else:
         raise RuntimeError
     return buff
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
     buff = pixelize_cylinder(data_source['px'],
                              data_source['pdx'],
                              data_source['py'],
                              data_source['pdy'],
                              size, data_source[field], bounds)
     return buff
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     surface_height = data_source.get_field_parameter("surface_height")
     if surface_height is None:
         if hasattr(data_source.ds, "surface_height"):
             surface_height = data_source.ds.surface_height
         else:
             surface_height = data_source.ds.quan(0.0, "code_length")
     r = data_source['py'] + surface_height
     # Because of the axis-ordering, dimensions 0 and 1 both have r as py
     # and the angular coordinate as px.  But we need to figure out how to
     # convert our coordinate back to an actual angle, based on which
     # dimension we're in.
     pdx = data_source['pdx'].d * np.pi / 180
     if self.axis_name[self.x_axis[dimension]] == 'latitude':
         px = (data_source['px'].d + 90) * np.pi / 180
         do_transpose = True
     elif self.axis_name[self.x_axis[dimension]] == 'longitude':
         px = (data_source['px'].d + 180) * np.pi / 180
         do_transpose = False
     else:
         # We should never get here!
         raise NotImplementedError
     buff = pixelize_cylinder(r, data_source['pdy'], px, pdx, size,
                              data_source[field], bounds)
     if do_transpose:
         buff = buff.transpose()
     return buff
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     surface_height = data_source.get_field_parameter("surface_height")
     if surface_height is None:
         if hasattr(data_source.ds, "surface_height"):
             surface_height = data_source.ds.surface_height
         else:
             surface_height = data_source.ds.quan(0.0, "code_length")
     r = data_source['py'] + surface_height
     # Because of the axis-ordering, dimensions 0 and 1 both have r as py
     # and the angular coordinate as px.  But we need to figure out how to
     # convert our coordinate back to an actual angle, based on which
     # dimension we're in.
     pdx = data_source['pdx'].d * np.pi/180
     if self.axis_name[self.x_axis[dimension]] == 'latitude':
         px = (data_source['px'].d + 90) * np.pi/180
         do_transpose = True
     elif self.axis_name[self.x_axis[dimension]] == 'longitude':
         px = (data_source['px'].d + 180) * np.pi/180
         do_transpose = False
     else:
         # We should never get here!
         raise NotImplementedError
     buff = pixelize_cylinder(r, data_source['pdy'],
                              px, pdx,
                              size, data_source[field], bounds)
     if do_transpose:
         buff = buff.transpose()
     return buff
Beispiel #11
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     name = self.axis_name[dimension]
     buff = np.zeros((size[1], size[0]), dtype="f8")
     if name == 'theta':
         pixelize_cylinder(buff, data_source['px'], data_source['pdx'],
                           data_source['py'], data_source['pdy'],
                           data_source[field], bounds)
     elif name == 'phi':
         # Note that we feed in buff.T here
         pixelize_cylinder(buff.T, data_source['px'], data_source['pdx'],
                           data_source['py'], data_source['pdy'],
                           data_source[field], bounds)
     else:
         raise RuntimeError
     return buff
 def __getitem__(self, item) :
     if item in self.data: return self.data[item]
     buff = pixelize_cylinder(self.data_source["r"], self.data_source["dr"],
                              self.data_source["theta"], self.data_source["dtheta"],
                              self.buff_size, self.data_source[item].astype("float64"),
                              self.radius)
     self[item] = buff
     return buff
Beispiel #13
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     name = self.axis_name[dimension]
     if name == 'theta':
         buff = pixelize_cylinder(data_source['px'],
                                  data_source['pdx'],
                                  data_source['py'],
                                  data_source['pdy'],
                                  size, data_source[field], bounds)
     elif name == 'phi':
         buff = pixelize_cylinder(data_source['px'],
                                  data_source['pdx'],
                                  data_source['py'],
                                  data_source['pdy'],
                                  size, data_source[field], bounds)
         buff = buff.transpose()
     else:
         raise RuntimeError
     return buff
Beispiel #14
0
 def _cyl_pixelize(self, data_source, field, bounds, size, antialias,
                   dimension):
     offset, factor = self._retrieve_radial_offset(data_source)
     r = factor * data_source['py'] + offset
     # Because of the axis-ordering, dimensions 0 and 1 both have r as py
     # and the angular coordinate as px.  But we need to figure out how to
     # convert our coordinate back to an actual angle, based on which
     # dimension we're in.
     pdx = data_source['pdx'].d * np.pi / 180
     if self.axis_name[self.x_axis[dimension]] == 'latitude':
         px = (data_source['px'].d + 90) * np.pi / 180
         do_transpose = True
     elif self.axis_name[self.x_axis[dimension]] == 'longitude':
         px = (data_source['px'].d + 180) * np.pi / 180
         do_transpose = False
     else:
         # We should never get here!
         raise NotImplementedError
     buff = pixelize_cylinder(r, data_source['pdy'], px, pdx, size,
                              data_source[field], bounds)
     if do_transpose:
         buff = buff.transpose()
     return buff