Commit c2c4d262 authored by chazelas's avatar chazelas

update the simulator before discussion with B. Delabre

parent ab2e882b
......@@ -188,7 +188,7 @@ class Spectro_simulate():
self.out.clear_output()
with self.out:
self.c_m=(1+self.OrderOverlap.value/100.)/2.
#print("coucou")
##print("coucou")
c_pix = 1- self.MarginLargest_order.value/100
Dlfsr_max = ( self.nx.value*self.lmax.value)/(self.spl_PSF.value*self.Res.value)
......@@ -207,7 +207,7 @@ class Spectro_simulate():
self.order_max.value = round(2*sin(self.Bldeg.value*pi/180)/(self.opt_d.value*1000*self.lmin.value*0.000000001))
self.No.value = self.order_max.value - self.order_min.value
Dlb = 2*sin(self.Bldeg.value*pi/180)/self.opt_d.value/(self.order_max.value*(self.order_max.value-1))
print(Dlb)
#print(Dlb)
Dbfsr_max = (self.c_m*2)*2 * sin(self.Bldeg.value*pi/180)/(self.order_min.value*cos(self.Bldeg.value*pi/180))
loc = 2*sin(self.Bldeg.value*pi/180)/(self.order_min.value*self.opt_d.value)*1000000
......@@ -220,7 +220,7 @@ class Spectro_simulate():
self.f_c.value = self.spl_PSF.value * self.pix_size.value *1e-3 / Dbres
self.ActualSampling.value = Dbres * self.f_c.value / (self.pix_size.value*1e-3)
#print(Dbfsr_max)
##print(Dbfsr_max)
self.Field_Camera.value = (self.nx.value * self.pix_size.value * 1e-3 / self.f_c.value ) *180/pi
......@@ -232,7 +232,7 @@ class Spectro_simulate():
self.cameraFN.value = self.f_c.value / self.g_height.value
print(dth_dl)
#print(dth_dl)
# Distance between the fibers in the focal plane
......@@ -259,7 +259,7 @@ class Spectro_simulate():
# Efficiency of the orders
#plot(atmos[:,0],atmos[:,1],"k",linewidth=0.2)
print("density : ", self.opt_d.value)
#print("density : ", self.opt_d.value)
llll = linspace(self.elmin.value,self.elmax.value,100000)
eff_g = zeros(llll.shape)
eff_gd = zeros(llll.shape)
......@@ -284,7 +284,7 @@ class Spectro_simulate():
figure()
plot(oooo[25:],eps0)
#print(eps0)
##print(eps0)
figure(figsize=(14, 4))
......@@ -297,7 +297,7 @@ class Spectro_simulate():
dl = loc / i * self.c_m
ll = linspace(loc - dl, loc + dl, 10000)
# print(i,loc-dl,loc+dl)
# #print(i,loc-dl,loc+dl)
beth = arcsin(i * ll * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
beth_c = arcsin(i * loc * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
pix = (beth - beth_c) * self.f_c.value * 1000 / self.pix_size.value + self.nx.value / 2
......@@ -317,17 +317,17 @@ class Spectro_simulate():
ll = linspace(loc-dl,loc+dl,100)
ml = (llll >= loc-dl)&(llll <= loc+dl)
#print(i,loc-dl,loc+dl)
##print(i,loc-dl,loc+dl)
beth = arcsin(i*ll*1e-6*self.opt_d.value-sin(self.Bldeg.value*pi/180))
bethg = arcsin(i*llll[ml]*1e-6*self.opt_d.value-sin(self.Bldeg.value*pi/180))
beth_c = arcsin(i*loc*1e-6*self.opt_d.value-sin(self.Bldeg.value*pi/180))
pix = (beth-beth_c)*self.f_c.value*1000/self.pix_size.value + self.nx.value/2
pix_g = (bethg-beth_c)*self.f_c.value*1000/self.pix_size.value + self.nx.value/2
#print(pix)
##print(pix)
beth[(pix < 0)|(pix > self.nx.value)] = nan
sig = 1e6/self.opt_d.value
#print(loc, sig,i * loc * 1e-6 * self.opt_d.value,beth_c,ptp(beth)*180/pi)
##print(loc, sig,i * loc * 1e-6 * self.opt_d.value,beth_c,ptp(beth)*180/pi)
eff = sinc(pi*(ll-loc)/(8*dl))**2
delta = (pi*sig*cos(self.Bldeg.value*pi/180)/(ll)*sin(beth-beth_c))
......@@ -367,14 +367,14 @@ class Spectro_simulate():
dl_order_b = 2*sin(self.Bldeg.value*pi/180)*(1/((self.order_max.value-1)*self.opt_d.value)-1/(self.order_max.value*self.opt_d.value))
dl_order_r = 2*sin(self.Bldeg.value*pi/180)*(1/((self.order_min.value)*self.opt_d.value)-1/((self.order_min.value+1)*self.opt_d.value))
print(dl_order_b)
#print(dl_order_b)
height_per_order = self.Nfiber.value * (self.InterFiber.value+self.orderCrossThickness.value) + self.InterOrder.value
dth_dl = self.pix_size.value*1e-3 * height_per_order /(self.f_c.value*dl_order_b)
dth_dl_r = self.pix_size.value*1e-3 * height_per_order /(self.f_c.value*dl_order_r) * 0.9
print(height_per_order)
print(self.pix_size.value*1e-3 * height_per_order)
print(dth_dl)
print(dth_dl_r)
#print(height_per_order)
#print(self.pix_size.value*1e-3 * height_per_order)
#print(dth_dl)
#print(dth_dl_r)
......@@ -397,8 +397,8 @@ class Spectro_simulate():
# case of the prism
print(dndlSF11(lomin/1000.))
print(self.g_height.value)
#print(dndlSF11(lomin/1000.))
#print(self.g_height.value)
#dth_dl1 = 1.25 * dth_dl
self.prism_thickness.value = dth_dl_r * self.g_height.value / dndlSF11(lomax/1000.)
self.prism_apex.value = 2*arcsin(dth_dl_r /(sqrt(dth_dl_r**2*nSF11(lomax/1000)**2+4*dndlSF11(lomax/1000.)**2)))*180/pi
......@@ -485,8 +485,8 @@ class Spectro_simulate():
def export_spectro(self,b):
with self.out:
#print("coucou")
#print(self.__dict__)
##print("coucou")
##print(self.__dict__)
workbook = xlsxwriter.Workbook('spectro'+time.strftime("%Y%m%d-%H%M%S",time.localtime())+'.xlsx')
worksheet = workbook.add_worksheet("spectro")
worksheet_order = workbook.add_worksheet("orders")
......@@ -699,7 +699,7 @@ class Spectro_simulate():
dl = loc / i * self.c_m
ll = linspace(loc - dl, loc + dl, 10000)
# print(i,loc-dl,loc+dl)
# #print(i,loc-dl,loc+dl)
beth = arcsin(i * ll * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
beth_c = arcsin(i * loc * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
pix = (beth - beth_c) * self.f_c.value * 1000 / self.pix_size.value + self.nx.value / 2
......@@ -710,7 +710,7 @@ class Spectro_simulate():
pmax = pix.max()
off = (self.nx.value /2 - (pmin+pmax)/2)
print("offsets : ",pmin,pmax,off)
#print("offsets : ",pmin,pmax,off)
......@@ -728,7 +728,7 @@ class Spectro_simulate():
ll = linspace(loc - dl, loc + dl, 10000)
# print(i,loc-dl,loc+dl)
# #print(i,loc-dl,loc+dl)
beth = arcsin(i * ll * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
beth_c = arcsin(i * loc * 1e-6 * self.opt_d.value - sin(self.Bldeg.value * pi / 180))
pix = (beth - beth_c) * self.f_c.value * 1000 / self.pix_size.value + self.nx.value / 2
......@@ -763,15 +763,15 @@ class Spectro_simulate():
(arange(self.Nfiber.value)-floor(self.Nfiber.value/2))*self.Fiber_distance.value]
f = self.CollFN.value/(0.5/ self.NA_fiber.value)*f
op.fields(fields=f)
print(c_[zeros(int(self.Nfiber.value)),
(arange(self.Nfiber.value)-self.Nfiber.value/2)*self.Fiber_distance.value])
#print(c_[zeros(int(self.Nfiber.value)),
# (arange(self.Nfiber.value)-self.Nfiber.value/2)*self.Fiber_distance.value])
ocenter = floor((self.order_min.value + self.order_max.value)/2)
orders = array([self.order_min.value,self.order_min.value+1,
ocenter,ocenter+1,self.order_max.value-1,self.order_max.value])
wls=self.waves(orders)
print(wls)
#print(wls)
op.wavelength_flat(wavelength=wls[:,2])
op.nconfigs(6)
op.wave_config(wavelengths=wls.T)
......@@ -781,14 +781,14 @@ class Spectro_simulate():
fcol = floor((self.g_height.value*self.CollFN.value/10)+1)*10
print(fcol)
#print(fcol)
s0=zmxgen.surface(0,0,0)
thetacol = 10
dycol = fcol*2/(1+cos(thetacol*pi/180))*sin(thetacol*pi/180)
fs = fcol*2/(1+cos(thetacol*pi/180))
s1=zmxgen.coordbreak(decentery=dycol,tiltx=10)
s1=zmxgen.coordbreak(decentery=dycol,tiltx=10,order = 1)
s2=zmxgen.surface(0,0,fcol)
s3=zmxgen.surface(-1/(2*fcol),-1,0,glass="MIRROR",comment="Collimator",decentery=-dycol,reverse=True)
......@@ -804,7 +804,7 @@ class Spectro_simulate():
s12=zmxgen.coordbreak(tilty="P6 -1 0")
s13=zmxgen.surface(0,0,fcol)
s14=zmxgen.surface(-1/(2*fcol),-1,0,glass="MIRROR",comment="Collimator",decentery=-dycol,reverse=True)
s15=zmxgen.coordbreak(decentery=-dycol)
s15=zmxgen.coordbreak(decentery=-dycol,order =1)
s16=zmxgen.surface(0,0,-fcol,decentery=dycol)
s17=zmxgen.surface(0,0,0)
s18=zmxgen.surface(0,0,"P16 -1 0",glass="MIRROR",comment="Focal mirror",decentery=-dycol)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment