solpolpy.core#

Core transformation functions for solpolpy.

Functions#

resolve(→ ndcube.NDCollection)

Apply a polarization transformation to a set of input dataframes.

determine_reference_angle(→ astropy.units.degree)

Get the instrument specific offset angle.

determine_input_kind(→ solpolpy.transforms.System)

Determine what kind of data was input in the NDCollection.

get_transform_path(→ list[str])

Given an input and output system type, determine the require path of transforms from the transform graph.

get_transform_equation(→ Callable)

Given a transform path, compose the equation, i.e. the composed function of transforms that executes that path.

requires_alpha(→ bool)

Determine if an alpha array is required for this transformation path.

_determine_image_shape(→ tuple[int, int])

Evaluates the shape of the image in the input NDCollection.

add_alpha(→ ndcube.NDCollection)

Adds an alpha array to an image NDCollection.

_compose2(→ Callable)

Compose 2 functions together, i.e. f(g(x)).

identity(→ Any)

Identity function that returns the input.

Module Contents#

solpolpy.core.resolve(input_data: list[str] | ndcube.NDCollection, out_system: str, in_angles: astropy.units.degree = None, out_angles: astropy.units.degree = None, reference_angle: astropy.units.degree = None) ndcube.NDCollection[source]#

Apply a polarization transformation to a set of input dataframes.

Parameters:
  • input_data (NDCollection or List[str]) – Either: 1) a collection where each member NDCube has an expected name or 2) a list of paths to FITS files. We recommend option 2.

  • out_system (string) –

    The polarization state you want to convert your input dataframes to. Must be one of the following strings:

    • ”mzpsolar”: Triplet of images taken at -60°, 0°, and +60° polarizing angles with a reference angle set to solar frame.

    • ”mzpinstru”: Triplet of images taken at -60°, 0°, and +60° polarizing angles with a reference angle set to instrument frame.

    • ”btbr”: A Pair of images with polarization along the tangential and radial direction with respect to the Sun respectively.

    • ”stokes”: Total brightness (“I”), polarized brightness along vertical and horizontal axes (Q) and polarized brightness along ±45° (U) .

    • ”bpb”: Total brightness and ‘excess polarized’ brightness images pair respectively.

    • ”bp3”: Analogous to Stokes I, Q and U, but rotates around the Sun instead of a fixed frame of reference of the instrument.

    • ”bthp”: Total brightness, angle and degree of polarization.

    • ”fourpol”: For observations taken at sequence of four polarizer angles, i.e. 0°, 45°, 90° and 135°.

    • ”npol”: Set of images taken at than arbitrary polarizing angles other than MZP

  • out_angles (u.degree) – Angles to use when converting to npol or some arbitrary system

  • in_angles (u.degree) – Angles to use when converting to from npol or some arbitrary system to mzpsolar

  • reference_angle (u.degree) – Reference angle used for the polarizer offset. If None, it will try to determine it from the metadata.

Returns:

The transformed data are returned as a NDCollection.

Return type:

NDCollection

solpolpy.core.determine_reference_angle(input_collection: ndcube.NDCollection) astropy.units.degree[source]#

Get the instrument specific offset angle.

solpolpy.core.determine_input_kind(input_data: ndcube.NDCollection) solpolpy.transforms.System[source]#

Determine what kind of data was input in the NDCollection.

Parameters:

input_data (NDCollection) – data to evaluate kind of

Returns:

a valid input kind, see documentation of resolve for the full list under out_system

Return type:

str

solpolpy.core.get_transform_path(input_kind: str, output_kind: str) list[str][source]#

Given an input and output system type, determine the require path of transforms from the transform graph.

Parameters:
  • input_kind (str) – starting point for transformations

  • output_kind (str) – ending point for transformations

Returns:

a list of transformation identifiers used to convert from input_kind to output_kind

Return type:

List[str]

solpolpy.core.get_transform_equation(path: list[str]) Callable[source]#

Given a transform path, compose the equation, i.e. the composed function of transforms that executes that path.

Parameters:

path (List[str]) – a list of transform identifiers from the path

Returns:

a function that executes the transformation

Return type:

Callable

solpolpy.core.requires_alpha(func: Callable) bool[source]#

Determine if an alpha array is required for this transformation path.

Parameters:

path (List[str]) – a path through the transform graph

Returns:

whether alpha array is required for transformation

Return type:

bool

solpolpy.core._determine_image_shape(input_collection: ndcube.NDCollection) tuple[int, int][source]#

Evaluates the shape of the image in the input NDCollection.

Parameters:

input_collection (NDCollection) – collection to determine image shape for

Returns:

shape of image data

Return type:

Tuple[int, int]

solpolpy.core.add_alpha(input_data: ndcube.NDCollection) ndcube.NDCollection[source]#

Adds an alpha array to an image NDCollection.

Parameters:

input_data (NDCollection) – dataset to append alpha to

Returns:

dataset with alpha array appended

Return type:

NDCollection

solpolpy.core._compose2(f: Callable, g: Callable) Callable[source]#

Compose 2 functions together, i.e. f(g(x)).

Parameters:
  • f (Callable) – outer function

  • g (Callable) – inner function

Returns:

composed function

Return type:

Callable

solpolpy.core.identity(x: Any, **kwargs) Any[source]#

Identity function that returns the input.

Parameters:

x (Any) – value

Returns:

input value returned back

Return type:

Any