John, Thank you very much, you confirmed that I was at least on the right track with what I was doing. The numbers are still not coming out correctly (at least not what I was expecting). This file seems to be geared towards a sun system, could this be effecting my results, would using binmode(FILE) help if it was?
Thanks again for you help... John On Sat, 07 Sep 2002 15:21:59 -0700 "John W. Krahn" <[EMAIL PROTECTED]> wrote: > John Cichy wrote: > > > > Hello all, > > Hello, > > > I have a binary I*2 format data file that I would like to extract data from. > > The file comes with a discription file that contains a fortran sub to extract > > the data. For the life of me I can't figure out how to accomplish the extraction. > > The following is from the description file nad includes the fortran sub: > > > > ---begin paste > > > > 2. The goes.nav is a file containing latitude/longitude data which can be > > used with satellite images in this directory to pinpoint geographical > > locations on goes-8 images. The file is binary I*2 format with the > > first two values being the pixel and line (x,y) size of the image. > > The succeeding pairs of elements are I*2 values of latitude longitude * 100. > > Compared to the goes image, the lat/lon pairs are stored by column first, > > then row; i.e. all the elements in row 1 are stored, then row 2 etc until > > the bottom of the image. > > > > The following is a fortran subroutine that can be used to read > > the goes.nav file: > > > > subroutine getnav(lat,lon) > > c************************************************************************ > > c* This routine reads goes.nav files with a maximum size of * > > c* 2000 pixels wide and 2000 lines/records and stores * > > c* latitude/longitude data into lat lon * > > c* the format of the goes.nav data is as follows * > > c* * > > c* i*2 i*2 * > > c* | | * > > c* V V * > > c* record 1 x size ysize * > > c* record 2 lat *100 lon*100 * > > c* record 3 lat *100 lon*100 * > > c* record 4 etc etc * > > c* * > > c************************************************************************ > character file_name*80 > > real lat(2000,2000),lon(2000,2000) > > c > > c > > integer*2 tempstor(2) > > integer*4 buffout,record_count,xsize,ysize,yyyy,xxxx > > equivalence (buffout,tempstor(1)) > > C > > C > > C PLEASE NOTE: recl=1 in the open statment below means > > C that the record length is 32 bits ( 4 bytes) > > C not 8 bits (1 byte) > > open(23,file='goes.nav',access='direct',recl=1,status='old') > > READ(23,REC=1)buffout > > C > > C > > xsize=tempstor(1) > > C > > C > > ysize=tempstor(2) > > type *,' width =',xsize, ' height =',ysize > > C > > C > > record_count=1 > > do yyyy=1,ysize > > do xxxx=1,xsize > > record_count = record_count + 1 > > read(23,rec=record_count)buffout > > lat(xxxx,yyyy)=tempstor(1) * .01 > > lon(xxxx,yyyy)=tempstor(2) * .01 > > c ............................................... > > c NOTE: LATITUDE VALUES OFF THE EARTH ARE 99.00 > > C AND LONGITUDE VALUES ARE -256.35999 AT THIS > > C POINT IN THE SUBROUTINE > > C ............................................... > > end do > > end do > > RETURN > > END > > > > ----end paste > > > Well, my FORTRAN is a little rusty (to say the least) but I'll give it a shot. > (caveat: this is a literal translation and isn't very "Perlish". YMMV) > > > my $file = 'goes.nav'; > open FILE, $file or die "Cannot open $file: $!"; > $/ = \4; > > my ( $xsize, $ysize ) = unpack 'ss', scalar <FILE>; > print " width=$xsize height=$ysize\n"; > > my ( @lat, @lon ); > for my $yyyy ( 1 .. $ysize ) { > for my $xxxx ( 1 .. $xsize ) { > ( $lat[$xxxx][$yyyy], $lon[$xxxx][$yyyy] ) = map $_ *= 0.01, unpack 'ss', >scalar <FILE>; > } > } > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]