Return weights for the data array values.
By default weights components are created for all axes of the field by one or more of the following methods, in order of preference:
- Volume cell measures
- Area cell measures
- Area calculated from (grid) latitude and (grid) longitude dimension coordinates with bounds
- Cell sizes of dimension coordinates with bounds
- Equal weights
and the outer product of the weights components is returned in a field which is broadcastable to the orginal field (see the components parameter).
The methods used by the default behaviour may differ between fields, depending on which metadata they contain (see the methods parameter), so it is possible to force weights to be created with particular methods (see the weights parameter).
New in version 1.0.
See also
cell_area, collapse
Parameters: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
|
||||||||||||||||
Examples: |
>>> f
<CF Field: air_temperature(time(1800), latitude(145), longitude(192)) K>
>>> f.weights('auto')
<CF Field: long_name:weight(time(1800), latitude(145), longitude(192)) 86400 s.rad>
>>> f.weights('auto', scale=True)
<CF Field: long_name:weight(time(1800), latitude(145), longitude(192)) 1>
>>> f.weights('auto', components=True)
{(0,): <CF Data: [1.0, ..., 1.0] d>,
(1,): <CF Data: [5.94949998503e-05, ..., 5.94949998503e-05]>,
(2,): <CF Data: [0.0327249234749, ..., 0.0327249234749] radians>}
>>> f.weights('auto', components=True, scale=True)
{(0,): <CF Data: [1.0, ..., 1.0]>,
(1,): <CF Data: [0.00272710399807, ..., 0.00272710399807]>,
(2,): <CF Data: [1.0, ..., 1.0]>}
>>> f.weights('auto', methods=True)
{(0,): 'linear time',
(1,): 'linear sine latitude',
(2,): 'linear longitude'}