[GrADS] How to plot stations climatology contour in a map?

Jayakrishnan PR prjayakrishnan at GMAIL.COM
Tue Jan 22 01:51:51 EST 2008


Dear Qingfang Dai,
    I have followed the same method as given by you in plotting station data
and was successful in plotting the shaded plots of the required value. I
herewith attaches the ctl file which I used and the c program. The program
looks almost same with some modifications. May be you can compare it with
your purposes because It is working well for me.

I have two suggestions....One is that it is better to create station map
from out side the gs file and incorperate it in the ctl file. Next
suggestion is that before running in the gs file kindly try the procedures
in the command terminal. That will be better to know where the error has
occured.
Hope this helps......best wishes....




On 1/22/08, Qingfang Dai <qdai at math.ualberta.ca> wrote:
>
>  Dear GrADS Users,
>
> I want to plot the stations' climatology contour. My TXT data file is the
> format of (stnid, lat, lon, climatology value). So I did as followings but
> it doesn't work. I don't how I shuld do.
>
> *First, I used the following C++ program to write the TXT file into DAT
> file:*
>
> #include "stdafx.h"
> #include <stdio.h>
>
> int main(int argc, char* argv[])
> {
>   /* Structure that describes a report header in a stn file */
>   struct rpthdr
>   {
>     char  id[8];    /* Station ID */
>     float lat;      /* Latitude of Station */
>     float lon;      /* Longitude of Station */
>     float t;        /* Time in grid-relative units */
>     int   nlev;     /* Number of levels following */
>     int   flag;     /* Level independent var set flag */
>   } hdr;
>
>   FILE  *ifile, *ofile;
>   char  rec[80];
>   //int   flag,year,month,yrsav,mnsav;
>   int   i;
>   float val;
>
> /* Open files */
>   ifile = fopen ("clim.txt","r");
>   ofile = fopen ("clim.dat","wb");
>
>    if (ifile==NULL || ofile==NULL) {
>     printf("Error opening files\n");
>     return 1;
>   }
>
> /* Read, write loop */
>   val = 0.0;
>   while (fgets(rec,79,ifile)!=NULL) {
>     /* Format conversion */
>   sscanf (rec+8," %g %g %g",&hdr.lat,&hdr.lon,&val);
>     for (i=0; i<8; i++) hdr.id[i] = rec[i];
>
>     /* Write this report */
>     hdr.nlev = 1;
>     hdr.flag = 1;
>     hdr.t = 0.0;
>     fwrite (&hdr,sizeof(struct rpthdr), 1, ofile);
>     fwrite (&val,sizeof(float), 1, ofile);
>   }
>   /* Time group terminator */
>   hdr.nlev = 0;
>   fwrite (&hdr,sizeof(struct rpthdr), 1, ofile);
>
>   fclose(ifile);
>   fclose(ofile);
>
>   return 0;
> }
>
> *Second, I write the ctl file 'clim.ctl' as*
>
> DSET ^clim.dat
> DTYPE  station
> STNMAP ^clim.map
> UNDEF -999.9
> TITLE 61-90 climatology
> TDEF  1 LINEAR Jan1960 1mo
> VARS  1
> prep  1  99  precipitation climatology of station
> ENDVARS
>
> *Finally, I write the gs file 'clim.gs' as*
>
> '!stnmap -i ../stnmap/AB_elev.ctl'
>
> 'reinit'
> 'open ../stnmap/AB_elev.ctl'
> 'set gxout contour'
> 'set grads off'
> 'set mproj nps'
> 'set grid off'
> 'set frame off'
> 'set cstyle 3'
> 'set csmooth off'
> 'set t 1 1'
> 'd prep'
>
> 'set font 1'
> 'set string 1 tc 3'
> 'set strsiz 0.15 0.15'
> 'draw title 1961-1990 Climatology in January'
> 'printim ../Clim.gif gif white'
>
> Thanks.
>
> Qingfang
>


Sincerely
--
***********************************************
Jayakrishnan.P.R
Junior Research Fellow
Department of Atmospheric Sciences
Cochin University of Science And Technology (CUSAT), Cochin-16
Kerala, India.
Mob: 09895417565

***********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20080122/2e34e2d6/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stnexample.ctl
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20080122/2e34e2d6/attachment.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stnkutty.c.c
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20080122/2e34e2d6/attachment.c 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stndata.gs
Type: application/octet-stream
Size: 216 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20080122/2e34e2d6/attachment.obj 


More information about the gradsusr mailing list