[gradsusr] ctl file for irregular lon and lat dimension

Adams, Jennifer M. (GSFC-610.2)[ADNET SYSTEMS INC] jennifer.m.adams at nasa.gov
Fri Jun 21 08:17:12 EDT 2019


Wendi,
What you have is station data, not gridded data. Here is some python3 code I wrote that will create a station data file. There may be other ways to do this, but I’ve been working in Python lately, so it’s fresh (for me). This will create a descriptor file for you, but you must run stnmap on it and then you can display it in GrADS:
[cid:image001.png at 01D52809.B9A431E0]

import os
import struct
# write a station report header
def writeHdr (stnfp,stid,lat,lon,t,ngrp,flag) :
    stnfp.write(bytes(stid,'utf8'))
    stnfp.write(struct.pack("f",lat))
    stnfp.write(struct.pack("f",lon))
    stnfp.write(struct.pack("f",t))
    stnfp.write(struct.pack("i",ngrp))
    stnfp.write(struct.pack("i",flag))

# write a station report value
def writeVal(stnfp,val) :
    stnfp.write(struct.pack("f",val))

# Open the file
fn = 'RDCA20150803_0305.txt'
fp = open(fn,"r")

# build file names for station data, descriptor, and stnmap
root,ext = os.path.splitext(fn)
stnfn = root+'.stn'
ctlfn = root+'.ctl'
mapfn = root+'.map'
stnfp = open(stnfn, 'wb')

i=0
for line in fp:
    lon = float(line.strip().split()[0])
    lat = float(line.strip().split()[1])
    val = float(line.strip().split()[2])
    if val > -900 :
      i=i+1
      # write out the data
      stid=("%8d" % i);
      t=0.0
      flag=1
      ngrp=1
      # write a report header
      writeHdr(stnfp,stid,lat,lon,t,ngrp,flag)
      # write sfc variables
      writeVal(stnfp,val)
      writeVal(stnfp,lon)
      writeVal(stnfp,lat)

# write a terminator header
ngrp=0
flag=0
writeHdr(stnfp,stid,lat,lon,t,ngrp,flag)
stnfp.close()

# write a descriptor file
ctlfp = open(ctlfn, 'w+')
ctlfp.write("dset ^"+stnfn+"\n")
ctlfp.write("dtype station\n")
ctlfp.write("stnmap ^"+mapfn+"\n")
ctlfp.write("undef -999.000\n")
ctlfp.write("tdef 1 linear 03aug2015 1hr\n")
ctlfp.write("vars 3\n")
ctlfp.write("val   0  99  Value\n")
ctlfp.write("slon  0  99  Longitude\n")
ctlfp.write("slat  0  99  Latitude\n")
ctlfp.write("endvars\n")
ctlfp.close()

--
Jennifer Miletta Adams
ADNET Systems, Inc.
NASA/GSFC, Code 610.2
Building 32, Room S159
(301) 614-6070


From: gradsusr <gradsusr-bounces at gradsusr.org> on behalf of wendi harjupa <wendiharjupa at gmail.com>
Reply-To: GrADS Users Forum <gradsusr at gradsusr.org>
Date: Wednesday, June 19, 2019 at 8:30 AM
To: GrADS Users Forum <gradsusr at gradsusr.org>
Subject: [gradsusr] ctl file for irregular lon and lat dimension

Dear GrADS user,

I want to plot the data which has irregular lon and lat...
I donot want to interpolate the data, so I just want to plot it as the original data.

My question is how to make the control file for the irregular lon and lat data.
I attach two data through this email,
1. asci data which shows the different of lon and lat of the data.
2. Binary format data of the asci data.

Thank you very much for your help.

best regards
wendi
[Image removed by sender.] RDCA20150803_0305.bin<https://drive.google.com/file/d/1HDCQXO30JwIRCaxTL-H1pf6eibRvhTpp/view?usp=drive_web>[Image removed by sender.]
[Image removed by sender.] RDCA20150803_0305.txt<https://drive.google.com/file/d/1l0vSZLO0Z21aBlfuMLF2UJM02m0kXTtC/view?usp=drive_web>[Image removed by sender.]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20190621/2b222399/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 255202 bytes
Desc: image001.png
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20190621/2b222399/attachment-0001.png>


More information about the gradsusr mailing list