solpolpy.core#

Core transformation functions for solpolpy.

Functions#

resolve(→ ndcube.NDCollection)

Apply a polarization transformation to a set of input dataframes.

determine_offset_angle(→ float)

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.

generate_imax_matrix(→ numpy.ndarray)

Define an A matrix with which to convert MZP^ (camera coords) = A x MZP (solar coords).

resolve_imax_effect(→ ndcube.NDCollection)

Resolves the IMAX effect for provided input data, correcting measured polarization angles for wide FOV imagers.

_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, imax_effect: bool = False, out_angles: astropy.units.degree = None) ndcube.NDCollection#

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:

    • ”mzp”: Triplet of images taken at -60°, 0°, and +60° polarizing angles.

    • ”btbr”: 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

  • imax_effect (Boolean) – The ‘IMAX effect’ describes the change in apparent measured polarization angle as an result of foreshortening effects. This effect becomes more pronounced for wide field polarized imagers - see Patel et al (2024, in preparation) If True, applies the IMAX effect for wide field imagers as part of the resolution process.

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

Returns:

The transformed data are returned as a NDCollection.

Return type:

NDCollection

solpolpy.core.determine_offset_angle(input_collection: ndcube.NDCollection) float#

Get the instrument specific offset angle.

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

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]#

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#

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#

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.generate_imax_matrix(array_shape) numpy.ndarray#

Define an A matrix with which to convert MZP^ (camera coords) = A x MZP (solar coords).

Parameters:

array_shape – Defined input WCS array shape for matrix generation

Returns:

Output A matrix used in converting between camera coordinates and solar coordinates

Return type:

ndarray

solpolpy.core.resolve_imax_effect(input_data: ndcube.NDCollection) ndcube.NDCollection#

Resolves the IMAX effect for provided input data, correcting measured polarization angles for wide FOV imagers.

Parameters:

input_data (NDCollection) – Input data on which to correct foreshortened polarization angles

Returns:

Output data with corrected polarization angles

Return type:

NDCollection

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

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#

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#

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#

Identity function that returns the input.

Parameters:

x (Any) – value

Returns:

input value returned back

Return type:

Any