m4.ground package¶
m4.ground.geo module¶
- Autors
- Briguglio: created on Mon Mar 16 11:00:08 2020
- F Miceli: add functionality on march 2022
-
m4.ground.geo.draw_mask(img, cx, cy, r, out=0)¶ Function to create circular mask Created by Runa
Parameters: - img (numpy array) – image to mask
- cx (int [pixel]) – center x of the mask
- cy (int [pixel]) – center y of the mask
- r (int [pixel]) – radius of the mask
Returns: img1 – start image mask whit circular new mask
Return type: numpy array
-
m4.ground.geo.qpupil(mask, xx=None, yy=None, nocircle=0)¶ Function for…. created by Runa
Parameters: mask (numpy array) – Returns: - x0
- y0
- r
- xx (numpy array) – grid of coordinates of the same size as input mask
- yy (numpy array) – grid of coordinates of the same size as input mask
-
m4.ground.geo.qpupil_circle(image, pixel_dir=0)¶ Function for… Created by Federico NOTA: la funzione usa come standard la direzione y per determinare la dimensione dei pixel
- pixel_dir: int
- indicates which direction to use for counting the number of pixels in the image. Y direction as standard
-
m4.ground.geo.qpupil_ellipse(image, pixel_dir=0)¶ Function for… Created by Federico NOTA: la funzione usa come standard la direzione y per determinare la dimensione dei pixel
-
m4.ground.geo.rotate(img, angle)¶ Function to rotate the image Created by Runa
Parameters: - image (numpy array) – The input array
- angle (float) – The rotation angle in degrees
Returns: img1 – The rotated input
Return type: numpy array
m4.ground.GUI module¶
m4.ground.logger_set_up module¶
- Autors
- Selmi: written in September 2020
Function to start the log:
from m4.ground import logger_set_up
logger_set_up.set_up_logger(file_path, logging_level)
-
m4.ground.logger_set_up.set_up_logger(file_path, logging_level)¶ Set up logger for the application
Parameters: - file_path (string) – file path and log name (txt) where to create the log
- logging_level (int) – Warning = 30, Info = 20, Debug = 10, Notset = 0
m4.ground.ottInformation module¶
- Authors
- Selmi: written in 2021
-
class
m4.ground.ottInformation.OttInformation(ott, interf)¶ Bases:
objectHOW TO USE IT:
from m4.configuration import start ott, interf = start.create_ott('../M4/Data/SYSCONFData/Config.yaml') from m4.ground.ottInformation import OttInformation info = OttInformation(ott, interf)
-
acquireAndLogOttPositions()¶ Function for reading and logging of current test tower positions
-
interferogramTimeHistory(n_measure, delay_in_seconds)¶ Parameters: - n_measure (int) – number of measurements to acquire
- delay_in_seconds (int [s]) – time in seconds for delay between the measurements
Returns: cube – meauserements cube
Return type: numpy masked array [pixel, pixel, n_measure]
-
temperatureTimeHistory(n_measure, delay_in_seconds)¶ Parameters: - n_measure (int) – number of measurements to acquire
- delay_in_seconds (int [s]) – time in seconds for delay between the measurements
Returns: temp_matrix – meauserements matrix
Return type: numpy array [n_measure, num_PT_sensor]
-
m4.ground.read_data module¶
- Authors
- Selmi: written in 2019
Function for reading file fits:
from m4.ground import read_data
numpy_array_data = read_data.readFits_object(fits_file_path)
or
numpy_masked_array_data = read_data.readFits_maskedImage(fits_file_path)
or
amplitude, mode_vector, cmd_matrix = read_data.readTypeFromFitsName(
'ampName.fits', 'mvec.fits', 'cmdMatrix.fits')
-
class
m4.ground.read_data.InterferometerConverter¶ Bases:
objectClass to use to convert H5 files to masked array
-
static
fromFakeInterf(filename)¶ Function for fake interferometer :param file: path name for data :type file: string
Returns: ima – masked array image Return type: numpy masked array
-
static
fromI4DToSimplerData(i4dname, folder, h5name)¶ Function for converting files from 4d 6110 files to H5 files :param i4dname: file name path of 4d data :type i4dname: string :param folder: folder path for new data :type folder: string :param h5name: name for h5 data :type h5name: string
Returns: file_name – finale path name Return type: string
-
static
fromPhaseCam4020(h5filename)¶ Function for PhaseCam4020 :param h5filename: path of h5 file to convert :type h5filename: string
Returns: ima – masked array image Return type: numpy masked array
-
static
fromPhaseCam6110(i4dfilename)¶ Function for PhaseCam6110 :param h5filename: path of h5 file to convert :type h5filename: string
Returns: ima – masked array image Return type: numpy masked array
-
static
-
m4.ground.read_data.readFitsSlimImage(fits_file_path)¶ Parameters: fits_file_path (string) – fits file path of masked array to read Returns: immagine Return type: numpy masked array
-
m4.ground.read_data.readFits_data(fits_file_path)¶ Parameters: fits_file_path (string) – fits file path of numpy array to read Returns: object Return type: numpy array
-
m4.ground.read_data.readFits_maskedImage(fits_file_path)¶ Parameters: fits_file_path (string) – fits file path of masked array to read Returns: masked_array Return type: numpy masked array
-
m4.ground.read_data.readTypeFromFitsName(amplitude_fits_file_name, mode_vector_fits_file_name, cmd_matrix_fits_file_name)¶ Parameters: - amplitude_fits_file_name (string) – vector with mode amplitude fits file name
- mode_vector_fits_file_name (string) – mode or actuator index vector to be applied fits file name
- cmd_matrix_fits_file_name (string) – matrix of mode commands fits file name
Returns: - amplitude (numpy array) – vector with mode amplitude
- modesVector (numpy array) – mode or actuator index vector to be applied
- cmd_matrix (numpy array [nActs x nModes]) – matrix of mode commands diagonal matrix in case of zonal commands
-
m4.ground.read_data.read_phasemap(file_path)¶ per leggere i tre formati di dati interferometrici
m4.ground.rebinner module¶
- Authors
- Selmi: written in April 2020
-
m4.ground.rebinner.rebin(a, *args)¶ rebin ndarray data into a smaller ndarray of the same rank whose dimensions are factors of the original dimensions. eg. An array with 6 columns and 4 rows can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows. example usages: >>> a=rand(6,4); b=rebin(a,3,2) >>> a=rand(6); b=rebin(a,2)
Parameters: - a (numpy array) – vector for rebin
- *args (int) – new dimension for vector
-
m4.ground.rebinner.rebin2(a, shape)¶
-
m4.ground.rebinner.rebin2DArray(a, new_shape, sample=False)¶ Replacement of IDL’s rebin() function for 2d arrays. Resizes a 2d array by averaging or repeating elements. New dimensions must be integral factors of original dimensions, otherwise a ValueError exception will be raised. :param a: Input array. :type a: ndarray :param new_shape: Shape of the output array :type new_shape: 2-elements sequence :param sample: if True, when reducing the array side elements are set
using a nearest-neighbor algorithm instead of averaging. This parameter has no effect when enlarging the array.Returns: rebinned_array – If the new shape is smaller of the input array the data are averaged, unless the sample parameter is set. If the new shape is bigger array elements are repeated.
Return type: ndarray
Raises: ValueError– in the following cases:- new_shape is not a sequence of 2 values that can be converted to int
- new dimensions are not an integral factor of original dimensions
NotImplementedError– - one dimension requires an upsampling while the other requires- a downsampling
Examples
>>> a = np.array([[0, 1], [2, 3]]) >>> b = rebin(a, (4, 6)) #upsize >>> b array([[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1], [2, 2, 2, 3, 3, 3], [2, 2, 2, 3, 3, 3]]) >>> rebin(b, (2, 3)) #downsize array([[0. , 0.5, 1. ], [2. , 2.5, 3. ]]) >>> rebin(b, (2, 3), sample=True) #downsize array([[0, 0, 1], [2, 2, 3]])
m4.ground.smooth_function module¶
- Autors
- Selmi: written in 2020
Function for data smoothing:
form m4.ground import smooth_function
ss = smooth_function.smooth(data, WSZ)
-
m4.ground.smooth_function.smooth(a, WSZ)¶ ‘
Parameters: - a (NumPy 1-D array) – containing the data to be smoothed
- WSZ (int) – smoothing window size needs, which must be odd number, as in the original MATLAB implementation
Returns: smooth – smoothd data
Return type: numpy array
m4.ground.timestamp module¶
HOW TO USE IT:
from m4.ground.timestamp import Timestamp
now = Timestamp.now()
today = Timestamp.today()
or
ts = Timestamp()
now = ts.asNowString()
today = ts.asTodayString()
-
class
m4.ground.timestamp.Timestamp¶ Bases:
objectClass for tracking numbers generation
-
asNowString()¶ Returns: now – yearMonthDay_hoursMinutesSeconds Return type: string
-
asTodayString()¶ Returns: today – year month day Return type: string
-
static
now()¶ Returns: now – yearMonthDay_hoursMinutesSeconds Return type: string
-
static
today()¶ Returns: today – year month day Return type: string
-
m4.ground.tracking_number_folder module¶
- Authors
- Selmi: written in 2019
- modified in July 2021
HOW TO USE IT:
from m4.ground import tracking_numbers_folder as tnf
path, tt = tnf.createFolderToStoreMeasurements(store_in_folder)
or
path = tnf.findTrackingNumberPath(tt)
-
m4.ground.tracking_number_folder.createFolderToStoreMeasurements(store_in_folder)¶ Create a new folder using the generation of the tracking number
Parameters: store_in_folder (string) – path where to create new fold Returns: - dove (string) – all path generated
- tt (string) – only tracking number
-
m4.ground.tracking_number_folder.findTrackingNumberPath(tt)¶ Function to find the entire path from tracking number
Parameters: tt (string) – tracking number Returns: final_path – total path Return type: string
m4.ground.zabbix module¶
m4.ground.zernike module¶
@file zernike.py @brief Zernike generation library @author M.Xompero @url - @date 20200202
Created by Tim van Werkhoven (t.i.m.vanwerkhoven@xs4all.nl) on 2011-10-12 Copyright (c) 2011 Tim van Werkhoven. All rights reserved.
This file is licensed under the Creative Commons Attribution-Share Alike license versions 3.0 or higher, see http://creativecommons.org/licenses/by-sa/3.0/
HOW TO USE IT:
from m4.ground import zernike
coeff, mat = zernike.zernikeFit(img, zernike_index_vector)
surf_image = zernike.zernikeSurface(img, coef, mat)
-
m4.ground.zernike.zernikeFit(img, zernike_index_vector, qpupil=True)¶ Parameters: - img (numpy masked array) – image for zernike fit
- zernike_index_vector (numpy array) – vector containing the index of Zernike modes to be fitted starting from 1
Returns: - coeff (numpy array [m]) – vector of zernike coefficients
- mat (numpy array)
-
m4.ground.zernike.zernikeFitAuxmask(img, auxmask, zernike_index_vector)¶ Parameters: - img (numpy masked array) – image for zernike fit
- auxmask (numpy array) – zero for masked point
- zernike_index_vector (numpy array) – vector containing the index of Zernike modes to be fitted starting from 1
Returns: - coeff (numpy array [m]) – vector of zernike coefficients
- mat (numpy array)
-
m4.ground.zernike.zernikeSurface(img, coef, mat)¶ Parameters: - img (numpy masked array) – image for zernike fit
- coeff (numpy array [m]) – vector of zernike coefficients
- mat (numpy array) –
Returns: surf – zernike surface generate by coeff
Return type: numpy masked array