pg_utils.pg_model.base.CollectionPG

class pg_utils.pg_model.base.CollectionPG(**fields)[source]

Bases: LabeledCollection

Base class for the collection of Plesio-Geostrophy (PG) variables

The field names are pre-defined, and arranged in the following way

  • Stream function (Psi)

  • Quadratic moments of magnetic field (Mss, Mpp, Msp, Msz, Mpz, zMss, zMpp, zMsp)

  • Magnetic fields in the equatorial plane (Bs_e, Bp_e, Bz_e, dBs_dz_e, dBp_dz_e)

  • Magnetic fields at the boundary (Br_b, Bs_p, Bp_p, Bz_p, Bs_m, Bp_m, Bz_m)

__init__(**fields) None[source]

Constructor

Methods

__init__(**fields)

Constructor

apply(fun[, inplace, metadata])

Overriding the LabeledCollection.copy method

as_empty()

Overriding the LabeledCollection.as_empty method

copy()

Deep copy, overriding the LabeledCollection.copy method

deserialize(obj[, parser])

Deserialize an object

generate_collection(index_array)

Generate a new collection based on indices

load_json(fp[, parser])

Load CollectionPG object from json

save_json(fp[, serializer])

Serialize the object in string format and save to json file

serialize([serializer])

Serialize the object

subs(sub_map[, inplace])

Substitute variables iteratively in all fields.

subset_B_bound()

Extract subset of B field at the boundary.

subset_B_bound_cyl()

Extract subset of B field at the boundary, cylindrical coordinates.

subset_B_equator()

Extract subset of B field on equatorial plane.

subset_mag()

Extract subset of magnetic quantities.

subset_moments()

Extract subset of magnetic moments.

vorticity()

Extract vorticity equation.

Attributes

iter_filter

iter_filter: bool determines whether None fields are skipped.

iter_name

iter_name: bool determines whether the string of the field is also returned.

pg_field_names

apply(fun: Callable[[...], Any], inplace: bool = False, metadata: bool = False) CollectionPG[source]

Overriding the LabeledCollection.copy method

as_empty() CollectionPG[source]

Overriding the LabeledCollection.as_empty method

copy() CollectionPG[source]

Deep copy, overriding the LabeledCollection.copy method

static deserialize(obj: ~typing.List[tuple], parser: ~typing.Callable[[str], ~typing.Any] = <function CollectionPG.<lambda>>) CollectionPG[source]

Deserialize an object

overriding the LabeledCollection.deserialize method

generate_collection(index_array: List[bool]) LabeledCollection[source]

Generate a new collection based on indices

Parameters:

index_array (List[bool]) – array of booleans indicating whether a field is to be included in the new collection

Returns:

new collection with elements specified by index_array

property iter_filter[source]

iter_filter: bool determines whether None fields are skipped.

property iter_name[source]

iter_name: bool determines whether the string of the field is also returned.

static load_json(fp: ~typing.TextIO, parser: ~typing.Callable[[str], ~typing.Any] = <function CollectionPG.<lambda>>) CollectionPG[source]

Load CollectionPG object from json

overriding the LabeledCollection.load_json method

save_json(fp: ~typing.TextIO, serializer: ~typing.Callable[[~typing.Any], str] = <class 'str'>) None[source]

Serialize the object in string format and save to json file

Parameters:
  • fp (TextIO) – file handle of the output file

  • serializer (Callable[[Any], str]) – a callable that maps an element to a string. Default is the str method.

serialize(serializer: ~typing.Callable[[~typing.Any], str] = <class 'str'>) List[tuple][source]

Serialize the object

Parameters:

serializer (Callable[[Any],str]) – a callable that maps an element to a string. Default is the str method.

Returns:

a list of serialized objects, in the format [(fname_1, serialized_element_1), (fname_2, serialized_element_2), …]

subs(sub_map: dict, inplace: bool = False)[source]

Substitute variables iteratively in all fields. This utility is for collections with sympy.Expr elements. See warning below.

Parameters:
  • sub_map (dict) – a substitution map

  • inplace (bool) – whether the change is made in place; default is False

Warning

To use this method, all elements in the collection need to have implemented the subs method. This is intended for a collection of which all elements are sympy.Expr type. Then, this method calls apply internally to substitute all the variables.

subset_B_bound()[source]

Extract subset of B field at the boundary.

subset_B_bound_cyl()[source]

Extract subset of B field at the boundary, cylindrical coordinates.

subset_B_equator()[source]

Extract subset of B field on equatorial plane.

subset_mag()[source]

Extract subset of magnetic quantities.

subset_moments()[source]

Extract subset of magnetic moments.

vorticity()[source]

Extract vorticity equation. Basically an alias as Psi