Re: write station data into netCDF

From: Àî¼ÎÅô <lijpbasin_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 20 2012 - 21:28:48 MDT

Hi, Chan
I haven't used cdo and sorry for not being able to help you with this. I guess cdo requires the netCDF file conforming to certain conventions like COARDS, you may need to check the cdo manual.

Good luck!
Jiapeng

At 2012-03-20 23:22:41,"Mark Chan" <cym263@yahoo.com> wrote:

Thanks a lot for your message, which is helpful. I did a small modification as "f_out->pwv = pwv", then got a message as below by using "ncdump".
However, when trying to find info by using CDO as "cdo info ppw.nc", then it failed (see the following message). I would like to make the netCDF file, which can be checked using CDO. Are there any further suggestion?

Thanks very much again!
Mark

----------------cdo message-------------------
cdo info: Open failed on >ppw.nc<
Unsupported file structure

------------ncdump message-----------------
:$ ncdump ppw.nc
netcdf ppw {
dimensions:
    ncl0 = 32 ;
    dim0 = 32 ;
variables:
    float pwv(ncl0) ;
    float lat(dim0) ;
    float lon(dim0) ;
data:

 pwv = 48, 46.3, 49.8, 45, 38.2, 46.6, 34.3, 50.2, 39.8, 47.1, 40.4, 46.7,
    39.9, 48.8, 46.5, 50.4, 26.4, 22.4, 49, 43.2, 41.4, 33.6, 33.9, 36.3,
    40.2, 31.7, 42.8, 45.9, 45.3, 47.9, 46.8, 38.6 ;

 lat = 36.75, 36.41, 36.63, 34.11, 40.08, 35.85, 38.31, 35.68, 33.02, 36.69,
    39.58, 36.79, 37.3, 36.03, 34.98, 36.36, 40.09, 36.56, 36.6, 36.43,
    36.88, 37.33, 38.2, 38.12, 37.84, 38.2, 37.38, 34.88, 35.36, 35.56,
    35.26, 36.07 ;

 lon = -97.25, -97.69, -96.81, -94.29, -97.31, -97.48, -97.29, -95.86,
    -100.98, -97.48, -94.17, -97.75, -95.6, -96.5, -97.52, -97.15, -100.65,
    -100.61, -97.49, -98.28, -98.29, -99.31, -99.32, -97.51, -97.02, -95.59,
    -96.18, -98.2, -98.98, -98.02, -97.48, -99.22 ;
}

From: Àî¼ÎÅô <lijpbasin@126.com>
To: Mark Chan <cym263@yahoo.com>
Sent: Tuesday, March 20, 2012 3:38 PM
Subject: Re:[ncl-talk] write station data into netCDF

Does this provide what you need?

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
;
; Data is stored in four columns: station_name lat lon pwv
; Read in each line as a string, and use "str_get_field" to
; read in the fields of interest.
;
  fname = "pw.dat"
  lines = asciiread(fname,-1,"string")

;
; Use "str_get_field" to indicate which fields to read in. Each field
; is separated by spaces.
;
  id = stringtochar(str_get_field(lines(1:),1," "))
  id_dims = dimsizes(id)
  id_len = id_dims(1)
  lat = stringtofloat(str_get_field(lines(1:),2," "))
  lon = stringtofloat(str_get_field(lines(1:),3," "))
  pwv = stringtofloat(str_get_field(lines(1:),4," "))
  delete(lines)

  ;print(id_len)
  ;print(chartostring(id))

;
; Write to pw.nc
;
  f_out = addfile("pw.nc", "c")
  id!0 = "dim0"
  id!1 = "dim1"
  lat!0 = "dim0"
  lon!0 = "dim0"
  f_out->id = id
  f_out->lat = lat
  f_out->lon = lon

Regards, Jiapeng

At 2012-03-20 21:54:18,"Mark Chan" <cym263@yahoo.com> wrote:

Dear NCL users,

The attached files are NCL script and the data, and I would like to make an NCL script to transform the data into netCDF format, in which the info of latitude and longitude are clearly inside the netCDF file.
Can anyone give a suggestion or modify the attached NCL script?

Thanks in advance!
Mark

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 20 21:29:03 2012

This archive was generated by hypermail 2.1.8 : Tue Mar 27 2012 - 08:50:24 MDT