Re: [netcdfgroup] Need help to convert .csv files to netCDF files

For many years I have used tbl2cdf (available
on Unidata's site, google it) to convert multiple
column input to netCDF. Then I use NCO to annotate
the metadata. tbl2cdf is just another filter.
My scripts look like this:

fl_stb='icr_JRI_dst_lac_1831_1992'
fl_src="${HOME}/icr/${fl_stb}.txt"
fl_tmp="/tmp/${fl_stb}.txt"
fl_hdr="/tmp/${fl_stb}.hdr"
fl_nc="${DATA}/icr/${fl_stb}.nc"
cat > ${fl_hdr} << EOF
time:f cnc_dst_ngxg:f cnc_lac_ngxg:f
EOF
tail --lines=+2 ${fl_src} > ${fl_tmp}
tbl2cdf -h ${fl_hdr} ${fl_tmp} ${fl_nc}
ncrename -O -d u,time ${fl_nc}
ncatted -a _FillValue,,o,f,-1.0 -a Description,,d,, ${fl_nc}
ncap2 -O -h -s 'cnc_dst=cnc_dst_ngxg*1.0e-9f;cnc_lac=cnc_lac_ngxg*1.0e-9f' -s 'cnc_dst_ngxg@long_name="Dust concentration";cnc_lac_ngxg@long_name="Black Carbon concentration"' -s 'global@Description="Attached are the monthly concentration data for James Ross. The dust record is identical to that in the PNAS 2007 article. It was computed from the HR-ICP-MS-recovery-corrected Al measurements assuming a crustal abundance for Al of 0.0804 (8.04%)."' ${fl_nc} ${fl_nc}

Hope this helps,
cz
--
Charlie Zender, Earth System Sci. & Computer Sci.
University of California, Irvine 949-891-2429 )'(



  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: