Hi Michael,

Huh, ok. yt-3.x doesn't use unyt, so not it's that. I wasn't able to reproduce this behavior in a quick test. It's possible that this issue has been fixed recently or that there is something unique about your data. It seems you've installed from source, so could you try pulling in the latest changes from the master branch? If that doesn't work, then maybe you could post your exact script as well. Is the data you're working with too large to share?

Britton

On Mon, Apr 27, 2020 at 9:25 PM Michael Jennings <robertmjenningsjr@berkeley.edu> wrote:
Hi Britton,

Thanks for your reply. I am using yt-3.7.dev0 and I am using unyt 2.7.1.

Best,
Michael

On Apr 27, 2020, at 3:23 AM, Britton Smith <brittonsmith@gmail.com> wrote:

Hi Michael,

Are you using yt-4.0 for this? If so, this might be an issue with the version of unyt. I experienced some similar issues with unyt 2.7.0, but these were fixed in 2.7.1. You can try upgrading that (pip install -U unyt). If you're not using yt-4.0 or that didn't work, let us know.

Britton

On Sat, Apr 25, 2020 at 6:42 PM Michael Jennings <robertmjenningsjr@berkeley.edu> wrote:
Thanks for the help! I decided to take the union approach.
However I’m running into a new problem when saving the region to a dataset and trying to reload the dataset. The region saves successfully but when loading it back in I get the following error:

box_file = box.save_as_dataset('datasets/box')
box_ds = yt.load(box_file)

---------------------------------------------------------------------------
KeyError
                                  Traceback (most recent call last)

<ipython-input-284-1b819f57f2a0> in <module>
      1 box = make_box(iso_cond[0],'n',box_size)
      2 box_file = box.save_as_dataset('datasets/box')
----> 3 boxds = yt.load(box_file)



~/yt-conda/src/yt-git/yt/convenience.py in load(*args, **kwargs)
     84     candidates = find_lowest_subclasses(candidates)
     85     if len(candidates) == 1:
---> 86         return candidates[0](*args, **kwargs)
     87     if len(candidates) == 0:
     88         if ytcfg.get("yt", "enzo_db") != '' \



~/yt-conda/src/yt-git/yt/frontends/ytdata/data_structures.py in __init__(self, filename, dataset_type, n_ref, over_refine_factor, units_override, unit_system)
    242         self.over_refine_factor =
 over_refine_factor

    243
         super(YTDataContainerDataset, self).__init__(filename, dataset_type,

--> 244
             units_override=units_override, unit_system=unit_system)

    245


    246     def _parse_parameter_file(self):



~/yt-conda/src/yt-git/yt/data_objects/static_output.py in __init__(self, filename, dataset_type, file_style, units_override, unit_system)
    248         self._create_unit_registry()
    249


--> 250         self._parse_parameter_file()
    251         self.set_units()
    252         self._assign_unit_system(unit_system)



~/yt-conda/src/yt-git/yt/frontends/ytdata/data_structures.py in _parse_parameter_file(self)
    245


    246     def _parse_parameter_file(self):
--> 247         super(YTDataContainerDataset, self)._parse_parameter_file()
    248         self.particle_types_raw = tuple(self.num_particles.keys())
    249         self.particle_types = self.
particle_types_raw


~/yt-conda/src/yt-git/yt/frontends/ytdata/data_structures.py in _parse_parameter_file(self)
    114             unit_system = "cgs"
    115         # reset unit system since we may have a new unit registry
--> 116         self._assign_unit_system(unit_system)
    117


    118         # assign units to parameters that have associated unit string



~/yt-conda/src/yt-git/yt/data_objects/static_output.py in _assign_unit_system(self, unit_system)
    920         else:
    921             sys_name = str(unit_system).lower()
--> 922             unit_system = _make_unit_system_copy(self.unit_registry, sys_name)
    923         self.unit_system =
 unit_system

    924



~/yt-conda/src/yt-git/yt/units/unit_systems.py in _make_unit_system_copy(unit_registry, unit_system)
    126         with the new registry.
    127
     """

--> 128     unit_system = unit_system_registry[unit_system]
    129     base_units = ["length", "mass", "time", "temperature", "angle"]
    130     if "current_mks" in unit_system._dims:



KeyError: 'us'




> On Apr 25, 2020, at 9:02 AM, Stephanie Tonnesen <stonnes@gmail.com> wrote:
>
> Hi Michael,
>
> I think the previous answer is your best bet, but I actually just ran into perhaps something like this-my colleague was making projections and forgot we didn’t center our object so the projection was automatically looping to the other side of the box (even though our box is not periodic). We didn’t check this carefully because we didn’t want this, but might be worth just seeing what happens!
>
> Best,
> Stephanie
>
> On Sat, Apr 25, 2020 at 9:05 AM Contact <contact@cphyc.me> wrote:
> Hi Michael,
>
> You can probably achieve the desired behaviour using an union of data objects, see https://yt-project.org/doc/analyzing/objects.html#boolean-data-objects.
> This lets you combine data objects. In your case, you could compute the (up to eight) rectangular regions that cover the area around your maximum overdensity.
> For example in 1D, if your maximum density is located at x=0.1 and you want all the data at a distance of 0.2, you would take the union of the regions [0.9, 1.0] and [0.0, 0.3] (here I assumed a domain width of 1).
>
> I hope that helps,
> CC
>
> 24 Apr 2020 19:27:07 Michael Jennings <robertmjenningsjr@berkeley.edu>:
>
> > Hello all,
> >
> > The documentation for the YTRegion class states "If the selected region extends past the edges of the domain, no data will be found there, though the object’s left_edge or right_edge are not modified.” Is there an easy way to change this to exhibit periodic behavior? For example: if the specified right_edge extended past the edges of the domain, data will be selected as continuing from the left of the domain.
> >
> > My ultimate goal is to create a square region centered on argmax(“density”) and calculate summed quantities in the region while successively increasing the size of the box assuming periodic boundaries.
> >
> > Does anyone have any insight?
> > _______________________________________________
> > yt-users mailing list -- yt-users@python.org
> > To unsubscribe send an email to yt-users-leave@python.org
> >
> >
>
> _______________________________________________
> yt-users mailing list -- yt-users@python.org
> To unsubscribe send an email to yt-users-leave@python.org
> --
> --
> Dr. Stephanie Tonnesen
> Associate Research Scientist
> CCA, Flatiron Institute
> New York, NY
>
> stonnes@gmail.com
> _______________________________________________
> yt-users mailing list -- yt-users@python.org
> To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org

_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/