API Documentation#
- class ggcmpy.openggcm.AmieTimeArrayCoder(use_cftime=None)#
A custom coder for encoding and decoding time arrays in xarray Variables. This class extends the CFDatetimeCoder to handle variables with a custom “time_array” encoding, and otherwise falls back to the usual CF coding/encoding.
- encode(variable: xr.Variable, name: Hashable | None = None) xr.Variable#
Encodes an xarray Variable with a “time_array” unit into a custom format.
- decode(variable: xr.Variable, name: Hashable | None = None) xr.Variable#
Decodes an xarray Variable with a “time_array” unit from a custom format.
- decode(variable, name=None)#
Convert a decoded variable to an encoded variable
- class ggcmpy.openggcm.OpenGGCMAccessor(xarray_obj)#
Xarray accessor to add OpenGGCM-specific features
As of now, that is ds.ggcm.coords which provides mlts and colats.
- Parameters:
xarray_obj (
Any)
- cl_index()#
Calculate the CL index from an iof dataset.
- Returns:
CL index as a DataArray.
- Return type:
xarray.DataArray
- property coords: Coordinates#
- cpcp()#
Calculate Cross Polar Cap Potential (CPCP) from an iof dataset.
- Returns:
Cross Polar Cap Potential (CPCP) as a DataArray.
- Return type:
xarray.DataArray
- ggcmpy.openggcm.cl_index(iof)#
Calculate the CL index from an iof dataset.
- Parameters:
iof (xarray.Dataset) – Input iof dataset – needs to contain ‘bfield’ variable.
- Returns:
CL index as a DataArray.
- Return type:
xarray.DataArray
- ggcmpy.openggcm.cotr(date, cfr, cto, r1)#
Transform coordinates between different coordinate systems.
This function wraps the Fortran routine cotr() in the f2py module ggcmpy._jrrle.f2py. takes vector r1 in coordinate system ‘cfr’ and returns the corresponding vector in coordinate system ‘cto’
Coordinate systems ‘cfr’ and ‘cto’ can be any of the following: ‘gei’ : geocentric equatorial inertial ‘geo’ : geographic ‘gse’ : geocentric solar ecliptic ‘gsm’ : geocentric solar magnetospheric ‘sm ‘ : solar magnetic ‘mag’ : geomagnetic ‘mhd’ : global mhd simulation system, like ‘gse’ with
x and y axes mirrored
- Parameters:
- Returns:
The transformed coordinates as a numpy array of shape (3,).
- Return type:
NDArray[Any]
- ggcmpy.openggcm.cpcp(iof)#
Calculate Cross Polar Cap Potential (CPCP) from an iof dataset.
- Parameters:
iof (xarray.Dataset) – Input iof dataset – needs to contain ‘pot’ variable.
- Returns:
Cross Polar Cap Potential (CPCP) as a DataArray.
- Return type:
xarray.DataArray
- ggcmpy.openggcm.decode_openggcm(ds)#
- Parameters:
ds (
Dataset)- Return type:
Dataset
- ggcmpy.openggcm.encode_openggcm(variables, attributes)#
- ggcmpy.openggcm.epoch1966(dt64)#
Convert a numpy datetime64 to seconds since 1966-01-01T00:00:00.
This is the time representation used in OpenGGCM, and is implemented here via the Fortran routine epoch1966() in the f2py module ggcmpy._jrrle.f2py.
- Parameters:
dt (np.datetime64) – The datetime to convert.
dt64 (
datetime64)
- Returns:
The number of seconds since 1966-01-01T00:00:00.
- Return type:
- ggcmpy.openggcm.read_grid(filename)#
- ggcmpy.openggcm.read_grid2(filename)#