sora.occultation

The Occultation Class

class sora.Occultation(star, body=None, ephem=None, time=None, reference_center='geocenter')[source]

Instantiates the Occultation object and performs the reduction of the occultation.

star

the coordinate of the star in the same reference frame as the ephemeris. It must be a Star object or a string with the coordinates of the object to search on Vizier.

Type

sora.Star, str, required

body

Object that will occult the star. It must be a Body object or its name to search in the Small Body Database.

Type

sora.Body, str

ephem

Object ephemeris. It must be an Ephemeris object or a list.

Type

sora.Ephem, list

time

Reference time of the occultation. Time does not need to be exact, but needs to be within approximately 50 minutes of the occultation closest approach to calculate occultation parameters.

Type

str, astropy.time.Time, required

reference_center

A SORA observer object or a string ‘geocenter’. The occultation parameters will be calculated in respect to this reference as center of projection.

Type

str, sora.Observer, sora.Spacecraft

Important

When instantiating with “body” and “ephem”, the user may define the Occultation in 3 ways:

  1. With body and ephem.

2. With only “body”. In this case, the “body” parameter must be a Body object and have an ephemeris associated (see Body documentation).

3. With only ephem. In this case, the ephem parameter must be one of the Ephem Classes and have a name (see Ephem documentation) to search for the body in the Small Body Database.

add_observation(obs, lightcurve)[source]

Adds observations to the Occultation object.

Parameters
  • obs (sora.Observer) – The Observer object to be added.

  • lightcurve (sora.LightCurve) – The LightCurve object to be added.

check_time_shift(time_interval=30, time_resolution=0.001, verbose=False, plot=False, use_error=True, delta_plot=100, ignore_chords=None)[source]

Check the needed time offset, so all chords have their center aligned.

Parameters
  • time_interval (int, float) – Time interval to check, default is 30 seconds.

  • time_resolution (int, float) – Time resolution of the search, default is 0.001 seconds.

  • verbose (bool) – If True, it prints text, default is False.

  • plot (bool, default=False) – If True, it plots figures as a visual aid.

  • use_error (bool, default=True) – if True, the linear fit considers the time uncertainty.

  • delta_plot (int, float, default=100) – Value to be added to increase the plot limit, in km.

  • ignore_chords (str, list, default=None) – Names of the chords to be ignored in the linear fit.

Returns

time_shift – Dictionary with needed time offset to align the chords, each key is the name of the chord.

Return type

dict

check_velocities()[source]

Prints the current velocity used by the LightCurves and its radial velocity.

fit_ellipse(**kwargs)[source]

Fits an ellipse to given occultation using given parameters.

Parameters
  • center_f (int, float, default=0) – The coordinate in f of the ellipse center.

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • equatorial_radius (int, float) – The Equatorial radius (semi-major axis) of the ellipse.

  • oblateness (int, float, default=0) – The oblateness of the ellipse.

  • position_angle (int, float, default=0) – The pole position angle of the ellipse in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.

  • dcenter_f (int, float) – Interval for coordinate f of the ellipse center.

  • dcenter_g (int, float) – Interval for coordinate g of the ellipse center.

  • int (dequatorial_radius) – Interval for the Equatorial radius (semi-major axis) of the ellipse.

  • float – Interval for the Equatorial radius (semi-major axis) of the ellipse.

  • doblateness (int, float) – Interval for the oblateness of the ellipse

  • dposition_angle (int, float) – Interval for the pole position angle of the ellipse in degrees.

  • loop (int, default=10000000) – The number of ellipses to attempt fitting.

  • dchi_min (int, float) – If given, it will only save ellipsis which chi square are smaller than chi_min + dchi_min. By default None when used with method=’chisqr’, and 3 for other methods.

  • number_chi (int, default=10000) – In the chisqr method if dchi_min is given, the procedure is repeated until number_chi is reached. In other methods it is the number of values (simulations) that should lie within the provided sigma_result.

  • verbose (bool, default=True) – If True, it prints information while fitting.

  • ellipse_error (int, float) – Model uncertainty to be considered in the fit, in km.

  • sigma_result (int, float) – Sigma value to be considered as result.

  • method (str, default=’least_squares’) – Method used to perform the fit. Available methods are: chisqr : monte carlo computation method used in versions of SORA <= 0.2.1. fastchi : monte carlo computation method, allows multithreading . least_squares or ls: best fit done used levenberg marquardt convergence algorithm. differential_evolution or de: best fit done using genetic algorithms. All methods return a Chisquare object.

  • threads (int) – Number of threads/workers used to perform parallel computations of the chi square object. It works with all methods except chisqr, by default 1.

Returns

chisquare – A ChiSquare object with all parameters.

Return type

sora.ChiSquare

Important

Each occultation is added as the first argument(s) directly.

Mandatory input parameters: ‘center_f’, ‘center_g’, ‘equatorial_radius’, ‘oblateness’, and ‘position_angle’.

Parameters fitting interval: ‘dcenter_f’, ‘dcenter_g’, ‘dequatorial_radius’, ‘doblateness’, and ‘dposition_angle’. Default values are set to zero. Search done between (value - dvalue) and (value + dvalue).

Examples

To fit the ellipse to the chords of occ1 Occultation object:

>>> fit_ellipse(occ1, **kwargs)

To fit the ellipse to the chords of occ1 and occ2 Occultation objects together:

>>> fit_ellipse(occ1, occ2, **kwargs)
fit_shape(**kwargs)[source]
Parameters
  • occ (sora.Occultation) – The Occultation object with information to fit

  • center_f (int, float, default=0) – The coordinate in f of the ellipse center.

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • dcenter_f (int, float) – Interval for coordinate f of the ellipse center.

  • dcenter_g (int, float) – Interval for coordinate g of the ellipse center.

  • scale (number) – Scale factor of the limb

  • dscale (number) – Interval for scale

  • loop (int, default=150000) – The number of centers to attempt fitting.

  • sigma_result (int, float) – Sigma value to be considered as result.

Returns

chisquare – A ChiSquare object with all parameters.

Return type

sora.ChiSquare

get_map_sites()[source]

Returns Dictionary with sites in the format required by plot_occ_map function.

Returns

sites – Dictionary with the sites in the format required by plot_occ_map function.

Return type

dict

new_astrometric_position(time=None, offset=None, error=None, verbose=True, observer=None)[source]

Calculates the new astrometric position for the object given fitted parameters.

Parameters
  • time (str, astropy.time.Time) – Reference time to calculate the position. If not given, it uses the instant of the occultation Closest Approach. It can be a string in the ISO format (yyyy-mm-dd hh:mm:ss.s) or an astropy Time object.

  • offset (list) –

    Offset to apply to the position. If not given, uses the parameters from the fitted ellipse.

    Note

    Must be a list of 3 values being [X, Y, ‘unit’]. ‘unit’ must be Angular or Distance unit.

    If Distance units for X and Y: Ex: [100, -200, ‘km’], [0.001, 0.002, ‘AU’]

    If Angular units fox X [d*a*cos(dec)] and Y [d*dec]: Ex: [30.6, 20, ‘mas’], or [-15, 2, ‘arcsec’]

  • error (list) –

    Error bar of the given offset. If not given, it uses the 1-sigma value of the fitted ellipse.

    Note

    Error must be a list of 3 values being [dX, dY, ‘unit’], similar to offset. It does not need to be in the same unit as offset.

  • verbose (bool) – If true, it Prints text, else it Returns text.

  • observer (str, sora.Observer, sora.Spacecraft) – IAU code of the observer (must be present in given list of kernels), a SORA observer object or a string: [‘geocenter’, ‘barycenter’]

observations()[source]

Print all the observations added to the Occultation object Pair (Observer, LightCurve)

plot_chords(all_chords=True, positive_color='blue', negative_color='green', error_color='red', ax=None, lw=2)[source]

Plots the chords of the occultation.

Parameters
  • all_chords (bool, default=True) – If True, it plots all the chords. If False, it sees what was deactivated in self.positions and ignores them.

  • positive_color (str, default=’blue’) – Color for the positive chords.

  • negative_color (str, default=’green’) – Color for the negative chords.

  • error_color (str, default=’red’) – Color for the error bars of the chords.

  • ax (maptlotlib.pyplot.Axes, default=None) – Axis where to plot chords (default: Uses matplotlib pool).

  • lw (int, float, default=2) – Linewidth of the chords.

plot_occ_map(**kwargs)[source]
Parameters
  • radius (int, float) – The radius of the shadow. If not given it uses saved value.

  • nameimg (str) – Change the name of the image saved.

  • path (str) – Path to a directory where to save map.

  • resolution (int, default=2) –

  • resolution. (Cartopy feature) –

  • "10m"; (- 1 means a resolution of) –

  • "50m"; (- 2 a resolution of) –

  • "100m". (- 3 a resolution of) –

  • states (bool) – If True, plots the states borders of the countries. The states of some countries will only be shown depending on the resolution.

  • zoom (int, float) – Zooms in or out of the map.

  • centermap_geo (list, default=None) – Center the map given coordinates in longitude and latitude. It must be a list with two numbers.

  • centermap_delta (list, default=None) – Displace the center of the map given displacement in X and Y, in km. It must be a list with two numbers.

  • centerproj (list) – Rotates the Earth to show occultation with the center projected at a given longitude and latitude. It must be a list with two numbers.

  • labels (bool, default=True) – Plots text above and below the map with the occultation parameters.

  • meridians (int, default=30) – Plots lines representing the meridians for given interval, in degrees.

  • parallels (int, default=30) – Plots lines representing the parallels for given interval, in degrees.

  • sites (dict) – Plots site positions in map. It must be a python dictionary where the key is the name of the site, and the value is a list with longitude, latitude, delta_x, delta_y and color. delta_x and delta_y are displacement, in km, from the point position of the site in the map and the name. color is the color of the point.

  • site_name (bool) – If True, it prints the name of the sites given, else it plots only the points.

  • countries (dict) – Plots the names of countries. It must be a python dictionary where the key is the name of the country and the value is a list with longitude and latitude of the lower left part of the text.

  • offset (list) – Applies an offset to the ephemeris, calculating new CA and instant of CA. It is a pair of delta_RA*cosDEC and delta_DEC.

  • mapstyle (int, default=1) – Define the color style of the map. '1' is the default black and white scale. '2' is a colored map.

  • error (int, float) – Ephemeris error in mas. It plots a dashed line representing radius + error.

  • ercolor (str) – Changes the color of the lines of the error bar.

  • ring (int, float) – Plots a dashed line representing the location of a ring. It is given in km, from the center.

  • rncolor (str) – Changes the color of ring lines.

  • atm (int, float) – Plots a dashed line representing the location of an atmosphere. It is given in km, from the center.

  • atcolor (str) – Changes the color of atm lines.

  • chord_delta (list) – List with distances from center to plot chords.

  • chord_geo (2d-list) – List with pairs of coordinates to plot chords.

  • chcolor (str, default=’grey’) – Color of the line of the chords.

  • heights (list) – It plots a circular dashed line showing the locations where the observer would observe the occultation at a given height above the horizons. This must be a list.

  • hcolor (str) – Changes the color of the height lines.

  • mapsize (list, default= [46.0, 38.0]) – The size of figure, in cm. It must be a list with two values.

  • cpoints (int, float, default=60) – Interval for the small points marking the center of shadow, in seconds.

  • ptcolor (str) – Change the color of the center points.

  • alpha (float, default=0.2) – The transparency of the night shade, where 0.0 is full transparency and 1.0 is full black.

  • fmt (str, default:’png’) – The format to save the image. It is parsed directly by matplotlib.pyplot.

  • dpi (int, default=100) – Resolution in “dots per inch”. It defines the quality of the image.

  • lncolor (str) – Changes the color of the line that represents the limits of the shadow over Earth.

  • outcolor (str) – Changes the color of the lines that represents the limits of the shadow outside Earth.

  • scale (int, float) – Arbitrary scale for the size of the name of the site.

  • cscale (int, float) – Arbitrary scale for the name of the country.

  • sscale (int, float) – Arbitrary scale for the size of point of the site.

  • pscale (int, float) – Arbitrary scale for the size of the points that represent the center of the shadow.

  • arrow (bool) – If True, it plots the arrow with the occultation direction.

Note

Only one of centermap_geo and centermap_delta can be given.

plot_radial_dispersion(ax=None, **kwargs)[source]

Plots the radial dispersion

A shape must have been fitted to the chords

Parameters
  • ax (matplotlib.pyplot.Axes) – The axes where to make the plot. If None, it will use the default axes.

  • **kwargs – Any other kwarg will be parsed directly by maplotlip.pyplot.plot. The only difference is that the default linewidth lw=1 and marker is marker=o.

property positions

Calculates the position and velocity for all chords. Saves it into an _PositionDict object.

remove_observation(key, key_lc=None)[source]

Removes an observation from the Occultation object.

Parameters
  • key (str) – The name given to Observer or LightCurve to remove from the list.

  • key_lc (str) – In the case where repeated names are present for different observations, key_lc must be given for the name of the LightCurve and key will be used for the name of the Observer.

to_file()[source]

Saves the occultation data to a file.

Three files are saved containing the positions and velocities for the observations. They are for the positive, negative and error bars positions.

The format of the files are: positions in f and g, velocities in f and g, the Julian Date of the observation, light curve name of the corresponding position.

to_log(namefile=None)[source]

Saves the occultation log to a file.

Parameters

namefile (str) – Filename to save the log.

The Chord Class

class sora.occultation.Chord(*, name, observer, lightcurve)[source]

Defines an Occultation Chord.

name

The name of the Chord.

Type

str

observer

The site of observation.

Type

sora.Observer

lightcurve

The lightcurve observed.

Type

sora.LightCurve

disable(*, time=None)[source]

Disables a contact point of the curve to be used in the fit.

Parameters

time (None, str) – If None, it will disable all contact points. If 'immersion' or 'emersion', it will disable respective contact point.

enable(*, time=None)[source]

Enables a contact point of the curve to be used in the fit.

Parameters

time (None, str) – If None, it will enable all contact points. If 'immersion' or 'emersion', it will enable respective contact point.

get_fg(*, time=None, vel=False)[source]

Returns the on-sky position for this chord at a given time.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • time (astropy.time.Time, str) – It must a time or a list of time to calculate the on-sky position. If time is 'immersion', 'emersion', 'start' or 'end', it will get the respective on-sky position. If time=None, it will return the on-sky position for the immersion and emersion times if positive or raise an error if negative.

  • vel (bool) – If True, it will return the on-sky velocity as well.

Returns

f, g, [vf, vg] – The geocentric on-sky Orthographic projection of the object with f pointing to the celestial North and g pointing to the celestial East. The respective velocities (vf, vg) are returned if vel=True.

Return type

float, float, [float, float]

get_impact_param(center_f=0, center_g=0, verbose=True)[source]

Gets the impact parameter, minimal distance between the chord and the centre position.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • center_f (int, float, default=0) – The coordinate in f of the ellipse center;

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • verbose (bool, default=True) – If True, prints the obtained values.

Returns

impact, sense – The impact parameter (in km) and the direction of the chord relative the ellipse center, North (N), South (S), East (E) and West (W).

Return type

list

get_limb_points(only_able=True)[source]

Computes the projected points and errors on the tangent plane

Parameters

only_able (bool) – Get only the contact points that are able to be used in the fit.

Returns

  • fg (numpy.array) – The projected points of occultation instants. Each line is a point on the projection with x and y respectively.

  • error (numpy.array) – Error vector of the projected occultation instants. Each line is the error of a point in x and y, respectively.

get_theoretical_times(equatorial_radius, center_f=0, center_g=0, oblateness=0, position_angle=0, sigma=0, step=1, verbose=True)[source]

Gets the theoretical times and chord size for a given ellipse.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • equatorial_radius (int, float) – The Equatorial radius (semi-major axis) of the ellipse.

  • center_f (int, float, default=0) – The coordinate in f of the ellipse center

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center

  • oblateness (int, float, default=0) – The oblateness of the ellipse.

  • position_angle (int, float, default=0) – The pole position angle of the ellipse in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.

  • sigma (int, float) – Uncertainty of the expected ellipse, in km.

  • step (int, float) – Time resolution of the chord, in seconds.

  • verbose (bool, default=True) – If True, prints the obtained values.

Returns

theory_immersion_time, theory_emersion_time, theory_chord_size – The expected immersion time for the given ellipse, the expected emersion time for the given ellipse, and the expected chord size for the given ellipse.

Return type

list

property is_able

Return a dictionary with the references enabled and disabled for the fit.

path(*, segment='standard', step=1)[source]

Returns the on-sky path of this chord.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • segment (str) –

    The segment to get the path of the chord. The available options are:

    'positive': to get the path between the immersion and emersion times if the chord is positive.

    'negative': to get the path between the start and end of observation if the chord is negative.

    'standard': to get the ‘positive’ path if the chord is positive or ‘negative’ if the chord is negative.

    'full': to get the path between the start and end of observation independent if the chord is positive or negative.

    'outer': to get the path outside the ‘positive’ path, for instance between the start and immersion times and between the emersion and end times.

    'error': to get the path corresponding to the error bars. Be aware that some of these segments may return more than 1 path, for example segment='error'.

  • step (int, float, str) –

    If a number, it corresponds to the step, in seconds, for each point of the path.

    This correspond to an approximate value if it is not a multiple of the interval of the segment.

    The step can also be equal to 'exposure'. In this case, the path will return a set of pairs where each pair will have the position at the beginning of the exposure and the end of the exposure.

Returns

path f, path g – It will return the path separated by f and g. If step='exposure', it will return f and g intercalated for each exposure.

Return type

array, array

plot_chord(*, segment='standard', only_able=False, ax=None, linestyle='-', time_direction=False, **kwargs)[source]

Plots the on-sky path of this chord.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • segment (str) –

    The segment to plot the chord. The available options are:

    'positive': to get the path between the immersion and emersion times if the chord is positive.

    'negative': to get the path between the start and end of observation if the chord is negative.

    'standard': to get the ‘positive’ path if the chord is positive

    or ‘negative’ if the chord is negative.

    'full': to get the path between the start and end of observation independent if the chord is positive or negative.

    'outer': to get the path outside the ‘positive’ path, for instance between the start and immersion times and between the emersion and end times.

    'error': to get the path corresponding to the error bars.

  • only_able (bool) – Plot only the contact points that are able to be used in the fit. If segment='error' it will show only the contact points able. If segment is any other, the path will be plotted only if both immersion and emersion are able, or it is a negative chord.

  • ax (matplotlib.pyplot.Axes) – The axes where to make the plot. If None, it will use the default axes.

  • linestyle (str) – Default linestyle used in matplotlib.pyplot.plot. The difference is that now it accepts linestyle='exposure', where the plot will be a dashed line corresponding to each exposure. The blank space between the lines can be interpreted as ‘dead time’.

  • time_direction (bool) – If enabled, it draws the direction of time flow on the chord line.

  • **kwargs – Any other kwarg will be parsed directly by maplotlip.pyplot.plot. The only difference is that the default linewidth lw=2.

status()[source]

Returns if the chord is positive or negative

The Chordlist Class

class sora.occultation.chordlist.ChordList(*, star, body, time)[source]

Defines a collection of Chord objects associated to an Occultation.

This object is not supposed to be defined by the user. It will be automatically defined in Occultation.

star

The Star occulted.

Type

sora.Star

body

The occulting Body.

Type

sora.Body

time

The occultation time.

Type

astropy.time.Time

add_chord(*, name=None, chord=None, observer=None, lightcurve=None)[source]

Add a chord to the occultation chord list

Parameters
  • name (str) – The name of the Chord. It must be unique within the list of chords. If not given, it will use the name in chord if chord is directly given or the name in the observer object. If the name in Chord already exists in the list, the name parameter can be given to update the chord name. The name parameter is required if given together with observer and lightcurve. It can not be an empty string.

  • sora.occultation.Chord (chord) – A chord instance defined by the user.

  • observer (sora.Observer) – An Observer instance defined by the user. It must be given together with a lightcurve.

  • lightcurve (sora.LightCurve) – A lightcurve defined by the user. It must be given together with observer.

Examples

Ways to add a chord:

>>> obj.add_chord(chord) # where the name in chord will be used.
>>> obj.add_chord(name, chord) # where the name in chord will be replaced by "name".
>>> obj.add_chord(observer, lightcurve) # where the name in observer will be used.
>>> obj.add_chord(name, observer, lightcurve)
disable(*, chord=None, time=None)[source]

Disable a contact point of the curve to be used in the fit.

Parameters
  • chord (str) – Name of the chord to disable. If chord=None, it applies to all chords.

  • time (None, str) – If time=None, it will disable all contact points. If ‘immersion’ or ‘emersion’, it will disable respective contact point.

enable(*, chord=None, time=None)[source]

Enable a contact point of the curve to be used in the fit.

Parameters
  • chord (str) – Name of the chord to enable. If chord=None, it applies to all chords.

  • time (Non`, str) – If time=None, it will enable all contact points. If ‘immersion’ or ‘emersion’, it will enable respective contact point.

get_impact_param(chords='all_chords', center_f=0, center_g=0, verbose=True)[source]

Get the impact parameter, minimal distance between the chord and the centre position.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • chords (int, str, default=’all_chords’) – Index or names of the chords to be considered.

  • center_f (int, float, default=0) – The coordinate in f of the ellipse center.

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • verbose (bool) – If True, prints the obtained values.

Returns

impact, sense, chord_name – The impact parameter (in km), the direction of the chord relative the ellipse center, North (N), South (S), East (E) and West (W), and the name of the chord

Return type

list

get_limb_points(only_able=True)[source]

Computes the projected points and errors on the tangent plane for every chord

Parameters

only_able (bool) – Get only the contact points that are able to be used in the fit.

Returns

  • fg (numpy.array) – The projected points of occultation instants. Each line is a point on the projection with x and y respectively.

  • error (numpy.array) – Error vector of the projected occultation instants. Each line is the error of a point in x and y, respectively.

get_theoretical_times(equatorial_radius, chords='all_chords', center_f=0, center_g=0, oblateness=0, position_angle=0, sigma=0, step=1, verbose=True)[source]

Get the theoretical times and chords sizes for a given ellipse.

This Chord object must be associated to an Occultation to work, since it needs the position of the star and an ephemeris.

Parameters
  • chords (int, str, default=’all_chords’) – Index or names of the chords to be considered.

  • equatorial_radius (int, float) – The Equatorial radius (semi-major axis) of the ellipse.

  • center_f (int, float, default=0) – The coordinate in f of the ellipse center.

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • oblateness (int, float, default=0) – The oblateness of the ellipse.

  • position_angle (int, float, default=0) – The pole position angle of the ellipse in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.

  • sigma (int, float) – Uncertainty of the expected ellipse, in km.

  • step (int, float) – Time resolution of the chord, in seconds.

  • verbose (bool) – If True, prints the obtained values.

Returns

theory_immersion_time, theory_emersion_time, theory_chord_size, chord_name – The expected immersion time for the given ellipse, the expected emersion time for the given ellipse, the expected chord size for the given ellipse, and the name of the chord.

Return type

list

plot_chords(*, segment='standard', ignore_chords=None, only_able=False, ax=None, linestyle='-', **kwargs)[source]

Plots the on-sky path of this chord.

Parameters
  • segment (str) –

    The segment to plot the chord. The available options are:

    'positive' to get the path between the immersion and emersion times if the chord is positive.

    'negative' to get the path between the start and end of observation if the chord is negative.

    'standard' to get the ‘positive’ path if the chord is positive or ‘negative’ if the chord is negative.

    'full' to get the path between the start and end of observation independent if the chord is positive or negative.

    'outer' to get the path outside the ‘positive’ path, for instance between the start and immersion times and between the emersion and end times.

    'error' to get the path corresponding to the error bars.

  • ignore_chords (str, list) – Name of chord or list of names to ignore in the plot.

  • only_able (bool) – Plot only the chords or contact points that are able to be used in the fit. If segment='error' it will show only the contact points able. If segment is any other, the path will be plotted only if both immersion and emersion are able, or it is a negative chord.

  • ax (matplotlib.pyplot.Axes) – The axes where to make the plot. If None, it will use the default axes.

  • linestyle (str) – Default linestyle used in matplotlib.pyplot.plot. The difference is that now it accept linestyle='exposure', where the plot will be a dashed line corresponding to each exposure. The blank space between the lines can be interpreted as ‘dead time’.

  • **kwargs – Any other kwarg will be parsed directly by maplotlip.pyplot.plot. The only difference is that the default linewidth lw=2.

remove_chord(*, name)[source]

Remove a chord from the chord list and disassociate it from the Occultation.

Parameters

name (str) – The name of the chord.

summary()[source]

Prints a table with the summary of the chords.

Fit Ellipse

sora.occultation.fit_ellipse(*args, equatorial_radius, dequatorial_radius=0, center_f=0, dcenter_f=0, center_g=0, dcenter_g=0, oblateness=0, doblateness=0, position_angle=0, dposition_angle=0, loop=10000, number_chi=10000, dchi_min=None, verbose=True, ellipse_error=0, sigma_result=1, method='least_squares', threads=1)[source]

Fits an ellipse to given occultation using given parameters.

Parameters
  • center_f (int, float, default=0) – The coordinate in f of the ellipse center.

  • center_g (int, float, default=0) – The coordinate in g of the ellipse center.

  • equatorial_radius (int, float) – The Equatorial radius (semi-major axis) of the ellipse.

  • oblateness (int, float, default=0) – The oblateness of the ellipse.

  • position_angle (int, float, default=0) – The pole position angle of the ellipse in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.

  • dcenter_f (int, float) – Interval for coordinate f of the ellipse center.

  • dcenter_g (int, float) – Interval for coordinate g of the ellipse center.

  • int (dequatorial_radius) – Interval for the Equatorial radius (semi-major axis) of the ellipse.

  • float – Interval for the Equatorial radius (semi-major axis) of the ellipse.

  • doblateness (int, float) – Interval for the oblateness of the ellipse

  • dposition_angle (int, float) – Interval for the pole position angle of the ellipse in degrees.

  • loop (int, default=10000000) – The number of ellipses to attempt fitting.

  • dchi_min (int, float) – If given, it will only save ellipsis which chi square are smaller than chi_min + dchi_min. By default None when used with method=’chisqr’, and 3 for other methods.

  • number_chi (int, default=10000) – In the chisqr method if dchi_min is given, the procedure is repeated until number_chi is reached. In other methods it is the number of values (simulations) that should lie within the provided sigma_result.

  • verbose (bool, default=True) – If True, it prints information while fitting.

  • ellipse_error (int, float) – Model uncertainty to be considered in the fit, in km.

  • sigma_result (int, float) – Sigma value to be considered as result.

  • method (str, default=’least_squares’) – Method used to perform the fit. Available methods are: chisqr : monte carlo computation method used in versions of SORA <= 0.2.1. fastchi : monte carlo computation method, allows multithreading . least_squares or ls: best fit done used levenberg marquardt convergence algorithm. differential_evolution or de: best fit done using genetic algorithms. All methods return a Chisquare object.

  • threads (int) – Number of threads/workers used to perform parallel computations of the chi square object. It works with all methods except chisqr, by default 1.

Returns

chisquare – A ChiSquare object with all parameters.

Return type

sora.ChiSquare

Important

Each occultation is added as the first argument(s) directly.

Mandatory input parameters: ‘center_f’, ‘center_g’, ‘equatorial_radius’, ‘oblateness’, and ‘position_angle’.

Parameters fitting interval: ‘dcenter_f’, ‘dcenter_g’, ‘dequatorial_radius’, ‘doblateness’, and ‘dposition_angle’. Default values are set to zero. Search done between (value - dvalue) and (value + dvalue).

Examples

To fit the ellipse to the chords of occ1 Occultation object:

>>> fit_ellipse(occ1, **kwargs)

To fit the ellipse to the chords of occ1 and occ2 Occultation objects together:

>>> fit_ellipse(occ1, occ2, **kwargs)

Complementary functions

sora.occultation.utils.add_arrow(line, position=None, direction='right', size=15, color=None)[source]

Add an arrow to a chord.

Parameters
  • line (Line2D object) – Line2D object

  • position (float, int) – x-position of the arrow. If None, mean of xdata is taken.

  • direction (string, default=’right’) – ‘left’ or ‘right’

  • size (float, int, default=15) – Size of the arrow in fontsize points.

  • color (string, default=None) – If None, line color is taken.

See also

https

//stackoverflow.com/a/34018322/3137585

sora.occultation.utils.filter_negative_chord(chord, chisquare, step=1, sigma=0)[source]

Get points for the ellipse with the given input parameters.

Parameters
  • chord (sora.observer.Chord) – Chord object, must be associated to an Occultation to work.

  • chisquare (sora.extra.ChiSquare) – Resulted ChiSquare object of fit_ellipse.

  • sigma (int, float) – Uncertainty of the expected ellipse, in km.

  • step (int, float, str) – If a number, it corresponds to the step, in seconds, for each point of the chord path. The step can also be equal to 'exposure'. In this case, the chord path will consider the lightcurve individual times and exptime.

sora.occultation.utils.positionv(star, ephem, observer, time)[source]

Calculates the position and velocity of the occultation shadow relative to the observer.

Parameters
  • star (sora.Star) – The coordinate of the star in the same reference frame as the ephemeris. It must be a Star object.

  • ephem (sora.Ephem) – The object ephemeris. It must be an Ephemeris object.

  • observer (sora.Observer) – The Observer information. It must be an Observer object.

  • time (astropy.time.Time) – Reference instant to calculate position and velocity. It can be a string in the ISO format (yyyy-mm-dd hh:mm:ss.s) or an astropy Time object.

Returns

f, g, vf, vg – The orthographic projection of the shadow relative to the observer. 'f' is in the x-axis (East-West direction; East positive). 'g' is in the y-axis (North-South direction; North positive).

Return type

list