[CIG-SHORT] Principle stress
Charles Williams
willic3 at gmail.com
Wed Dec 4 17:05:42 PST 2013
Without really knowing where the error is, it appears to me that you’ve opened a file read-only, and you’re then attempting to create a dataset in that file. Also, Matt is correct that this is really an h5py question.
Cheers,
Charles
On 5/12/2013, at 1:00 pm, Ma, Xiao <xiaoma5 at illinois.edu> wrote:
> Hi,
> Thanks for the help. hoever I still can't get this done I got these error from python
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 523, in runfile
> execfile(filename, namespace)
> File "C:\Users\Max\Desktop\New folder (2)\model82\pricstress.py", line 19, in <module>
> field = h5.create_dataset('cell_fields/pstress',data=pstress[:,:])
> File "C:\Python27\lib\site-packages\h5py\_hl\group.py", line 71, in create_dataset
> dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds)
> File "C:\Python27\lib\site-packages\h5py\_hl\dataset.py", line 91, in make_new_dset
> dset_id = h5d.create(parent.id, None, tid, sid, dcpl=dcpl)
> File "h5d.pyx", line 75, in h5py.h5d.create (h5py\h5d.c:1567)
> ValueError: unable to create dataset (Dataset: Unable to initialize object
> _______________________________________________________________
> Here is what I am coding :
> import numpy
> import h5py
> import matplotlib.pyplot as plt
> # Load in change in tractions from coseismic simulation
> h5 = h5py.File("output/stress.h5", 'r', driver="sec2")
>
> vertices = h5['geometry/vertices'][:]
> #tractions_change = h5['vertex_fields/traction_change'][0,:,:]
> stress=h5['cell_fields/stress'][:]
> #h5.close()
> pstress=(stress[:,:,0]+stress[:,:,1])/2+numpy.sqrt(((stress[:,:,0]-stress[:,:,1])/2)**2+(stress[:,:,2])**2)
> field = h5.create_dataset('cell_fields/pstress',data=pstress[:,:])
> field.attrs['vector_field_type']='other'
> h5.close()
> ______________________________________________________________
> Thank you so much
> Best wishes,
> Xiao
> _______________________________________________
> CIG-SHORT mailing list
> CIG-SHORT at geodynamics.org
> http://geodynamics.org/cgi-bin/mailman/listinfo/cig-short
Charles A. Williams
Scientist
GNS Science
1 Fairway Drive, Avalon
PO Box 30368
Lower Hutt 5040
New Zealand
ph (office): 0064-4570-4566
fax (office): 0064-4570-4600
C.Williams at gns.cri.nz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://geodynamics.org/pipermail/cig-short/attachments/20131205/3b4ddba8/attachment.html>
More information about the CIG-SHORT
mailing list