reading 30s WPS topo binary data

Dataset specific topics involving WPS.

reading 30s WPS topo binary data

Postby joegrim » Mon Oct 31, 2011 9:20 am

Hi,

I am trying to edit the 30s resolution topographic dataset for use within WPS. I plan on using it for large reservoirs and terminal lakes with widely varying lake surface elevations. The topographic data are in binary files that cover an area of 10deg Lat x 10deg Lon. Here is the information on the binary files
type = continuous
signed = yes
projection = regular_ll
dx = 0.00833333
dy = 0.00833333
known_x = 1.0
known_y = 1.0
known_lat = -89.99583
known_lon = -179.99583
wordsize = 2
tile_x = 1200
tile_y = 1200
tile_z = 1
tile_bdr=3
units="meters MSL"
description="Topography height"

Thanks to others' help, I have determined that the data is 1206x1206 (because of the tile_bdr of 3 on each edge). Each piece of data is 16 bits (file size is 2908872 bytes, so 2908872/1206/1206 = 2 bytes = 16 bits). The data were written by .../WPS/geogrid/src/write_geogrid.c Unfortunately, I don't know C, but I do know NCL and some FORTRAN. I tried using the NCL fbindirread function:
fbindirread(geog_data_path+filename,0,dims+6,"short")
but the resultant arrays had values ranging from -32768 to 32525 (very near the range of possible values represented by a "short" 2-byte signed integer.) I also tried using FORTRAN, but am not very proficient in its use. I therefore converted the array in NCL to a netCDF file so I could view it to find out more about it. I have posted an image of it at http://www.joeandfrede.com/topo_30s.gif As you can see, the flat areas (e.g., the Great Salt Lake and Salt Flats in the lower right, the banana-shaped Sanke River valley just below center, the plains of Montana in the upper-right, etc.) are visible by their weak gradient. The mountainous areas seem to have a repeating pattern, indicating the range of possible values are not wide enough.

Does anyone have a suggestion for what I can do to get the array in a format that provides the correct values? Even better, does anybody have a snippet of FORTRAN or NCL code that I could use to read and re-write this data?

Thank you!

Joe Grim
joegrim
 
Posts: 6
Joined: Wed May 20, 2009 5:27 pm

Re: reading 30s WPS topo binary data

Postby huzidaxian » Thu Jan 14, 2021 11:43 pm

I just solve this problem, maybe this reply is quite late for you, but should be helpful to other people.

When you use NCL to parse this data, you need first to set 'ByteOrder', for my case I set it to 'BigEndian' using 'setfileoption ( "bin" , "ReadByteOrder" , "BigEndian" )' and then use fbindirread function to read this data like 'data = fbindirread("01681-01800.00721-00840",0,126,"short")', 126 here may need some change depending on what resolution data you are parsing, short means it's 2 bytes for each piece of data.

Note: As with any binary file, the "endian-ness" of the data on the file and that of the current system must agree. The "ReadByteOrder" option in the setfileoption procedure can be used to force the "endian" type in a file. This allows big-endian files to be read on a little-endian machine and vice versa. The isbigendian function can be used to determine the endian-ness of your current system.

Huzidaxian
huzidaxian
 
Posts: 1
Joined: Thu Jan 14, 2021 11:31 pm


Return to Working with Various Datasets

Who is online

Users browsing this forum: No registered users and 1 guest