[Thread Prev][Thread Next][Index]

[ferret_users] Re: EDITING .netcdf files by scripts (without dumping and editing manually)



Hi-
This question was addressed to contact_ferret, but I'm replying to ferret_users, as it is a topic of general interest.

On 5/19/2011 9:42 PM, Prasad SJ. wrote:
Respected Authority,
 
Greetings !!!
 
i am working on oil spill modeling and forecast for which i have to handle .netcdf files which has to be fed into my model GNOME developed by NOAA.During the execution i will feed the wind and current movers in .nc format.before feeding i have to edit those .nc files as per the required format.
 
the following actions will be carried out:
 
1. dumping the nc files using ncdump
 
2. changing the variable name
 
 in the wind file (from x_lon to lon),(from y_lat to lat),(from U to air_u & from Vto air_v)
 
3. editing the header info
 
arranging in the order
 
variables :
 
             time
 
             lon
 
              lat
 
data :
 
              time step values
 
              lon
 
              lat               
 
               air_u values
 
               air_v values
}
 
4. converting the edited cdl file to nc using ncgen
 
 
and hence i need a tool/script for doing the above said actions automatically by a script using ferret or any tool.
 
kindly suggest me in this regard , so that i can handle more ncfiles for my model execution.
 
 
 

There's a set of tools called the NCO operators that do just this kind of thing:
http://nco.sourceforge.net/

You can extract portions of variables, add attributes, and rename variables, see
http://nco.sourceforge.net/nco.html#ncrename-netCDF-Renamer

It takes a bit of study to learn from the documentation how to specify all the options - there are options that apply to many commands, and those aren't always listed with each particular command.

These are command-line tools and you may find that you have them installed as part of your linux system, or you can get them from the sourceforge pages.  If you have them installed you can run them from the command line, or from Ferret using the NCO function.  We also have a specific function to call the attribute editor.

yes? show function nco
NCO(operator,arguments)
    Call an NCO utility
    operator: name of operator (STRING)
    arguments: one string with all arguments (STRING)
yes? show function nco_attr
NCO_ATTR(FileName,VariableName,AttributeName,AttType,Mode,AttributeValue)
    Call ncatted to edit attributes in a netCDF file
    FileName: netCDF file name (STRING)
    VariableName: Variable name (or global) (STRING)
    AttributeName: Attribute to change (STRING)
    AttType: Attribute type (STRING)
    Mode: o=edit, a=append, d=delete (STRING)
    AttributeValue: new value of attribute (STRING)



(which we created for some special use cases where we wanted these tools but where we're running Ferret in -server mode and so can't just spawn out to the unix command line).

Finally, if instead you wanted to change variable names for use within Ferret, you would open the dataset in Ferret and then use SET VAR/NAME=  to change any variable names you want.

-Ansley

Thanks and Regards

S.J.Prasad
Project Scientist - B
Ocean Science & Information Services Group                
Indian National Centre for Ocean Information Services (INCOIS)                         
Ministry of Earth Sciences, Goverment of India                         
IDA- Jeedimetla (P.O)
P. B. No. 21, Hyderabad-500 055, India
Phone :04023886088
Email : p
rasadsj@xxxxxxxxxxxxx
url     :       www.incois.gov.in

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement