PDA

View Full Version : Convert netcdf to plain ASCII



Toby
6th April 2006, 06:45 PM
Hello fellow forum users,

i am a student of geoscience and pretty new to the wide field of NCEP/NCAR reanalysis data. First i have to say that my overall aim is to get the data into a plain ASCII format for further analysis (spatial and temporal) in a GIS. Therefor i have to convert the netcdf files into normal ASCII textfiles. And there i have a problem. I use ncdump to convert the data, but the result always is frustrating. There is another user who seemed to have the same problem a few month ago.
Here is the link to the post:

http://www.oceanographers.net/forums/showthread.php?t=338&highlight=netcdf

Actually my russian language skills arenīt the best ;)

Here is a part of the result after the data was convertet with ncdump (air temperature in kelvin):

netcdf air2004 {
dimensions:
lon = 144 ;
lat = 73 ;
time = 366 ;
variables:
float lat(lat) ;
lat:units = "degrees_north" ;
lat:actual_range = 90.f, -90.f ;
lat:long_name = "Latitude" ;
float lon(lon) ;
lon:units = "degrees_east" ;
lon:long_name = "Longitude" ;
lon:actual_range = 0.f, 357.5f ;
double time(time) ;
time:units = "hours since 1-1-1 00:00:0.0" ;
time:long_name = "Time" ;
time:actual_range = 17557968., 17566728. ;
time:delta_t = "0000-00-01 00:00:00" ;
time:avg_period = "0000-00-01 00:00:00" ;
short air(time, lat, lon) ;
air:long_name = "mean Daily Air temperature at sigma level 995" ;
air:valid_range = 185.16f, 331.16f ;
air:actual_range = 185.16f, 316.13f ;
air:units = "degK" ;
air:add_offset = 512.81f ;
air:scale_factor = 0.01f ;
air:missing_value = 32766s ;
air:precision = 2s ;
air:least_significant_digit = 1s ;
air:GRIB_id = 11s ;
air:GRIB_name = "TMP" ;
air:var_desc = "Air temperature\n",
"A" ;
air:dataset = "NCEP Reanalysis Daily Averages" ;
air:level_desc = "Surface\n",
"0" ;
air:statistic = "Mean\n",
"M" ;
air:parent_stat = "Individual Obs\n",
"I" ;

// global attributes:
:Conventions = "COARDS" ;
:title = "mean daily NMC reanalysis (2004)" ;
:base_date = 2004s, 1s, 1s ;
:history = "created 2004/01/03 by Hoop (netCDF2.3)" ;
:description = "Data is from NMC initialized reanalysis\n",
"(4x/day). These are the 0.9950 sigma level values." ;
:platform = "Model" ;
data:

air =
-25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981, -25981,

The problem is that i dont understand why always these huge negative numbers appear, although the actual range of the air temperature is between 185 and 332 kelvin. I guess it has something to do with data format of the variables within the netcdf files itself, but i am not sure.

so..i hope that all of you understand my problem. If anyone has experience with converting these kinds of data, i would really appreciate any help, hints, suggestions and solutions.

Thanks very much in advance!

Toby

rocksea
7th April 2006, 04:28 AM
The problem is that i dont understand why always these huge negative numbers appear, although the actual range of the air temperature is between 185 and 332 kelvin. I guess it has something to do with data format of the variables within the netcdf files itself, but i am not sure.
In the header details, do you see this:
air:add_offset = 512.81f ;
air:scale_factor = 0.01f ;

So, you have to multiply the values by a scale factor 0.01 and then add the offset 512.8 to it. You'll get the output in the required range :thumbsup:

eg:
-25981 * 0.01 = -259.81
-259.81 + 512.81 = 253 Kelvin

koldunovn
10th April 2006, 07:27 AM
The same was in this http://www.oceanographers.net/forum...ighlight=netcdf (showthread.php?t=338&highlight=netcdf) post in Russian. :thumbsup:

Toby
12th April 2006, 07:35 PM
hi rocksea,

thanks for your help. It works perfectly well. Such a long question and such a short answer ;)

Now the real work can begin :)

And hi Nicolay,

i am aware of your post in russian. As you can see, i refered to your thread in my first post, but actually i didnīt help me very much ;)

thanks to all!

Toby

42d3e78f26a4b20d412==