Single Dish Radio Astronomy Software Tools¶
For an overview of SDRAST and the current status please visit https://sdrast.github.io/.
Todo¶
Change import * from math
to import math
.
Math Package¶
Local mathematical functions in addition to the Python ‘math’ module.
The smoothing functions are adapted from: http://www.swharden.com/blog/2008-11-17-linear-data-smoothing-in-python/
Functions¶
|
Return the arc cosine (measured in radians) of x. |
|
Return the inverse hyperbolic cosine of x. |
|
Computes Allan variance |
|
Return the arc sine (measured in radians) of x. |
|
Return the inverse hyperbolic sine of x. |
|
Return the arc tangent (measured in radians) of x. |
|
Return the arc tangent (measured in radians) of y/x. |
|
Return the inverse hyperbolic tangent of x. |
|
Converts a binary string, sign bit then msb on left, to an integer. |
|
Return the ceiling of x as an Integral. |
|
Return a float with the magnitude (absolute value) of x but the sign of y. |
|
Return the cosine of x (measured in radians). |
|
Return the hyperbolic cosine of x. |
|
Converts integer to binary string of length nbits, sign bit and then m.s.b. |
|
Convert angle x from radians to degrees. |
|
Error function at x. |
|
Complementary error function at x. |
|
Return e raised to the power of x. |
|
Return exp(x)-1. |
|
Return the absolute value of the float x. |
|
Find x!. |
|
Return the floor of x as an Integral. |
|
Return fmod(x, y), according to platform C. |
|
Return the mantissa and exponent of x, as pair (m, e). |
|
Return an accurate floating point sum of values in the iterable seq. |
|
Gamma function at x. |
|
Un-normalized gaussian |
|
greatest common divisor of x and y |
|
Computes the variance of n_data points of data[], averaged in groups of n_grps and returns the variance for these groups |
|
Return the Euclidean distance, sqrt(x*x + y*y). |
|
Determine whether two floating point numbers are close in value. |
|
Return True if x is neither an infinity nor a NaN, and False otherwise. |
|
Return True if x is a positive or negative infinity, and False otherwise. |
|
Return True if x is a NaN (not a number), and False otherwise. |
|
Return x * (2**i). |
|
Natural logarithm of absolute value of Gamma function at x. |
|
Return the logarithm of x to the given base. |
|
Return the base 10 logarithm of x. |
|
Return the natural logarithm of 1+x (base e). |
|
Return the base 2 logarithm of x. |
|
Return the fractional and integer parts of x. |
|
gaussian function whose area under the curve is unity. |
|
Return x**y (x to the power of y). |
|
This finds the integer greater than ‘number’ which is a power of two. |
|
Convert angle x from degrees to radians. |
|
Difference between x and the closest integer multiple of y. |
|
returns a normalized gauusian’s value at x, given the mean and full width at half maximam |
|
Return the sine of x (measured in radians). |
|
Return the hyperbolic sine of x. |
|
Smooth a list of numbers by averaging ‘degree’ samples. |
|
Gaussian data smoothing function. |
|
Smooth a list of numbers by convolving with a triangle. |
|
Solid angle for a circular pattern |
|
Return the square root of x. |
|
Return the tangent of x (measured in radians). |
|
Return the hyperbolic tangent of x. |
|
Truncates the Real x to the nearest Integral toward 0. |
Math.Bin Module¶
Binary operations
- Example::
In [1]: import Math.Bin as B
In [2]: B.setbit(0,12) Out[2]: 4096
In [3]: “%x” % B.setbit(0,12) Out[3]: ‘1000’
Functions¶
|
Counts the number of set bits in the binary value. |
|
Clear bit in word (set to 0) |
|
Set a bit mask |
|
Extract a value from a range of bits (bit field) |
|
get the value of bit in word |
|
Reverse the pattern |
|
|
|
|
|
Set a value into a bit field |
|
set bit in word to 1 |
Math.geometry Module¶
Classes for properties of geometrical objects.
This isn’t exactly difficult math but it illustrates object-oriented programming pretty well.
For simple calculations it isn’t necessary to create instances of the objects. For example:
In [1]: from Math.geometry import *
In [2]: Sphere(6000).area
Out[2]: 452389342.11693019
In [3]: Sphere(6000).horizon(0.01)
Out[3]: 10.95443745708116
Sometimes, an instance is useful though:
In [4]: s = Sphere(6000)
In [5]: r = s.horizon(300)
In [6]: visible_fraction = Circle(r).area/s.area
In [7]: visible_fraction
Out[7]: 0.023242630385487552
Classes¶
|
Circle, a subclass of Circular() |
|
Superclass for circular objects, like Circle() and Sphere() |
|
Sphere, a subclass of Circular() |
Class Inheritance Diagram¶
Math.least_squares Module¶
leastsq_support - short-cuts for scipy.optimize.leastsq
Functions¶
|
Find x!. |
|
Invoke least squares fit to a Gaussian function |
|
Gaussian function |
|
Difference between model and actual data |
|
Minimize the sum of squares of a set of equations. |
|
Return the logarithm of x to the given base. |
|
Smooth (and optionally differentiate) data with a Savitzky-Golay filter. |
|
In cyclic voltammetry, voltage (being the abcissa) changes like a triangle wave. |
|
un-normalized gaussian for fitting |
|
Return the square root of x. |
|
Standard deviation from Gaussian full width at half maxiuam |
|
Gaussian full width at half maximum from standard deviation |
Math.multigauss Module¶
Functions¶
|
A form of ‘multigauss’ that curfit can use. |
|
Un-normalized gaussian |
|
Returns the value of the sum of multiple Gaussians. |
Math.statistics Module¶
Allan variance
not yet tested since bug fixes - tbhk 2007-10-12
Functions¶
|
Computes Allan variance |
|
Computes the variance of n_data points of data[], averaged in groups of n_grps and returns the variance for these groups |