setcurrent
- setcurrent(nc, index_or_name)
On a multi-variable
NetCDFsets the specified variable as the current variable. Functions and operators act on the current variable only.- Parameters
nc (
NetCDF) – input NetCDFindex_or_name (number or str) – index or name of the NetCDF variable
- Return type
None
A
NetCDFproduced by the Metview applications are uni-variable, so in their casesetcurrent()need not be used. For a multi-variableNetCDFsetcurrent()can be usefully combined withvariables()as the example below illustrates it.- Example
import metview as mv nc = mv.read("my_data.nc") for v in mv.variables(nc): mv.setcurrent(nc, v) # acts on current variable only nc = nc - 273.16