yt-project / yt

Main yt repository
http://yt-project.org
Other
469 stars 280 forks source link

Logarithmic Scaling for multiple 1d profiles #1159

Closed yt-fido closed 7 years ago

yt-fido commented 8 years ago

Originally reported by: Miguel de Val-Borro (Bitbucket: migueldvb, GitHub: migueldvb)


Axis scaling manipulation using the set_log() function does not work for multiple 1d profiles created using yt.create_profile

#!python

#!/usr/bin/python

import yt

profiles = []
basename = "Sedov_3d/sedov_hdf5_chk"
for i in [0, 1]:
    filename = "{0}_{1:04d}".format(basename, i)
    ds = yt.load(filename)
    sphere = ds.sphere([0., 0., 0.], (1, 'cm'))
    profile = yt.create_profile(sphere, "radius", ["radial_velocity_absolute"],
            logs = {"radius": False, "radial_velocity_absolute": False}
            )
    profiles.append(profile)

plot = yt.ProfilePlot.from_profiles(profiles)
plot.set_log("radial_velocity_absolute", False)
plot.save()

The traceback error obtained from this script is shown below:

#!python

Traceback (most recent call last):
  File "./profiles_test.py", line 17, in <module>
    plot.set_log("radial_velocity_absolute", False)
  File "/home/mdevalbo/project/yt_analysis/yt/yt/visualization/plot_container.py", line 64, in newfunc
    rv = f(*args, **kwargs)
  File "/home/mdevalbo/project/yt_analysis/yt/yt/visualization/profile_plotter.py", line 468, in set_log
    field, = self.profiles[0].data_source._determine_fields([field])
  File "/home/mdevalbo/project/yt_analysis/yt/yt/data_objects/data_containers.py", line 985, in _determine_fields
    finfo = self.ds._get_field_info("unknown", fname)
ReferenceError: weakly-referenced object no longer exists

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


This is fixed now.

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


Also worth noting that a workaround is to keep the datasets in memory. The following variation on the script in the issue description will run without crashing:

#!python

import yt

profiles = []
ds_list = []
basename = "Sedov_3d/sedov_hdf5_chk"
for i in [0, 1]:
    filename = "{0}_{1:04d}".format(basename, i)
    ds = yt.load(filename)
    ds_list.append(ds)
    sphere = ds.sphere([0., 0., 0.], (1, 'cm'))
    profile = yt.create_profile(sphere, "radius", ["radial_velocity_absolute"],
            logs = {"radius": False, "radial_velocity_absolute": False}
            )
    profiles.append(profile)

plot = yt.ProfilePlot.from_profiles(profiles)
plot.set_log("radial_velocity_absolute", False)
plot.save()
yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


The fix would be to avoid these calls to _determine_fields and just look at the fields being profiled in the already created profile objects.