Carpe diem!

Make your lives extraordinary

perl : memotong segy file per FFID/fldr

SU Unix is powerful tools to process segy data.

#!/usr/bin/perl

sub trim {
my $string = shift;
for ($string) {
s/^\s+//;
s/\s+$//;
}
return $string;
}

# convert to SU file
#system(‘segyread tape=data.sgy endian=0 verbose=1 | segyclean > data.su’);
# reading header file
#system(‘sugethw < data.su key=fldr > data.hdr’);

#loop to write
open(FILE,”data.hdr”) || die “cannot open file”;
$prevdata = ‘www’;
while(<FILE>)
{
$info = $_;
#print $info;
# parse info
$key = ‘none’;
($key,$val)=split(‘=’,$info);
#print(‘*’,trim($key),’*’,$val,’*’);
$key = trim($key);
$val = trim($val);
print(“*$key*$val* \n”);
if ($key eq “fldr”) {
if ($val ne  $prevdata) {
system(“suwind key=fldr min=$val max=$val < data.su  > $val.su”);
system(“segyhdrs < $val.su”);
system(“segywrite tape=$val.segy endian=0 verbose=1 < $val.su”);
$prevdata=$val;
}else{
#skip
print(“—>skipped already process : $val \n”);
}
}else{
#skip
print(“–>skipped empty \n”);
}

}
close(FILE);
#end loop

have a nice try!

April 22, 2009 - Posted by | code Warior, curhat, Ngoprek, santai, techno

1 Comment »

  1. […]  Kode Sumber lengkap dapat dilihat di posting saya sebelumnya  dalam script perl […]

    Pingback by Lowongan Waviv Technologies « Carpe diem! | May 19, 2009 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: