Skip to content

Commit

Permalink
Create setup mechanism and optimize imports
Browse files Browse the repository at this point in the history
This commit introduces a setup mechanism based on setuptools. As a result, it is now geared to being used as an installed package.
The imports have been modified/simplified to work with this new paradigm; import optimization has also been done in an effort to simplify and standardize the code structure.
The __load__opao.py files for configuring the path are no longer required and have been removed; the MKL availability check and additional functionality present in those files has been moved to the top level __init__.py.
The tutorials have also been modified to work with this new approach.
Instructions for installing this package have been added to the README file.
  • Loading branch information
joao-aveiro committed Nov 17, 2022
1 parent 66c6195 commit d1768da
Show file tree
Hide file tree
Showing 60 changed files with 10,344 additions and 10,683 deletions.

This file was deleted.

7 changes: 0 additions & 7 deletions AO_modules/tools/__init__.py

This file was deleted.

1,422 changes: 712 additions & 710 deletions AO_modules/Atmosphere.py → OOPAO/Atmosphere.py
100755 → 100644

Large diffs are not rendered by default.

857 changes: 429 additions & 428 deletions AO_modules/DeformableMirror.py → OOPAO/DeformableMirror.py
100755 → 100644

Large diffs are not rendered by default.

83 changes: 43 additions & 40 deletions AO_modules/Detector.py → OOPAO/Detector.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 14:37:29 2020
@author: cheritie
"""

import numpy as np
import inspect
class Detector:
def __init__(self,nRes,readoutNoise=0,photonNoise=0,QE=1):
self.resolution=nRes
self.QE=1
self.readoutNoise=readoutNoise
self.photonNoise=photonNoise
self.frame=np.zeros([nRes,nRes])
self.tag='detector'

def rebin(self,arr, new_shape):
shape = (new_shape[0], arr.shape[0] // new_shape[0],
new_shape[1], arr.shape[1] // new_shape[1])
out = (arr.reshape(shape).mean(-1).mean(1)) * (arr.shape[0] // new_shape[0]) * (arr.shape[1] // new_shape[1])
return out

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def show(self):
attributes = inspect.getmembers(self, lambda a:not(inspect.isroutine(a)))
print(self.tag+':')
for a in attributes:
if not(a[0].startswith('__') and a[0].endswith('__')):
if not(a[0].startswith('_')):
if not np.shape(a[1]):
tmp=a[1]
try:
print(' '+str(a[0])+': '+str(tmp.tag)+' object')
except:
print(' '+str(a[0])+': '+str(a[1]))
else:
if np.ndim(a[1])>1:
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 14:37:29 2020
@author: cheritie
"""

import inspect

import numpy as np


class Detector:
def __init__(self,nRes,readoutNoise=0,photonNoise=0,QE=1):
self.resolution=nRes
self.QE=1
self.readoutNoise=readoutNoise
self.photonNoise=photonNoise
self.frame=np.zeros([nRes,nRes])
self.tag='detector'

def rebin(self,arr, new_shape):
shape = (new_shape[0], arr.shape[0] // new_shape[0],
new_shape[1], arr.shape[1] // new_shape[1])
out = (arr.reshape(shape).mean(-1).mean(1)) * (arr.shape[0] // new_shape[0]) * (arr.shape[1] // new_shape[1])
return out

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def show(self):
attributes = inspect.getmembers(self, lambda a:not(inspect.isroutine(a)))
print(self.tag+':')
for a in attributes:
if not(a[0].startswith('__') and a[0].endswith('__')):
if not(a[0].startswith('_')):
if not np.shape(a[1]):
tmp=a[1]
try:
print(' '+str(a[0])+': '+str(tmp.tag)+' object')
except:
print(' '+str(a[0])+': '+str(a[1]))
else:
if np.ndim(a[1])>1:
print(' '+str(a[0])+': '+str(np.shape(a[1])))
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 3 10:56:59 2020
@author: cheritie
"""

# -*- coding: utf-8 -*-
"""
Created on Fri Apr 3 10:56:59 2020
@author: cheritie
"""
Loading

0 comments on commit d1768da

Please sign in to comment.