Re: [netcdfgroup] easiest way to convert a variable type within a netcdf file

Hi Dave,

Thanks. This is exactly what I am looking for.

best
simon

On Thu, Sep 2, 2010 at 6:00 PM, Dave Allured <dave.allured@xxxxxxxx> wrote:

> Simon,
>
> "Best way" depends on what software you have installed, how often you need
> to convert, file size, style preferences, etc.  Here are some reasonable
> alternatives; there are other ways.
>
> 1.  If you have NCO installed, use the ncap2 type conversion feature.
>
>  http://nco.sourceforge.net/nco.html#Manual-type-conversion
>
> 2.  Use ncdump to convert the file to CDL text, then edit using sed or your
> choice of stream editor.
>
>  ncdump infile.nc | sed -e 's/double varname(/float varname(/' \
>     > temp.cdl
>  ncgen -o outfile.nc temp.cdl
>
> 3.  For "small" files, do the same as (2), except use a manual text editor
> instead of sed.  This may be the most expedient if you also need to fiddle
> with attributes or other metadata.
>
> With all methods, you may also need to perform type conversion on
> attributes directly related to the data variable, in particular _FillValue,
> missing_value, and/or valid_range.
>
> --Dave A.
> NOAA/PSD/CIRES
>
>
> On 9/1/2010 3:40 PM, Simon Su wrote:
>
>> Hi All,
>>
>> What would be the best way to convert a variable type within a netcdf
>> file?
>> I need to change a variable of the type double to float within a netcdf
>> file.
>>
>> thanks
>> Simon
>>
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: