#! /bin/bash # #+ # NAME: # sync_ips_daily # PURPOSE: # Controls the processing of new IPS data arriving from Nagoya. # CALLING SEQUENCE: # as cron job: # bash --login -c "sync_ips_daily" # # interactive: # sync_ips_daily [-tomography] # INPUTS: # Only one of the following should be specified. # # -mirror force download from Nagoya, even if there is # no email alert, followed by running of tomography # -tomography if set the script jumps straight to running # the tomography programs, bypassing the download # of new daily IPS files. # OPTIONAL INPUT PARAMETERS: # We have available both NSO/NOAA and WSO/NOAA magnetic field data. # These are added to the processing by defining the env vars BB_PREFIXES, # BB_PREFIXES_SLOW and BB_PREFIXES_FAST. # To use the same magnetic data for both corotating and time-dependent # tomography used BB_PREFIXES: # BB_PREFIXES='wson' only WSO/NOAA data # BB_PREFIXES='nson' only NSO/NOAA data # BB_PREFIXES='wson nson' both WSO/NOAA and NSO/NOAA # To use different magnetic fields for corotating and time-dependent # tomography set the pair BB_PREFIXES_SLOW and BB_PREFIXES_FAST to the # desired magnetic data. # CALLS: # sync_ips_mirror, ipsd, ipsdt, vox_update # run_mean, run_marker # PROCEDURE: # Finally one or more tomography programs are called to update the # latest tomographic reconstructions. # MODIFICATION HISTORY: # JAN-2001, Paul Hick (UCSD/CASS) # SEP-2001, Paul Hick (UCSD/CASS) # Added honcho email list # 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' # Also added the -tomography keyword. # OCT-2002, Paul Hick (UCSD/CASS) # The script does not abort anymore when the corotating tomography # fails, but continues with the time-dependent program. # All image updates are now done after both tomography programs # have been run. The intermediate update of the corotating images # prior to running the time-dependent tomography has been dropped. # JUN-2003, Paul Hick (UCSD/CASS) # Added calls to gzip to compress all nv3d*, etc., both raw # and final versions. # JUL-2003, Paul Hick (UCSD/CASS) # Removed call to 'idl run_map' # NOV-2003, Paul Hick (UCSD/CASS) # Removed compression of final files in this script using a single # gzip -f after the call to run_marker run_mean. Instead this is now # done by the IDL procedure vu_write on a file by file basis. # The gzip -f call caused problems for the hourly forecast run while # run_marker was creating new final files. For some time the old # (gzipped) final files would coexist with the new (unzipped) final # files (until gzip -f was completed). An hourly forecast run during # this time would find multiple files referring to the same time. # The results are blank maps at the hourly forecast time. # AUG-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) # Modified selection of magnetic field data by env variables. #- start_time=$(date) # People on the honcho list receive emails. honcho="pphick@ucsd.edu bvjackson@ucsd.edu" #==== Check command line =============== if [ -z "$1" ]; then # No command line argument: start download sync_ips_mirror "$honcho" "$1" if [ $? = 1 ]; then echo "$(date), tomography not run" exit 1 fi elif [ "$1" == "-tomography" ]; then shift elif [ "$1" == "-mirror" ]; then sync_ips_mirror "$honcho" "$1" if [ $? = 1 ]; then echo "$(date), tomography not run" exit 1 fi shift fi # Set type of magnetic data. mag_wso_noaa="wso_noaa=wso_noaa[4]_[3]_[1].fts,$DAT,map,wso_noaa,hcss" mag_nso_noaa="nso_noaa=nso_ktpk[4]_[3].fts,$DAT,map,nso_ktpk,hcss" if [ -n "$(echo $BB_PREFIXES $BB_PREFIXES_SLOW | grep wson)" ]; then mag_slow="$mag_slow $mag_wso_noaa" fi if [ -n "$(echo $BB_PREFIXES $BB_PREFIXES_SLOW | grep nson)" ]; then mag_slow="$mag_slow $mag_nso_noaa" fi if [ -n "$(echo $BB_PREFIXES $BB_PREFIXES_FAST | grep wson)" ]; then mag_fast="$mag_fast $mag_wso_noaa" fi if [ -n "$(echo $BB_PREFIXES $BB_PREFIXES_FAST | grep nson)" ]; then mag_fast="$mag_fast $mag_nso_noaa" fi # === Initialization section ================= # Input for the tomography programs. # These files are piped into standard input. nagoya_slow=$SYS/nagoya/nagoya_forecast.slow nagoya_fast=$SYS/nagoya/nagoya_forecast.fast # Output directories where to put the raw tomography files. # File spec for locating magnetic source surface files. slow_raw=$NAGOYA/slow/raw fast_raw=$NAGOYA/fast/raw slow_final=$NAGOYA/slow/final fast_final=$NAGOYA/fast/final slow_vox=$NAGOYA/slow/vox fast_vox=$NAGOYA/fast/vox # === Run corotating tomography program ========= # The program takes its input from the file $nagoya_slow. This starts the # program in forecast mode. The modified Julian reference time is left blank # so the default calculated by the tomography program is accepted. # The tomography program writes its output into the working directory, # so we cd to the directory where we want the output. savepwd=$PWD echo echo "$(date), co-rotating tomography running" echo "$mag_slow" cd $slow_raw ipsd $mag_slow < $nagoya_slow > $TUB/cron_ipsd.txt case $? in 1) status=finished ;; *) status=error ;; esac echo "$(date), corotating tomography $status" if [ -n "$honcho" ]; then date | mail $honcho -s"Corotating tomography $status" fi if [ $status = finished ]; then gzip -rf $slow_raw echo echo "$(date), run_mean: creating final corotating tomography files" idl -quiet run_mean.pro fi # === Run time-dependent tomography program =========== # If an error occurs a message is output, but the script does not abort. echo echo "$(date), time-dependent tomography running" echo "$mag_fast" cd $fast_raw ipsdt $mag_fast < $nagoya_fast > $TUB/cron_ipsdt.txt case $? in 1) status=finished ;; *) status=error ;; esac echo "$(date), time-dependent tomography $status" if [ -n "$honcho" ]; then date | mail $honcho -s"Time-dependent tomography $status" fi if [ $status = finished ]; then gzip -rf $fast_raw echo echo "$(date), run_marker: creating final time-dependent tomography files" idl -quiet run_marker.pro fi cd $savepwd # === Create animations ============= echo echo "$(date), creating forecast movies" idl -quiet run_movie.pro # TEMPORARY: remove all mng movies rm -f $HTM/forecast/slow/current/*movie.mng rm -f $HTM/forecast/fast/current/*movie.mng # === Create vox files ============== if [ "$(date +%d)" == "1" ]; then echo "$(date), update vox files (fast)" vox_update.py -source=$fast_final -destination=$fast_vox -nv_prefix=nv3f echo "$(date), update vox files (slow)" vox_update.py -source=$slow_final -destination=$slow_vox -nv_prefix=nv3d fi if [ -n "$honcho" ]; then echo "Start at $start_time; Finished at $(date)" | mail $honcho -s"Nagoya IPS tomography finished" fi echo $(date), "done" exit 0