# noctua.utils package

## Submodules

## noctua.utils.analysis module

Analysis-related functions

class noctua.utils.analysis.EllipticalMoffat(amplitude=2000, x_0=0, y_0=0, fwhm_x=9, fwhm_y=9, alpha=5, theta=0, **kwargs)

  Bases: `Fittable2DModel`

  From: http://www.aspylib.com/doc/aspylib_fitting.html

  alpha = Parameter('alpha', value=5.0, bounds=(None, 10))
  amplitude = Parameter('amplitude', value=2000.0, bounds=(0, 65535))
  static evaluate(x, y, amplitude, x_0, y_0, fwhm_x, fwhm_y, alpha, theta)

    Evaluate the model on some input variables.

  fwhm_x = Parameter('fwhm_x', value=9.0)
  fwhm_y = Parameter('fwhm_y', value=9.0)
  param_names = ('amplitude', 'x_0', 'y_0', 'fwhm_x', 'fwhm_y', 'alpha', 'theta')

    Names of the parameters that describe models of this type.

    The parameters in this tuple are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.

    When defining a custom model class the value of this attribute is automatically set by the ~astropy.modeling.Parameter attributes defined in the class body.

  theta = Parameter('theta', value=0.0, bounds=(-1.5707963267948966, 1.5707963267948966))
  x_0 = Parameter('x_0', value=0.0)
  y_0 = Parameter('y_0', value=0.0)

class noctua.utils.analysis.Moffat2DXY(amplitude=2000, x_0=0, y_0=0, gamma_x=9, gamma_y=9, alpha=3, **kwargs)

  Bases: `Fittable2DModel`

  alpha = Parameter('alpha', value=3.0)
  amplitude = Parameter('amplitude', value=2000.0, bounds=(0, 65535))
  static evaluate(x, y, amplitude, x_0, y_0, gamma_x, gamma_y, alpha)

    Evaluate the model on some input variables.

  static fit_deriv(x, y, amplitude, x_0, y_0, gamma_x, gamma_y, alpha)
  gamma_x = Parameter('gamma_x', value=9.0)
  gamma_y = Parameter('gamma_y', value=9.0)
  param_names = ('amplitude', 'x_0', 'y_0', 'gamma_x', 'gamma_y', 'alpha')

    Names of the parameters that describe models of this type.

    The parameters in this tuple are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.

    When defining a custom model class the value of this attribute is automatically set by the ~astropy.modeling.Parameter attributes defined in the class body.

  x_0 = Parameter('x_0', value=0.0)
  y_0 = Parameter('y_0', value=0.0)

noctua.utils.analysis.fit_star(data, fwhm=10, background_estimation=900, model='moffat', display=False)

noctua.utils.analysis.skyflat_exptime(average_counts_per_exptime, expected_counts=50000, binning=1, repeat=20, min_exp=0.1, max_exp=60)

  Calculate the exptime of sky flat images to obtain a given number of expected counts. Based on Tyson&Gal

## noctua.utils.check module

Collection of decorators to check several type of errors in specific types of functions.

noctua.utils.check.ascom_errors(func)

  Decorator for handling exceptions on a class method. Put it on top of the class method.

noctua.utils.check.content_errors(content)

  Decorator for handling exceptions. Put it on top of the content() method in the shinsapp class.

noctua.utils.check.meteo_errors(func)

  Decorator for handling exceptions on a class method. Put it on top of the class method.

noctua.utils.check.request_errors(func)

  Decorator for handling exceptions on a class method. Put it on top of the class method.

noctua.utils.check.socket_errors(func)

  Decorator for handling exceptions on a class method. Put it on top of the class method.

noctua.utils.check.telnet_errors(func)

  Decorator for handling exceptions on a class method. Put it on top of the class method.

## noctua.utils.coordinates module

Coordinates-related functions

noctua.utils.coordinates.apply_offset(fits_file='temp.fits', box=100, model='moffat', display=False)

  Take an image, fit a Moffat2d on a centered box center supposing there is a star, calculate the offset with respect to the center, sum it to the existing telescope offset.

noctua.utils.coordinates.calculate_offset(string='13 56 44 +27 28 01', header=None)

  Take a string of coordinates representing what is expected to be the center of an OARPAF FITS image, and the header of that FITS image. Uses the coordinates of that image to calculate the difference between that point and the center of the image in [alt, az], units of deg.

noctua.utils.coordinates.to_hms(number)

  Transform a value in units of degrees, i.e. 89.0, in a string coordinate, i.e. “+89 00 00”.

noctua.utils.coordinates.to_hms_dms(array, join=False)

  Transform an array of coordinates from units of degrees, i.e. [12.0, 89.0] in an array of string coordinates, i.e. [“12 00 00”, “+89 00 00”].

noctua.utils.coordinates.to_radec(string)

  Transform a string containing the object name, i.e. “Polaris”, or the object coordinates, i.e. “12 34 56.7 +89 00 00.0” in an array of float coordinates in units of [hours, degrees].

noctua.utils.coordinates.to_radians(string, equinox=None)

  Transform a string containing the object name, i.e. “Polaris”, or the object coordinates, i.e. “12 34 56.7 +89 00 00.0” in an array of float coordinates in units of radians.

## noctua.utils.data_access_object module

class noctua.utils.data_access_object.ObservationBlockObject(path)

  Bases: `object`

  content(name)
  create(name)
  delete(name)
  read(filename)
  show(name)
  property todos
  update(name, data=[])

noctua.utils.data_access_object.guess(value)

## noctua.utils.logger module

Custom format log

noctua.utils.logger.main()

  Main function

noctua.utils.logger.mylog()

  logger function

## noctua.utils.structure module

Functions managing the several directory names.

noctua.utils.structure.date_folder()

  Create a date folder string based on astronomical convention (changes at midday UTC).

noctua.utils.structure.fits_path(header, dry=False)

  Create a fits file path where the file will be stored

noctua.utils.structure.foc_path(timestamp, dry=False)

  Create the focus output text file name and its path

noctua.utils.structure.frame_folder(header)

  Create a folder depending on the image type in FITS header

noctua.utils.structure.log_path(dry=False)

  Returns the Path object for the log directory. Creates it if it doesn’t exist (unless dry=True).

noctua.utils.structure.save_filename(infile_path_str)

  Save a fits file in its path with an ESO-style filename.

## noctua.utils.url_stuff module

Utilities related to URLs

noctua.utils.url_stuff.build_url(itn)

  Build an URL from info of a .ini file

## Module contents

Utils