<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>Hi there,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>I would rather been watching the World Cup, but I
have to get this data in a usable format and there is no better place to get it
than from GDAL’s experts.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>The “Intergovernmental Panel on Climate Change”
(IPCC) offers data on the web in a format described by this Fortran source
code: (The file extension is just a generic “.dat”)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><a
href="http://ipcc-ddc.cru.uea.ac.uk/obs/observed_fileformat.html">http://ipcc-ddc.cru.uea.ac.uk/obs/observed_fileformat.html</a><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>> more cpre0130.dat<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>
grd_sz xmin
ymin xmax
ymax n_cols n_rows n_months<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>
0.50 0.25
-89.75 359.75
89.75
720 360
12<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>-9999-9999-9999-9999-9999-9999-9999-9999-9999
52 88 103 91 65
45 27 32 …<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>-9999-9999-9999-9999-9999 11
20 22 25 27 26
27 28 31 29 28 30 …<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>It’s not hard to analyze the pattern on the
data or the code, so I figured that:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- It’s an ASCII format;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- There are two lines of reader (easy to read)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- Each cell is 5 characters wide;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- The no-data is “-9999”;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- There is no separator between cells (what makes my
task difficult);<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- It’s a multi-band raster dataset with 12
bands; (720x360x12 cells)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>- I am not sure if positive values can go beyond
9999 (that reminds me COBOL)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>I am heading in the direction of writing a
Python+GDAL script to do the task, but I am stuck in how to separate the cells.
The Fortran code is doing it in just one command as you can see in the code. I
am thing that maybe by using the NumPY stuff embedded in GDAL I could do the
same.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>Any Idea? Any experience with this data format?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>Thanks in advance,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>Ivan<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>-------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>This is a Python command line interaction with the
data:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>>>> import gdal<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>>>> f = open('C:/Data/IPCC/cpre0130.dat',
'r');<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>>>> f.readline()<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>'
grd_sz xmin
ymin xmax
ymax n_cols n_rows n_months\n'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>>>> f.readline()<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>'
0.50 0.25
-89.75 359.75
89.75
720 360
12\n'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>>>> f.readline()<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>'-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>-------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'>Fortran source code:<o:p></o:p></span></font></p>
<pre style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'><o:p> </o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>program rd_ascii <o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>!<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>! f90 program to read in an integer ascii grid with<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>! variable dimensions into a global grid (720x360x12)<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>!<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> parameter :: n_cols=720<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> parameter :: n_rows=360<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> integer, dimension (n_cols,n_rows,12) :: grid<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> character(len=72) :: infl<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> character(len=20) :: fmt<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>!<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> call getarg(1,infl)<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>! <o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> if(infl.eq.' ')then<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> write(*,*) 'Enter ascii grid file name'<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> read(*,'(a72)')infl<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> end if<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>! <o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> open(1,file=infl,status='old')<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> read(1,*)<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> read(1,*)xmin,ymin,xmax,ymax,ncols,nrows,nmonths,missing<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> grid=missing<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> fmt='( i5)'<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> write(fmt(2:4),'(i3)')n_cols<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> do im=1,nmonths<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> do lat=1,n_rows<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> read(1,fmt)(grid(lon,lat,im),lon=1,n_cols)<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> enddo<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'> enddo<o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>! <o:p></o:p></span></font></pre><pre
style='background:white'><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;color:#333333'>end program rd_ascii<o:p></o:p></span></font></pre>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=1 face="Courier New"><span style='font-size:8.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>