def __init__(self, axis, coords, ds=None, field_parameters=None, data_source=None): super(YTOrthoRay, self).__init__(ds, field_parameters, data_source) self.axis = fix_axis(axis, self.ds) xax = self.ds.coordinates.x_axis[self.axis] yax = self.ds.coordinates.y_axis[self.axis] self.px_ax = xax self.py_ax = yax # Even though we may not be using x,y,z we use them here. self.px_dx = 'd%s' % ('xyz'[self.px_ax]) self.py_dx = 'd%s' % ('xyz'[self.py_ax]) # Convert coordinates to code length. if isinstance(coords[0], YTQuantity): self.px = self.ds.quan(coords[0]).to("code_length") else: self.px = self.ds.quan(coords[0], "code_length") if isinstance(coords[1], YTQuantity): self.py = self.ds.quan(coords[1]).to("code_length") else: self.py = self.ds.quan(coords[1], "code_length") self.sort_by = 'xyz'[self.axis]
def __init__(self, axis, coords, ds=None, field_parameters=None, data_source=None): validate_axis(ds, axis) validate_iterable(coords) for c in coords: validate_float(c) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) super(YTOrthoRay, self).__init__(ds, field_parameters, data_source) self.axis = fix_axis(axis, self.ds) xax = self.ds.coordinates.x_axis[self.axis] yax = self.ds.coordinates.y_axis[self.axis] self.px_ax = xax self.py_ax = yax # Even though we may not be using x,y,z we use them here. self.px_dx = 'd%s' % ('xyz'[self.px_ax]) self.py_dx = 'd%s' % ('xyz'[self.py_ax]) # Convert coordinates to code length. if isinstance(coords[0], YTQuantity): self.px = self.ds.quan(coords[0]).to("code_length") else: self.px = self.ds.quan(coords[0], "code_length") if isinstance(coords[1], YTQuantity): self.py = self.ds.quan(coords[1]).to("code_length") else: self.py = self.ds.quan(coords[1], "code_length") self.sort_by = 'xyz'[self.axis]
def __init__(self, ds, axis, fields, center="c", width=None, image_res=None, **kwargs): fields = ensure_list(fields) axis = fix_axis(axis, ds) center, dcenter = ds.coordinates.sanitize_center(center, axis) slc = ds.slice(axis, center[axis], **kwargs) w, frb = construct_image(ds, axis, slc, dcenter, width=width, image_res=image_res) super(FITSSlice, self).__init__(frb, fields=fields, wcs=w)
def __init__(self, ds, axis, fields, center="c", width=None, weight_field=None, image_res=None, **kwargs): fields = ensure_list(fields) axis = fix_axis(axis, ds) center, dcenter = ds.coordinates.sanitize_center(center, axis) prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs) w, frb = construct_image(ds, axis, prj, dcenter, width=width, image_res=image_res) super(FITSProjection, self).__init__(frb, fields=fields, wcs=w)
def __init__(self, ds, axis, fields, center="c", **kwargs): fields = ensure_list(fields) axis = fix_axis(axis, ds) center = get_sanitized_center(center, ds) slc = ds.slice(axis, center[axis], **kwargs) w, frb = construct_image(slc, center=center) super(FITSSlice, self).__init__(frb, fields=fields, wcs=w) for i, field in enumerate(fields): self[i].header["bunit"] = str(frb[field].units)
def __init__(self, ds, axis, fields=None, color='b', center='c', width=None, depth=(1, '1'), weight_field=None, axes_unit=None, origin='center-window', fontsize=18, field_parameters=None, window_size=8.0, aspect=None, data_source=None): # this will handle time series data and controllers ts = self._initialize_dataset(ds) self.ts = ts ds = self.ds = ts[0] axis = fix_axis(axis, ds) (bounds, center, display_center) = \ get_window_parameters(axis, center, width, ds) if field_parameters is None: field_parameters = {} if axes_unit is None: axes_unit = get_axes_unit(width, ds) # if no fields are passed in, we simply mark the x and # y fields using a given color. Use the 'particle_ones' # field to do this. We also turn off the colorbar in # this case. self._use_cbar = True splat_color = None if fields is None: fields = ['particle_ones'] weight_field = 'particle_ones' self._use_cbar = False splat_color = color depth = ds.coordinates.sanitize_depth(depth) x_coord = ds.coordinates.x_axis[axis] y_coord = ds.coordinates.y_axis[axis] width = np.zeros_like(center) width[x_coord] = bounds[1] - bounds[0] width[y_coord] = bounds[3] - bounds[2] width[axis] = depth[0].in_units(width[x_coord].units) ParticleSource = ParticleAxisAlignedDummyDataSource(center, ds, axis, width, fields, weight_field, field_parameters=field_parameters, data_source=data_source) PWViewerMPL.__init__(self, ParticleSource, bounds, origin=origin, fontsize=fontsize, fields=fields, window_size=window_size, aspect=aspect, splat_color=splat_color) self.set_axes_unit(axes_unit) if self._use_cbar is False: self.hide_colorbar()
def __init__(self, ds, axis, fields, center="c", weight_field=None, **kwargs): fields = ensure_list(fields) axis = fix_axis(axis, ds) center = get_sanitized_center(center, ds) prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs) w, frb = construct_image(prj, center=center) super(FITSProjection, self).__init__(frb, fields=fields, wcs=w) for i, field in enumerate(fields): self[i].header["bunit"] = str(frb[field].units)
def __init__( self, ds, axis, fields, image_res=512, center="c", width=None, length_unit=None, **kwargs, ): fields = list(iter_fields(fields)) axis = fix_axis(axis, ds) center, dcenter = ds.coordinates.sanitize_center(center, axis) slc = ds.slice(axis, center[axis], **kwargs) w, frb, lunit = construct_image(ds, axis, slc, dcenter, image_res, width, length_unit) super().__init__(frb, fields=fields, length_unit=lunit, wcs=w)
def __init__( self, ds, axis, fields, image_res=512, center="c", width=None, weight_field=None, length_unit=None, **kwargs, ): fields = list(iter_fields(fields)) axis = fix_axis(axis, ds) center, dcenter = ds.coordinates.sanitize_center(center, axis) prj = ds.proj(fields[0], axis, weight_field=weight_field, **kwargs) w, frb, lunit = construct_image(ds, axis, prj, dcenter, image_res, width, length_unit) super().__init__(frb, fields=fields, length_unit=lunit, wcs=w)
def on_axis(self, axis, center="c", width=(1, "unitary"), nx=800, source=None): r""" Make an on-axis projection of the SZ signal. Parameters ---------- axis : integer or string The axis of the simulation domain along which to make the SZprojection. center : A sequence of floats, a string, or a tuple. The coordinate of the center of the image. If set to 'c', 'center' or left blank, the plot is centered on the middle of the domain. If set to 'max' or 'm', the center will be located at the maximum of the ('gas', 'density') field. Centering on the max or min of a specific field is supported by providing a tuple such as ("min","temperature") or ("max","dark_matter_density"). Units can be specified by passing in *center* as a tuple containing a coordinate and string unit name or by passing in a YTArray. If a list or unitless array is supplied, code units are assumed. width : tuple or a float. Width can have four different formats to support windows with variable x and y widths. They are: ================================== ======================= format example ================================== ======================= (float, string) (10,'kpc') ((float, string), (float, string)) ((10,'kpc'),(15,'kpc')) float 0.2 (float, float) (0.2, 0.3) ================================== ======================= For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a window that is 10 kiloparsecs wide along the x axis and 15 kiloparsecs wide along the y axis. In the other two examples, code units are assumed, for example (0.2, 0.3) requests a plot that has an x width of 0.2 and a y width of 0.3 in code units. If units are provided the resulting plot axis labels will use the supplied units. nx : integer, optional The dimensions on a side of the projection image. source : yt.data_objects.data_containers.YTSelectionContainer, optional If specified, this will be the data source used for selecting regions to project. Examples -------- >>> szprj.on_axis("y", center="max", width=(1.0, "Mpc"), source=my_sphere) """ axis = fix_axis(axis, self.ds) ctr, dctr = self.ds.coordinates.sanitize_center(center, axis) width = self.ds.coordinates.sanitize_width(axis, width, None) L = np.zeros(3) L[axis] = 1.0 beta_par = generate_beta_par(L) self.ds.add_field(("gas", "beta_par"), function=beta_par, units="g/cm**3") setup_sunyaev_zeldovich_fields(self.ds) proj = self.ds.proj("density", axis, center=ctr, data_source=source) frb = proj.to_frb(width[0], nx, height=width[1]) dens = frb["density"] Te = frb["t_sz"] / dens bpar = frb["beta_par"] / dens omega1 = frb["t_squared"] / dens / (Te * Te) - 1. bperp2 = np.zeros((nx, nx)) sigma1 = np.zeros((nx, nx)) kappa1 = np.zeros((nx, nx)) if self.high_order: bperp2 = frb["beta_perp_squared"] / dens sigma1 = frb["t_beta_par"] / dens / Te - bpar kappa1 = frb["beta_par_squared"] / dens - bpar * bpar tau = sigma_thompson * dens * self.mueinv / mh nx, ny = frb.buff_size self.bounds = frb.bounds self.dx = (frb.bounds[1] - frb.bounds[0]) / nx self.dy = (frb.bounds[3] - frb.bounds[2]) / ny self.nx = nx self._compute_intensity(np.array(tau), np.array(Te), np.array(bpar), np.array(omega1), np.array(sigma1), np.array(kappa1), np.array(bperp2)) self.ds.field_info.pop(("gas", "beta_par"))
def on_axis(self, axis, center="c", width=(1, "unitary"), nx=800, source=None): r""" Make an on-axis projection of the SZ signal. Parameters ---------- axis : integer or string The axis of the simulation domain along which to make the SZprojection. center : A sequence of floats, a string, or a tuple. The coordinate of the center of the image. If set to 'c', 'center' or left blank, the plot is centered on the middle of the domain. If set to 'max' or 'm', the center will be located at the maximum of the ('gas', 'density') field. Centering on the max or min of a specific field is supported by providing a tuple such as ("min","temperature") or ("max","dark_matter_density"). Units can be specified by passing in *center* as a tuple containing a coordinate and string unit name or by passing in a YTArray. If a list or unitless array is supplied, code units are assumed. width : float, tuple, or YTQuantity. The width of the projection. A float will assume the width is in code units. A (value, unit) tuple or YTQuantity allows for the units of the width to be specified. nx : integer, optional The dimensions on a side of the projection image. source : yt.data_objects.data_containers.YTSelectionContainer, optional If specified, this will be the data source used for selecting regions to project. Examples -------- >>> szprj.on_axis("y", center="max", width=(1.0, "Mpc"), source=my_sphere) """ axis = fix_axis(axis, self.ds) ctr, dctr = self.ds.coordinates.sanitize_center(center, axis) width = self.ds.coordinates.sanitize_width(axis, width, None) L = np.zeros((3)) L[axis] = 1.0 beta_par = generate_beta_par(L) self.ds.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3") setup_sunyaev_zeldovich_fields(self.ds) proj = self.ds.proj("density", axis, center=ctr, data_source=source) frb = proj.to_frb(width[0], nx, height=width[1]) dens = frb["density"] Te = frb["t_sz"]/dens bpar = frb["beta_par"]/dens omega1 = frb["t_squared"]/dens/(Te*Te) - 1. bperp2 = np.zeros((nx,nx)) sigma1 = np.zeros((nx,nx)) kappa1 = np.zeros((nx,nx)) if self.high_order: bperp2 = frb["beta_perp_squared"]/dens sigma1 = frb["t_beta_par"]/dens/Te - bpar kappa1 = frb["beta_par_squared"]/dens - bpar*bpar tau = sigma_thompson*dens*self.mueinv/mh nx,ny = frb.buff_size self.bounds = frb.bounds self.dx = (frb.bounds[1]-frb.bounds[0])/nx self.dy = (frb.bounds[3]-frb.bounds[2])/ny self.nx = nx self._compute_intensity(np.array(tau), np.array(Te), np.array(bpar), np.array(omega1), np.array(sigma1), np.array(kappa1), np.array(bperp2)) self.ds.field_info.pop(("gas","beta_par"))
def on_axis(self, axis, center="c", width=(1, "unitary"), nx=800, source=None): r""" Make an on-axis projection of the SZ signal. Parameters ---------- axis : integer or string The axis of the simulation domain along which to make the SZprojection. center : array_like or string, optional The center of the projection. width : float or tuple The width of the projection. nx : integer, optional The dimensions on a side of the projection image. source : yt.data_objects.api.AMRData, optional If specified, this will be the data source used for selecting regions to project. Examples -------- >>> szprj.on_axis("y", center="max", width=(1.0, "Mpc"), source=my_sphere) """ axis = fix_axis(axis, self.ds) if center == "c": ctr = self.ds.domain_center elif center == "max": v, ctr = self.ds.find_max("density") else: ctr = center L = np.zeros((3)) L[axis] = 1.0 beta_par = generate_beta_par(L) self.ds.add_field(("gas", "beta_par"), function=beta_par, units="g/cm**3") setup_sunyaev_zeldovich_fields(self.ds) proj = self.ds.proj("density", axis, center=ctr, data_source=source) frb = proj.to_frb(width, nx) dens = frb["density"] Te = frb["t_sz"] / dens bpar = frb["beta_par"] / dens omega1 = frb["t_squared"] / dens / (Te * Te) - 1. bperp2 = np.zeros((nx, nx)) sigma1 = np.zeros((nx, nx)) kappa1 = np.zeros((nx, nx)) if self.high_order: bperp2 = frb["beta_perp_squared"] / dens sigma1 = frb["t_beta_par"] / dens / Te - bpar kappa1 = frb["beta_par_squared"] / dens - bpar * bpar tau = sigma_thompson * dens * self.mueinv / mh nx, ny = frb.buff_size self.bounds = frb.bounds self.dx = (frb.bounds[1] - frb.bounds[0]) / nx self.dy = (frb.bounds[3] - frb.bounds[2]) / ny self.nx = nx self._compute_intensity(np.array(tau), np.array(Te), np.array(bpar), np.array(omega1), np.array(sigma1), np.array(kappa1), np.array(bperp2)) self.ds.field_info.pop(("gas", "beta_par"))