Commit 51462dbe authored by chazelas's avatar chazelas

* update the simulator to allow to change slightly the focal length of the...

* update the simulator to allow to change slightly the focal length of the camera in order to pass smoothly between having the requested resolution or having all on the CCD.

* remove the warnings from the notebook
parent c2c4d262
from pylab import *
from ipywidgets import Layout, Button, Box, FloatText, Textarea, Dropdown, Label, IntSlider, interact, Output, Checkbox, RadioButtons, Text
from ipywidgets import Layout, Button, Box, FloatText, Textarea, Dropdown, Label, IntSlider, interact, Output, Checkbox, RadioButtons, Text, FloatSlider
import pandas as pd
from scipy.interpolate import interp1d
import xlsxwriter
......@@ -46,7 +46,8 @@ class Spectro_simulate():
self.Bldeg = Dropdown(value=70.0,options=blaze,layout=short_input)
self.real_d = Dropdown(options=densite,layout=short_input)
self.use_real_grating = Checkbox(value=False, description='Use real grating')
self.reduce_sampling_or_out_of_ccd = RadioButtons(value ="Keep resolution" , options=["Reduce resolution","Keep resolution"])
self.reduce_sampling_or_out_of_ccd = RadioButtons(value ="Keep resolution" , options=["Reduce resolution","Keep resolution","Tune"])
self.resolution_slider = FloatSlider(value = 1, min = 0, max = 1)
self.opt_d = FloatText(layout=short_input)
self.order_min = FloatText(layout=short_input)
self.order_max = FloatText(layout=short_input)
......@@ -124,7 +125,8 @@ class Spectro_simulate():
Label(value='Order Overlap in %'),self.OrderOverlap], layout=self.form_item_layout),
Box([Label(value='Real Density'),self.use_real_grating,self.real_d], layout=self.form_item_layout),
Box([Label(value='How to deal with imperfection'),self.reduce_sampling_or_out_of_ccd], layout=self.form_item_layout),
Box([Label(value='Resolution Tuning'), self.resolution_slider],
layout=self.form_item_layout),
Box([Label(value='Optimal density'),self.opt_d,
Label(value='Real Sampling'),self.ActualSampling], layout=self.form_item_layout),
Box([Label(value='Margin on the diffraction'),self.diffraction_margin],layout=self.form_item_layout),
......@@ -171,7 +173,7 @@ class Spectro_simulate():
flex_flow='column',
border='solid 1px',
justify='space-around',
width='60%'
width='70%'
))
......@@ -181,7 +183,9 @@ class Spectro_simulate():
self.compute.on_click(self.compute_spectro)
self.exportBtn.on_click(self.export_spectro)
self.exportZMXBtn.on_click(self.export_spectro_zmx)
self.resolution_slider.observe(self.tune_resolution,names="value")
self.reduce_sampling_or_out_of_ccd.observe(self.tune_resolution, names="value")
self.use_real_grating.observe(self.tune_resolution, names="value")
def compute_spectro(self,b,export_graph=False):
......@@ -216,8 +220,12 @@ class Spectro_simulate():
if "Reduce" in self.reduce_sampling_or_out_of_ccd.value:
self.f_c.value = c_pix * self.nx.value * self.pix_size.value * 1e-3 / Dbfsr_max
else:
elif "Keep" in self.reduce_sampling_or_out_of_ccd.value:
self.f_c.value = self.spl_PSF.value * self.pix_size.value *1e-3 / Dbres
else:
f_c1 = self.f_c.value = c_pix * self.nx.value * self.pix_size.value * 1e-3 / Dbfsr_max
f_c2 = self.spl_PSF.value * self.pix_size.value *1e-3 / Dbres
self.f_c.value = (self.resolution_slider.value * f_c1 + (1-self.resolution_slider.value) * f_c2)
self.ActualSampling.value = Dbres * self.f_c.value / (self.pix_size.value*1e-3)
##print(Dbfsr_max)
......@@ -403,7 +411,10 @@ class Spectro_simulate():
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
self.prism_input_angle.value = arcsin(nSF11((lomin+lomax)/2/1000)*sin(self.prism_apex.value*pi/180/2))*180/pi
apex_dbl = 2*arcsin((dth_dl_r/2) /(sqrt((dth_dl_r/2)**2*nSF11(lomax/1000)**2+4*dndlSF11(lomax/1000.)**2)))*180/pi
inp_a_dbl = arcsin(nSF11((lomin+lomax)/2/1000)*sin(apex_dbl*pi/180/2))*180/pi
print("apex double pasage : ",apex_dbl)
print("double passage input angle : ",inp_a_dbl)
# Orders on the CCD grating
......@@ -870,4 +881,6 @@ class Spectro_simulate():
self.limax.value = self.licen.value + self.c_m * self.licen.value / self.Order.value
#self.compute_spectro(b)
def tune_resolution(self,b):
with self.out:
self.compute_spectro(b)
......@@ -2,13 +2,15 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n",
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
......@@ -18,7 +20,9 @@
"%autoreload 2\n",
"%aimport -pylab\n",
"%pylab inline\n",
"from spectro_modeling import *"
"from spectro_modeling import *\n",
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
},
{
......@@ -30,13 +34,13 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7236ebb133ab46388b68444e29039371",
"model_id": "0aee9f3fb7814ca19369eda9e03b02b6",
"version_major": 2,
"version_minor": 0
},
......
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