Re: [feature request] user-declared data format

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Mar 03 2013 - 15:15:06 MST

NCL already does this.

Just add a ".nc" to addfile or addfiles

netCDF files named "foo1", "foo2.ncf"

    f1 = addfile("foo1.nc", "r")
    f2 = addfile("foo2.ncf.nc", "r")
or
    ext = ".nc"

    f1 = addfile("foo1"+ext, "r")
    f2 = addfile("foo2.ncf"+ext, "r")

or
    fils = (/"foo1","foo2.ncf"/)
    nfils = dimsizes(fils)

    do nf=0,nfils-1
       f = addfile (fils(nf)+ext, "r")
         :
    end do
--------

NCL will look for the file named (say) "foo1.nc", if it does not
find the file named "foo1.nc", then it will look for the file
"foo1" and treat it as a netCDF file.

On 3/3/13 2:58 PM, Tom Roche wrote:
>
> I work on a model that reads and writes netCDF with different file
> extensions. Particularly, I regularly analyze and operate on files
> with extension='.ncf', or no extension at all. (Given that the model
> is "mature," and part of an ecosystem with similar culture, I am
> unlikely to be able to effect any upstream change. Furthermore,
> there's a *lot* of old data.)
>
> NCL makes file extension problematic, because it refuses to handle
> (e.g., with `addfile`
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml
>
> ) files that do not provide one of a given set of supported extensions
> (e.g.,
>
> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclFormatSupport.shtml
>> NCL's supported data formats are:
>> * NetCDF - Network Common Data Format (.nc, .cdf, or .netcdf
>
> ) This requires me to do an annoying amount of file renaming.
> Am I missing something? If so, please let me know. But if not, ...
>
> I assert that NCL should provide API that allows the user to declare
> the format of a given data file. Since (IIUC) NCL lacks optional
> arguments, I'd like to see API like
>
> function addfile_format(
> file_path [1] : string,
> status [1] : string,
> format [1] : string
> )
> return_val [1] : file
>
> (a relatively simple extension to `addfile`) where 'format' is one of
> (e.g.)
>
> * CCM
> * ESRI
> * GMT
> * GRIB
> * HDF-EOS
> * HDF-EOS5
> * HDF-SDS
> * HDF5
> * MapInfo
> * NetCDF
> * TIGER
>
> If there's a better place to make an NCL FR, please let me know.
>
> FWIW, Tom Roche <Tom_Roche@pobox.com>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Mar 3 15:15:19 2013

This archive was generated by hypermail 2.1.8 : Thu Mar 07 2013 - 08:55:58 MST