wavy.ncmod

This module encompasses classes and methods to read and write to netcdf files from model, station, or satellite output. I try to mostly follow the PEP convention for python code style. Constructive comments on style and effecient programming are most welcome!

Attributes

insitu_dict

satellite_dict

variable_info

definition of some global functions

Functions

check_if_ncfile_accessible(fstr, **kwargs)

read_netcdfs(paths[, dim, decode_times, use_cftime])

build_usr_pw_path(path, remoteHostName, usr, pw)

read_netcdfs_with_credentials_aggregated(path, ...[, ...])

read_netcdfs_naive(paths, varnames, varalias, **kwargs)

process_one_path_netCDF4(path, varnames, varalias)

consolidate_darrays(→ numpy.ndarray)

build_xr_ds(darray, varnames, varalias)

build_xr_ds_multivar(darray, varnames, varalias)

build_xr_ds_from_dict(dict_var, var_name_ref)

read_netcdfs_KF(paths[, dim])

read_mf_netcdfs(paths)

process_one_path_lru(path, t, varname)

process_one_path(path, t, varname)

read_netcdfs_sel_lru(paths, dlst, varname[, dim])

read_netcdfs_sel(paths, dlst, varname[, dim])

get_swim_var_coords(varalias)

read_swim_nc(path, varnamedict)

read_swim_netcdfs(pathlst, varalias)

get_arcmfc_ts(pathtofile)

get_arcmfc_stats(pathtofile)

get_filevarname(varalias, variable_info, srcdict, ...)

get_filevarname_list(varalias, variable_info, srcdict, ...)

get_nc_ts(pathtofile, varlst, **kwargs)

get_varlst_from_nc_1D(pathtofile, varlst, sdate, edate)

dumptonc_stats(pathtofile, title, time_dt, time_unit, ...)

ncdump(nc_fid[, verb])

Function from:

ncdumpMeta(pathtofile)

Returns dict of netcdf-file content

find_attr_in_nc(attrstr[, pathtofile, ncdict, subattrstr])

fct to find a specific attribute with its value in a netcdf-file

get_varname_for_cf_stdname_in_ncfile(ncdict, stdname)

Module Contents

wavy.ncmod.insitu_dict
wavy.ncmod.satellite_dict
wavy.ncmod.variable_info

definition of some global functions

wavy.ncmod.check_if_ncfile_accessible(fstr, **kwargs)
wavy.ncmod.read_netcdfs(paths, dim='time', decode_times=None, use_cftime=None, **kwargs)
wavy.ncmod.build_usr_pw_path(path, remoteHostName, usr, pw)
wavy.ncmod.read_netcdfs_with_credentials_aggregated(path, remoteHostName, usr, pw, decode_times=None, use_cftime=None)
wavy.ncmod.read_netcdfs_naive(paths, varnames, varalias, **kwargs)
wavy.ncmod.process_one_path_netCDF4(path: str, varnames: dict, varalias: str)
wavy.ncmod.consolidate_darrays(darrays: list) numpy.ndarray
wavy.ncmod.build_xr_ds(darray: numpy.ndarray, varnames: dict, varalias: str)
wavy.ncmod.build_xr_ds_multivar(darray: numpy.ndarray, varnames: dict, varalias: list)
wavy.ncmod.build_xr_ds_from_dict(dict_var, var_name_ref)
wavy.ncmod.read_netcdfs_KF(paths, dim='time')
wavy.ncmod.read_mf_netcdfs(paths)
wavy.ncmod.process_one_path_lru(path, t, varname)
wavy.ncmod.process_one_path(path, t, varname)
wavy.ncmod.read_netcdfs_sel_lru(paths, dlst, varname, dim='time', **kwargs)
wavy.ncmod.read_netcdfs_sel(paths, dlst, varname, dim='time', **kwargs)
wavy.ncmod.get_swim_var_coords(varalias)
wavy.ncmod.read_swim_nc(path, varnamedict)
wavy.ncmod.read_swim_netcdfs(pathlst, varalias)
wavy.ncmod.get_arcmfc_ts(pathtofile)
wavy.ncmod.get_arcmfc_stats(pathtofile)
wavy.ncmod.get_filevarname(varalias, variable_info, srcdict, ncdict, **kwargs)
wavy.ncmod.get_filevarname_list(varalias, variable_info, srcdict, ncdict, **kwargs)
wavy.ncmod.get_nc_ts(pathtofile, varlst, **kwargs)
wavy.ncmod.get_varlst_from_nc_1D(pathtofile, varlst, sdate, edate)
wavy.ncmod.dumptonc_stats(pathtofile, title, time_dt, time_unit, valid_dict)
  1. check if nc file already exists

    • if so use append mode

    • if not create file

wavy.ncmod.ncdump(nc_fid, verb=True)

Function from: http://schubert.atmos.colostate.edu/~cslocum/netcdf_example.html # ncdump outputs dimensions, variables and their attribute information. The information is similar to that of NCAR’s ncdump utility. ncdump requires a valid instance of Dataset. # Parameters ———- nc_fid : netCDF4.Dataset

A netCDF4 dateset object

verbBoolean

whether or not nc_attrs, nc_dims, and nc_vars are printed

# Returns ——- nc_attrs : list

A Python list of the NetCDF file global attributes

nc_dimslist

A Python list of the NetCDF file dimensions

nc_varslist

A Python list of the NetCDF file variables

wavy.ncmod.ncdumpMeta(pathtofile)

Returns dict of netcdf-file content Input: str pointing to netcdf-file Output: dict of attributes

wavy.ncmod.find_attr_in_nc(attrstr, pathtofile=None, ncdict=None, subattrstr=None)

fct to find a specific attribute with its value in a netcdf-file when only a fraction of attribute name is given, can also search in a deeper layer of attribute hierarchy. input: path to the nc-file or ncdict

string of desired attribute string of desired sub-attribute (optional)

output: dict

wavy.ncmod.get_varname_for_cf_stdname_in_ncfile(ncdict, stdname)