Problems with using stnmap - help me

SB smitabodepudi at YAHOO.COM
Sat Feb 11 14:16:11 EST 2006


im using Grads vers v1.8SL11 32-bit little-endianion on windows xp
Im trying to use stnmap utility to generate a map file.

what shuld be the nlev and flag data types in stn header (shuld they be
defined as int  or float)

Issue 1:
--------

When i define nlev and flag as integers i get the following error

Starting scan of station data binary file.
Binary data file open: c:\programs\output.txt
Processing time = 1
  Invalid station hdr found in station binary file
  Possible causes:  Invalid level count in hdr
                    Descriptor file mismatch
                    File not station data
                    Invalid relative time
    levs = 0  flag = 1633771873  time = 0


but when i define them as float stnmap doesn't complain and creates a a
map file.

here is the c program for reference.


struct stnhdr
{
  char id[8];
  float lat;
  float lon;
  float t;
  int  nlev;   /* if defined as float then no error in stnmap */
  int flag;    /* same
}stn;
FILE *f2;

int main ()
{

int i,j,k;
float value;
f2 = fopen("OUTPUT.TXT","wb");

for(i =0;i<8;i++)
   stn.id[i]='a';
for(j=0;j<10;j++)
{
for(i = 0; i< 10; i++)
{
   stn.lat = j;
   stn.lon = i;
   value = i*j;
  if (i == 0)
  {
     stn.nlev = 0;
     stn.flag = 0;
     stn.t = 0.0;
     fwrite(&stn,sizeof(struct stnhdr),1,f2);
  }

  stn.nlev=1;
  stn.flag =1;
  fwrite(&stn,sizeof(struct stnhdr),1,f2);
  fwrite(&value, sizeof(float),1,f2);

}
}
stn.nlev = 0;
fwrite(&stn,sizeof(struct stnhdr),1,f2);

}


Issue 2:
--------
I try to plot using map file generated with float types in header  with
the following  script : but i don't get any data plotted. could any one
help me wht is wrong with the following ?

following is the script and ctl file that i m using

ctl file :

DSET      c:\programs\output.txt
DTYPE     station
STNMAP    abc.map
UNDEF     -999.0
TITLE     Rain Fall
TDEF      1 LINEAR 1JAN2000 1DY
VARS      1
x  0  99  Data Points
ENDVARS

script :
      clear
     set gxout value
     set display color
     open stat.ctl
     set lat 0 100
     set lon 0 100
     set stid off
     set ccolor rainbow
     display x



More information about the gradsusr mailing list