##!/usr/bin/python2
## -*- coding: utf-8 -*-


<%page args="shot,  page, default_path"/>

<%
from pygolem_lite import Shot, loadconst
from pygolem_lite.config import  TororoidalMagneticFieldTrigger, TororoidalMagneticFieldCapacitor, CurrentDriveElectricFieldCapacitor, StabilizationCapacitor, BreakDownElectricFieldCapacitor
import datetime, cStringIO
from pygolem_lite.web import cat, emph, get_page_paths, make_zoom_image, wiki, source_link
from pygolem_lite.modules import  cData
page_path, base_path, page  = get_page_paths(shot, page, default_path)

get = cData.get_nice
%>

<h2> <a href="basic_diagn.py"> [Source - basic_diagn.py ]</a>   <a href="main.py"> [Source - main.py ]</a> </h2>


##<h2> ${source_link( page_path, get('code_revision'),default_path, 'basic_diagn.py', 'Source - basic_diagn.py' )}
##${source_link( page_path, get('code_revision'),default_path,  'main.py', 'Source - main.py')} </h2>


<table >
<tr valign='top'>
<td>
<h2>&nbsp;&nbsp;&nbsp;&nbsp;Basic parameters:  <font size='3'>(<a href="http://golem.fjfi.cvut.cz/utils/golplot?action=Plot+All&shotno_0=${shot}&diagn_0=loop_voltage&shotno_1=${shot-1}&diagn_1=loop_voltage&preview=1">compare</a>)</font> </h2>
##<a href="http://golem.fjfi.cvut.cz/golplot/index12.php">compare</a>

<ul>
    %try:
      
	<li>Gas pressure p<sub>ch</sub>:${ emph( get('pressure_initial', '%.2f'))}-&gt;${ emph( get('pressure', '%.2f'))}  mPa
	(request: ${ get('pressure_request', '%i')} mPa) ${wiki("/predecessor-CASTOR/Vacuum/vacuum")}     </li>
	<li>Working gas:
	%try:
	    %if  int(get('gas_filling')):
		${emph(get('working_gas'))}
	    %else:
		None
	    %endif
	%except:
	    None
	%endtry
	</li>
	<li>Preionization: ${ "ON" if int(get('preionization')) else "OFF"}</li>

	<li>Chamber temperature: ${get('chamber_temperature', '%.2f')} C</li>

	<li>C<sub>B<sub>t</sub></sub> capacitors changed to: ${emph(get('Ub', '%i V'))}, \
	triggered ${emph(get('Tb', '%.1f ms', 1e3))}  ${wiki("/Infrastructure/Capacitors/ToroidalMagneticFieldLine/generation_toroidal")}</li>
	<li>C<sub>BD</sub> capacitors changed to: ${emph(get('Ubd', '%i V'))}, triggered \
	${emph(get('Tbd', '%.1f ms', 1e3))} ${wiki("/Tokamak/Coils/TransformerPrimary-BreakdownElectricField/generation_transformer")}</li>
	<li>C<sub>CD</sub> capacitors changed to: ${emph(get('Ucd', '%i V'))}, triggered  \
	${emph(get('Tcd', '%.1f ms', 1e3))}  ${wiki("/Tokamak/Transformer/coils_transformer") } </li>
	<li>C<sub>ST</sub> capacitors changed to: ${emph(get('Ust', '%i V'))}, triggered \
	${ emph(get('Tst','%.1f ms', 1e3))}   ${wiki("/Tokamak/Coils/Stabilization/coils_stabilisation")}</li>
	%try:
	    ${ ( "<li><font color='red'> Max saturation of iron core transformator:  " + get('transformator_saturation', '%i%%', 100) + " </font> " + wiki("/Tokamak/Transformer/coils_transformer") + "</li>" ) if float(get('transformator_saturation')) > 0.8 else "" }
	    ${ ( "<li><font color='red'>  Level of noise <a href='basicdiagn/graphpresb.png'>(dBt)</a> in room:  " + get('noise_level', '%0.3f V') + " </font> </li>" ) if float(get('noise_level')) > 0.03 else "" }
	%except:

	%endtry
      <li> Probability of breakdown: ${get('breakdown_probability', '%i%%')} ${wiki("/Education/ExperimentMenu/BreakdownStudies/Breakdownstudies")}  </li>
      <li>Time since session beginning: ${str(datetime.timedelta(seconds=int(get('session_length'))))} h</li>
    %except Exception, e:
	<h2> Parameters loading failed: ${str(e)} </h2>
    %endtry

    
    </ul>
    </td>
    <td>



%try:
    % if get("plasma") == 1:
    <h2>&nbsp;&nbsp;&nbsp;&nbsp;Plasma parameters:</h2>

	<ul>
	<li>Plasma life time <b> ${get('plasma_life', '%.1f', 1e3)} </b> [ms] (from  ${ get('plasma_start', '%.1f', 1e3)} to ${get('plasma_end', '%.1f', 1e3)}) </li>
	<li>Mean toroidal magnetic field Bt:  ${get('toroidal_field_mean', '%.2f')}  T ${wiki("/Diagnostics/Basic/ToroidalMagneticField/index")}</li>
	<li>Mean plasma current: ${ get('plasma_current_mean', '%.2f', 1e-3)}  kA ${wiki("/Diagnostics/Magnetic/RogowskiCoilArroundChamber/Theory/diagnostics_rogowski")}</li>
	<li>Mean Uloop: ${get('loop_voltage_mean', '%.2f')}  V ${wiki("/Diagnostics/Basic/Uloop/index")}</li>
	<li>Break down voltage: ${get('breakdown_voltage',  '%.1f') }  V ${wiki("/Education/ExperimentMenu/BreakdownStudies/Breakdownstudies")} </li>
	<li><a href='/shots/${shot}/analysis/Basics/0612AdvancedAnalysis.ON/#power_balance'>Ohmic heating power: </a> ${get('input_power_mean', '%.2f', 1e-3)}   kW</li>
	<li><a href='/shots/${shot}/analysis/Basics/0612AdvancedAnalysis.ON/#safety_factor'>Q edge:</a>  ${get('safety_factor_mean', '%.1f')} ${wiki("http://fusionwiki.ciemat.es/wiki/Rotational_transform")} </li>
	<li><a href='/shots/${shot}/analysis/Basics/0612AdvancedAnalysis.ON/#electron_temperature'>Electron temperature:</a>  ${ emph( get('temperature_mean', '%.1f'))} eV ${wiki("/Diagnostics/Basic/Uloop/index#theory")}</li>
	<li><a href='/shots/${shot}/analysis/Basics/0612AdvancedAnalysis.ON/#density'>Line electron density:</a>  ${ emph(get('electron_density_mean', "%.2f" , 1e-17) ) } [10^17.m^-2] 
	${wiki("/Diagnostics/Basic/Interferometry/index")} </li>
	</ul>
	
    %endif


%except Exception, e:
    <h2> Plasma parameters loading failed: ${str(e)} </h2>
%endtry

</td>
</tr>
</table>





${make_zoom_image( '/'+base_path + 'basicdiagn/graphpres' , "", "_home")}
${make_zoom_image( '/'+base_path + 'basicdiagn/graphpresb' , "", "_home")}
${make_zoom_image( '/'+base_path + 'basicdiagn/graphpresi' , "", "_home")}
${make_zoom_image( '/'+base_path + 'basicdiagn/graphpresfull' , "", "_home")}



<h3>Diagnostics:</h3><ul>

<li>Figures:<br/>
raw data: <a href='/${default_path}/${shot}/basicdiagn/graphpresb.png'>${default_path}/${shot}/basicdiagn/graphpresb.png</a><br/>
integrated data (I<sub>ch+p</sub>): <a href='/${default_path}/${shot}/basicdiagn/graphpresi.png'>${default_path}/${shot}/basicdiagn/graphpresi.png</a><br/>
integrated data (I<sub>p</sub>): <a href='/${default_path}/${shot}/basicdiagn/graphpresfull.png'>${default_path}/${shot}/basicdiagn/graphpresb.png</a><br/>
zoomed data: <a href='/${default_path}/${shot}/basicdiagn/graphpres.png'>${default_path}/${shot}/basicdiagn/graphpresb.png</a>
</li>

</ul>



<h2> Basic discharge parameters: </h2>


${Shot(shot).get_pygolem_list( ['loop_voltage', 'toroidal_field', 'rogowski_current', 'plasma_current', 'chamber_current', 'photodiode', 'photodiode_alpha', 'plasma', 'wwwcomment', 'input_power', 'input_power_total', 'plasma_start', 'plasma_end', 'plasma_life',  ])}
