# Splits /dihv9p_enc_v2/data/{radrev,rad,if}/2005/185 into smaller subdirectories 
# of about 450-500 MB each.
#
# Split data by type of imaging:
#   185a  Exp ID 9000322 - 9000866  250 MB  Continoura comet imaging
#   185b  Exp ID 9000901 - 9000999  482 MB  Impact imaging
#   185c  Exp ID 9001000 - 9001051  471 MD  Impact imaging
#   186d  Exp ID 9010000 - 9020016  411 MB  Lookback imaging
#   185e  Exp ID 9030000 - 9070016  494 MB  Lookback imaging
#
# 2006-12-07, sam:  
# Run this script in the /n/diraid02/data/develop/dihv9p_enc_v2/.
# Run three times, changing radrev->rad and rad-if as you go.
#

cd /n/diraid02/data/develop/dihv9p_enc_v2/data/radrev/2005/

mkdir 185a
mkdir 185b
mkdir 185c
mkdir 185d
mkdir 185e

# Use the exposure ID in the file names to move data from
# the daily directory to the 'part' directories

mv 185/*_90003* 185a/
mv 185/*_90004* 185a/
mv 185/*_90005* 185a/
mv 185/*_90006* 185a/
mv 185/*_90007* 185a/
mv 185/*_90008* 185a/

mv 185/*_900090* 185b/
mv 185/*_900091* 185b/
mv 185/*_900092* 185b/
mv 185/*_900093* 185b/
mv 185/*_900094* 185b/
mv 185/*_900095* 185b/
mv 185/*_900096* 185b/
mv 185/*_900097* 185b/
mv 185/*_900098* 185b/
mv 185/*_900099* 185b/

mv 185/*_9001* 185c/

mv 185/*_901* 185d/
mv 185/*_902* 185d/

mv 185/*_903* 185e/
mv 185/*_904* 185e/
mv 185/*_905* 185e/
mv 185/*_906* 185e/
mv 185/*_907* 185e/

# Make sure 185 directory is empty

find 185/

cd /n/diraid02/data/develop/dihv9p_enc_v2/

tar cvf DOWNLOAD/2005185a_radrev.tar data/radrev/2005/185a
tar cvf DOWNLOAD/2005185b_radrev.tar data/radrev/2005/185b
tar cvf DOWNLOAD/2005185c_radrev.tar data/radrev/2005/185c
tar cvf DOWNLOAD/2005185d_radrev.tar data/radrev/2005/185d
tar cvf DOWNLOAD/2005185e_radrev.tar data/radrev/2005/185e

mv DOWNLOAD/2005185a_radrev.tar /n/pdsraid01/archive/dihv9p_enc/DOWNLOAD/
mv DOWNLOAD/2005185b_radrev.tar /n/pdsraid01/archive/dihv9p_enc/DOWNLOAD/
mv DOWNLOAD/2005185c_radrev.tar /n/pdsraid01/archive/dihv9p_enc/DOWNLOAD/
mv DOWNLOAD/2005185d_radrev.tar /n/pdsraid01/archive/dihv9p_enc/DOWNLOAD/
mv DOWNLOAD/2005185e_radrev.tar /n/pdsraid01/archive/dihv9p_enc/DOWNLOAD/

# Move data in 'part' directories back to the original DOY directory,
# then delete tha 'part' directories

cd /n/diraid02/data/develop/dihv9p_enc_v2/data/radrev/2005/

mv 185a/* 185/
mv 185b/* 185/
mv 185c/* 185/
mv 185d/* 185/
mv 185e/* 185/

rmdir 185a
rmdir 185b
rmdir 185c
rmdir 185d
rmdir 185e