Calling NCL functions from PyNGL

From: Ravi Shekhar <ravi.shekhar_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 09 2012 - 08:46:48 MDT

Hi,

I work with WRF output, and I was wondering what the best way to use a NCL function is from python. Specifically, I have a WRF netcdf file, like the one here: (http://shekhar.info/wrfout_d01_1996-06-11_00_00_00). I would like to convert the winds (U, V, W) from model vertical coordinates (eta) to pressure coordinates. There exists a function to do this, as referenced here: (http://www.ncl.ucar.edu/Document/Functions/Built-in/wrf_interp_3d_z.shtml)

What's the best way to use this function from python? Is there a way to call it? Or do I need to write a NCL script, produce an intermediate output file, and load that from python?

Oh, and one other small question. Is there an equivalent to NCLs addfiles to treat a series of netcdf files as a single unit for the purposes of reading in data? I've been using a loop to assemble my arrays over the record dimension, but I was wondering if there's a better way.

I appreciate any help. Possibly relevant installation info is below the signature. Thanks,

Ravi

-- 
Ravi Shekhar
ravi.shekhar@yale.edu
"""
rs7@login-0-1 [10:31:19]> python
Python 2.7.1 (r271:86832, Sep 24 2012, 21:58:35) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Nio, Ngl
>>> print(dir(Nio)); print(dir(Ngl))
['NIOError', '_C_API', '_Nio', '_Proxy', '__all__', '__array_module__', '__array_module_version__', '__builtins__', '__doc__', '__file__', '__formats__', '__getitem__', '__name__', '__package__', '__setitem__', '__version__', '_builtins', '_fill_value_to_masked', '_get_axis_att', '_get_cf_dims', '_get_masked_array_mode', '_get_option_value', '_is_new_ma', '_known_proxy_classes', '_localatts', '_make_binder', '_masked_to_fill_value', '_proxy', 'assign_value', 'close', 'crdSelect', 'create_variable', 'cs', 'get_value', 'get_variable', 'idxSelect', 'idxsel2xsel', 'inp2csel', 'inp2isel', 'inp2xsel', 'ma', 'np', 'open_file', 'option_defaults', 'options', 'set_option', 'xSelect']
['HAS_MA', 'IS_NEW_MA', 'NGGetNCARGEnv', 'NglGaus_p', 'NhlAddAnnotation', 'NhlAddData', 'NhlAddOverlay', 'NhlAppGetDefaultParentId', 'NhlChangeWorkstation', 'NhlClassName', 'NhlClearWorkstation', 'NhlClose', 'NhlCreate', 'NhlDataPolygon', 'NhlDataPolyline', 'NhlDataPolymarker', 'NhlDestroy', 'NhlDraw', 'NhlFATAL', 'NhlFrame', 'NhlFreeColor', 'NhlGETRL', 'NhlGetDouble', 'NhlGetDoubleArray', 'NhlGetFloat', 'NhlGetFloatArray', 'NhlGetGksCi', 'NhlGetInteger', 'NhlGetIntegerArray', 'NhlGetMDDoubleArray', 'NhlGetMDFloatArray', 'NhlGetMDIntegerArray', 'NhlGetNamedColorIndex', 'NhlGetParentWorkstation', 'NhlGetString', 'NhlGetStringArray', 'NhlGetValues', 'NhlGetWorkspaceObjectId', 'NhlINFO', 'NhlInitialize', 'NhlIsAllocatedColor', 'NhlIsApp', 'NhlIsDataComm', 'NhlIsDataItem', 'NhlIsDataSpec', 'NhlIsTransform', 'NhlIsView', 'NhlIsWorkstation', 'NhlLABELONLY', 'NhlLINEANDLABEL', 'NhlLINEONLY', 'NhlNDCPolygon', 'NhlNDCPolyline', 'NhlNDCPolymarker', 'NhlNOERROR', 'NhlNOLINE', 'NhlName',
  'NhlNew
Color', 'NhlNewDashPattern', 'NhlNewMarker', 'NhlOpen', 'NhlPAppClass', 'NhlPContourPlotClass', 'NhlPDataToNDC', 'NhlPGraphicStyleClass', 'NhlPLogLinPlotClass', 'NhlPNDCToData', 'NhlPNcgmWorkstationClass', 'NhlPOLYGON', 'NhlPOLYLINE', 'NhlPOLYMARKER', 'NhlPPDFWorkstationClass', 'NhlPPSWorkstationClass', 'NhlPScalarFieldClass', 'NhlPXWorkstationClass', 'NhlPcoordArraysClass', 'NhlPlabelBarClass', 'NhlPlegendClass', 'NhlPmapPlotClass', 'NhlPscalarFieldClass', 'NhlPstreamlinePlotClass', 'NhlPtextItemClass', 'NhlPtickMarkClass', 'NhlPtitleClass', 'NhlPvectorFieldClass', 'NhlPvectorPlotClass', 'NhlPxyPlotClass', 'NhlRLClear', 'NhlRLCreate', 'NhlRLDestroy', 'NhlRLIsSet', 'NhlRLSetDouble', 'NhlRLSetFloat', 'NhlRLSetFloatArray', 'NhlRLSetInteger', 'NhlRLSetIntegerArray', 'NhlRLSetMDDoubleArray', 'NhlRLSetMDFloatArray', 'NhlRLSetMDIntegerArray', 'NhlRLSetString', 'NhlRLSetStringArray', 'NhlRLUnSet', 'NhlRemoveAnnotation', 'NhlRemoveData', 'NhlRemoveOverlay', 'NhlSETRL', 'NhlSetColor',
  'NhlSet
Values', 'NhlUpdateData', 'NhlUpdateWorkstation', 'NhlWARNING', 'PlotIds', 'Resources', 'RscConv', '__all__', '__array_module__', '__array_module_version__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_add_poly', '_arg_with_scalar', '_check_res_value', '_ck_for_rangs', '_convert_from_ma', '_convert_to_ma', '_crt_dict', '_dfran', '_dptlclskewt', '_dpwskewt', '_dsatlftskewt', '_dshowalskewt', '_dtdaskewt', '_dtmrskewt', '_fill_bw_xy', '_find_cross_xy', '_get_MDdouble_array', '_get_arr_and_force_fv', '_get_arr_and_fv', '_get_double', '_get_double_array', '_get_fill_value', '_get_integer_version', '_get_key_value_keep', '_get_parent_workstation', '_get_res_value_keep', '_get_skewt_msg', '_get_values', '_inputt', '_int_id', '_is_list_or_tuple', '_is_numpy', '_is_numpy_array', '_is_numpy_ma', '_is_numpy_scalar', '_is_python_scalar', '_is_scalar', '_ismissing', '_lst2pobj', '_mask_lambert_conformal', '_ncargpath', '_pobj2lst', '_poly', '_promot
 e_scalar
', '_promote_scalar_int32', '_pseq2lst', '_pynglpath_ncarg', '_set_contour_res', '_set_default_msg', '_set_labelbar_res', '_set_legend_res', '_set_map_res', '_set_msg_val_res', '_set_spc_defaults', '_set_spc_res', '_set_streamline_res', '_set_tickmark_res', '_set_vector_res', '_skewtx', '_skewty', '_test_for_mask_lc', 'add_annotation', 'add_cyclic', 'add_new_coord_limits', 'add_poly_wrap', 'add_polygon', 'add_polyline', 'add_polymarker', 'add_text', 'add_text_wrap', 'asciiread', 'betainc', 'blank_plot', 'blank_plot_wrap', 'bndary', 'c_cpcldr', 'c_cprect', 'c_cpseti', 'c_cpsetr', 'c_cssgrid', 'c_dcapethermo', 'c_dgcdist', 'c_dptlclskewt', 'c_dpwskewt', 'c_dsatlftskewt', 'c_dshowalskewt', 'c_dtdaskewt', 'c_dtmrskewt', 'c_hlsrgb', 'c_hsvrgb', 'c_nngetcp', 'c_nngeti', 'c_nngetrd', 'c_nnsetc', 'c_nnseti', 'c_nnsetrd', 'c_pcseti', 'c_pcsetr', 'c_plchhq', 'c_plotif', 'c_rgbhls', 'c_rgbhsv', 'c_rgbyiq', 'c_set', 'c_wmbarbp', 'c_wmgetcp', 'c_wmgetip', 'c_wmgetrp', 'c_wmsetcp', 'c_wmse
 tip', 'c
_wmsetrp', 'c_wmstnmp', 'c_yiqrgb', 'change_workstation', 'chiinv', 'clear_workstation', 'commands', 'contour', 'contour_map', 'contour_map_wrap', 'contour_wrap', 'copy_intp', 'datatondc', 'dcapethermo', 'define_colormap', 'delete_floatArray', 'delete_intp', 'delete_wks', 'destroy', 'dfran_iseq', 'dfran_rseq', 'dim_gbits', 'draw', 'draw_colormap', 'draw_colormap_wrap', 'draw_ndc_grid', 'end', 'first_call_to_open_wks', 'floatArray_getitem', 'floatArray_setitem', 'fplib', 'frame', 'free_color', 'fspan', 'ftcurv', 'ftcurvc', 'ftcurvp', 'ftcurvpc', 'ftcurvpi', 'ftcurvpic', 'gactivate_ws', 'gaus', 'gc_convert', 'gc_dist', 'gc_inout', 'gc_interp', 'gc_qarea', 'gc_tarea', 'gdeactivate_ws', 'gendat', 'generate_2d_array', 'get_MDfloat_array', 'get_MDinteger_array', 'get_bounding_box', 'get_float', 'get_float_array', 'get_integer', 'get_integer_array', 'get_named_color_index', 'get_nglRes_c', 'get_nglRes_f', 'get_nglRes_i', 'get_nglRes_s', 'get_string', 'get_string_array', 'get_workspa
 ce_id', 
'getbb', 'hlsrgb', 'hlu', 'hsvrgb', 'ind', 'intp_assign', 'intp_value', 'labelbar_ndc', 'labelbar_ndc_wrap', 'legend_ndc', 'legend_ndc_wrap', 'linmsg', 'ma', 'map', 'map_wrap', 'mapgci', 'math', 'maximize_plot', 'maximize_plots', 'merge_colormaps', 'natgrid', 'natgridc', 'ndctodata', 'nearlyequal', 'new_color', 'new_dash_pattern', 'new_floatArray', 'new_intp', 'new_marker', 'nice_cntr_levels', 'nngetp', 'nnsetp', 'normalize_angle', 'numpy', 'open_wks', 'open_wks_wrap', 'os', 'overlay', 'panel', 'panel_wrap', 'pkgs_pth', 'poly_wrap', 'polygon', 'polygon_ndc', 'polyline', 'polyline_ndc', 'polymarker', 'polymarker_ndc', 'pvoid', 'pyngl_version', 'pynglpath', 're', 'regline', 'remove_annotation', 'remove_overlay', 'retrieve_colormap', 'rgbhls', 'rgbhsv', 'rgbyiq', 'set_PCMP04', 'set_color', 'set_nglRes_c', 'set_nglRes_f', 'set_nglRes_i', 'set_nglRes_s', 'set_values', 'site', 'skewt_bkg', 'skewt_plt', 'streamline', 'streamline_map', 'streamline_map_wrap', 'streamline_scalar', 'str
 eamline_
scalar_map', 'streamline_scalar_map_wrap', 'streamline_scalar_wrap', 'streamline_wrap', 'string', 'sys', 'text', 'text_ndc', 'text_ndc_wrap', 'text_wrap', 'types', 'update_workstation', 'vector', 'vector_map', 'vector_map_wrap', 'vector_scalar', 'vector_scalar_map', 'vector_scalar_map_wrap', 'vector_scalar_wrap', 'vector_wrap', 'vinth2p', 'wmbarb', 'wmbarbmap', 'wmgetp', 'wmsetp', 'wmstnm', 'xy', 'xy_wrap', 'y', 'y_wrap', 'yiqrgb']
"""

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Tue Oct 9 08:46:56 2012

This archive was generated by hypermail 2.1.8 : Thu Nov 01 2012 - 09:04:53 MDT