³ò
LäÔIc        #   @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z l Z l Z d  d k l	 Z	 d Z
 e	 e
 ƒ Z e i d d d d d	 d
 d d ƒe i d d d d d	 d d d ƒe i d d d d d	 d d d ƒe i d d d d d	 e i d e i ƒ  ƒ d d ƒe i d d d d d d  d	 e d d! ƒe i d" d# d d$ d d  d	 e d d% ƒe i d& d' d d( d	 d d d) ƒe i d* d+ d d, d	 d- d d. ƒe i d/ d0 d d1 d	 d2 d d3 ƒe i d4 d5 d d6 d	 d7 d d8 ƒe i d9 d: d d; d d  d	 e d d< ƒe i ƒ  \ Z Z e e ƒ d= j o e i d> ƒ n e i o e i o e i d? ƒ n e i i e i ƒ p e i d@ e i ƒ n e i i e i ƒ p e i dA e i ƒ n e i i e i ƒ p e i dB e i ƒ n e i i e i ƒ p e i dC e i ƒ n e i e j o e i o e i dD ƒ n e e dE ƒ Z  e! e dF ƒ Z" e i dG e i# dH e i$ Z% e i Z e i i& e i dI ƒ Z' e i i& e i dJ ƒ Z( e i) Z) e i Z* dK GHdL e  GHdM e" GHdN e GHdO e i i& e e) ƒ GHdP e% GHdQ e' GHdR e( GHxêe+ e" ƒ D]ÜZ, e i ƒ  Z- e e. e  ƒ e, ƒ Z/ e i pìe0 e' dS ƒ Z1 e i i& e e) dT e/ dU ƒ Z2 e i i& e e) dV e) dW e/ dX ƒ Z3 y e i4 e2 ƒ Wn e5 j
 o dY GHn Xe0 e3 dZ ƒ Z6 e e% d[ e d\ e d] e2 d^ e7 ƒZ8 d_ GxI e1 i9 ƒ  D]; Z: e8 i; i< e: i= d` e/ ƒ ƒ e6 i< e: i= d` e/ ƒ ƒ q)Wda GHe1 i> ƒ  db Ge/ GHdE Z? d Z@ xze8 iA ƒ  ple i ƒ  ZB e iC o e! eB e- ƒ dc dF j o< e? dE j o/ dd GHe i de e i ƒ  ƒ Gdf GHdd GHdF Z? n e! eB e- ƒ dc dg j o e? dF j o
 dE Z? q?n e8 iD iE ƒ  ZF e8 iD iG ƒ  e@ d j ol eF iH dh ƒ ZI eI d  j oL eF eI e dh ƒ ZJ e6 i< di eJ ƒ e! eJ ƒ dE j o
 e7 Z@ qÐe Z@ qÔn e iC o eF iK ƒ  GHn e6 i< eF ƒ e6 iG ƒ  qWe6 i> ƒ  e@ o' dj GHe iL e2 e2 dk ƒ e2 dk Z2 n dl Ge/ GHn e i p´e i i e i i& e e) dT e/ dm ƒ ƒ oJ e7 Z@ e i i& e e) dT e/ dm ƒ Z2 e i i& e e) dn e/ dm ƒ ZM n e i i e i i& e e) dT e/ dU ƒ ƒ oJ e Z@ e i i& e e) dT e/ dU ƒ Z2 e i i& e e) dn e/ dU ƒ ZM n d Z@ do GHe  iN dF ƒ dp GHdq Ge@ GHdr Ge2 GHds GeM GHe i o9e, dE j o,dt Ge i GHe i e i i& e2 du ƒ ƒ ZO eO iP ƒ  yd e e i ƒ dv j oA g  ZQ eO D]  ZR eQ e dw e i ƒ eR j qí[Q iS e7 ƒ ZT n
 e i ZT Wn, eU j
 o  dx Ge i GHe  iN dF ƒ n XeO eT ZV eW g  ZX eV D] ZR eX e i iY eR ƒ qt	[X ƒ i= dy dz ƒ i= d{ d| ƒ i= d} d~ ƒ ZV n e0 e( dS ƒ ZZ y e i4 eM ƒ Wn e5 j
 o d GHn Xe d$ d[ e d\ e d€ e d] e* d^ e7 ƒZ[ e i i& e e) dV e) dW e/ d ƒ Z\ e0 e\ dZ ƒ Z] e i^ d‚ ƒ dƒ GxÚ eZ i9 ƒ  D]Ì Z: e: i= d„ e2 ƒ Z: e: i= d… eM ƒ Z: e@ o e: i= d† d‡ ƒ Z: n e: i= d† d~ ƒ Z: e i o5 e, dE j o( e: i= dˆ d‰ i& eV ƒ i& d} ƒ ƒ Z: n e: i= dˆ d~ ƒ Z: e: GHe[ i; i< e: ƒ e] i< e: ƒ q{
Wda GHeZ i> ƒ  dŠ GHdE Z? xƒe[ iA ƒ  pue i ƒ  ZB e iC o e! eB e- ƒ dc dF j o< e? dE j o/ dd GHe i de e i ƒ  ƒ Gd‹ GHdd GHdF Z? n e! eB e- ƒ dc dg j o e? dF j o
 dE Z? qn e[ iD iE ƒ  ZF e iC o eF iK ƒ  GHn e[ iD iG ƒ  eF i_ ƒ  d~ j o e] i< eF ƒ e] iG ƒ  qhe eF ƒ dE j o= dŒ GHe iC o) d Ge eF ƒ GdŽ GeF GdŽ GeW eF ƒ GHn Pn e iC o e i^ dF ƒ qhqhWe[ i` ƒ  e] i> ƒ  d Ge/ GHq0q0Wd S(   iÿÿÿÿN(   t   Popent   PIPEt   STDOUT(   t   OptionParsers9   usage: %prog START_ROTATION NUMBER_OF_ROTATIONS [options]s   -bs	   --basedirt   destt   outbaset   defaults   /smeitom/tomt   helps3   Base directory for output files [default: %default]s   -cs   --cfgt   configfiless   /smeitom/tom/wrappersW   Directory containing Tomography and IDL wrapper configuration files [default: %default]s   -Ps   --prot	   idlscripts   /smeitom/tom/prosG   Directory containing script called from tomwrap.cfg [default: %default]s   -ts	   --timedirt   timedirs   %d-%b-%Ys‚   Subdirectory of base where events and images are written, only use this to overwrite or resume an existing run [default: %default]s   -Ts   --tomot   tomot   actiont
   store_trues3   Run only tomography, skip IDL, usually used with -ts   -Is   --idlt   idls3   Run only IDL, skip tomography, usually used with -ts   -Ss   --startt   starts²   Used in conjunction with --idl, specify a carrington rotation (with fractional rotation) or the file index number (if 20 png files exist for a given type of image, then enter 21)s   -es   --exet   exes"   /smeitom/tom/exe/smeiipstd0n_intels6   Full path to tomography executable [default: %default]s   -ss   --smeit   smeis    /smeitom/int/inter_data/base/*.*s,   smei path for tomography [default: %default]s   -ns   --nagoyat   nagoyas    nagoya,/zshare/dat/nagoya/yearlys.   nagoya path for tomography [default: %default]s   -vs	   --verboset   verboses=   Write tomography/IDL output to the screen [default: %default]i   s   Incorrect number of argumentss'   Cannot use -I and -T, pick one, or nones%   Configuration directory not found: %ss   Base directory not found: %ss#   Tomography executable not found: %ss"   IDL script directory not found: %ss,   Don't use -S/--start without -I/--idl and -ti    i   s    nagoya=s    smei=s   tomwrap.cfgs   tomwrap-idl.cfgs?   Tomography/IDL wrapper beginning with the following parameters:s   Rotation: %ss   Number of rotations: %ss   Base directory: %ss   Subdirectory for this run: %ss   Tomography command: %ss   Tomography configuration: %ss   IDL configuration: %st   rt   events_t   _HRs
   tomoutput-t   -s	   -tomo.logs,   Events directory exists, continuing anyways.t   at   stdint   stdoutt   cwdt   shells   Piping tomography config file: t   ROTATIONt   dones"   Tomography starting for rotation: i<   s   ------------------------------s   %d-%b-%Y %H:%Ms   Still Alivei2   s   V observations s   VELOCITIES FOUND: s$   Velocities found, renaming directoryt   _vs!   Finished tomography for rotation:t   _HR_vt   images_s<   No Tomography directory found, cannot run IDL from this paths   IDL Parameterss   Velocities  : s   Source      : s   Destination : s   Restarting : s   nv3h*i   t   nv3hs.   Cannot resume, something wrong with --start %st   [t   {t   ]t   }t   't    sM   failed to make images directory: already exists or IO error, continue anywayst   stderrs   -idl.logi   s    Parsing IDL configuration file: t   SOURCEt   DESTINATIONt   SPEEDs   , /speedt   FILTERs
   , filter='s   Starting IDLs   IDL Still Alives&   Exiting, either IDL finished or broke.s   Reason: t   ,s#   IDL program finished for rotation: (a   t   syst   ost   timet   globt
   subprocessR    R   R   t   optparseR   t   usaget   parsert
   add_optiont   strftimet	   localtimet   Falset   Nonet
   parse_argst   optionst   argst   lent   errorR   R   t   patht   existsR   R   R   R	   R   t   strt   rotationt   intt	   rotationsR   R   t   cmdt   joint
   configfilet   idlconfigfileR
   t   idlscriptdirt   ranget   numt	   starttimet   floatt   rotrunt   opent   configt   writedirt
   outputfilet   makedirst   OSErrort   outputt   Truet   smeiproct	   readlinest   lineR   t   writet   replacet   closet   settimet   hasvelocityt   pollt   timenowR   R   t   readlinet	   outputvalt   flusht   findt   vobst
   velocitiest   rstript   renamet   imagedirt   exitt   filelistt   sortt   _[1]t   it   indext   indexvalt
   ValueErrort
   filterlistt   reprt   _[2]t   basenamet	   idlconfigt   idlproct   idloutputfilet	   idloutputt   sleept   stript   wait(    (    (    s   ./tomwrap.pys   <module>   sn  0"""4((""""(									 
 (
$ 
	
(
(



- $- $			
A
[
*( (

(
(

)


