# mascpy
This is a Python port of the [masclab](https://github.com/Fall-tech/masclab) suite. Note that the layout of functions and overall organization are somewhat different.

Open a terminal.
ssh -Y u1128559@meteo11.chpc.utah.edu
password:
module purge
module load opencv/3.3.0.singularity
cd Documents/python/mascpy/
cv2-python -m analysis.Standalone -recdir -i ./OliktokTest/ -oi outAnalysisImages.txt -op outAnalysisParticles.txt -ob outBins.txt -bw 5m -acs config_%d_%T.xml -ap analysis/defImgAnlParams.json -sci -dis '*_dataInfo.txt' -iis '*_imgInfo.txt' -sci

Adjustable parameters are located in analysis/defImgAnlParams.json

For help type: python -m analysis.Standalone -h

For testing parameters:
python -m analysis.Standalone -imgd -i 2013.04.02_03.12.22.483830_flake_80793_cam_1.png -ap analysis/defImgAnlParams.json

Can do the following:
module load python/2.7.3
module load opencv
go to mascpy/


1. This is the command to rename the input files downloaded from amf3 and DMF:
Open a terminal in the directory where you have saved the data.
bash
for fname in olimascM1.*.png;
do mv "$fname" "$(echo "$fname" | sed -e 's/olimascM1.00.*.raw.//')";
done;

Another way which is more simple:
Open a terminal in the directory where you have saved the data.
bash
for fname in olimascM1.*;
do mv "$fname" "${fname:33:500}";
done

2. This is the command to create the direcotries based on the timing for Jan. 30 of 2017:
Open a terminal in the directory where you want to create the folders.
bash
for i in {00..23};
do mkdir masc_2017.01.30_Hr_"$i";
done

3. This is the command to create the directories based on the date and time from Jan. 01 to Jan. 31 of 2017 and then to move each image from the saved directory into the proper folder:
Open a terminal in the directory where you have all the saved the data.
bash
for dy in {01..31};
do for hr in {00..23};
do for file in oliMASCM1.a0.201701"$dy"."$hr"*;
do mkdir -p ~/Documents/mascpy/OliktokTest/masc_2017.01."$dy"_Hr_"$hr" && rsync -av $file ~/Documents/mascpy/OliktokTest/masc_2017.01."$dy"_Hr_"$hr";
done;
done;
done;

If you want to print the result, type echo $hr $file just before mkdir

4. Now, I delete all the created directories that only have .txt files (from one to three .txt files)  with no .png file:
bash
cd ~/Documents/mascpy/OliktokTest
shopt -s globstar;
for d in **/;
do f=("$d"/*);
[[ ${#f[@]} -lt 4 ]] && rm -r -- "$d";
done;
