A container for handling physical variable together with its dimensions so that while the variable is manipulated (e.g. averaged along one axis), the information of the dimensions change accordingly.
It can be indexed/sliced the same way as indexing a numpy array
Append to the history attribute in the variable. If history doesn’t exist, create one
mask the variable’s last axes with a mask This function changes the variable
If the data in the variable is not a masked array and missing_value is present Read the data and convert the numpy ndarray into masked array, note that this will be slow if the data is large. But this will only be done once.
Returns: None
Return the dimensions of the variable as a list of numpy arrays In the order of dimension
Return a numpy array of an axis of a variable Input:
- axis (int or str): if it is an integer, do nothing and return axis
- if it is a str, look for index of the dimension which matches the required cartesian axis using the CAxes function
Returns: | numpy array |
---|
See also
CAxes, getIAxis, getDim
get the cartesian axes for all the dimensions. Return a list of cartesian axes. if it is undefined, replace with dummy: A,B,C,...(excludes: T/Z/X/Y)
Return the time axis date in an array format of “Year,Month,Day,Hour,Minute,Second” Toggle one or many among Y/m/d/H/M/S to select a particular time format
Parameters: |
|
---|
no_continuous_duplicate_month will check if there are adjacent months that are identical. If so, check if the data is a monthly series and correct for the duplicates
Examples
>>> # return an array of the month of the time axis
>>> var.getDate("m")
array([ 1, 2, 3, 4, 5, 6 ])
>>> # return an array with the first column showing the years,
>>> # second column showing the months, third column
>>> # for days
>>> getDate("Ymd")
array([[ 1990, 1, 15 ], [ 1990, 2, 15 ], [ 1990, 3, 15 ]])
Return a the Dimension instance of an axis of a variable Input:
- axis (int or str): if it is an integer, do nothing and return axis
- if it is a str, look for index of the dimension which matches the required cartesian axis using the CAxes function
Returns: | numpy array |
---|
See also
CAxes, getIAxis, getAxis
Return the domain of the variable
If the axis is a longitude axis, make all negative degree positive (only for output; the variable longitude data is unchanged)
Parameters: | axis (str or int) – query the domain of a particular dimension. If it is not specified, the domains of all dimensions are returned |
---|---|
Returns: | dict |
Examples
>>> # var is a regional variable within (20S-20N, 140E-140W)
>>> var.getDomain()
{"X": (140.,220.), "Y": (-20.,20.)}
>>> var.getDomain("X")
{"X": (140.,220.)}
Return the integer for the required cartesian axis Input:
- axis (int or str): if it is an integer, do nothing and return axis
- if it is a str, look for index of the dimension which matches the required cartesian axis using the CAxes function
Returns: | int |
---|
See also
CAxes, getAxis, getDim
Return “missing_value” if defined in the attributes Otherwise “_FillValue” will be used as missing value If both are undefined, the numpy default for the variable data type is returned
Return a new Variable object within the region specified.
Values have to be a length-2 iterable that specifies the range
Keys “time”,”t”,”TIME”,”T” are all considered as “T” for time axis.
Examples
>>> # Extracts the region where -20. <= latitude <= 20.
>>> # and 100. <= longitude <= 200.
>>> var.getRegion(lat=(-20.,20.), lon=(100.,200.))
Return a tuple of slice object corresponding a region specified. Example: variable.getSlice(lat=(-30.,30.))
Return the value of an attribute of the variable
Java style getter
Check if the shape of the data matches the dimensions
Raise ValueError if the dimensions do not match
Running mean along an axis. N specifies the size of the window
Parameters: | N – size of the window if axis is int, N is treated as the number of
|
---|---|
Returns: | geodat.nc.Variable |
Examples
# Running average for every 5 elements on the first axis >>> var.runave(5, 0)
# Running average with a window of longitudinal-width of 40-degree >>> var.runave(40., “X”)
# Climatological running average with a window of 3 years # axis=0 for the time axis >>> var.runave(3, 0, step=12)
Change the region of interest for the variable This function slices the data.
Set values for a particular region Example: variable.setRegion_value(0.,lat=(-90.,-30.))
Perform the slicing operation on both the data and axes
Parameters: | sliceobj (tuple) – slice object |
---|
Returns: None