Skip to content

Commit

Permalink
WIP documentation. Version now 1.0.0 (METIS-FDR)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles Orban de Xivry committed Jul 7, 2022
1 parent 9c32585 commit 799f926
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 68 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ dmypy.json
*.tar.gz
data/wavefront
.idea/
scripts/
data/_archives/
*bat
*fits
/data/pupil/eso
data/pupil/eso
!data/pupil/ELT_fullM1.fits
!data/pupil/ls_CVC_L_285_dRext=0.0209_dRint=0.09_dRspi=0.0245.fits
!data/pupil/ls_CVC_N2_119_dRext=0.0268_dRint=0.09_dRspi=0.0357.fits
Expand Down
3 changes: 1 addition & 2 deletions config/config_demo_metis_compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# =======
# 0. mode = 'ELT' for no coronagraph (only telescope)
# 1. mode = 'CVC' for Classical Vortex Coronagraph
# (2. mode = 'RAVC' for Ring Apodized Vortex Coronagraph)
# 2. mode = 'RAVC' for Ring Apodized Vortex Coronagraph
# (3. mode = 'APP' for Apodizing Phase Plate)
inst_mode = 'ELT', # HCI instrument mode
vc_charge = 2, # (CVC and RAVC only) vortex topological charge
Expand All @@ -45,7 +45,6 @@
# # CVC N2-band: ls_CVC_N2_119_dRext=0.0268_dRint=0.09_dRspi=0.0357.fits
# # RAVC L-band: ls_RAVC_L_285_dRext=0.0477_dRint=0.04_dRspi=0.0249.fits


# RAVC LS L-band:
f_lyot_stop = _tmp_dir + 'pupil/ls_RAVC_L_285_dRext=0.0477_dRint=0.04_dRspi=0.0249.fits',

Expand Down
2 changes: 1 addition & 1 deletion psi/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '1.0.0'
13 changes: 12 additions & 1 deletion psi/configParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Parameters(object):
``ncpa_dynamic`` -
``ncpa_sampling`` -
``ncpa_scaling`` -
``ncpa_expected_rms`` -
``ncpa_folder`` -
``ncpa_prefix`` -
``turb_folder`` -
Expand All @@ -71,6 +70,9 @@ def __init__(self, filename, logger=LazyLogger('Params')):
self.logger = logger

def readfile(self):
'''
Read configuration file -> create `conf` namespace
'''

#Exec the config file, which should contain a dict ``simConfiguration``
try:
Expand All @@ -85,6 +87,9 @@ def readfile(self):
self.params = conf

def check_parameters(self):
'''
Performs a number of sanity checks on the configuration parameters
'''
# TODO had a check that the Lyot stop is for the correct mode and band
# look at the file name and search for strings

Expand Down Expand Up @@ -139,6 +144,9 @@ def check_parameters(self):
self.params.save_results = True

def compute_parameters(self):
'''
Compute some parameters based on the configuration file parameters
'''
self.params.nb_ao_frames_per_science = int(self.params.dit / \
(self.params.ao_frame_decimation / self.params.ao_framerate))

Expand All @@ -151,6 +159,9 @@ def compute_parameters(self):


def loadConfiguration(filename):
'''
Load the configuration file and return a configuration object.
'''
cfg_obj = Parameters(filename)

cfg_obj.readfile()
Expand Down
68 changes: 64 additions & 4 deletions psi/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def aperture(self, aper):
self._aperture = aper

@abc.abstractmethod
def grabWfsTelemetry(self):
def grabWfsTelemetry(self, nbOfSeconds):
'''
Grab wavefront sensor telemetry and returns wavefront buffer
'''
pass

@abc.abstractmethod
def grabScienceImages(self):
def grabScienceImages(self, nbOfSeconds):
'''
Grab science images and returns science images buffer
'''
Expand Down Expand Up @@ -355,6 +355,17 @@ def _update_water_vapour(self, current_time):
def grabScienceImages(self, nbOfPastSeconds):
'''
Grab a buffer of science images
Parameters
------------
nbOfPastSeconds : float
number of seconds of science images (can be equivalent to one or several images)
Returns
--------
image_buffer : numpy ndarray
science image buffer of dimension (nbOfSciImages, nx, ny)
'''
self.nbOfSciImages = int(nbOfPastSeconds / self.sci_exptime)
assert self.nbOfSciImages <= nbOfPastSeconds / self.sci_exptime
Expand Down Expand Up @@ -485,8 +496,17 @@ def _grabOneScienceImage(self):

def grabWfsTelemetry(self, nbOfPastSeconds):
'''
Grab a buffer of WFS telemetry
Parameters
------------
nbOfPastSeconds : float
number of seconds of science images (can be equivalent to one or several images)
Returns
phase cube in units of radian
--------
phase_cube : numpy ndarray
phase cube in units of radian
'''
# self._compass_start_time=2011 # COMPASS 0 indexing in msec

Expand Down Expand Up @@ -524,10 +544,28 @@ def grabWfsTelemetry(self, nbOfPastSeconds):
return phase_cube

def setNcpaCorrection(self, phase):
'''
Apply NCPA correction
Parameters
----------
phase : numpy ndarray
phase correction to be applied
'''
self.phase_ncpa_correction = self.phase_ncpa_correction + phase

def synchronizeBuffers(self, wfs_telemetry_buffer, sci_image_buffer):
'''
Synchronize science and wfs telemetry buffers
Parameters
----------
wfs_telemetry_buffer : numpy ndarray
WFS telemetry buffer as returned by 'grabWfsTelemetry'
sci_image_buffer : numpy ndarray
Science image buffer as returned by 'grabScienceImages'
Note:
wfs_telemetry_buffer & sci_image_buffer are actually not used here.
To be realistic, one could correlate the tip-tilt in both to sync them.
Expand All @@ -553,6 +591,11 @@ def synchronizeBuffers(self, wfs_telemetry_buffer, sci_image_buffer):
return telemetry_indexing

def getNumberOfPhotons(self):
'''
Returns
--------
Number of photons for a single science exposure
'''
return self.num_photons

class DemoCompassSimInstrument(CompassSimInstrument):
Expand Down Expand Up @@ -651,8 +694,17 @@ def _grabOneScienceImage(self):

def grabWfsTelemetry(self, nbOfPastSeconds):
'''
Grab a buffer of WFS telemetry
Parameters
------------
nbOfPastSeconds : float
number of seconds of science images (can be equivalent to one or several images)
Returns
phase cube in units of radian
--------
phase_cube : numpy ndarray
phase cube in units of radian
'''
# self._compass_start_time=2011 # COMPASS 0 indexing in msec

Expand Down Expand Up @@ -690,10 +742,18 @@ def grabWfsTelemetry(self, nbOfPastSeconds):
return phase_cube

class HcipySimInstrument(GenericInstrument):
'''
Not implemented
'''
# raise NotImplementedError()
pass


class ErisInterfaceOffline(GenericInstrument):
'''
Not implemented
'''
# raise NotImplementedError()
pass


Expand Down
Loading

0 comments on commit 799f926

Please sign in to comment.