// An imageJ macro to be used with exercice 
// Pour avoir les accents, enregistrer en format
// OCCIDENTAL WINDOWS LATIN 1
// sinon ça plante !

setBatchMode(false);

macroDir = getDirectory("SalsaJ")+"Data/imagesFT_Corot-2b/";
//print("macroDir=",macroDir);
//macroDir = "/Users/melchior/EUHOU/SalsaJ/Release/Data/imagesFT_Corot-2b/"
//remoteDir="http://www.euhou.net/SalsaJ/Data/imagesFT_Corot-2b/";
//homeDir=getDirectory("home");
print("Script to extract a small image around Corot-2b");
print("Load the image files, extract a small area and adjust the intensity thresholds");

runMacro("Close_All_Windows.txt");

//for (i=102; i<201; i++) {
for (i=102; i<202; i=i+3) {
    name="b_e_20120620_"+i+"_1_1_1.fits";
    //openImage(name,macroDir,remoteDir);
    file=macroDir+name; open(file);
    makeRectangle(800, 800, 400, 400);
    run(		      "Crop");
    run("Rogner");
    saveAs("FITS", macroDir+"Extract_"+name);
    setMinAndMax(0.000000000, 150.000000000);
    close();
}
