³ò
ó½Jc           @   sÚ  d  Z  d d k Z d d k Z d d k Z d d k l Z l Z d d k l Z e d j oye d e i	 ƒ Z
 e d e i	 ƒ Z d e i e i ƒ  ƒ i Z e d	 e i	 ƒ Z e d
 j o; e i d Z e i i e d ƒ Z e i i e d ƒ Z n— e i i e ƒ p e i e ƒ n e i i e d ƒ Z e i i e ƒ p e i e ƒ n e i i e d ƒ Z e i i e ƒ p e i e ƒ n e oK e d' d e f d( d) d* d+ g ƒ Z e e e ƒ ƒ d j o
 d Z
 qßn e
 oÙe i e ƒ Z e i ƒ  d Ge GHg  Z g  Z x$e D]Z e d d !e j o qn e e i i e e ƒ d ƒ i  ƒ  Z! e! i" d ƒ Z! e i# d ƒ d j o[ x¯ e! D]L Z$ e e$ ƒ d j o3 e$ d d  j o" e$ d d! j o e i% e$ ƒ qŒqŒWqxT e! D]L Z$ e e$ ƒ d j o3 e$ d d  j o" e$ d d! j o e i% e$ ƒ qçqçWqWd i e ƒ d Z e e i i e d" e d# ƒ d$ ƒ i& e ƒ d i e ƒ d Z e e i i e d% e d# ƒ d$ ƒ i& e ƒ n
 d& Ge GHe i' ƒ  n d S(,   sÝ  
#+
# NAME:
#	sync_ace
# PURPOSE:
# 	Downloads real-time ACE data from ftp.sec.noaa.gov
#	for the SWEPAM and MAG instruments
# CALLING SEQUENCE:
#	usually as cron job:
#	bash --login -c "sync_ace.py [-mirror -force year=<year> <dat=dat>]"
# OPTIONAL INPUT PARAMETERS:
#	year		four-digit year; default: current year
#					yearly ACE file to be updated
#					(currently disabled)
#	dat=<dat>	if specified this directory is used instead of $DAT.
#					(the directory is created if it doesn't exist yet).
#	-mirror		if set then the local ACE data base is updated from
#					the SEC data base.
#	-force		forces update of yearly file from the currently
#					available ACE data.
# RESTRICTIONS:
#	The directories $DAT/insitu and $DAT/insitu/ace must exist. The
#	Perl script mirror is in SolarSoft ($SSW/gen/mirror/mirror)
# CALLS:
#	mirror, tiny.is_there, tiny.start
# PROCEDURE:
#	The ACE data are stored at NOAA in monthly files with filenames
#	200002_swepam_1hr.txt, where the numbers indicate year and month.
#	These monthly files are updated regularly with real-time ACE data.
#
#	Monthly files are stored locally in $DAT/insitu/ace2. This directory
#	maintains copies of all SWEPAM and MAG files from the NOAA site.
#	This is done using the Perl script 'mirror'.
#
#	If no year is specified on the command line then the current yearly
#	file is updated only if new data have been down loaded from NOAA.
#	If a year is specified then the file for that year is regenerated.
# MODIFICATION HISTORY:
#	???-1999, James Chao, Paul Hick
#		Original bash version
#	JAN-2000, Paul Hick (UCSD/CASS)
#		Added a couple of error checks
#	AUG-2002, Paul Hick (UCSD/CASS)
#		Removed explicit calls to bash startup scripts
#		/etc/profile and ~/.bash_profile.
#	OCT-2002, Paul Hick (UCSD/CASS)
#		Rewrite of download section. Now uses Perl script 'mirror'
#	DEC-2003, Paul Hick (UCSD/CASS)
#		Changed solar.sec.noaa.edu to ftp.sec.noaa.edu
#	DEC-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
#		Converted from bash to Python
#-
iÿÿÿÿN(   t   is_theret   start(   t   mirrort   __main__s   -forces   -mirrors   %ds   dat=t    t   DATt   insitut   ace2t   jobt   real_time_acet	   local_dirt   remote_sites   ftp.sec.noaa.govt
   remote_dirs   /pub/lists/ace2/t	   recursivet   falset   get_patts"   ace_mag_1h.txt$|ace_swepam_1h.txt$i    i   s   sync_ace, updating yeari   t   rs   
t   swepamt   :t   #t   acesw_s   .hravgt   wt   aceb_s   sync_ace, no update for year(   s   jobR	   (   s   remote_sites   ftp.sec.noaa.gov(   s
   remote_dirs   /pub/lists/ace2/(   s	   recursives   false(   s   get_patts"   ace_mag_1h.txt$|ace_swepam_1h.txt$((   t   __doc__t   ost   syst   timet   tinyR    R   R   t   __name__t   argvt   forcet   mgett	   localtimet   tm_yeart   yeart
   insitu_dirt   environt   patht   joinR
   t   existst   mkdirt   dictt   argst   lent   listdirt   filest   sortt   sw_allt   bb_allt   filet   opent   readt   datat   splitt   findt   linet   appendt   writet   exit(    (    (    s   ./sync_ace.pys   <module>6   st   		
	 $ 5 5-1	