<div>List, <br> </div>
<div>I'm working on a project that involves parsing through a page of text, stripping out the data I want, and writing it to a binary file. Ultimately I would like to take the data in the binary file and plot it as station data in GrADS, but I've come across a problem when I try to write my data out as binary.
</div>
<div> </div>
<div>I'm decoding RR2 SHEF encoded snowfall data, stripping out the LAT/LON of the station of interest, 6/12/24hr snowfall totals (if available, using -999.0 to fill in missing data), and snow depth (again, -999.0 if 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 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 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 (<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>DVH6\S{4}\s(\d+.\d+)"LAT=(\d{2}.\d+)\sLON=(-\d{2}.\d+)\s<span class="moz-txt-tag">/</span></i>){ <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: $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, $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 depth. I didn't bother to include them here, they look the same except 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, $nFlag"; <br>print $buffer; <br><br>
exit; <br><br>Again, following suit with what I've seen before. I get a snowfall.bin file w/out a problem, but when I go to run `stnmap -i snowfall.ctl`...I 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 don't have any errors in there, just 4 variables (6hr,12hr,24hr,sd) and the DTYPE set to station. While the error is semi-cryptic, I can infer that something's not right with how the data is being written to the binary file. Like I said, this is more of a problem of getting data into a "grads-readable" format instead of actually using GrADS, but maybe someone has used station data enough to have come across this error. Does anyone have any insight as to how I can go about fixing it? Any help would be appreciated!
<br><br>Thanks! <br><br>Dan Leins <br> </div>