[Developers] Plugin Beginner

Raman Singh raman at opendtect.org
Wed Oct 17 12:20:43 CEST 2007


Dear Fernando,

I was preparing an introduction to the Tutorial plugin when your mail 
came in. That gives me another reason to post that introduction as soon 
as possible.

Before that, let me assist you with your plugin development. The first 
part which calculates the average of data values between two Z values 
for each trace is similar to the Tutorial Seismic Tools. If you look at 
the function Tut::SeisTools::handleTrace() in 
"$WORK/plugins/Tut/tutseistools.cc", it does a similar operation for 
case 'Smooth', over a fixed number of samples. In your case, you just 
need to pass the two Z values, get the corresponding sample numbers 
using the SeisTrc function 'nearestSample' 
($WORK/include/Seis/seistrc.h) and take the average of all the values 
between the two samples.

The second part deals with the storage of the calculated values in a 
horizon.
I would suggest you to check if you are missing on one of these points:

1) Make sure you get the correct PosID.
-- Get the BinID from 'trcin_.info().binid',
-- Get the corresponding EM::SubID from binid.getSerialized(),
-- Get the EM::ObjectID from horizon_->id(),
-- And finally get an EM::PosID from the ObjectID, SectionID and SubID.

I would suggest to create the posid before the loop over all traces, 
like: EM::PosID posid( horizon_->id(), horion_->sectionID(0) );
Then set the subid inside the loop, like: posid.setSubID( 
trcin_.info().binid.getSerialized() );

2) In the statement "horizon_->auxdata.setAuxDataVal(dataidx_, posid_, 
average)", make sure that dataidx_ is same as the one you got after 
adding the auxdata using "horizon_->auxdata.addAuxData( ATTRIBUTE NAME 
). You can have a look at an example in function 
'Tut::ThicknessFinder::init' ( in "$WORK/plugins/Tut/tuthortools.cc" ).

I hope it helps you solve your problems. For further assistance, you can 
always get back to us.

Regards,

Raman



Fernando J. Zunino wrote:
> Hi,
> I'm trying to solve a problem and I don't know how to do it.
>
> I'll begin with the simple version of the problem.
> I want to develop a plugin which given an input cube and two timeslice
> coordinates outputs, for each seismic trace, the average of the samples
> contained between those two coordinates.
>
> I've take as an example the Tutorial Plugin published in
> http://www2.opendtect.org/devel/html/Programmer/plugins.html#tutplugin, 
> not the one in
> http://www2.opendtect.org/rel/html/Programmer/plugins.html#tutpi.
>
> My idea was to take an input cube and iterate over all its traces using
> a SeisTrcReader. Then with every SeisTrc calculate its average looping
> over all its values.
> Here I've encountered my first stopper: I could get the values of the
> SeisTrc using trcin_.get(i, 0) but I can't get the timeslice coordinate
> for the value. This makes impossible the average calculation between two
> timeslice coordinates.
>
> The other problem that I've encountered is how to store the average
> calculation for every trace. My idea was to use the auxiliary data of an
> horizon to store this calculation: Define an horizon with some fixed z
> coordinate (a timeslice plane) and for every SeisTrc obtain its (x, y)
> coordinate, compute its average and store in the same (x, y) coordinate
> of the horizon auxiliary data this calculation.
> Here I've encountered another stopper: I couldn't correctly map the
> SeisTrc (x, y) coordinate to the horizon (x, y) coordinates.
>
> For example:
>
> Coord3 pos;
> pos.x = trcin_.info().coord.x;
> pos.y = trcin_.info().coord.y;
> pos.z = 1000;
>
> horizon_->setPos(posid_, pos, false);
> horizon_->auxdata.setAuxDataVal(dataidx_, posid_, average);
>
>
> Is this the correct way to do it? Is there another way?
>
> Thanks in advance,
> Fernando
>   

-- 
Raman K Singh
dGB India
304, Gateway Plaza
Hiranandani Gardens, Powai
Mumbai  400 076
India

Ph.  +91 22 25704984
Mob: +91 98190 82417
www.opendtect.org





More information about the Developers mailing list