How to unpickle the files of .vtu or .pvtu?

24 views
Skip to first unread message

Kiny Wan

unread,
Jul 5, 2020, 6:00:20 AM7/5/20
to PyFR Mailing List
Hello everyone,
        The Cpickle converts your object to a byte stream, which achieve fast speed for data processing. In PyFR, the pickle procedure is defined in following class memoize() and acts as a wrapper @memoize to handle the data. The resultant file of .vtu can be post-precessed with paraview, but its data is unable to visualize with a common text editor. So far I have not reached such a strong level of programming, is it possible to unpickle the files of .vtu? And can it be commented out to facilitate debugging? Any tips are appreciated.

class memoize(object):
   
def __init__(self, func):
       
self.func = func


   
def __get__(self, instance, owner):
       
return self.func if instance is None else ft.partial(self, instance)


   
def __call__(self, *args, **kwargs):
        instance
= args[0]


       
try:
            cache
= instance._memoize_cache
       
except AttributeError:
            cache
= instance._memoize_cache = {}


        key
= (self.func, pickle.dumps(args[1:], 1), pickle.dumps(kwargs, 1))


       
try:
            res
= cache[key]
       
except KeyError:
            res
= cache[key] = self.func(*args, **kwargs)


       
return res


Thanks,
Kiny

Freddie Witherden

unread,
Jul 5, 2020, 2:20:45 PM7/5/20
to Kiny Wan, PyFR Mailing List
There is no connection between the memoize class, which is an implementation of the standard memoization pattern, and the VTU output, which conforms to the VTU file format specifications as outlined by Kitware (the developers of VTK and ParaView).

Regards, Freddie.

On 5 Jul 2020, at 05:00, Kiny Wan <wlc...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "PyFR Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyfrmailingli...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pyfrmailinglist/d5e2d1ca-270c-40be-9e79-387f1c95f7e4o%40googlegroups.com.

Kiny Wan

unread,
Jul 5, 2020, 11:14:01 PM7/5/20
to PyFR Mailing List
Hi Freddie, thanks for helping me figure out this problem. The bytes in .vtu is required for following data structure of paraview, and it is achieved by "with open(pfn, 'wb') as fh:". There is no connection between the memoize class and VTU output. 
<AppendedData encoding="raw">
/AppendedData>


Reply all
Reply to author
Forward
0 new messages