[yt-users] Pickling YT objects

John Wise jwise at physics.gatech.edu
Fri Feb 14 06:43:22 PST 2014


Hi Sam,

You could try saving the projections to disk by turning on 
serialization.  This was on by default before last summer.  You can see 
the email where it was turned off here.

http://lists.spacepope.org/pipermail/yt-users-spacepope.org/2013-July/003824.html

You can also save multiple types of projections, i.e. different regions 
if you're not doing a full projection, by running

name='test'
prj = yt.mods.ProjectionPlot(pf, 2, var, center=[0.5, 0.5, 0.5],
                       width=(rlim, 'pc'), weight_field=None,
                       field_parameters={'node-name':name})

I save my projections to disk for large simulations where recalculating 
them is troublesome and time consuming.  However, you can read about the 
drawbacks in the original email linked above.

Cheers,
John

On 02/14/2014 09:22 AM, Sam Geen wrote:
> Hmm, just found this:
> http://yt-project.org/doc/analyzing/objects.html?#storing-and-loading-objects
> although it claims that cPickle should work as well (I have a library
> that handles the pickling so I'd prefer the cPickle solution if possible
> to avoid complicating the code)
>
> I should add that I'm using a RAMSES gas-only simulation.
>
> Sam
>
> On 14/02/2014 15:19, Sam Geen wrote:
>> Hi,
>>
>> I'm making plots of my data and I want to save them as pickle files so
>> I can load them later and perhaps mess with the colour map limits,
>> say, without reprocessing all the data (I have about 9TB to go
>> through). When I tried this I got the error: "TypeError: can't pickle
>> instancemethod objects"
>>
>> Do you know if this is possible, or some variant of it? I'm running:
>>
>>     pf = yt.mods.load(file_location)
>>     prj = yt.mods.ProjectionPlot(pf, 2, var, center=[0.5, 0.5, 0.5],
>>                      width=(rlim, 'pc'), weight_field=None)
>>
>> and trying to pickle prj, when I get the error. prj appears to be a
>> yt.visualization.plot_window.ProjectionPlot object and not an instance
>> method, but I could be wrong.
>>
>> At least it could be good to save the 2D image array and link it back
>> later to a YT plot object, but I don't know much about the internal
>> workings of the plot objects as to whether this is possible or not.
>>
>> Thanks,
>>
>> Sam
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

-- 
John Wise
Assistant Professor of Physics
Center for Relativistic Astrophysics, Georgia Tech
http://cosmo.gatech.edu



More information about the yt-users mailing list