Re: Problem in dump.write for vector variables
I filed https://github.com/usnistgov/fipy/issues/691 to address this > On Jan 9, 2020, at 8:34 AM, Guyer, Jonathan E. Dr. (Fed) via fipy > wrote: > > Thank you for the feedback. I'm inclined to agree. > > - Jon > >> On Jan 9, 2020, at 3:47 AM, Marcel UJI (IMAP) wrote: >> >> Hi Jonathan >> >> Sorry by my late reply >> >> I think that the second one would be enough as I only need to read this data >> later for further processing. Actually this is not much an issue, as I can >> simply save phi and later recompute phi.faceGrad, which is also much more >> economic in terms of storage. >> >> Thank you anyway for spending some time on this >> >> Marcel >> >> >> >> El 20/12/19 a les 16:27, Guyer, Jonathan E. Dr. (Fed) via fipy ha escrit: >>> Glad you found a solution, Marcel. >>> >>> The issue is that a FaceGradVariable doesn't pickle itself properly. It >>> stores the state for a generic FaceVariable, but then it doesn't know how >>> to rebuild itself from that. >>> >>> It either should >>> - pickle the correct information, which would also involve pickling phi >>> OR >>> - pickle itself as a plain FaceVariable, losing connection to phi on >>> unpickling (which is what your solution does) >>> >>> Do you have an opinion on which behavior you'd like? >>> >>> On Dec 20, 2019, at 2:35 AM, Marcel UJI (IMAP) wrote: Thank you Trevor, This works, but it saves the array values only. I found an alternative solution with: dump.write({'E' : FaceVariable(mesh=mesh,value=phi.faceGrad,rank=1)},filename='prova.gz',extension='.gz') which preserves the FaceVariable character. Merry Christmas! Marcel El 19/12/19 a les 19:04, Keller, Trevor (Fed) via fipy ha escrit: > The error message indicates that `dump.read` got something unexpected > -- namely, a `value` field -- and threw. > > Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` > appears to do the trick. > > > -- Dr. Marcel Aguilella-Arzo Professor Titular d'Universitat, Física Aplicada Coordinador de la Subespecialitat de CCEETT del Màster en Professor d'Educació Secundària Departament de Física Escola Superior de Tecnologia i Ciències Experimentals Universitat Jaume I Av. Sos Baynat, s/n 12071 Castelló de la Plana (Spain) +34 964 728 046 a...@uji.es ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] >>> >>> ___ >>> fipy mailing list >>> >>> fipy@nist.gov >>> http://www.ctcms.nist.gov/fipy >>> >>> [ NIST internal ONLY: >>> https://email.nist.gov/mailman/listinfo/fipy >>> ] >>> >> -- >> Dr. Marcel Aguilella-Arzo >> Professor Titular d'Universitat, Física Aplicada >> Coordinador de la Subespecialitat de CCEETT del Màster en Professor >> d'Educació Secundària >> Departament de Física >> Escola Superior de Tecnologia i Ciències Experimentals >> Universitat Jaume I >> Av. Sos Baynat, s/n >> 12071 Castelló de la Plana (Spain) >> +34 964 728 046 >> >> a...@uji.es >> ___ >> fipy mailing list >> fipy@nist.gov >> http://www.ctcms.nist.gov/fipy >> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] > > > ___ > fipy mailing list > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Problem in dump.write for vector variables
Thank you for the feedback. I'm inclined to agree. - Jon > On Jan 9, 2020, at 3:47 AM, Marcel UJI (IMAP) wrote: > > Hi Jonathan > > Sorry by my late reply > > I think that the second one would be enough as I only need to read this data > later for further processing. Actually this is not much an issue, as I can > simply save phi and later recompute phi.faceGrad, which is also much more > economic in terms of storage. > > Thank you anyway for spending some time on this > > Marcel > > > > El 20/12/19 a les 16:27, Guyer, Jonathan E. Dr. (Fed) via fipy ha escrit: >> Glad you found a solution, Marcel. >> >> The issue is that a FaceGradVariable doesn't pickle itself properly. It >> stores the state for a generic FaceVariable, but then it doesn't know how to >> rebuild itself from that. >> >> It either should >> - pickle the correct information, which would also involve pickling phi >> OR >> - pickle itself as a plain FaceVariable, losing connection to phi on >> unpickling (which is what your solution does) >> >> Do you have an opinion on which behavior you'd like? >> >> >>> On Dec 20, 2019, at 2:35 AM, Marcel UJI (IMAP) >>> wrote: >>> >>> Thank you Trevor, >>> >>> This works, but it saves the array values only. >>> >>> I found an alternative solution with: >>> >>> dump.write({'E' : >>> FaceVariable(mesh=mesh,value=phi.faceGrad,rank=1)},filename='prova.gz',extension='.gz') >>> >>> which preserves the FaceVariable character. >>> >>> Merry Christmas! >>> >>> Marcel >>> >>> >>> >>> El 19/12/19 a les 19:04, Keller, Trevor (Fed) via fipy ha escrit: >>> The error message indicates that `dump.read` got something unexpected -- namely, a `value` field -- and threw. Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` appears to do the trick. >>> -- >>> Dr. Marcel Aguilella-Arzo >>> Professor Titular d'Universitat, Física Aplicada >>> Coordinador de la Subespecialitat de CCEETT del Màster en Professor >>> d'Educació Secundària >>> Departament de Física >>> Escola Superior de Tecnologia i Ciències Experimentals >>> Universitat Jaume I >>> Av. Sos Baynat, s/n >>> 12071 Castelló de la Plana (Spain) >>> +34 964 728 046 >>> >>> >>> a...@uji.es >>> >>> ___ >>> fipy mailing list >>> >>> fipy@nist.gov >>> http://www.ctcms.nist.gov/fipy >>> >>> [ NIST internal ONLY: >>> https://email.nist.gov/mailman/listinfo/fipy >>> ] >>> >> >> ___ >> fipy mailing list >> >> fipy@nist.gov >> http://www.ctcms.nist.gov/fipy >> >> [ NIST internal ONLY: >> https://email.nist.gov/mailman/listinfo/fipy >> ] >> > -- > Dr. Marcel Aguilella-Arzo > Professor Titular d'Universitat, Física Aplicada > Coordinador de la Subespecialitat de CCEETT del Màster en Professor > d'Educació Secundària > Departament de Física > Escola Superior de Tecnologia i Ciències Experimentals > Universitat Jaume I > Av. Sos Baynat, s/n > 12071 Castelló de la Plana (Spain) > +34 964 728 046 > > a...@uji.es > ___ > fipy mailing list > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Problem in dump.write for vector variables
Hi Jonathan Sorry by my late reply I think that the second one would be enough as I only need to read this data later for further processing. Actually this is not much an issue, as I can simply save phi and later recompute phi.faceGrad, which is also much more economic in terms of storage. Thank you anyway for spending some time on this Marcel El 20/12/19 a les 16:27, Guyer, Jonathan E. Dr. (Fed) via fipy ha escrit: Glad you found a solution, Marcel. The issue is that a FaceGradVariable doesn't pickle itself properly. It stores the state for a generic FaceVariable, but then it doesn't know how to rebuild itself from that. It either should - pickle the correct information, which would also involve pickling phi OR - pickle itself as a plain FaceVariable, losing connection to phi on unpickling (which is what your solution does) Do you have an opinion on which behavior you'd like? On Dec 20, 2019, at 2:35 AM, Marcel UJI (IMAP) wrote: Thank you Trevor, This works, but it saves the array values only. I found an alternative solution with: dump.write({'E' : FaceVariable(mesh=mesh,value=phi.faceGrad,rank=1)},filename='prova.gz',extension='.gz') which preserves the FaceVariable character. Merry Christmas! Marcel El 19/12/19 a les 19:04, Keller, Trevor (Fed) via fipy ha escrit: The error message indicates that `dump.read` got something unexpected -- namely, a `value` field -- and threw. Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` appears to do the trick. -- Dr. Marcel Aguilella-Arzo Professor Titular d'Universitat, Física Aplicada Coordinador de la Subespecialitat de CCEETT del Màster en Professor d'Educació Secundària Departament de Física Escola Superior de Tecnologia i Ciències Experimentals Universitat Jaume I Av. Sos Baynat, s/n 12071 Castelló de la Plana (Spain) +34 964 728 046 a...@uji.es ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] -- Dr. Marcel Aguilella-Arzo Professor Titular d'Universitat, Física Aplicada Coordinador de la Subespecialitat de CCEETT del Màster en Professor d'Educació Secundària Departament de Física Escola Superior de Tecnologia i Ciències Experimentals Universitat Jaume I Av. Sos Baynat, s/n 12071 Castelló de la Plana (Spain) +34 964 728 046 a...@uji.es ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Problem in dump.write for vector variables
Glad you found a solution, Marcel. The issue is that a FaceGradVariable doesn't pickle itself properly. It stores the state for a generic FaceVariable, but then it doesn't know how to rebuild itself from that. It either should - pickle the correct information, which would also involve pickling phi OR - pickle itself as a plain FaceVariable, losing connection to phi on unpickling (which is what your solution does) Do you have an opinion on which behavior you'd like? > On Dec 20, 2019, at 2:35 AM, Marcel UJI (IMAP) wrote: > > Thank you Trevor, > > This works, but it saves the array values only. > > I found an alternative solution with: > > dump.write({'E' : > FaceVariable(mesh=mesh,value=phi.faceGrad,rank=1)},filename='prova.gz',extension='.gz') > > which preserves the FaceVariable character. > > Merry Christmas! > > Marcel > > > > El 19/12/19 a les 19:04, Keller, Trevor (Fed) via fipy ha escrit: >> The error message indicates that `dump.read` got something unexpected >> -- namely, a `value` field -- and threw. >> >> Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` >> appears to do the trick. >> >> > -- > Dr. Marcel Aguilella-Arzo > Professor Titular d'Universitat, Física Aplicada > Coordinador de la Subespecialitat de CCEETT del Màster en Professor > d'Educació Secundària > Departament de Física > Escola Superior de Tecnologia i Ciències Experimentals > Universitat Jaume I > Av. Sos Baynat, s/n > 12071 Castelló de la Plana (Spain) > +34 964 728 046 > > a...@uji.es > ___ > fipy mailing list > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Problem in dump.write for vector variables
Thank you Trevor, This works, but it saves the array values only. I found an alternative solution with: dump.write({'E' : FaceVariable(mesh=mesh,value=phi.faceGrad,rank=1)},filename='prova.gz',extension='.gz') which preserves the FaceVariable character. Merry Christmas! Marcel El 19/12/19 a les 19:04, Keller, Trevor (Fed) via fipy ha escrit: The error message indicates that `dump.read` got something unexpected -- namely, a `value` field -- and threw. Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` appears to do the trick. -- Dr. Marcel Aguilella-Arzo Professor Titular d'Universitat, Física Aplicada Coordinador de la Subespecialitat de CCEETT del Màster en Professor d'Educació Secundària Departament de Física Escola Superior de Tecnologia i Ciències Experimentals Universitat Jaume I Av. Sos Baynat, s/n 12071 Castelló de la Plana (Spain) +34 964 728 046 a...@uji.es ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Re: Problem in dump.write for vector variables
The error message indicates that `dump.read` got something unexpected -- namely, a `value` field -- and threw. Naïvely, dumping `phi.faceGrad.value` instea dof `phi.faceGrad` appears to do the trick. -- Trevor Keller, Ph.D. Materials Science and Engineering Division National Institute of Standards and Technology 100 Bureau Dr. MS 8550; Gaithersburg, MD 20899 Office: 223/A131 or (301) 975-2889 On Thu, Dec 19, 2019 at 04:26:07PM +0100, Marcel UJI wrote: >I'm getting errors dumping vector variables in fipy. This minimal code >shows the problem: > >from fipy import * > >mesh=Grid3D(nx=10,ny=10,nz=10) > >phi=CellVariable(mesh=mesh,value=(mesh.x*mesh.y)) > >dump.write({'E' : (phi.faceGrad)},filename='prova.gz',extension='.gz') > >fitxer=dump.read('prova.gz') > >produces: > >--- > >TypeError Traceback (most recent call >last) > in () >> 1 fitxer=dump.read('prova.gz') >/home/marcel/.local/lib/python2.7/site-packages/fipy/tools/dump.pyc in >read(filename, fileobject, communicator, mesh_unmangle) >123 unpickler.find_global = find_class >124 >--> 125 return unpickler.load() >126 >127 def _test(): >/usr/lib/python2.7/pickle.pyc in load(self) >862 while 1: >863 key = read(1) >--> 864 dispatch[key](self) >865 except _Stop, stopinst: >866 return stopinst.value >/usr/lib/python2.7/pickle.pyc in load_build(self) > 1221 setstate = getattr(inst, "__setstate__", None) > 1222 if setstate: >-> 1223 setstate(state) > 1224 return > 1225 slotstate = None >/home/marcel/.local/lib/python2.7/site-packages/fipy/variables/variable >.pyc in __setstate__(self, dict) > 1525 self._refcount = sys.getrefcount(self) > 1526 >-> 1527 self.__init__(**dict) > 1528 > 1529 def _test(self): >TypeError: __init__() got an unexpected keyword argument 'value' > >Any idea on what is wrong in this code?? > >Marcel > -- > Dr. Marcel Aguilella-Arzo > Professor Titular d'Universitat, Física Aplicada > Coordinador de la Subcomissió d'Especialitat de Ciències Experimentals i > Tecnolo > gia > del Màster Universitari en Professor d'Educació Secundària Obligatòria i > Batxill > erat, > Formació Professional i Ensenyament d'Idiomes > Departament de Física > Escola Superior de Tecnologia i Ciències Experimentals > Universitat Jaume I > Av. Sos Baynat, s/n > 12071 Castelló de la Plana (Spain) > +34 964 728 046 > [1]a...@fca.uji.es > > References > >1. mailto:a...@fca.uji.es > ___ > fipy mailing list > fipy@nist.gov > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] ___ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]