Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting rsf to numpy array #176

Open
tgautam03 opened this issue Jan 16, 2020 · 3 comments
Open

converting rsf to numpy array #176

tgautam03 opened this issue Jan 16, 2020 · 3 comments

Comments

@tgautam03
Copy link

I am trying to convert amoco velocity model to numpy array but I am getting error :

Traceback (most recent call last):
File "model.py", line 4, in
inp = m8r.Input("vel.rsf")
File "/home/atom/rsf2.0/lib/python2.7/dist-packages/m8r.py", line 715, in init
self.__create_variable_dictionary(self.header)
File "/home/atom/rsf2.0/lib/python2.7/dist-packages/m8r.py", line 791, in __create_variable_dictionary
if rhs[0] in (squot, dquot):
IndexError: string index out of range

when I am running the following code

import m8r
import numpy as np
import matplotlib.pyplot as plt
inp = m8r.Input("vel.rsf")
n1 = inp.int("n1")
n2 = inp.int("n2")
 
data =inp.read(shape=(n2,n1))
data = data.transpose() # Example of numpy in action
print("SHAPE OF ARRAY : ", data.shape)
print("MAX VEL : ", np.max(data))
print("MIN VEL : ", np.min(data))
#print("UNIQUE VELS : ", np.unique(data))
np.save('pvel.npy', data)
plt.imshow(data)
plt.show()

Here is my code for the SConstruct file

from rsf.proj import *

Fetch('velmodel.hh','Amoco')

Flow('vel','velmodel.hh',
	'''
	dd form=native | scale rscale=0.001 |
     	put label1=Depth  unit1=km label2=Lateral unit2=km
	''')
Plot('vel',
	'''
	grey color=j mean=y title="Amoco model" 
	scalebar=y bartype=v barlabel="V" 
	barunit="km/s" screenratio=0.45 color=j labelsz=10 titlesz=12
	''')

End()
@zhichenggeng
Copy link
Contributor

Fixed in 67a1d15.

@tgautam03
Copy link
Author

@zhichenggeng I updated m8r.py as you have mentioned but now I am geeting this error :

Traceback (most recent call last):
File "model.py", line 4, in
inp = m8r.Input("/home/atom/work/github/mdg/madagascar/2D_modeling/amoco/vel.rsf")
File "/home/atom/rsf2.0/lib/python2.7/dist-packages/m8r.py", line 720, in init
self.f = open(self.filename,'r')
FileNotFoundError: [Errno 2] No such file or directory: '"/var/tmp/madagascar/2D_modeling/amoco/vel.rsf@"'

@tgautam03
Copy link
Author

Earlier the same code worked for marmousi model but after updating there's same error on that code as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants