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

Data not shown #229

Closed
mmusalhi opened this issue May 6, 2020 · 17 comments
Closed

Data not shown #229

mmusalhi opened this issue May 6, 2020 · 17 comments
Assignees

Comments

@mmusalhi
Copy link

mmusalhi commented May 6, 2020

Problem description

I tried to plot inversion refraction data form a file, but not all data are used.

Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:

import pygimli as pg
from pygimli.physics import Refraction


ra = Refraction("BTK.txt")
print(ra)


ra.showData()
ra.showVA() 

ra.invert()
ra.showResult()
...

data should be 336 but show 87
This is the data file
BTK.txt

Data: Sensors: 56 data: 87
Refraction object
Data: Sensors: 56 data: 87
None
3 data of 87 not shown
[28, 57, 86]
@halbmy halbmy self-assigned this May 7, 2020
@halbmy
Copy link
Contributor

halbmy commented May 7, 2020

Hello, apparently you misunderstood the data file format. In the header, there is the list of sensors (both shot and geophone positions), and below in the data section, there is the data where the columns s and g refer to numbers (not positions!) in the sensor section.

So

-5	0	0.004
-5	2	0.0045
...

will considered invalid (<0) as well as those above the number of sensors (>56)

63	0	0.018
63	2	0.0175
63	4	0.017
...

and automatically deleted which is why you end up in much less data.

@mmusalhi
Copy link
Author

mmusalhi commented May 7, 2020

Hi @halbmy
I got it thanks for your explanation.

But I got some white spaces in the plot
BTK

Is there a way to interpolate the white spaces?

@halbmy
Copy link
Contributor

halbmy commented May 7, 2020

the white regions are not covered by any ray and therefore blanked, however, this behaviour by
mgr.showResult(useCoverage=False)

@mmusalhi
Copy link
Author

mmusalhi commented May 7, 2020

Thanks @halbmy
It is worked.

@mmusalhi mmusalhi closed this as completed May 7, 2020
@BoDoNgAhAi
Copy link

Hello,
I have a similar problem like this but even I have followed your comment above on how to treat the data file I got fewer measurements (Data: Sensors: 11 data: 80 ) than actual measurements. It supposes to be 405 measurements (Line_1.txt). I checked many times and modified it in various ways like changing x, y positions numbers, etc. Also, I prepared another data file (Line_2.txt) to make sure I am doing right in preparing data but giving the same result.
Here are the data files.
Line_1.txt
Line_2.txt
Thank you for your consideration and advice.

@halbmy
Copy link
Contributor

halbmy commented Nov 13, 2020

pg.load is a convenience function for autoloading but it decides upon the file extension. Therefore it does not work. You should use the constructor pg.DataContainer(filename) instead, working for both files. As shot and geophone are indices and no float values you should use

data = pg.DataContainer("Line_1.txt", "s g")

anyway.

@BoDoNgAhAi
Copy link

Thank you for your quick response.
I used data = pg.DataContainer("Line_1.txt", "s, g") but it gives the same issue. If I remove "s g" it is working fine but when I run this shot_rec_dis = traveltime.shotReceiverDistances(data, full=True) it does not work and gives this error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-16-7bf805fdf0d0> in <module>
      1 # Checking shot and receiver distances
----> 2 shot_rec_dis = traveltime.shotReceiverDistances(data)
      3 print(shot_rec_dis)

~\anaconda3\envs\pg\lib\site-packages\pygimli\physics\traveltime\ratools.py in shotReceiverDistances(data, full)
     32     else:
     33         px = pg.x(data)
---> 34         gx = np.array([px[g] for g in data.id("g")])
     35         sx = np.array([px[s] for s in data.id("s")])
     36         return np.absolute(gx - sx)

RuntimeError: C:/msys64/home/halbm/gimli/gimli/core/src/datacontainer.cpp: 670		const IndexArray GIMLI::DataContainer::id(const string&) const  token: g is not an index list: SensorIdx:  Data: g s t valid

I do not understand why it is still giving the same issue. Is the data format wrong?

And, I have another question. I have seismic data that acquired a continuous common shot gather method. 48 geophones interval is 3m, and 6 shots interval is 6m, out of geophone line (in front of the first geophone). The first shot is 36 m far away from the first geophone and it ends at 6m far away from the first geophone then the first 12 geophones moved and planted at behind the last geophone 48. And, the entire process begins again until the shot number reaches 36.
I have drawn a sketch picture to show how it is conducted.
image
The question is how to make data in this situation for pygimli.
Thank you for your time and understanding.

@halbmy
Copy link
Contributor

halbmy commented Nov 15, 2020

  1. Please remove the comma, it should be data = pg.DataContainer("Line_1.txt", "s g") and NOT data = pg.DataContainer("Line_1.txt", "s, g"). Then it works.

@halbmy
Copy link
Contributor

halbmy commented Nov 15, 2020

  1. The second questions sounds like a little bit basic programming. First make a list of all existing sensors (shots and geophones) and then think about how to generate the lists with some simple for loops. Shouldn't be a problem and has nothing to do with pyGIMLi.

@BoDoNgAhAi
Copy link

Yes, I removed the comma, and it is still the same. I am sorry for the code I upload with the comma. Also, I used data.sortSensorsIndex() and data.sortSensorsX() codes respectively and together but still giving the same error above.

@halbmy
Copy link
Contributor

halbmy commented Nov 16, 2020

Can you please paste the whole code leading to the error along with the pygimli version you used?

@BoDoNgAhAi
Copy link

Yes, sure.

import pygimli as pg
from pygimli.physics import traveltime
from pygimli.physics.traveltime import TravelTimeManager
data = pg.DataContainer("Line_1.txt", "s g")
#data.sortSensorsIndex() <-- I used it and result is the same
#data.sortSensorsX()        <-- also this one
print(data)

Data: Sensors: 11 data: 80, nonzero entries: ['g', 's', 't', 'valid']

shot_rec_dis = traveltime.shotReceiverDistances(data, full=True)
print(shot_rec_dis)

RuntimeError                              Traceback (most recent call last)
<ipython-input-7-0a707cbff353> in <module>
      1 # Checking shot and receiver distances
----> 2 shot_rec_dis = traveltime.shotReceiverDistances(data, full=True)
      3 print(shot_rec_dis)

~\anaconda3\envs\pg\lib\site-packages\pygimli\physics\traveltime\ratools.py in shotReceiverDistances(data, full)
     27     if full:
     28         pos = data.sensors()
---> 29         s, g = data.id('s'), data.id('g')
     30         off = [pos[s[i]].distance(pos[g[i]]) for i in range(data.size())]
     31         return np.absolute(off)

RuntimeError: C:/msys64/home/halbm/gimli/gimli/core/src/datacontainer.cpp: 670		const IndexArray GIMLI::DataContainer::id(const string&) const  token: s is not an index list: SensorIdx:  Data: g s t valid 

Using Jupyter Notebook
print(pg.version) --------> 1.1.0+31.g47c8d810

Operating system: Win7 Ultimate 64 bit
Python version: 3.7.6

@halbmy
Copy link
Contributor

halbmy commented Nov 16, 2020

That's strange indeed. It seems like the token s is not registered as sensor index, which is exactly what's done in the constructor in the C++ core. You can do it in Python by the following code:

    data = pg.DataContainer()
    data.registerSensorIndex("s")
    data.registerSensorIndex("g")
    data.load("Line_1.txt")

which should solve your problem. Can you try, please?
I can only assume encoding problems in the strings as the reason for it.

@BoDoNgAhAi
Copy link

BoDoNgAhAi commented Nov 16, 2020

It is still giving the same result if I use data = pg.DataContainer("Line_1.txt", "s g")

runfile('C:/Users/Mc/untitled0.py', wdir='C:/Users/Mc')
Data: Sensors: 11 data: 80, nonzero entries: ['g', 's', 't', 'valid']

and it is working fine on shot_rec_dis = traveltime.shotReceiverDistances(data, full=True)

Although, the data contains 405 measurements. If I do not use "s g" it gives the exact number of the measurements. Then I use shot_rec_dis = traveltime.shotReceiverDistances(data, full=True) it gives the error above.

I am sorry for the last comment. I did a mistake there that I uploaded the code working fine with the error from the code without "s g".

@halbmy
Copy link
Contributor

halbmy commented Nov 16, 2020

Ah yes, I am sorry, I mixed things up. I need to make things clear about the data format:

11 # shot/geophone points		
#x	y	
-20	0	
0	0	
20	0	
40	0	
60	0	
80	0	
100	0	
120	0	
140	0	
160	0	
180	0	

means that there are only 11 sensors (shots or geophones) involved. By registering s and g as sensor indices (pointing into this list to map a number into a position), only indices between 1 and 11 do make sense. All others are automatically deleted and thus only 80 valid data remain. So the problem is in your data file. I guess your list of 11 is just for the shots but it needs to include both shots and geophones.

@halbmy
Copy link
Contributor

halbmy commented Nov 16, 2020

To make it clear by an example, the data line (s, g, t):

3	15	0.020159992

means use sensor number 3 as shot (i.e. x=20m) and geophone number 15, but it is not clear where this geophone is as it has not been defined in the list above. You could add the geophone coordinates after the shot coordinates (but avoid duplicate sensor positions!) and do data.sortSensorsX() to resort them.

@BoDoNgAhAi
Copy link

Thank you very much for your clear explanation! and everything. Now it makes sense :)

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

3 participants