Saving to a netCDF in a script

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
TJS
Posts: 90
Joined: Thu Mar 05, 2009 7:31 pm

Saving to a netCDF in a script

Post by TJS »

Sorry if this is already documented, but how to I save to a netCDF in a script.

So, similar to the file / save / to netCDF

Thanks,
TJS
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: Saving to a netCDF in a script

Post by bobc »

Hi TJS -

You can export a netCDF file using the Export > Export Grid/Image to netCDF formula. You can find this formula in the Field Selector, once you select Formulas under Data Sources on the left side of the tab. If you mouse over this formula, you will see that the actual function name for this formula is exportGridToNetcdf. This is the function name you would use in your script.

For example, here is a script that loads in data from a remote grid and exports the earliest time of MSLP as a NetCDF file:

Code: Select all

gridParms = dict(
    filename = 'http://weather.rsmas.miami.edu/thredds/dodsC/grib/NCEP/GFS/CONUS_80km/GFS_CONUS_80km_20150821_0600.grib1/GC',
    field = 'Pressure_reduced_to_MSL_msl',
    )
mslpField = loadGrid(**gridParms)
exportGridToNetcdf(mslpField,'C:/Users/myuser/netcdfTest2.nc')

As an alternative to finding out the function names by mousing over the formula in the Field Selector, you can look in the Jython Library (Tools>Formulas>Jython Library) where you can look under the System tree. Or you can look at the Jython Library page in the User's Guide.

Please let me know if you have any questions.

Thanks -
Bob Carp
Post Reply