{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Conventions\n", "\n", "Here, we will outline some of the conventions used by prysm. These will be useful to understand if extending the library, or performing custom analysis.\n", "\n", "prysm uses a large number of classes which carry data and metadata about the signals with their namesakes. They can be divided loosely into two caregories,\n", "\n", "* phases\n", "* images\n", "\n", "Both have common properties of `x` and `y`, which are one dimensional arrays giving the gridded coordinates in x and y." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# an example of a phase-type object and an image-type object\n", "from prysm import Pupil, Slit\n", "\n", "pu = Pupil()\n", "sl = Slit(1, sample_spacing=0.075, samples=64)\n", "\n", "pu.x[:3], sl.y[:3] # only first three elements for brevity" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Each has an array that holds the numerical representation of the signal itself, for phaes-type objects this is `phase` and for image-type objects this is `data`. The convention is `y,x` indices, consistent with numpy. This is the opposite convention used by matlab." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pu.phase[:3,:3], sl.data[:3,:3]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "both inherit from BasicData (in fact, just about every class in prysm does) which imbues them with a brevy of properties:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from prysm._basicdata import BasicData\n", "help(BasicData)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "prysm is a metadata-heavy library, with many functions and procedures taking a several arguments, most of which populated with sane default values. A number of these defaults can be controlled through prysm's config object," ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from prysm import config" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "controlled_properties = [i for i in dir(config) if not i.startswith('_') and not i == 'initialized']\n", "print(controlled_properties)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To change the value used by prysm, simply assign to the property," ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# use 32-bit floats instead of 64-bit, ~50% speedup to all operations in exchange for accuracy\n", "config.precision = 32" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }