Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ENH: Cartesian fields in spherical geometry #4497

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions yt/geometry/coordinates/spherical_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,53 @@ def _path_phi(field, data):
units="code_length",
)

self.setup_cartesian_fields(registry)

def setup_cartesian_fields(self, registry):
Comment on lines +84 to +86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be an existing method name in other CoordinateHandler classes and I can't see what we get from splitting this into a separate method, is there any benefit I'm not seeing ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with it being in the same function. I was using this for debugging, and wasn't sure if we wanted to make it a property of the superclass.

def _cartesian_x(field, data):
return (
data[("index", "r")]
* np.sin(data[("index", "theta")])
* np.cos(data[("index", "phi")])
)

def _cartesian_y(field, data):
return (
data[("index", "r")]
* np.sin(data[("index", "theta")])
* np.sin(data[("index", "phi")])
)

def _cartesian_z(field, data):
return data[("index", "r")] * np.cos(data[("index", "theta")])

registry.add_field(
("index", "cartesian_x"),
sampling_type="local",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "local", and not "cell" ?

function=_cartesian_x,
units="code_length",
display_field=True,
take_log=False,
)

registry.add_field(
("index", "cartesian_y"),
sampling_type="local",
function=_cartesian_y,
units="code_length",
display_field=True,
take_log=False,
)

registry.add_field(
("index", "cartesian_z"),
sampling_type="local",
function=_cartesian_z,
units="code_length",
display_field=True,
take_log=False,
)

def pixelize(
self, dimension, data_source, field, bounds, size, antialias=True, periodic=True
):
Expand Down