geodat.pyferret_func

geodat.pyferret_func.fer2num(var)[source]

Filter the dictionary returned by pyferret.getdata PyFerret usually returns data with extra singlet dimension Need to filter those

Parameters:var (dict) – as is returned by pyferret.getdata
Returns:{‘data’: a numpy ndarray, ‘varname’: the name of the variable,

‘coords’: a list of numpy ndarrays for the dimensions, ‘dimunits’: a list of strings, the units for the dimensions, ‘dimnames’: a list of strings, the names for the dimensions}

Return type:dict
geodat.pyferret_func.num2fer(data, coords, dimunits, varname='UNKNOWN', data_units=None, missing_value=None, cartesian_axes=None, dimnames=None)[source]

Create a dictionary that resemble the Ferret data variable structure to be passed to pyferret.putdata

Parameters:
  • data (numpy.ndarray) –
  • coords (a list of numpy.ndarray) –
  • dimunits (a list of str) – dimension units (e.g. [‘months’,’degrees_N’])
  • varname (str, optional) –
  • data_units (str, optional) –
  • missing_value (numeric) –
  • cartesian_axes (a list of characters) – specifies the cartesian axes e.g. [‘T’,’Y’,’X’]. If this is not specified, guesses will be made using the dimension units (say unit month will be interpreted as a [T]IME axis. Specifying cartesian_axes overwirtes the guesses.
  • dimnames (a list of str) –
Returns:

dict

Length of cartesian_axes, dimnames, dimunits and coords need to agree with the number of dimensions of data

geodat.pyferret_func.regrid_once_primitive(var, ref_var, axis, verbose=False, prerun=None, transform='@ave')[source]

A generic function that regrids a variable without the dependence of geodat.nc.Variable

Parameters:
  • var (dict) – arguments for num2fer Required keys: data,coords,dimunits
  • ref_var (dict) – arguments for num2fer. This supplies the grid for regridding Required keys: coords,dimunits
  • axis (str) – the axis for regridding e.g. ‘X’/’Y’/’XY’/”YX”
  • verbose (bool) – whether to print progress (default: False)
  • prerun (a list of str) – commands to be run at the start (default: None)
  • transform (str) – “@ave” (Conserve area average), “@lin” (Linear interpolation),...see Ferret doc
Returns:

dict

geodat.pyferret_func.regrid_primitive(*args, **kwargs)

A generic function that regrids a variable without the dependence of geodat.nc.Variable

Parameters:
  • var (dict) – arguments for num2fer Required keys: data,coords,dimunits
  • ref_var (dict) – arguments for num2fer. This supplies the grid for regridding Required keys: coords,dimunits
  • axis (str) – the axis for regridding e.g. ‘X’/’Y’/’XY’/”YX”
  • verbose (bool) – whether to print progress (default: False)
  • prerun (a list of str) – commands to be run at the start (default: None)
  • transform (str) – “@ave” (Conserve area average), “@lin” (Linear interpolation),...see Ferret doc
Returns:

dict

geodat.pyferret_func.run_worker(f)[source]

A workaround for clearing memory used by PyFerret

Fork me on GitHub