-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDefinitions_for_matrices.py
689 lines (558 loc) · 20.3 KB
/
Definitions_for_matrices.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 15 10:57:10 2021
@author: apotier
"""
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
from poppy import matrixDFT
fft = np.fft.fft2
ifft = np.fft.ifft2
shift = np.fft.fftshift
ishift=np.fft.ifftshift
def Upload_CoroConfig(ModelDirectory, coro, wavelength):
"""
Parameters
----------
ModelDirectory : path to model directory
coro : coro type
wavelength :
Returns
-------
mask384 : 2D apodizer
Pup384 : 2D pupil
ALC : 2D focal plane mask
Lyot384: 2D Lyot stop
"""
if coro == 'APLC':
mask384 = fits.getdata(ModelDirectory+'apod-4.0lovD_384-192.fits')
Pup384 = fits.getdata(ModelDirectory+'generated_VLT_pup_384-192.fits')
ALC = 'ALC2'
Lyot384 = fits.getdata(ModelDirectory+'sphere_stop_ST_ALC2.fits')
elif coro == 'FQPM':
#used to define the sampling of the focal images
mask384 = roundpupil(384,int(384/2))#fits.getdata(ModelDirectory+'apod-4.0lovD_384-192.fits')
# VLT pupil
Pup384 = fits.getdata(ModelDirectory+'generated_VLT_pup_384-192.fits')
ALC=''
# Lyot stop
Lyot384 = fits.getdata(ModelDirectory+'generated_ST_4QPM2_Potier.fits')
return mask384, Pup384, ALC, Lyot384
def roundpupil(nbpix,prad1):
"""
Generate unobstructed pupil
Parameters
----------
nbpix : size image
prad1 : pupil radius in pixels
Returns
-------
pupilnormal : 2D pupil binary
"""
xx, yy = np.meshgrid(np.arange(nbpix)-(nbpix)/2, np.arange(nbpix)-(nbpix)/2)
rr = np.hypot(yy, xx)
pupilnormal = np.zeros((nbpix,nbpix))
pupilnormal[rr<=prad1] = 1.
return pupilnormal
def SaveFits(image,head,doc_dir2,name,replace=False):
"""
Parameters
----------
image : TYPE
DESCRIPTION.
head : TYPE
DESCRIPTION.
doc_dir2 : TYPE
DESCRIPTION.
name : TYPE
DESCRIPTION.
replace : TYPE, optional
DESCRIPTION. The default is False.
Returns
-------
None.
"""
hdu = fits.PrimaryHDU(image)
hdul = fits.HDUList([hdu])
hdr = hdul[0].header
hdr.set(head[0],head[1])
hdu.writeto(doc_dir2+name+'.fits', overwrite=replace)
#RGa
def definition_isz(pupsizetmp,wave):
"""
Extract relevant data
Parameters
----------
pupsizetmp : Entrance pupil size in pix (should be 384)
wave : Wavelength
Returns
-------
isz: lyot plane image size
ld_mas: l/D in milliarcsec
"""
pupsizeinmeter = 8 #Pupsizeinmeter
#Raccourcis conversions angles
d2rad = np.pi / 180.0 # degree to radian conversion factor
d2arcsec = 3600
arcsec2rad = d2rad/d2arcsec # radian to milliarcsecond conversion factor
#SPHERE detector resol
resolinarcsec_pix = 12.25e-3 #arcsec/pix
resolinrad_pix = resolinarcsec_pix*arcsec2rad #rad/pix
resolinpix_rad = 1 / resolinrad_pix #pix/rad
ld_rad = wave / pupsizeinmeter #lambda/D en radian
ld_p = ld_rad * resolinpix_rad #lambda/D en pixel
ld_mas = ld_rad / arcsec2rad *1e3 #lambda/D en milliarcsec
isz=int(pupsizetmp*ld_p)#-1 # Nombre de pixels dans le plan pupille pour atteindre la résolution ld_p voulue
return [isz,ld_mas]
def pupiltodetector(input_wavefront, wave, lyot_mask, Name_ALC, isz_foc, coro, pupparf=False):
"""
Propagate E-field from entrance pupil plane to detector
Parameters
----------
input_wavefront : E-field in entrance pupil
wave : wavelength
lyot_mask : 2D Lyot mask
Name_ALC : Lyot focal mask
isz_foc : Processed image size on detector
coro : coronagraph type
pupparf : boolean representing perfect pupil
Raises
------
ValueError
DESCRIPTION.
Returns
-------
detector_img: image on detector
"""
pup_shape = input_wavefront.shape
# Size of pupil in pixel (384)
pupsize = pup_shape[0]
# Nombre de pixels dans le plan pupille pour atteindre la résolution ld_p voulue
[isz_pup,ld_mas] = definition_isz(pupsize, wave)
if coro == 'APLC':
if Name_ALC == 'ALC2':
# Taille masque corono en lambda/D ALC2
radFPMinld=92.5/ld_mas
elif Name_ALC == 'ALC3':
# Taille masque corono en lambda/D ALC3
radFPMinld=120/ld_mas
else:
raise ValueError("ALC name unsupported")
# [pixels/(l/D)] sampling factor of the computed focal plane field with the MFT
mft_sampling = 100
# focal plane field of view for computing the field. REQUIRED??
occulter_fov = 5
# radius of the occulting mask in pixels.
occ_rad_pix = radFPMinld * mft_sampling
# force even dimension
npix = (int(np.round(occulter_fov * mft_sampling)) // 2 ) *2
# focal plane field of view for computing the field.
occulter_fov = float(npix) / float(mft_sampling)
# Computing focal plane image
focal_plane = matrixDFT.matrix_dft(input_wavefront, occulter_fov, npix, centering='FFTSTYLE')
# Computing occulted area in pixel
occulter_area = roundpupil(npix, occ_rad_pix)
# Computing rejected lyot plane
lyot_plane_rejected = matrixDFT.matrix_dft(focal_plane*occulter_area, occulter_fov, pup_shape, inverse=True, centering='FFTSTYLE')
# E-field Lyot stop
before_lyot_stop = (input_wavefront - lyot_plane_rejected)
after_lyot_stop = before_lyot_stop * lyot_mask
# Resample Lyot stop
after_lyot_stop2 = zeropad(after_lyot_stop, isz_pup)
elif coro == 'FQPM':
# Proper sampling of input entrance pupil E-field and Lyot
input_wavefront = zeropad(input_wavefront, isz_pup)
lyot_mask = zeropad(lyot_mask, isz_pup)
# Centering between 4 pixels
PSFcentering = translationFFT(isz_pup,.5,.5)
# Create FQPM
fqpm_mask = create_fqpm(isz_pup)
# Compute Lyot stop E-field
before_lyot_stop = goto_pupil(goto_focal(input_wavefront*PSFcentering)*fqpm_mask)
# Return perfect pupil for FQPM (i.e. pupil that null the E-field in the focal plane with no aberration)
# Axel: I think it is unnecessary
if pupparf == True:
pupperf = (shift(ifft(fft(shift(before_lyot_stop*(1-lyot_mask)))*fqpm_mask))*np.conjugate(PSFcentering))#[int(isz_pup/2-pupsize/2):int(isz_pup/2+pupsize/2),int(isz_pup/2-pupsize/2):int(isz_pup/2+pupsize/2)]
return cropimage(pupperf, isz_pup/2, isz_pup/2, pupsize)
# Filtering Lyot stop E field with Lyot stop pupil
after_lyot_stop2 = before_lyot_stop * lyot_mask * np.conjugate(PSFcentering)
else:
print('coro should be APLC or FQPM')
# Propagate LS to detector
detector_img = goto_focal(after_lyot_stop2)#[int(isz_pup/2-isz_foc/2):int(isz_pup/2+isz_foc/2),int(isz_pup/2-isz_foc/2):int(isz_pup/2+isz_foc/2)]
# Crop image to relevant size
detector_img = cropimage(detector_img, isz_pup/2, isz_pup/2, isz_foc)
return detector_img
def goto_focal(pupil_plane):
"""
Propagate E-field from pupil plane to focal plane
Parameters
----------
pupil_plane : TYPE
DESCRIPTION.
Returns
-------
focal_plane : TYPE
DESCRIPTION.
"""
pupil_plane = shift(pupil_plane)
focal_plane = fft(pupil_plane)
focal_plane = shift(focal_plane)
return focal_plane
def goto_pupil(focal_plane):
"""
Propagate E-field from focal plane to pupil plane
Parameters
----------
focal_plane : TYPE
DESCRIPTION.
Returns
-------
pupil_plane : TYPE
DESCRIPTION.
"""
focal_plane = ishift(focal_plane)
pupil_plane = ifft(focal_plane)
pupil_plane = ishift(pupil_plane)
return pupil_plane
def invertDSCC(interact, cut ,goal='e', regul="truncation", visu=False):
"""
Invert with SVD + regularization
Parameters
----------
interact : TYPE
DESCRIPTION.
cut : TYPE
DESCRIPTION.
goal : TYPE, optional
DESCRIPTION. The default is 'e'.
regul : TYPE, optional
DESCRIPTION. The default is "truncation".
visu : TYPE, optional
DESCRIPTION. The default is False.
Returns
-------
list
DESCRIPTION.
"""
U, s, V = np.linalg.svd(interact, full_matrices=False)
S = np.diag(s)
InvS=np.linalg.inv(S)
if(visu==True):
plt.plot(np.diag(InvS),'r.')
plt.yscale('log')
if goal == 'e':
InvS[np.where(InvS>cut)]=0
if goal == "c":
if regul == "truncation":
InvS[cut:] = 0
if regul == "tikhonov":
InvS = np.diag(s / (s**2 + s[cut]**2))
if visu == True:
plt.plot(np.diag(InvS), "b.")
plt.yscale("log")
# plt.show()
plt.show()
pseudoinverse = np.dot(np.dot(np.transpose(V),InvS),np.transpose(U))
return [np.diag(InvS),pseudoinverse]
def createvectorprobes(input_wavefront, wave, lyot_mask , Name_ALC , isz_foc, pushact, posprobes , cutsvd, coro):
"""
Create PW matrix
Parameters
----------
input_wavefront : TYPE
DESCRIPTION.
wave : TYPE
DESCRIPTION.
lyot_mask : TYPE
DESCRIPTION.
Name_ALC : TYPE
DESCRIPTION.
isz_foc : TYPE
DESCRIPTION.
pushact : TYPE
DESCRIPTION.
posprobes : TYPE
DESCRIPTION.
cutsvd : TYPE
DESCRIPTION.
coro : TYPE
DESCRIPTION.
Returns
-------
list
DESCRIPTION.
"""
# Initialize parameters
pup_shape = input_wavefront.shape
# Size of pupil in pixel (384)
pupsize = pup_shape[0]
numprobe = len(posprobes)
deltapsik = np.zeros((numprobe , isz_foc , isz_foc),dtype=complex)
probephase = np.zeros((numprobe , pupsize , pupsize))
matrix = np.zeros((numprobe,2))
Vecteurenvoi = np.zeros((isz_foc**2,2,numprobe))
SVD = np.zeros((2,isz_foc,isz_foc))
[isz_pup,ld_mas] = definition_isz(pupsize, wave)
# Create off-axis PSF
maskoffaxis = cropimage(translationFFT(isz_pup,30,30), int(isz_pup/2), int(isz_pup)/2, pupsize)
OffAxisPSF = pupiltodetector(maskoffaxis*input_wavefront, wave, lyot_mask , Name_ALC , isz_foc,coro)
squaremaxPSF = np.amax(np.abs(OffAxisPSF))
# Regularization
cutsvd = 0.3*squaremaxPSF*8/(400/37)
# Get constant E-field in the detector with corono
pupilnoabb = pupiltodetector(input_wavefront , wave , lyot_mask , Name_ALC , isz_foc,coro)
k=0
for i in posprobes:
print(i)
# Poke one actuator and compute complex entrance pupil
probephase[k] = pushact[i]
probephase[k] = 2*np.pi*(probephase[k])*1e-9/wave
#entrance pupil plane field (can be real, or complex with amplitude and phase)
input_wavefront_k = input_wavefront*(1+1j*probephase[k])
# Propagate input through the coronagraph, remove constant E-field and normalize with PSF
deltapsikbis = pupiltodetector(input_wavefront_k, wave,lyot_mask,Name_ALC,isz_foc,coro)
deltapsik[k] = (deltapsikbis-pupilnoabb)/squaremaxPSF
k=k+1
# invert matrix
l=0
for i in np.arange(isz_foc):
for j in np.arange(isz_foc):
matrix[:,0] = np.real(deltapsik[:,i,j])
matrix[:,1] = np.imag(deltapsik[:,i,j])
try:
SVD[:,i,j] = invertDSCC(matrix,cutsvd,visu=False)[0]
Vecteurenvoi[l] = invertDSCC(matrix,cutsvd,visu=False)[1]
except:
print('Careful: Error! for l='+str(l))
SVD[:,i,j] = np.zeros(2)
Vecteurenvoi[l] = np.zeros((2,numprobe))
l = l+1
return [Vecteurenvoi,SVD,abs(deltapsik[0])**2,abs(deltapsik[1])**2]
def creatingWhichinPupil(pupil, pushact, cutinpupil):
"""
Compute an array with actuator indices that are located inside the pupil
Parameters
----------
pupil : TYPE
DESCRIPTION.
pushact : TYPE
DESCRIPTION.
cutinpupil : TYPE
DESCRIPTION.
Returns
-------
WhichInPupil : TYPE
DESCRIPTION.
"""
WhichInPupil = []
for i in np.arange(len(pushact)):
Psivector = - pushact[i]
cut = cutinpupil * np.sum(-pushact[182])
if(np.sum(Psivector * pupil) > cut):
WhichInPupil.append(i)
WhichInPupil = np.array(WhichInPupil)
return WhichInPupil
def creatingMaskDH(dimimages,
shape,
choosepixDH=[8, 35, -35, 35],
circ_rad=[8, 10],
circ_side="Full",
circ_offset=8,
circ_angle=0):
""" --------------------------------------------------
Create a binary mask.
Parameters:
----------
dimimages: int, size of the output squared mask
shape: string, can be 'square' or 'circle' , define the shape of the binary mask.
choosepixDH: 1D array, if shape is 'square', define the edges of the binary mask in pixels.
circ_rad: 1D array, if shape is 'circle', define the inner and outer edge of the binary mask
circ_side: string, if shape is 'circle', can define to keep only one side of the circle
circ_offset : float, remove pixels that are closer than circ_offset if circ_side is set
circ_angle : float, if circ_side is set, remove pixels within a cone of angle circ_angle
Return:
------
maskDH: 2D array, binary mask
-------------------------------------------------- """
xx, yy = np.meshgrid(
np.arange(dimimages) - (dimimages) / 2,
np.arange(dimimages) - (dimimages) / 2)
rr = np.hypot(yy, xx)
if shape == "square":
maskDH = np.ones((dimimages, dimimages))
maskDH[xx < choosepixDH[0]] = 0
maskDH[xx > choosepixDH[1]] = 0
maskDH[yy < choosepixDH[2]] = 0
maskDH[yy > choosepixDH[3]] = 0
if shape == "circle":
maskDH = np.ones((dimimages, dimimages))
maskDH[rr >= circ_rad[1]] = 0
maskDH[rr < circ_rad[0]] = 0
if circ_side == "Right":
maskDH[xx < np.abs(circ_offset)] = 0
if circ_angle != 0:
maskDH[yy - xx / np.tan(circ_angle * np.pi / 180) > 0] = 0
maskDH[yy + xx / np.tan(circ_angle * np.pi / 180) < 0] = 0
if circ_side == "Left":
maskDH[xx > -np.abs(circ_offset)] = 0
if circ_angle != 0:
maskDH[yy - xx / np.tan(circ_angle * np.pi / 180) < 0] = 0
maskDH[yy + xx / np.tan(circ_angle * np.pi / 180) > 0] = 0
if circ_side == "Bottom":
maskDH[yy < np.abs(circ_offset)] = 0
if circ_angle != 0:
maskDH[yy - xx * np.tan(circ_angle * np.pi / 180) < 0] = 0
maskDH[yy + xx * np.tan(circ_angle * np.pi / 180) < 0] = 0
if circ_side == "Top":
maskDH[yy > -np.abs(circ_offset)] = 0
if circ_angle != 0:
maskDH[yy - xx * np.tan(circ_angle * np.pi / 180) > 0] = 0
maskDH[yy + xx * np.tan(circ_angle * np.pi / 180) > 0] = 0
return maskDH
def creatingCorrectionmatrix(input_wavefront, wave, lyot_mask , Name_ALC , isz_foc, pushact, Whichact, coro):
"""
Create full jacobian
Parameters
----------
input_wavefront : TYPE
DESCRIPTION.
wave : TYPE
DESCRIPTION.
lyot_mask : TYPE
DESCRIPTION.
Name_ALC : TYPE
DESCRIPTION.
isz_foc : TYPE
DESCRIPTION.
pushact : TYPE
DESCRIPTION.
Whichact : TYPE
DESCRIPTION.
coro : TYPE
DESCRIPTION.
Returns
-------
Gmatrixbis : TYPE
DESCRIPTION.
"""
pup_shape = input_wavefront.shape
# Size of pupil in pixel (384)
pupsize = pup_shape[0]
[isz_pup,ld_mas] = definition_isz(pupsize, wave)
# Create off-axis PSF
maskoffaxis = cropimage(translationFFT(isz_pup,30,30), int(isz_pup/2), int(isz_pup)/2, pupsize)
OffAxisPSF = pupiltodetector(maskoffaxis*input_wavefront, wave, lyot_mask , Name_ALC , isz_foc, coro)
squaremaxPSF = np.amax(np.abs(OffAxisPSF))
# Get constant E-field in the detector with corono
pupilnoabb = pupiltodetector(input_wavefront , wave , lyot_mask , Name_ALC , isz_foc, coro)
# Jacobian calculation cube (Real-Imag, pixels, nb modes)
Gmatrixbis=np.zeros((2,int(isz_foc*isz_foc),len(Whichact)))
k=0
for i in Whichact:
print(i)
# Poke one actuator and compute complex entrance pupil
Psivector = pushact[i]
Psivector = 2*np.pi*(Psivector)*1e-9/wave
# Entrance pupil plane field (can be real, or complex with amplitude and phase)
input_wavefront_k = input_wavefront*(1+1j*Psivector)
# Propagate input through the coronagraph, remove constant E-field and normalize with PSF
Gvectorbisbis = (pupiltodetector(input_wavefront_k , wave , lyot_mask , Name_ALC , isz_foc, coro)- pupilnoabb)/squaremaxPSF
# Fill jacobian with real data
Gmatrixbis[0,:,k] = np.real(Gvectorbisbis).flatten()
# Fill jacobian with imag data
Gmatrixbis[1,:,k] = np.imag(Gvectorbisbis).flatten()
k=k+1
return Gmatrixbis
def get_masked_jacobian(complex_jacobian, mask):
"""
Extract DH pixels in jacobian calculated with creatingCorrectionmatrix
Parameters
----------
complex_jacobian : (Real-Imag, pixels, nb modes)
mask : TYPE
DESCRIPTION.
Returns
-------
masked_jacobian : TYPE
DESCRIPTION.
"""
mask_flattened = mask.flatten()
# Create jacobian in good dimensions (real values + imag values, nb modes)
masked_jacobian = np.zeros((2*int(np.sum(mask)),complex_jacobian.shape[2]))
# Fill in jacobian
masked_jacobian[0:int(np.sum(mask))] = complex_jacobian[0,np.where(mask_flattened)]
masked_jacobian[int(np.sum(mask)):] = complex_jacobian[1,np.where(mask_flattened)]
return masked_jacobian
def translationFFT(dim_im,a,b):
""" --------------------------------------------------
Create a phase ramp of size (dim_im,dim_im) that can be used as follow
to shift one image by (a,b) pixels : shift_im = real(fft(ifft(im)*exp(i phase ramp)))
Parameters
----------
dim_im : int
Size of the phase ramp (in pixels)
a : float
Shift desired in the x direction (in pixels)
b : float
Shift desired in the y direction (in pixels)
Returns
------
masktot : 2D array
Phase ramp
-------------------------------------------------- """
# Verify this function works
maska = np.linspace(-np.pi * a, np.pi * a, dim_im, endpoint = False)
maskb = np.linspace(-np.pi * b, np.pi * b, dim_im, endpoint = False)
xx, yy = np.meshgrid(maska, maskb)
return np.exp(-1j * xx) * np.exp(-1j * yy)
def zeropad(tab,dim):
"""
Zero padding around image
Parameters
----------
tab : image
dim : new image dimension
Returns
-------
newtab : image in new dimension, padded with zeroes
"""
newtab = np.zeros((dim,dim),dtype=complex)
left = int(dim/2-tab.shape[0]/2)
right = int(dim/2+tab.shape[0]/2)
bottom = int(dim/2-tab.shape[1]/2)
top = int(dim/2+tab.shape[1]/2)
newtab[left:right,bottom:top] = tab
return newtab
def cropimage(img, ctr_x, ctr_y, newsizeimg):
""" --------------------------------------------------
Crop an image
Parameters:
----------
img: 2D array, image to crop
ctr_x: int, center of the cropped image in the x direction
ctr_y: int, center of the cropped image in the y direction
newsizeimg: int, size of the new image in x and y direction (same dimentsion for both)
Return:
------
cropped: 2D array, cropped image
-------------------------------------------------- """
newimgs2 = newsizeimg / 2
cropped = img[int(ctr_x-newimgs2):int(ctr_x+newimgs2),int(ctr_y-newimgs2):int(ctr_y+newimgs2)]
return cropped
def create_fqpm(isz_pup):
"""
Create Four Quadrant Phase Mask of size isz_pup
Parameters
----------
isz_pup : TYPE
DESCRIPTION.
Returns
-------
None.
"""
fqpm_mask = np.ones((isz_pup,isz_pup))
fqpm_mask[0:int(isz_pup/2),0:int(isz_pup/2)] = -1
fqpm_mask[int(isz_pup/2):isz_pup,int(isz_pup/2):isz_pup] = -1
return fqpm_mask