oimUtils

Various utilities for optical interferometry

Functions:

getDataTypeIsAnalysisComplex(dataType)

getDataArrname(dataType)

getDataType(dataArrname)

getDataTypeError(dataArrname)

blackbody(wavelength, temperature)

Planck's law with output in cgs.

calculate_intensity(wavelengths, temperature)

Calculates the blackbody_profile via Planck's law and the emissivity_factor for a given wavelength, temperature- and dust surface density profile.

pad_image(image)

Pads an image with additional zeros for Fourier transform.

rebin_image(image[, binning_factor, rdim])

Bins a 2D-image down according.

get_next_power_of_two(number)

Returns the next power of two for an integer or float input.

convert_angle_to_distance(radius, distance)

Converts an angle from milliarcseconds to meters.

convert_distance_to_angle(radius, distance)

Converts a distance from meters to an angle in milliarcseconds.

loadOifitsData(something[, mode])

return the oifits data from either filenames, already opened oifts or a oimData boject as either a list of hdlulist (default) or as a oimData object using the option mode="oimData".

getBaselineName(oifits[, hduname, length, ...])

Gets the baseline names, i.e., telescopes names separated by minus sign, in an extension of a oifits file.

getConfigName(oifits[, hduname, extver, squeeze])

getBaselineLengthAndPA(oifits[, arr, ...])

Return a tuple (B, PA) of the baseline lengths and orientation (position angles) from a fits extension within an opened oifits file.

get2DSpaFreq(oifits[, arr, unit, extver, ...])

Parameters:
  • oifits (TYPE) -- DESCRIPTION.

getSpaFreq(oifits[, arr, unit, extver, squeeze])

Parameters:
  • oifits (TYPE) -- DESCRIPTION.

getWlFromOifits(oifits[, arr, extver, ...])

hdulistDeepCopy(hdulist)

cutWavelengthRange(oifits[, wlRange, addCut])

getWlFromFitsImageCube(header[, outputUnit])

Returns the wl law from a chromatic cube image in the fits format

_createOiTab(extname, keywords_def, ...)

createOiTarget(**kwargs)

createOiArray(**kwargs)

createOiWavelength(**kwargs)

createOiVis2(**kwargs)

createOiVis(**kwargs)

createOiT3(**kwargs)

createOiFlux(**kwargs)

createOiTargetFromSimbad(names)

shiftWavelength(oifits, shift[, verbose])

spectralSmoothing(oifits, kernsize[, ...])

_rebin(arr, binsize[, median])

_rebinHdu(hdu, binsize[, exception])

binWavelength(oifits, binsize[, normalizeError])

oifitsFlagWithExpression(data, arr, extver, expr)

computeDifferentialError(oifits[, ranges, ...])

setMinimumError(oifits, dataTypes, values[, ...])

oimodeler.oimUtils.getDataTypeIsAnalysisComplex(dataType)
oimodeler.oimUtils.getDataArrname(dataType)
oimodeler.oimUtils.getDataType(dataArrname)
oimodeler.oimUtils.getDataTypeError(dataArrname)
oimodeler.oimUtils.blackbody(wavelength: ndarray, temperature: ndarray) ndarray

Planck’s law with output in cgs.

Parameters:
  • wavelength (np.ndarray) – The wavelength [cm].

  • temperature ſ np.ndarray – The temperature [K].

Returns:

blackbody – The blackbody [erg/(cm² s Hz sr)].

Return type:

np.ndarray

oimodeler.oimUtils.calculate_intensity(wavelengths: Unit('um'), temperature: Unit('K'), pixel_size: float | None = None) ndarray

Calculates the blackbody_profile via Planck’s law and the emissivity_factor for a given wavelength, temperature- and dust surface density profile.

Parameters:
  • wavelengths (astropy.units.um) – Wavelength value(s).

  • temp_profile (astropy.units.K) – Temperature profile.

  • pixSize (float, optional) – The pixel size [rad].

Returns:

intensity – Intensity per pixel.

Return type:

numpy.ndarray

oimodeler.oimUtils.pad_image(image: ndarray)

Pads an image with additional zeros for Fourier transform.

oimodeler.oimUtils.rebin_image(image: ndarray, binning_factor: int | None = None, rdim: bool | None = False) ndarray

Bins a 2D-image down according.

The down binning is according to the binning factor in oimOptions[“FTBinningFactor”]. Only accounts for square images.

Parameters:
  • image (numpy.ndarray) – The image to be rebinned.

  • binning_factor (int, optional) – The binning factor. The default is 0

  • rdim (bool) – If toggled, returns the dimension

Returns:

  • rebinned_image (numpy.ndarray) – The rebinned image.

  • dimension (int, optional) – The new dimension of the image.

oimodeler.oimUtils.get_next_power_of_two(number: int | float) int

Returns the next power of two for an integer or float input.

Parameters:

number (int or float) – An input number.

Returns:

closest_power_of_two – The, to the input, closest power of two.

Return type:

int

oimodeler.oimUtils.convert_angle_to_distance(radius: float | ndarray, distance: float, rvalue: bool | None = False) float | ndarray

Converts an angle from milliarcseconds to meters.

Parameters:
  • radius (float or numpy.ndarray) – The radius of the object around the star [mas].

  • distance (float) – The star’s distance to the observer [pc].

  • rvalue (bool, optional) – If toggled, returns the value witout u.else returns an astropy.u.Quantity object. The default is False.

Returns:

radius – The radius of the object around the star [m].

Return type:

float or numpy.ndarray

Notes

The formula for the angular diameter small angle approximation is

\[\delta = \frac{d}{D}\]

where d is the distance from the star and D is the distance from the star to the observer and ..math::delta is the angular diameter.

oimodeler.oimUtils.convert_distance_to_angle(radius: float | ndarray, distance: float, rvalue: bool | None = False) float | ndarray

Converts a distance from meters to an angle in milliarcseconds.

Parameters:
  • radius (float or numpy.ndarray) – The radius of the object around the star [au].

  • distance (float) – The star’s distance to the observer [pc].

  • rvalue (bool, optional) – If toggled, returns the value witout u.else returns an astropy.u.Quantity object. The default is False.

Returns:

radius – The radius of the object around the star [m].

Return type:

float or numpy.ndarray

Notes

The formula for the angular diameter small angle approximation is

\[\delta = \frac{d}{D}\]

where d is the distance from the star and D is the distance from the star to the observer and ..math::delta is the angular diameter.

oimodeler.oimUtils.loadOifitsData(something, mode='listOfHdlulist')

return the oifits data from either filenames, already opened oifts or a oimData boject as either a list of hdlulist (default) or as a oimData object using the option mode=”oimData”. This Function is used in oimData and multiple plotting functions

Parameters:
  • something (astropy.io.fits.hdu.hdulist.HDUList, oimodeler.oimData, string, list) – The data to deal with. Can be a oimData object, a hdulist, a string representing a filename or a list of these kind of object

  • mode (str, optional) – The type of the return data, either “listOfHdlulist” or “oimData” The default is “listOfHdlulist”

oimodeler.oimUtils.getBaselineName(oifits, hduname='OI_VIS2', length=False, angle=False, extver=None, squeeze=True)

Gets the baseline names, i.e., telescopes names separated by minus sign, in an extension of a oifits file.

By default it is reading the ‘OI_VIS’ extension

Parameters:
  • oifits (astropy.io.fits.hdu.hdulist.HDUList) – An oifits file structure already opened with astropy.io.fits

  • hduname (str, optional) – The fits extension name. The default is “OI_VIS2”.

  • length (bool, optional) – Add baseline length to the returned result. The default is False.

  • angle (bool, optional) – Add baseline position angle ((in deg)à=) to the returned result. The default is False

Returns:

name – The array containing the baseline names (or triplet) and optionally the baseline length and orientation.

Return type:

python list of str

oimodeler.oimUtils.getConfigName(oifits, hduname='OI_VIS2', extver=None, squeeze=True)
oimodeler.oimUtils.getBaselineLengthAndPA(oifits, arr='OI_VIS2', extver=None, squeeze=True, returnUV=False, T3Max=False)

Return a tuple (B, PA) of the baseline lengths and orientation (position angles) from a fits extension within an opened oifits file.

By default it is reading the OI_VIS extension.

Parameters:
  • oifits (astropy.io.fits.hdu.hdulist.HDUList) – An oifits file structure already opened with astropy.io.fits.

  • arr (str, optional) – The fits extension name. The default is “OI_VIS2”.

  • returnUV (bool) – if True also return the u,v coordinates in m the default is False

Returns:

  • B (numpy.ndarray) – the array containing the baselines length.

  • PA (numpy.ndarray) – the array containing the baselines orientation (in deg).

  • ucoord (numpy.ndarray) – the array containing the u coordinate (in m)(optional)

  • ucoord (numpy.ndarray) – the array containing the u coordinate (in m)(optional)

oimodeler.oimUtils.get2DSpaFreq(oifits, arr='OI_VIS2', unit=None, extver=None, squeeze=True)
Parameters:
  • oifits (TYPE) – DESCRIPTION.

  • arr (TYPE, optional) – DESCRIPTION. The default is “OI_VIS2”.

  • unit (TYPE, optional) – DESCRIPTION. The default is None.

Returns:

spaFreq – DESCRIPTION.

Return type:

TYPE

oimodeler.oimUtils.getSpaFreq(oifits, arr='OI_VIS2', unit=None, extver=None, squeeze=True)
Parameters:
  • oifits (TYPE) – DESCRIPTION.

  • arr (TYPE, optional) – DESCRIPTION. The default is “OI_VIS2”.

  • unit (TYPE, optional) – DESCRIPTION. The default is None.

Returns:

spaFreq – DESCRIPTION.

Return type:

TYPE

oimodeler.oimUtils.getWlFromOifits(oifits, arr='OI_VIS2', extver=None, returnBand=False)
oimodeler.oimUtils.hdulistDeepCopy(hdulist)
oimodeler.oimUtils.cutWavelengthRange(oifits, wlRange=None, addCut=[])
oimodeler.oimUtils.getWlFromFitsImageCube(header, outputUnit=None)

Returns the wl law from a chromatic cube image in the fits format

Parameters:
  • header (astropy.io.fits.header) – DESCRIPTION.

  • outputUnit (astropy.unit, optional) – If set convert the result to the proper unit. The default is None.

Returns:

wl – The wavelength in the given unit of the fits cube or the u.specified by the user if outputUnit is set

Return type:

float

oimodeler.oimUtils._createOiTab(extname, keywords_def, colums_def, dataTypeFromShape, **kwargs)
oimodeler.oimUtils.createOiTarget(**kwargs)
oimodeler.oimUtils.createOiArray(**kwargs)
oimodeler.oimUtils.createOiWavelength(**kwargs)
oimodeler.oimUtils.createOiVis2(**kwargs)
oimodeler.oimUtils.createOiVis(**kwargs)
oimodeler.oimUtils.createOiT3(**kwargs)
oimodeler.oimUtils.createOiFlux(**kwargs)
oimodeler.oimUtils.createOiTargetFromSimbad(names)
oimodeler.oimUtils.shiftWavelength(oifits, shift, verbose=False)
oimodeler.oimUtils.spectralSmoothing(oifits, kernsize, cols2Smooth='all', normalizeError=True)
oimodeler.oimUtils._rebin(arr, binsize, median=True)
oimodeler.oimUtils._rebinHdu(hdu, binsize, exception=[])
oimodeler.oimUtils.binWavelength(oifits, binsize, normalizeError=True)
oimodeler.oimUtils.oifitsFlagWithExpression(data, arr, extver, expr, keepOldFlag=False)
oimodeler.oimUtils.computeDifferentialError(oifits, ranges=[[0, 5]], excludeRange=False, rangeType='index', dataType='VISPHI', extver=[None])
oimodeler.oimUtils.setMinimumError(oifits, dataTypes, values, extver=None)