exoctk.contam_visibility package¶
Submodules¶
exoctk.contam_visibility.astro_funcx module¶
- exoctk.contam_visibility.astro_funcx.JWST_same_ori(tgt0_c1, tgt0_c2, p0, tgt_c1, tgt_c2)[source]¶
Calculates normal orientation of second target, given first target’s orientation is normal. This is in Ecliptic coordinates!
- Parameters:
- tgt0_c1: float
The RA of the first target.
- tgt0_c2: float
The Dec of the first target.
- p0: float
The origin.
- tgt1_c1: float
The RA of the second target.
- tgt1_c2: float
The Dec of the second target.
- Returns:
- float
The normal orientation.
- exoctk.contam_visibility.astro_funcx.delta_pa_no_roll(pos1_c1, pos1_c2, pos2_c1, pos2_c2)[source]¶
Calculates the change in position angle between two positions with no roll about V1
- Parameters:
- pos1_c1: float
The RA of the first position.
- pos1_c2: float
The Dec of the first position.
- pos2_c1: float
The RA of the second position.
- pos2_c2: float
The Dec of the second position.
- Returns:
- float
The change in position angle.
- exoctk.contam_visibility.astro_funcx.dist(obj1_c1, obj1_c2, obj2_c1, obj2_c2)[source]¶
Calculates the angular distance betrween two objects, positions specified in spherical coordinates
- Parameters:
- obj1_c1: float
The RA of the first object.
- obj1_c2: float
The Dec of the first object.
- obj2_c1: float
The RA of the second object.
- obj2_c2: float
The Dec of the second object.
- Returns:
- float
The distance between the objects.
- exoctk.contam_visibility.astro_funcx.pa(tgt_c1, tgt_c2, obj_c1, obj_c2)[source]¶
Calculates position angle of object at tgt position.
- Parameters:
- tgt_c1: float
The RA of the target.
- tgt_c2: float
The Dec of the target.
- obj_c1: float
The RA of the reference.
- obj_c2: float
The Dec of the reference.
- Returns:
- float
The position angle.
exoctk.contam_visibility.ephemeris_old2x module¶
- class exoctk.contam_visibility.ephemeris_old2x.Ephemeris(ephem_file, cnvrt=False)[source]¶
Bases:
object
A class for the ephemeris of an observation.
Ephemeris constructor
- Parameters:
- ephem_file: str
The path to the ephemeris file.
- cnvrt: bool, optional
Converts into Ecliptic frame.
- OP_window(adate, ngc_1, ngc_2, pa, mdelta, pdelta)[source]¶
Attitude at adate must be valid, else returns (0, 0). If valid, returns (adate-mdelta, adate+pdelta) or the constraint window, which ever is smaller.
- Parameters:
- date: float
The date of the observation.
- ngc_1: flaot
The RA of the reference in radians.
- ngc_2: float
The Dec of the reference in radians.
- pa: float
The position angle.
- mdelta: float
Delta time on low end.
- pdelta: float
Delta time on high end.
- Returns:
- tuple
The OP window.
- Vsun_pos(adate)[source]¶
The vector of the sun at the given date
- Parameters:
- adate: datetime
The date of the observation
- Returns:
- Vector
The position of the sun as a Vector object
- bisect_by_FOR(in_date, out_date, ngc_1, ngc_2)[source]¶
Find the midpoint in time between in and out of FOR, assumes only one “root” in interval
- Parameters:
- in_date: float
The in date of the observation.
- out_date: float
The out date of the observation.
- ngc_1: flaot
The RA of the reference in radians.
- ngc_2: float
The Dec of the reference in radians.
- Returns:
- float
The midpoint in time.
- bisect_by_attitude(in_date, out_date, ngc_1, ngc_2, pa)[source]¶
Find the midpoint in time between in and out of FOR, assumes only one “root” in interval
- Parameters:
- in_date: float
The in date of the observation.
- out_date: float
The out date of the observation.
- ngc_1: flaot
The RA of the reference in radians.
- ngc_2: float
The Dec of the reference in radians.
- pa: float
The position angle.
- Returns:
- float
The midpoint in time.
- in_FOR(date, ngc_1, ngc_2)[source]¶
Test if in the FOR
- Parameters:
- date: float
The date of the observation.
- ngc_1: flaot
The RA of the reference in radians.
- ngc_2: float
The Dec of the reference in radians.
- Returns:
- bool
Is it in the FOR.
- is_valid(date, ngc_1, ngc_2, V3pa)[source]¶
Indicates whether an attitude is valid at a given date.
- Parameters:
- date: float
The date of the observation.
- ngc_1: flaot
The RA of the reference in radians.
- ngc_2: float
The Dec of the reference in radians.
- V3pa: float
The V3 position of the telescope.
- Returns:
- bool
Is it a valid PA.
- long_term_attitude(date)[source]¶
Defines a long-term safe attitude as of a given date.
- Parameters:
- date: float
The date of computation, as an mjd.
- Returns:
- Attitude
The Attitude object at the given date.
- normal_pa(adate, tgt_c1, tgt_c2)[source]¶
Calculate the V3 position
- Parameters:
- adate: datetime.datetime object
The date of the observation.
- tgt_c1: float
The RA in radians.
- tgt_c2: float
The Dec in radians.
- Returns:
- float
The V3 position.
- pos(adate)[source]¶
Computes the position of the telescope at a given date using the grid of positions of the ephemeris as a starting point and applying a linear interpolation between the ephemeris grid points
- Parameters:
- adate: datetime.datetime object
The date of the observation.
- Returns:
- qx.Vector object
The position of the telescope as a Vector object
exoctk.contam_visibility.f_visibilityPeriods module¶
Series of functions to compute the visibility periods for a given (RA, DEC) with in some cases the possibility to select a PA value.
Functions derived from the code of Wayne Kinzel provided by Jeff Valenti Extract from the e-mail of Wayne Kinzel: As before, the code is not officially tested, nor is it an official STScI product. Users should be warned that the apparent position of the Sun changes ~+/-0.2 degrees epending upon where JWST is in its orbit. So do not rely strongly on these results if the target is within ~0.2 degrees of |ecliptic latitude| 45 degrees or 85 degrees. For example if a target is at 84.9 degrees latitude and the tool says it is CVZ, it may not be with the operational orbit.
- exoctk.contam_visibility.f_visibilityPeriods.f_computeDurationOfVisibilityPeriodWithPA(ephemeris, mjdmin, mjdmax, ra, dec, pa, mjdc)[source]¶
Computes the duration of a specific visibility period associated to a given (RA,DEC), a given PA and given date
flag = 0 visibility period fully in the search interval flag = -1 start of the visibility period truncated by
the start of the search interval
- flag = -2 end of the visibility period truncated by
the end of the search interval
- flag = +1 the search interval is fully included in
the visibility period
- Parameters:
- ephemeris: Ephemeris
The input ephemeris object.
- mjdmin: float
The beginning of the search interval (modified Julian date). It must be covered by the ephemeris.
- mjdmax: float
The end of the search interval (modified Julian date). It must be covered by the ephemeris.
- ra: float
The input RA coordinate (equatorial coordinate, in rad).
- dec: float
The input DEC coordinate (equatorial coordinate, in rad).
- pa: float
The position angle.
- Returns:
- tuple
The lists of visibility period starts and ends with flags.
- exoctk.contam_visibility.f_visibilityPeriods.f_computeVisibilityPeriods(ephemeris, mjdmin, mjdmax, ra, dec)[source]¶
Returns two lists containing the start end end of each visibility period and a list containing a status flag
flag = 0 visibility period fully in the search interval flag = -1 start of the visibility period truncated by
the start of the search interval
- flag = -2 end of the visibility period truncated by
the end of the search interval
- flag = +1 the search interval is fully included in
the visibility period
- Parameters:
- ephemeris: Ephemeris
The input ephemeris object.
- mjdmin: float
The beginning of the search interval (modified Julian date). It must be covered by the ephemeris.
- mjdmax: float
The end of the search interval (modified Julian date). It must be covered by the ephemeris.
- ra: float
The input RA coordinate (equatorial coordinate, in rad).
- dec: float
The input DEC coordinate (equatorial coordinate, in rad).
- Returns:
- tuple
The lists of visibility period starts and ends with flags.
- exoctk.contam_visibility.f_visibilityPeriods.f_computeVisibilityPeriodsWithPA(ephemeris, mjdmin, mjdmax, ra, dec, pa)[source]¶
Returns two lists containing the start end end of each visibility period and a list containing a status flag
flag = 0 visibility period fully in the search interval flag = -1 start of the visibility period truncated by
the start of the search interval
- flag = -2 end of the visibility period truncated by
the end of the search interval
- flag = +1 the search interval is fully included in
the visibility period
- Parameters:
- ephemeris: Ephemeris
The input ephemeris object.
- mjdmin: float
The beginning of the search interval (modified Julian date). It must be covered by the ephemeris.
- mjdmax: float
The end of the search interval (modified Julian date). It must be covered by the ephemeris.
- ra: float
The input RA coordinate (equatorial coordinate, in rad).
- dec: float
The input DEC coordinate (equatorial coordinate, in rad).
- pa: float
The position angle.
- Returns:
- tuple
The lists of visibility period starts and ends with flags
exoctk.contam_visibility.math_extensionsx module¶
This module provides simple extensions to the Python mathematical library. 2018/06/26 Made PEP8 compliant and added sind() and cosd() - Joe Filippazzo Version 1 August 23, 2010 RLH - Added OBLIQUITY. Version 0 August 6, 2010 RLH - Created
- class exoctk.contam_visibility.math_extensionsx.Circle(radius)[source]¶
Bases:
object
Class to represent a circle.
Initialize a circle with a specified radius.
- Parameters:
- radius: float
The radius of the circle.
- class exoctk.contam_visibility.math_extensionsx.ContinuousHistogram(boundaries, highest_inclusive=False)[source]¶
Bases:
Histogram
Class to represent a histogram with continuous values.
Initializes a continuous histogram.
- Default behavior with highest_inclusive = False:
Bin 0 is defined by x <= boundaries[0]. For i > 0, bin i is defined by boundaries[i-1] < x <= boundaries[i]. Bin n+1 is defined by x > boundaries[n-1].
- Behavior with highest_exclusive = True:
Bins below n are defined in the same way as above. Bin n is defined by boundaries[n-2] < x < boundaries[n-1]. Bin n+1 is defined by x >= boundaries[n-1].
- Parameters:
- boundaries: sequence
List of numbers that separate the bins, in increasing order.
- highest_inclusive: bool
True if highest bin includes the last boundary, False (default) otherwise.
- class exoctk.contam_visibility.math_extensionsx.DiscreteBin(bin_value)[source]¶
Bases:
HistogramBin
Class to represent a bin with a fixed value.
Constructor for a fixed-value bin
- Parameters:
- bin_value: float
The value of the bin.
- class exoctk.contam_visibility.math_extensionsx.DiscreteHistogram(values)[source]¶
Bases:
Histogram
Class to represent a histogram with discrete values.
Initializes a histogram with discrete values.
- Parameters:
- values: sequence
List of the discrete values.
- retrieve_count_by_value(value)[source]¶
Returns the count matching a certain value. If not found, return None
- Parameters:
- value: float
The value to retrieve.
- store_items(value, count=1)[source]¶
Stores a value in the discrete histogram if it matches one of the bin values.
Count = number of items with that value to store (default 1).
Returns True if a match was found and the value could be stored, False otherwise
- Parameters:
- value: float
The value to store.
- count: int
Number of items with that value to store (default 1).
- Returns:
- foundbool
Whether or not a match was found.
- class exoctk.contam_visibility.math_extensionsx.Histogram[source]¶
Bases:
object
Class to represent a histogram.
- normalize(total=None)[source]¶
Takes a histogram and returns a new histogram that normalizes all its values.
- Parameters:
- total: int
Number of items to divide each bin by for the normalization. If not supplied, it defaults to the total in the histogram.
- Returns:
- new_histogramHistogram
The new histogram.
- class exoctk.contam_visibility.math_extensionsx.HistogramBin[source]¶
Bases:
object
Class to represent a bin within a histogram.
- class exoctk.contam_visibility.math_extensionsx.LinearEquation(coeff0, coeff1)[source]¶
Bases:
Polynomial
Subclass of Polynomial for linear equations. This implementation is three times faster, so Polynomial should be reserved for higher orders.
Constructor for a linear equation to provide a more ‘natural’ interface without using a list.
- Parameters:
- coeff0: float
Additive constant.
- coeff1: float
Multiplicative coefficient.
- class exoctk.contam_visibility.math_extensionsx.PoissonDistribution(mean, max_boundary)[source]¶
Bases:
DiscreteHistogram
Class to represent a Poisson distribution.
Constructor function for the Poisson distribution.
- Parameters:
- mean: float
Mean parameter for the Poisson distribution.
- max_boundary: float
The largest parameter for which the probability is to be computed. All values larger than max_boundary will be lumped into the highest bin.
- cumulative_probability(value)[source]¶
Returns the probability that a random variable will have a value no greater than the one specified.
- Parameters:
- value: float
The value between 0 and the max_boundary of the distribution.
- Returns:
- float
The probability.
- probability(k)[source]¶
Computes the probability that the Poisson distribution takes on the value k.
Value must be a nonnegative integer.
- Parameters:
- k: float
The value to compute.
- Returns:
- float
The probability.
- class exoctk.contam_visibility.math_extensionsx.Polynomial(coefficients)[source]¶
Bases:
object
Class to represent a polynomial.
Constructor for a polynomial. Coefficients = a list of coefficients, starting with order 0 and increasing.
- Parameters:
- coefficients: sequence
The list of coefficients, starting with order 0 and increasing.
- class exoctk.contam_visibility.math_extensionsx.RangeBin(min_value=None, max_value=None, lower_inclusive=False, upper_inclusive=True)[source]¶
Bases:
HistogramBin
Class to represent a bin with a range.
Constructor for a range bin.
- Parameters:
- min_value: float
Minimum value for the bin.
- max_value: float
Maximum value for the bin.
- lower_inclusive: bool
True if min_value is inclusive, else False (default).
- upper_inclusive: bool
True if max_value is inclusive, else False (default).
- describe_limits(precision=2)[source]¶
Returns a printed representation of the limits of the bin.
- Parameters:
- precision: int
Number of digits to print after the decimal point.
- Returns:
- str
The limits of the bin.
- class exoctk.contam_visibility.math_extensionsx.Rectangle(length, width)[source]¶
Bases:
object
Class to represent a rectangle.
Initialize a rectangle with a specified length and width.
- Parameters:
- length: float
The length of the rectangle.
- width: float
The width of the rectangle.
- motion_tolerant_area(motion_length, motion_angle)[source]¶
Returns the area within a rectangle that can tolerate a motion in a known direction while remaining within the rectangle.
- Parameters:
- motion_length: float
Distance of motion (same units as rectangle length and width).
- motion_angle: float
Angle in radians between the direction of motion and long direction of rectangle.
- Returns:
- float
The area.
- class exoctk.contam_visibility.math_extensionsx.Square(side)[source]¶
Bases:
Rectangle
Class to represent a square.
Initialize a square with a specified side length.
- Parameters:
- side: float
The length of the square side.
- class exoctk.contam_visibility.math_extensionsx.StatisticalList(data=None)[source]¶
Bases:
list
Numeric list class with statistical attributes.
Initializes a statistical list.
- Parameters:
- data: sequence
List of inputs to list.
- compute_statistics(min_value=None, max_value=None, max_bins=None)[source]¶
Computes statistics for a StatisticalList object; must contain at least one element.
- Parameters:
- min_value: float
Minimum value for cutoff of histogram (defaults to minimum in list).
- max_value: float
Maximum value for cutoff of histogram (defaults to maximum in list).
- max_bins: int
Maximum number of bins in histogram.
- exoctk.contam_visibility.math_extensionsx.acos2(val)[source]¶
Safe version of acos that handles invalid arguments in the same way as asin2
- Parameters:
- val: float
The evaluand.
- Returns:
- float
The arccos of the value.
- exoctk.contam_visibility.math_extensionsx.asin2(val)[source]¶
Safe version of asin that handles invalid arguments.
Arguments greater than 1 are truncated to 1; arguments less than -1 are set to -1.
- Parameters:
- val: float
The evaluand.
- Returns:
- float
The arcsin of the value.
- exoctk.contam_visibility.math_extensionsx.atan2d(x)[source]¶
Return the arctan in degrees
- Parameters:
- x: float
The evaluand.
- Returns:
- float
The arctan of x in degrees.
- exoctk.contam_visibility.math_extensionsx.average_histograms(histograms)[source]¶
Takes a list of histogram objects and simply averages all the bin values.
All histograms in the list must be identical except for the count.
- Parameters:
- histograms: sequence
A lst of Histogram objects to combine.
- Returns:
- new_histogramHistogram
The averaged histogram.
- exoctk.contam_visibility.math_extensionsx.avg(numbers)[source]¶
Returns the average of a list of numbers
- Parameters:
- numbers: sequence
The list of numbers.
- Returns:
- float
The average.
- exoctk.contam_visibility.math_extensionsx.avg2(num1, num2)[source]¶
Returns the average of two numbers
- Parameters:
- num1: float
The first number.
- num2: float
The second number.
- Returns:
- float
The average.
- exoctk.contam_visibility.math_extensionsx.combine_histograms(histograms)[source]¶
Takes a list of histograms and returns a new Histogram object that sums the values in each bin.
All histograms in the list must be identical except for the count.
- Parameters:
- histograms: sequence
A lst of Histogram objects to combine.
- Returns:
- Histogram
The combined histogram.
- exoctk.contam_visibility.math_extensionsx.conditional_probability(p_joint, p_B)[source]¶
Returns probability of event A given event B.
- Parameters:
- p_joint: float
P(A,B).
- p_B: float
Probability of event B.
- Returns:
- float
The probability.
- exoctk.contam_visibility.math_extensionsx.cosd(x)[source]¶
Return the cos in degrees
- Parameters:
- x: float
The evaluand.
- Returns:
- float
The cos of x in degrees.
- exoctk.contam_visibility.math_extensionsx.factorial(num)[source]¶
Returns the factorial of a nonnegative integer. This function is provided in math module starting with Python 2.6, but implement anyway for compatibility with older systems.
- Parameters:
- num: int
The number to factorialize.
- Returns:
- int
The factorial.
- exoctk.contam_visibility.math_extensionsx.output_as_percentage(num, fractional_digits=1)[source]¶
Output a percentage neatly.
- Parameters:
- num: float
The number to make into a percentage.
- fractional_digits: int
Number of digits to output as fractions of a percent. If not supplied, there is no reduction in precision.
- Returns:
- str
The percentage.
- exoctk.contam_visibility.math_extensionsx.percent_str(num, fractional_digits=1)[source]¶
Output a number as a percentage.
- Parameters:
- num: float
The number to make into a percentage.
- fractional_digits: int
Number of digits to output as fractions of a percent. If not supplied, there is no reduction in precision.
- Returns:
- str
The percentage.
- exoctk.contam_visibility.math_extensionsx.really_greater_than(x, y)[source]¶
Safe greater-than function that returns true if and only if x is “significantly” greater than y
- Parameters:
- x: float
The first number.
- y: float
The second number.
- Returns:
- bool
True if x is greater, else False.
- exoctk.contam_visibility.math_extensionsx.really_less_than(x, y)[source]¶
Safe less-than function that returns true if and only if x is “significantly” less than y.
- Parameters:
- x: float
The first number.
- y: float
The second number.
- Returns:
- bool
True if x is less, else False.
- exoctk.contam_visibility.math_extensionsx.sind(x)[source]¶
Return the sin in degrees.
- Parameters:
- x: float
The evaluand.
- Returns:
- float
The sin of x in degrees.
exoctk.contam_visibility.quaternionx module¶
Version 4 September 9, 2010 WMK Flipped sign of the angle in the QX, QY, QZ, QJX, QJY, QJZ, set_values, set_as_QX, … functions to be consistent with the corrected multiplication. Also updated the doc strings.
Version 3 September 8, 2010 RLH Backed out change to cnvrt in version 2.
Version 2 September 3, 2010 RLH Fixed sign error in quaternion multiplication functions. Added quaternion __str__ method. Modified cnvrt method to return a CelestialVector
4/9/2010 WMK Redefined the __init__ inputs Changed from a Vector internal representation to 3 scalers Fixed an error in cvt_att_Q_to_angles, was assuming an att2inertial Quaternion! Streamlined some of the functions
Version 1.0 August 3, 2010 Got rid of degrees trig functions.
Combined this and rotationsx.py module to avoid circular imports and made it PEP Compliant Joe Filippazzo - 2018/06/26
- class exoctk.contam_visibility.quaternionx.Attitude(ra=0.0, dec=0.0, pa=0.0, frame='eq', degrees=True)[source]¶
Bases:
CelestialVector
Defines an Observatory attitude by adding a position angle.
Constructor for an Attitude.
pa = position_angle in degrees(default) or radians if degrees=False is specified. Other arguments are the same as with CelestialVector
- Parameters:
- ra: float
The right ascension.
- dec: float
The declination.
- pa: float
The position angle.
- frame: str
The frame to use.
- degrees: bool
Use degrees.
- class exoctk.contam_visibility.quaternionx.CelestialVector(ra=0.0, dec=0.0, frame='eq', degrees=True)[source]¶
Bases:
Vector
Class to encapsulate a unit vector on the celestial sphere.
Constructor for a celestial vector.
There are two spherical coordinates, a longitudinal coordinate (called right ascension), and a latitudinal coordinate (called declination). The RA is defined as the counterclockwise angle from a reference direction on the equatorial plane; it ranges from 0-360 degrees. The DEC is the angle between the vector and the equatorial plane; it ranges from -90 to 90 degrees. Angles are specified in degrees but represented internally as radians.
The frame attribute indicates the coordinate frame of the vector, which may be ‘eq’ (equatorial, default), ‘ec’ (ecliptic), or ‘gal’ (galactic). In equatorial coordinates, the equatorial plane is the celestial equator (extension of the Earth’s equator) and the reference axis is the vernal equinox. In ecliptic coordiantes, the equatorial plane is the ecliptic (the Earth’s orbital plane) and the reference axis is usually defined relative to the Sun. In galactic coordinates, the equatorial plane is the plane of the Galaxy.
The degrees attribute should be True if the RA, DEC inputs are in degrees. Otherwise radians is assumed.
The coordinates “ra” and “dec” may be used in all three systems. Other names for coordinates in different frames may be defined for clarity.
A CelestialVector is also an ordinary unit vector, with Cartesian coordinates defined relative to the equatorial plane.
- Parameters:
- ra: float
The right ascension.
- dec: float
The declination.
- frame: str
The frame to use.
- degrees: bool
Use degrees.
- position_angle(v)[source]¶
Returns the position angle of v at the self vector, in radians.
v is an arbitrary vector that should be a CelestialVector object. The position angle is the angle between the North vector on the plane orthogonal to the self vector and the projection of v onto that plane, defined counterclockwise. See “V3-axis Position Angle”, John Isaacs, May 2003 for further discussion.
- Parameters:
- v: Vector
The vector to measure against.
- Returns:
- pafloat
The position angle between the two vectors.
- rotate_about_axis(angle, axis)[source]¶
This rotates a vector about an axis by the specified angle by using a rotation matrix. A new vector is returned.
Axis must be ‘x’, ‘y’, or ‘z’. The x-rotation rotates the y-axis toward the z-axis. The y-rotation rotates the z-axis toward the x-axis. The z-rotation rotates the x-axis toward the y-axis.
- Parameters:
- angle: float
The angle of rotation.
- axis: str
The axis to rotate about, [‘x’, ‘y’, ‘z’].
- Returns:
- resultVector
The rotated vector.
- rotate_about_eigenaxis(angle, eigenaxis)[source]¶
Rotates a vector about arbitrary eigenaxis.
eigenaxis = Vector object (axis about which to rotate). angle = angle to rotate by in radians. Rotation is counterclockwise looking outward from origin along eigenaxis. Function uses rotation matrix from Rodrigues formula.
Note: This function is more general than rotate_about_axis above and could be used in its place. However, rotate_about_axis is faster and clearer when the rotation axis is one of the Cartesian axes.
- Parameters:
- angle: float
The angle of rotation.
- eigenaxis: Vector
The eigenaxis to rotate about.
- Returns:
- resultVector
The rotated vector.
- rotate_by_posang(pa)[source]¶
Returns the vector that results from rotating the self vector counterclockwise from the North projection onto the plane orthogonal to that vector by the specified position angle (in radians). See “V3-axis Position Angle”, John Isaacs, May 2003 for further discussion.
- Parameters:
- pa: float
The position angle.
- Returns:
- resultVector
The rotated vector.
- rotate_using_quaternion(angle, eigenaxis)[source]¶
Rotates a vector about arbitrary eigenaxis using quaternion.
This is an alternative formulation for rotate_about_eigenaxis. Interface is the same as rotate_about_eigenaxis.
- Parameters:
- angle: float
The angle of rotation.
- eigenaxis: Vector
The eigenaxis to rotate about.
- Returns:
- Vector
The rotated vector.
- set_eq(ra, dec, degrees=False)[source]¶
Modifies a celestial vector with a new RA and DEC.
degrees = True if units are degrees. Default is radians.
- Parameters:
- ra: float
The right ascension.
- dec: float
The declination.
- degrees: bool
Use degrees.
- transform_frame(new_frame)[source]¶
Transforms coordinates between celestial and ecliptic frames and returns result as a new CelestialVector. If new coordinate frame is the same as the old, a copy of the vector is returned.
- Parameters:
- new_frame: str
Convert to new frame.
- Returns:
- resultVector
The transformed vector.
- class exoctk.contam_visibility.quaternionx.GalacticPole(latitude, longitude, ascending_node)[source]¶
Bases:
object
Represents coordinates of galactic pole.
Initializes the coordinates of the galactic pole.
- Parameters:
- latitude: float
Latitude of pole, in degrees.
- longitude: float
Longitude of pole, in degrees.
- ascending_node: float
Ascending node of pole, in degrees.
- class exoctk.contam_visibility.quaternionx.Matrix(rows)[source]¶
Bases:
list
Class to encapsulate matrix data and methods.
A matrix is simply a list of lists that correspond to rows of the matrix. This is just intended to handle simple multiplication and vector rotations. For anything more advanced or computationally intensive, Python library routines should be used.
Constructor for a matrix.
This accepts a list of rows. It is assumed the rows are all of the same length.
- Parameters:
- rows: sequence
The rows of the matrix.
- column(col_index)[source]¶
Returns a specified column of the matrix as a numeric list.
- Parameters:
- col_index: int
The column index.
- Returns:
- list
The column values.
- class exoctk.contam_visibility.quaternionx.NumericList(iterable=(), /)[source]¶
Bases:
list
List class that supports multiplication. Only valid for numbers.
- exoctk.contam_visibility.quaternionx.QX(angle)[source]¶
Creates rotation quaternion about X axis, rotates a vector about this axis.
- Parameters:
- angle: float
The angle to rotate by.
- exoctk.contam_visibility.quaternionx.QY(angle)[source]¶
Creates rotation quaternion about Y axis, rotates a vector about this axis.
- Parameters:
- angle: float
The angle to rotate by.
- exoctk.contam_visibility.quaternionx.QZ(angle)[source]¶
Creates rotation quaternion about Z axis, rotates a vector about this axis
- Parameters:
- angle: float
The angle to rotate by.
- exoctk.contam_visibility.quaternionx.Qmake_a_point(V)[source]¶
Creates a pure Q, i.e. defines a pointing not a rotation
- Parameters:
- V: Vector
The vector.
- Returns:
- Quaternion
The point as a quaternion.
- exoctk.contam_visibility.quaternionx.Qmake_aperture2inertial(coord1, coord2, APA, xoff, yoff, s, YapPA, V3ref, V2ref)[source]¶
Creates a rotation Q, going from the target in aperture frame to body.
- Parameters:
- coord1: float
The first coordinate.
- coord2: float
The second coordinate.
- APA: float
The apature position.
- xoff: float
The x offset.
- yoff: float
The y offset.
- s: float
The multiplicative factor.
- V2ref: float
The V2 position.
- V3ref: float
The V3 position.
- Returns:
- Quaternion
The rotation quaternion.
- exoctk.contam_visibility.quaternionx.Qmake_body2inertial(coord1, coord2, V3pa)[source]¶
Creates a rotation Q, going from the body frame to inertial.
- Parameters:
- coord1: float
The first coordinate.
- coord2: float
The second coordinate.
- V3pa: float
The V3 position.
- Returns:
- Quaternion
The rotation quaternion
- exoctk.contam_visibility.quaternionx.Qmake_v2v3_2body(v2, v3)[source]¶
Creates a rotation Q, going from v2 and v3 in the body frame to inertial.
- Parameters:
- v2: float
The V2 position.
- V3: float
The V3 position.
- Returns:
- Quaternion
The rotation quaternion.
- exoctk.contam_visibility.quaternionx.Qmake_v2v3_2inertial(coord1, coord2, V3pa, v2, v3)[source]¶
Creates a rotation Q, going from v2 and v3 in the body frame to inertial
- Parameters:
- coord1: float
The first coordinate.
- coord2: float
The second coordinate.
- V3pa: float
The V3 position.
- v2: float
The V2 position.
- v3: float
The V3 position.
- Returns:
- Quaternion
The rotation quaternion.
- class exoctk.contam_visibility.quaternionx.Quaternion(V, q4)[source]¶
Bases:
object
This representation is used by Wertz and Markley
Quaternion constructor.
- Parameters:
- V: Vector
The vector to construct the quaternion with.
- q4: Vector
The fourth vector.
- cnvrt(V)[source]¶
Rotates a vector from the starting frame to the ending frame defined by the Q.
- Parameters:
- V: Vector
The vector to rotate.
- Returns:
- Vector
The rotated Vector.
- inv_cnvrt(V)[source]¶
Rotates a vector from the ending frame to the starting frame defined by the Q.
- Parameters:
- V: Vector
The vector to invert.
- Returns:
- Vector
The inverted Vector.
- set_as_QX(angle)[source]¶
Sets quaterion in place like QX function.
- Parameters:
- angle: float
The angle of rotation
- set_as_QY(angle)[source]¶
Sets quaterion in place like QY function
- Parameters:
- angle: float
The angle of rotation
- set_as_QZ(angle)[source]¶
Sets quaterion in place like QZ function.
- Parameters:
- angle: float
The angle of rotation.
- set_as_mult(QQ1, QQ2)[source]¶
Sets self as QQ1*QQ2 in place for quaternion multiplication.
- Parameters:
- QQ1: Quaternion
The first quaternion.
- QQ2: Quaternion
The second quaternion.
- class exoctk.contam_visibility.quaternionx.Vector(x=0.0, y=0.0, z=0.0)[source]¶
Bases:
object
Class to encapsulate vector data and operations.
Constructor for a three-dimensional vector.
Note that two-dimensional vectors can be constructed by omitting one of the coordinates, which will default to 0.
- Parameters:
- x: float
The x coordinate.
- y: float
The y coordinate.
- z: float
The z coordinate.
- angle(V2)[source]¶
Returns angle between the two vectors in degrees.
- Parameters:
- V2: Vector
The vector to measure.
- Returns:
- float
The angle between the two vectors.
- cross(V1, V2)[source]¶
returns cross product of two vectors
- Parameters:
- V1: Vector
The vector to cross.
- V2: Vector
The vector to cross.
- Returns:
- Vector
The resultant vector.
- dot(V2)[source]¶
returns dot product between two vectors.
- Parameters:
- V2: Vector
The vector to dot.
- Returns:
- Vector
The resultant vector.
- exoctk.contam_visibility.quaternionx.angle(V1, V2)[source]¶
returns angle between two vectors in degrees, non class member.
- Parameters:
- V1: Vector
The first vector.
- V2: Vector
The second vector.
- Returns:
- float
The angle between the vectors.
- exoctk.contam_visibility.quaternionx.cross(v1, v2)[source]¶
Returns cross product between two vectors, non class member.
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- Returns:
- float
The cross product of the vectors.
- exoctk.contam_visibility.quaternionx.cvt_body2inertial_Q_to_c1c2pa_tuple(Q)[source]¶
Creates a angle tuple from Q, assuming body frame to inertial Q and 321 rotation sequence.
- Parameters:
- Q: Quaternion
The quaternion.
- Returns:
- coord1float
The first coordinate.
- coord2float
The second coordinate.
- pafloat
The poosition angle.
- exoctk.contam_visibility.quaternionx.cvt_c1c2_using_body2inertial_Q_to_v2v3pa_tuple(Q, coord1, coord2)[source]¶
Given Q and a position, returns v2, v3, V3PA tuple
- Parameters:
- Q: Quaternion
The quaternion.
- coord1: float
The first coordinate.
- coord2: float
The second coordinate
- Returns:
- coord1float
The first coordinate.
- coord2float
The second coordinate.
- pafloat
The poosition angle.
- exoctk.contam_visibility.quaternionx.cvt_pt_Q_to_V(Q)[source]¶
Converts a pure (pointing) Q to a unit position Vector
- Parameters:
- Q: Quaternion
The quaternion to convert to a Vector.
- Returns:
- Vector
The point as a vector.
- exoctk.contam_visibility.quaternionx.cvt_v2v3_using_body2inertial_Q_to_c1c2pa_tuple(Q, v2, v3)[source]¶
Given Q and v2, v3 gives pos on sky and V3 PA.
- Parameters:
- Q: Quaternion
The quaternion.
- v2: float
The V2 position.
- v3: float
The V3 position.
- Returns:
- tuple
The coordinates and position angle
- exoctk.contam_visibility.quaternionx.dec_separation(v1, v2)[source]¶
Returns difference in declination between two CelestialVectors.
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- Returns:
- float
The separation between Dec values
- exoctk.contam_visibility.quaternionx.dot(v1, v2)[source]¶
returns dot product between two vectors, non class member.
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- Returns:
- float
The dot product of the vectors.
- exoctk.contam_visibility.quaternionx.make_celestial_vector(v)[source]¶
Takes a Vector object and creates an equivalent CelestialVector.
Input vector v must be a unit vector.
- Parameters:
- v: Vector
The vector to convert.
- Returns:
- resultVector
The updated vector.
- exoctk.contam_visibility.quaternionx.pos_V_to_ra_dec(V)[source]¶
Returns tuple of spherical angles from unit direction Vector.
- Parameters:
- V: Vector
The vector to analyze.
- Returns:
- rafloat
The ra of the vector.
- decfloat
The dec of the vector.
- exoctk.contam_visibility.quaternionx.projection(v, axis)[source]¶
Returns projection of vector v on plane normal to axis.
First take cross-product of v and the axis and normalize it. Then cross the axis with the result and return a CelestialVector. See http://www.euclideanspace.com/maths/geometry/elements/plane/ lineOnPlane/index.htm.
- Parameters:
- v: Vector
The vector to convert.
- axis: str
The axis to project onto.
- Returns:
- Vector
The updated vector.
- exoctk.contam_visibility.quaternionx.ra_delta(v1, v2)[source]¶
Returns difference in right ascension between two CelestialVectors.
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- Returns:
- delta_rafloat
The difference in RA.
- exoctk.contam_visibility.quaternionx.ra_separation(v1, v2)[source]¶
Returns separation in right ascension between two CelestialVectors. This is accurate only if the difference in declination is small.
|sep| = DELTA-RA cos DEC
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- Returns:
- float
The separation between RA values.
- exoctk.contam_visibility.quaternionx.separation(v1, v2, norm=False)[source]¶
Returns angle between two unit vectors in radians.
The angle between two normalized vectors is the arc-cosine of the dot product. Unless the norm attribute is set to True, it is assumed the vectors are already normalized (for performance).
- Parameters:
- v1: Vector
The first vector.
- v2: Vector
The second vector.
- norm: bool
Normalize the vectors.
- Returns:
- separationfloat
The separation of the vectors.
exoctk.contam_visibility.resolve module¶
exoctk.contam_visibility.sossContamFig module¶
exoctk.contam_visibility.sossFieldSim module¶
exoctk.contam_visibility.time_extensionsx module¶
Module containing library functions for time manipulation. Standard for time representation in this project is fractional days. Dates are represented as modified Julian dates (mjd). An mjd gives the number of days since midnight on November 17, 1858.
- class exoctk.contam_visibility.time_extensionsx.FlexibleInterval(est, lst, let)[source]¶
Bases:
Interval
Class to represent an interval with flexibility on when it can start and end.
Constructor for a FlexibileInterval.
- Parameters:
- est: float
Earliest start time (mjd).
- lst: float
Latest start time (mjd).
- let: float
Latest end time (mjd).
- class exoctk.contam_visibility.time_extensionsx.Interval(start, end)[source]¶
Bases:
object
Class to represent a simple temporal interval.
Constructor for an interval.
- Parameters:
- start: float
The start time.
- end: float
The end time.
- temporal_relationship(time)[source]¶
Returns the temporal relationship between an interval and an absolute time.
Returns ‘before’ if the interval ends at or before the time, ‘after’ if the interval begins at or after the time, ‘includes’ if the time occurs during the interval.
- Parameters:
- time: float
The time.
- Returns:
- relstr
The temporal relationship.
- exoctk.contam_visibility.time_extensionsx.compute_mjd(year, day_of_year, hour, minute, second)[source]¶
Computes a modified Julian date from a date specified as a year, day of year, hour, minute, and second. Arguments should be integers.
- Parameters:
- year: int
The year.
- day_of_year: int
The day.
- hour: int
The hour.
- minute: int
The minute.
- second: int
The second.
- Returns:
- float
The modified julian day.
- exoctk.contam_visibility.time_extensionsx.days_in_year(year)[source]¶
Returns the number of days in a year.
- Parameters:
- year: int
The year to search.
- Returns:
- daysint
The number of days that year.
- exoctk.contam_visibility.time_extensionsx.days_to_seconds(days)[source]¶
Takes a time in fractional days and converts it into integer seconds.
- Parameters:
- days: float
The number of days as a float.
- Returns:
- int
The number of seconds in as many days.
- exoctk.contam_visibility.time_extensionsx.display_date(mjd)[source]¶
Returns a string representation of the date represented by a modified Julian date.
- Parameters:
- mjd: float
The modified julian day.
- Returns:
- str
The MJD as a string.
- exoctk.contam_visibility.time_extensionsx.display_time(time, force_hours=False)[source]¶
Returns a string representation of a time specified in fractional days.
- Parameters:
- time: float
The time as a float.
- force_hours: bool
Force the hour calculation.
- Returns:
- str
The time as a string.
- exoctk.contam_visibility.time_extensionsx.integer_days(time)[source]¶
Takes a time in fractional days and returns integer component.
- Parameters:
- time: float
The float time.
- Returns:
- int
The integer time.
- exoctk.contam_visibility.time_extensionsx.is_leap_year(year)[source]¶
Returns True if the year is a leap year, False otherwise.
- Parameters:
- year: int
The year to check.
- Returns:
- bool
Is the year a leap year?
- exoctk.contam_visibility.time_extensionsx.jd_to_mjd(jd)[source]¶
Converts a Julian date to a modified Julian date.
- Parameters:
- jd: float
The true Julian day.
- Returns:
- float
The modified Julian day.
- exoctk.contam_visibility.time_extensionsx.leap_years(year1, year2)[source]¶
Returns the number of leap years between year1 and year2, non-inclusive.
year1 and year2 must be integers, with year2 > year1
- Parameters:
- year1: int
The start year.
- year2: int
The end year.
- Returns:
- int
The number of leap years between year1 and year2.
- exoctk.contam_visibility.time_extensionsx.mjd_from_string(time_string)[source]¶
Takes a string of the form yyyy.ddd:hh:mm:ss and returns an mjd.
- Parameters:
- time_string: str
The MJD as a string.
- Returns:
- float
The modified julian day.
- exoctk.contam_visibility.time_extensionsx.mjd_to_jd(mjd)[source]¶
Converts a modified Julian date to a true Julian date.
- Parameters:
- mjd: float
The modified julian day.
- Returns:
- float
The true Julian day.
- exoctk.contam_visibility.time_extensionsx.round_to_second(time)[source]¶
Rounds a time in days to the nearest second.
- Parameters:
- time: int
The number of days as a float.
- Returns:
- float
The number of seconds in as many days.
- exoctk.contam_visibility.time_extensionsx.seconds_into_day(time)[source]¶
Takes a time in fractional days and returns number of seconds since the start of the current day.
- Parameters:
- time: float
The time as a float.
- Returns:
- int
The day’s duration in seconds.
- exoctk.contam_visibility.time_extensionsx.seconds_to_days(seconds)[source]¶
Takes a time in integer seconds and converts it into fractional days.
- Parameters:
- seconds: int
The number of seconds.
- Returns:
- float
The number of days as a float.
- exoctk.contam_visibility.time_extensionsx.time_from_string(time_string)[source]¶
Takes a string of the form ddd:hh:mm:ss and converts it to fractional days. All subfields above seconds are optional and may be omitted if the subfield and all higher-order ones are zero.
- Parameters:
- time_string: str
The time as a string.
- Returns:
- float
The fractional days.
exoctk.contam_visibility.visibilityPA module¶
Produces a graph of the visibility & accessible position angles for a given RA & DEC, and prints out corresponding information, including the ranges of accessible and inaccessible PAs.
- Usage: python visibilityPA.py RA DEC [targetName]
if targetName is specified, then the figure is saved
-Created by David Lafreniere, March 2016 -makes use of (and hacks) several scripts created by Pierre Ferruit
that are part of the JWST Python tools JWSTpylib and JWSTpytools
- exoctk.contam_visibility.visibilityPA.checkVisPA(ra, dec, targetName=None, ephFileName=None, fig=None)[source]¶
Check the visibility at a range of position angles.
- Parameters:
- ra: str
The RA of the target in hh:mm:ss.s or dd:mm:ss.s or representing a float
- dec: str
The Dec of the target in hh:mm:ss.s or dd:mm:ss.s or representing a float
- targetName: str
The target name
- ephFileName: str
The filename of the ephemeris file
- fig: bokeh.plotting.figure
The figure to plot to
- Returns:
- paGoodfloat
The good position angle.
- paBadfloat
The bad position angle.
- gdmatplotlib.dates object
The greogrian date.
- figbokeh.plotting.figure object
The plotted figure.
- exoctk.contam_visibility.visibilityPA.select_badPAs_ge_paNomnan(badPAs, paNomnan, threshold=7)[source]¶
Returns the absolute difference between each badPAs and paNomnan Should be greater than threshold (default=7)
- Parameters:
- badPAs: list
The list of bad position angles
- paNomnan: list
The list of nominal PAs
- Returns:
- np.ndarray
The array of PAs
- exoctk.contam_visibility.visibilityPA.using_gtvt(ra, dec, instrument, targetName='noName', ephFileName=None, output='bokeh')[source]¶
Plot the visibility (at a range of position angles) against time.
- Parameters:
- rastr
The RA of the target (in degrees) hh:mm:ss.s or dd:mm:ss.s or representing a float
- decstr
The Dec of the target (in degrees) hh:mm:ss.s or dd:mm:ss.s or representing a float
- instrumentstr
Name of the instrument. Can either be (case-sensitive): ‘NIRISS’, ‘NIRCam’, ‘MIRI’, ‘FGS’, or ‘NIRSpec’
- ephFileNamestr
The filename of the ephemeris file.
- outputstr
Switches on plotting with Bokeh. Parameter value must be ‘bokeh’.
- Returns:
- paGoodfloat
The good position angle.
- paBadfloat
The bad position angle.
- gdmatplotlib.dates object
The gregorian date.
- figbokeh.plotting.figure object
The plotted figure.
Module contents¶
Package to calculate target visibility and contamination