<div>All,</div>
<div> </div>
<div>Ok yes, following those conventions definitely had the desired effect! </div>
<div> </div>
<div>Thanks for pointing me in the right direction!<br> </div>
<div>Dan<br><br> </div>
<div><span class="gmail_quote">On 12/12/05, <b class="gmail_sendername">Diane Stokes</b> <<a href="mailto:Diane.Stokes@noaa.gov">Diane.Stokes@noaa.gov</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi, Dan.<br><br>I didn't go through your msg carefully to catch everything, but for<br>starters, it doesn't look like you are following the required format
<br>described at:<br><br> <a href="http://grads.iges.org/grads/gadoc/aboutstationdata.html#station">http://grads.iges.org/grads/gadoc/aboutstationdata.html#station</a><br><br>The station id should be the first word in your header and should be
<br>written out as type character with length 8. nlev and nflag should be<br>written as integer, not float.<br><br> Diane<br><br><br>Dan Leins wrote:<br>> List,<br>><br>> I'm working on a project that involves parsing through a page of text,
<br>> stripping out the data I want, and writing it to a binary file.<br>> Ultimately I would like to take the data in the binary file and plot it<br>> as station data in GrADS, but I've come across a problem when I try to
<br>> write my data out as binary.<br>><br>> I'm decoding RR2 SHEF encoded snowfall data, stripping out the LAT/LON<br>> of the station of interest, 6/12/24hr snowfall totals (if available,<br>> using -999.0
to fill in missing data), and snow depth (again, -999.0 if<br>> missing).<br>><br>><br>> .A CLE141 1126 Z DH0000/DVH12/SFV 1.5"LAT=41.86 LON=-80.8 ASHTABULA 3S"/<br>> .A CLE130 1126 Z DH0000/DVH12/SFV
1.5"LAT=41.58 LON=-81.2 CHARDON"/<br>> .A CLE221 1126 Z DH0000/DVH12/SFV 1.4"LAT= 41.16 LON=-81.21 RAVENNA 1E"/<br>> .A CLE032 1126 Z DH0000/DVH12/SFV 5.0"LAT=41.83 LON=-80.09 CAMBRIDGE<br>
> SPRINGS"/<br>> .A CLE020 1126 Z DH0000/DVH12/SFV 3.2"LAT=41.93 LON=-80.3 FRANKLIN CTR"/<br>> .A CLE023 1126 Z DH0000/DVH12/SFV 0.8"LAT=41.92 LON=-79.64 CORRY"/<br>> .A CLE032 1126 Z DH0230/DVH24/SFV
3.0"LAT=41.81 LON=-80.07 CAMBRIDGE<br>> SPGS"/<br>> .A CLE020 1126 Z DH0000/DVH6/SFV 16.0"LAT=41.93 LON=-80.3 FRANKLIN CTR"/<br>> .A CLE141 1126 Z DH0000/SD/ 5.0"LAT=41.86 LON=-80.8 ASHTABULA 3S"/
<br>> .A CLE130 1126 Z DH0000/SD/ 10.0"LAT=41.58 LON=-81.2 CHARDON"/<br>> .A CLE221 1126 Z DH0230/SD/ 6.0"LAT=41.34 LON=-81.2 HIRAM RAPIDS"/<br>> .A CLE221 1126 Z DH0000/SD/ 6.0"LAT=41.16
LON=-81.21 RAVENNA 1E"/<br>> .A CLE032 1126 Z DH0000/SD/ 15.0"LAT=41.83 LON=-80.09 CAMBRIDGE SPRINGS"/<br>> .A CLE032 1126 Z DH0230/SD/ 7.0"LAT=41.81 LON=-80.07 CAMBRIDGE SPGS"/<br>> .A CLE023 1126 Z DH0000/SD/
17.0"LAT=41.92 LON=-79.64 CORRY"/<br>> .A CLE020 1126 Z DH0000/SD/ 12.0"LAT=41.93 LON=-80.3 FRANKLIN CTR"/<br>><br>> Using the logic from an existing script...I start w/<br>><br>> #!/usr/local/perl/bin/perl
<br>> open BINFILE, ">snowfall.bin";<br>><br>> open (RR2, "<rr2.txt");<br>> while (<RR2>){<br>><br>> #6 hr snow depth search<br>> if (/DVH6\S{4}\s(\d+.\d+)"LAT=(\d{2}.\d+)\sLON=(-\d{2}.\d+)\s/){
<br>> $sf_6 = $1;<br>> $latitude="$2";<br>> $longitude="$3";<br>> $sf_12= "-999.0";<br>> $sf_24= "-999.0";<br>> $sd= "-999.0";<br>> print "6hr: $sf_6 12hr: $sf_12 24hr: $sf_24 SD: $sd LAT: $latitude LON:
<br>> $longitude\n";<br>> $nLev=1;<br>> $nFlag=1;<br>> $timeInc=0.;<br>> $buffer = pack 'f f f f f f f f f', $latitude, $longitude, $timeInc,<br>> $nLev, $nFlag, $sf_6, $sf_12, $sf_24, $sd;<br>> print BINFILE $buffer;
<br>> }<br>><br>> I do the same thing for the other variables too, 12hr, 24hr, and snow<br>> depth. I didn't bother to include them here, they look the same except<br>> for the - 999.0 values which vary.<br>
><br>> At the end of my script, I end w/<br>><br>><br>> $nLev=0;<br>> $nFlag=0;<br>> $buffer = "pack 'f f f f f', $latitude, $longitude, $timeInc, $nLev,<br>> $nFlag";<br>> print $buffer;
<br>><br>> exit;<br>><br>> Again, following suit with what I've seen before. I get a snowfall.bin<br>> file w/out a problem, but when I go to run `stnmap -i snowfall.ctl`...I<br>> get the following error...
<br>><br>> Name of binary data set: snowfall.bin<br>> Number of times in the data set: 1<br>> Number of surface variables: 4<br>> Number of level dependent variables: 0<br>><br>> Starting scan of station data binary file.
<br>> Binary data file open: snowfall.bin<br>> Processing time = 1<br>> Invalid station hdr found in station binary file<br>> Possible causes: Invalid level count in hdr<br>> Descriptor file mismatch
<br>> File not station data<br>> Invalid relative time<br>> levs = -998653952 flag = 1069547520 time = 1<br>><br>> My snowfall.ctl file is pretty straightforward, I'm pretty confident I
<br>> don't have any errors in there, just 4 variables (6hr,12hr,24hr,sd) and<br>> the DTYPE set to station. While the error is semi-cryptic, I can infer<br>> that something's not right with how the data is being written to the
<br>> binary file. Like I said, this is more of a problem of getting data<br>> into a "grads-readable" format instead of actually using GrADS, but<br>> maybe someone has used station data enough to have come across this
<br>> error. Does anyone have any insight as to how I can go about fixing it?<br>> Any help would be appreciated!<br>><br>> Thanks!<br>><br>> Dan Leins<br>><br><br>--<br>Diane Stokes<br>Environmental Modeling Center
<br>National Weather Service/NOAA<br></blockquote></div><br>