geodat.nc.Dimension - Dimension container

class geodat.nc.Dimension(data, dimname=None, units=None, attributes=None, parent=None)[source]

A container for handling physical dimensions such as time, latitude. It can be indexed/sliced the same way as indexing a numpy array

__getitem__(sliceobj)[source]

Apply the slice object on the data (numpy.ndarray)

getCAxis()[source]

Get cartesian axis (T/Z/Y/X) for a dimension instance

if the dimension has a cartesian_axis attribute, the value of the attribute is returned. Otherwise, the unit is used as a clue

Example

dim.setattr(“cartesian_axis”,”X”) dim.getCAxis() –> “X”

Example

dim.units = “months” dim.getCAxis() –> “T”

Example

dim.units = “degreeN” dim.getCAxis() –> “Y”

getDate(toggle='YmdHMS', no_continuous_duplicate_month=False)[source]

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:
  • toggle (iterable of str) – each item should be among Y/m/d/H/M/S
  • no_continuous_duplicate_month (bool) – used for toggle==”m” only

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 ]])
getattr(att, default=None)[source]

Java style getter for attributes

info(detailed=False, file_out=None)[source]

Print brief info about the dimension

if detailed is True, attributes and length of axis are also printed

is_climo()[source]

Return True if the axis is a climatological time axis

is_monotonic()[source]

Return True if the axis is monotonic, False otherwise

setattr(att, value)[source]

Java style setter for attributes

time0()[source]

Return a datetime.datetime object referring to the t0 of a time axis

time2array()[source]

Given a dimension object, if it is a time axis, return ndarray of size (N,6) where N is the number of time point, and the six indices represent: YEAR,MONTH,DAY,HOUR,MINUTE,SECOND

Same as getDate()

Fork me on GitHub