avigan / pyzelda Goto Github PK
View Code? Open in Web Editor NEWZernike wavefront sensor analysis and simulation tools
License: MIT License
Zernike wavefront sensor analysis and simulation tools
License: MIT License
Necessary to handle properly the NEAR (VISIR) mask.
Method to calculate the PSD of an OPD map between two given spatial frequencies. Use normalization derived by S. Tourenq (2015 LAM intern).
Calls to ztools.create_reference_wave() are computationaly intensive, but the results could be saved in a dictionary with keys equal to the wavelength to avoid recomputing them each time.
See avigan/SPHERE#8.
Current code uses a simplification (and approximation) when using data taken at another wavelength than the design wavelength.
On MITHIC we currently have 2 ZELDA masks and 2 cameras. Solution is probably to have 2 configuration files.
Currently the code assumes that there is only a single clear pupil image for one or multiple ZELDA pupil images, but for some sequences, there can be one clear pupil image for each ZELDA pupil image. Supporting multiple clear pupil images needs to adapt the following methods:
Instruments
Testbeds
Example SPHERE FITS files already available in the example/ subdirectory, but there is no example programme to show how to use the module.
On MITHIC the image size is not always the same depending on the crop applied to the camera during the acquisition.
Add germanium to the refractive index to the refractive_index method.
Take into account the absence of Sellmeier formula for the Germanium.
create tools to make simulations with zelda (propagation of aberration, gamme dynamique, etc)
next step:
pyZELDA in two modules:
Current version is not compatible with the rest of the code.
To be homogeneous with OPD maps.
read_file and read_file_sequence
collapse cube or not as an option
Code only support Python 3, but could probably support Python 2.7 with following imports:
import sys
if sys.version_info < (3,0):
from __future__ import absolute_import, division, print_function
I am trying to learn how to use your library using the code in the example repertory (simple_zelda_analysis.py).
however something is not working, I get this error message:
TypeError: only size-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "~\simulations\python\pyZELDA\examples\simple_zelda_analysis.py", line 39, in <module>
basis, coeff, opd_zern = ztools.zernike_expand(opd_map.mean(axis=0), 20)
File "~\anaconda3\envs\poppystable\lib\site-packages\pyzelda-1.1-py3.8.egg\pyzelda\ztools.py", line 688, in zernike_expand
reconstructed_opd[i] += coeffs_tmp[z] * basis[z, :, :]
ValueError: setting an array element with a sequence.
This is happening in function zernike_expand
in the ztools.py
.
I have been at it all morning I actually do not see how this can work:
reconstructed_opd[i]
is a float
coeffs_tmp[z]
is a float
basis[z, :, :]
is a 2 dimensional array
So multiplying a float by an array is fine but trying to add an array into a single numpy array element will not work.
After investigation I think the culprit is line 39 of simple_zelda_analysis.py :
basis, coeff, opd_zern = ztools.zernike_expand(opd_map.mean(axis=0), 20)
The the script works for me if i remove that .mean
. Can you confirm that this is the way to go please?
I suspect that this was made this way in cases where opd_map
actually has three dimension ? (why would it though?)
I put there after the entire script that works for me with both datasets you provide.
I left #FIXME comment where I changed something, the original lines are commented and the following line is the one that fixes the problem for me.
import matplotlib.pyplot as plt
import numpy as np
import pyzelda.zelda as zelda
import pyzelda.ztools as ztools
import pyzelda.utils.aperture as aperture
from pathlib import Path
# path = Path('/Users/mndiaye/Dropbox/python/zelda/pyZELDA/')
# path = Path('/Users/avigan/Work/GitHub/pyZELDA/data/')
# path = Path('D:/Programmes/GitHub/pyZELDA/')
path = Path('../data')
wave = 1.642e-6
# internal data
# clear_pupil_files = ['SPHERE_CLEAR_PUPIL_CUBE1_NDIT=3', 'SPHERE_CLEAR_PUPIL_CUBE1_NDIT=3']
# zelda_pupil_files = ['SPHERE_ZELDA_PUPIL_CUBE1_NDIT=3', 'SPHERE_ZELDA_PUPIL_CUBE2_NDIT=3']
# dark_file = 'SPHERE_BACKGROUND'
# pupil_tel = False
# on-sky data
clear_pupil_files = ['SPHERE_GEN_IRDIS057_0002']
zelda_pupil_files = ['SPHERE_GEN_IRDIS057_0001']
dark_file = 'SPHERE_GEN_IRDIS057_0003'
pupil_tel = True
# ZELDA analysis
z = zelda.Sensor('SPHERE-IRDIS', pupil_telescope=pupil_tel)
clear_pupil, zelda_pupil, center = z.read_files(path, clear_pupil_files, zelda_pupil_files, dark_file,
collapse_clear=True, collapse_zelda=True)
opd_map = z.analyze(clear_pupil, zelda_pupil, wave=wave)
# decomposition on Zernike polynomials
#FIXME
# basis, coeff, opd_zern = ztools.zernike_expand(opd_map.mean(axis=0), 20)
basis, coeff, opd_zern = ztools.zernike_expand(opd_map, 20)
# plot
fig = plt.figure(0, figsize=(16, 4))
plt.clf()
ax = fig.add_subplot(141)
ax.imshow(clear_pupil.mean(axis=0), aspect='equal', vmin=0, vmax=15000, origin='lower')
ax.set_title('Clear pupil')
ax = fig.add_subplot(142)
ax.imshow(zelda_pupil.mean(axis=0), aspect='equal', vmin=0, vmax=15000, origin='lower')
ax.set_title('ZELDA pupil')
ax = fig.add_subplot(143)
#FIXME
# ax.imshow(opd_map.mean(axis=0), aspect='equal', vmin=-150, vmax=150, cmap='magma', origin='lower')
ax.imshow(opd_map, aspect='equal', cmap='magma', origin='lower')
ax.set_title('OPD map')
ax = fig.add_subplot(144)
#FIXME
# cax = ax.imshow(opd_zern.mean(axis=0), aspect='equal', vmin=-150, vmax=150, cmap='magma', origin='lower')
cax = ax.imshow(opd_zern[0], aspect='equal', cmap='magma', origin='lower')
ax.set_title('Zernike projected OPD map')
cbar = fig.colorbar(cax)
cbar.set_label('OPD [nm]')
plt.tight_layout()
plt.show()
Cheers,
Anne-Laure
It would enable having direct access to the pupil once the sensor is created, e.g. for simulations.
ZWFS parameters are hard-coded.
Modify create_reference_wave to manage ZWFS from different instruments
Will enable testing methods that handle multiple pupil files.
Hi,
trying to use pyZelda on a windows machine, we got some trouble with the 'pathlib' module (creating a 'WindowsPath' object) and 'ConfigParser'.
The fix was in the 'Sensor' class (line 105) to replace:
config.read(configfile)
by
config.read(configfile.as_posix())
should be compatible with linux.
cheers,
Gilles
factorize functions between sections 2D image and 3D cube
Find the right reference to compute the refractive index of Germanium at T=60K and wave=11.2 um.
So far, two references: Barnes & Piltch (1979) and Li et al. (1980).
Li et al. (1980) give refractive index for a temperature range from 100K to 1200K and wavelength range from 1.9um to 18.0um.
Barnes & Piltch (1979) give refractive index for a temperature range from 50K to 300K and wavelength range from 2.5um to 14.0um. Barnes & Piltch (1979) seem to have underestimated refractive index with respect to Li et al. (1980) and Frey et al. (2006).
The pupil is currently always assumed to be circular and unobstructed, but when obtaining data on-sky the real shape of the telescope pupil should be taken into account.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.